@@ -1130,3 +1130,59 @@ store_temp<RangeCheck>([2]) -> ([2]);
11301130return([2]);
11311131
11321132test::foo@F0([0]: RangeCheck, [1]: BoundedIntGuarantee<0, 4294967295>) -> (RangeCheck);
1133+
1134+ //! > ==========================================================================
1135+
1136+ //! > u128_to_u32_guarantees libfunc.
1137+
1138+ //! > test_runner_name
1139+ SmallE2ETestRunner
1140+
1141+ //! > cairo_code
1142+ extern type BoundedIntGuarantee<const MIN: felt252, const MAX: felt252>;
1143+ type U32Guarantee = BoundedIntGuarantee<0, 0xffffffff>;
1144+
1145+ extern fn u128_to_u32_guarantees(
1146+ value: u128,
1147+ ) -> (U32Guarantee, U32Guarantee, U32Guarantee, U32Guarantee) nopanic;
1148+
1149+ fn foo(value: u128) -> (U32Guarantee, U32Guarantee, U32Guarantee, U32Guarantee) {
1150+ u128_to_u32_guarantees(value)
1151+ }
1152+
1153+ //! > casm
1154+ %{ (memory[ap + 3], memory[ap + 5]) = divmod(memory[fp + -3], 4294967296) %}
1155+ %{ (memory[ap + 4], memory[ap + 6]) = divmod(memory[ap + 3], 4294967296) %}
1156+ %{ (memory[ap + 8], memory[ap + 7]) = divmod(memory[ap + 4], 4294967296) %}
1157+ ap += 3;
1158+ [ap + -3] = [ap + 0] * 4294967296, ap++;
1159+ [fp + -3] = [ap + -4] + [ap + 1], ap++;
1160+ [ap + -4] = [ap + -1] * 4294967296, ap++;
1161+ [ap + -3] = [ap + -5] + [ap + 0], ap++;
1162+ [ap + -5] = [ap + 1] * 4294967296, ap++;
1163+ [ap + -4] = [ap + -6] + [ap + -1], ap++;
1164+ [ap + 0] = [ap + -4], ap++;
1165+ [ap + 0] = [ap + -4], ap++;
1166+ [ap + 0] = [ap + -4], ap++;
1167+ [ap + 0] = [ap + -4], ap++;
1168+ ret;
1169+
1170+ //! > function_costs
1171+ test::foo: SmallOrderedMap({Const: 1100})
1172+
1173+ //! > sierra_code
1174+ type u128 = u128 [storable: true, drop: true, dup: true, zero_sized: false];
1175+ type BoundedIntGuarantee<0, 4294967295> = BoundedIntGuarantee<0, 4294967295> [storable: true, drop: false, dup: false, zero_sized: false];
1176+ type Tuple<BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>> = Struct<ut@Tuple, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>> [storable: true, drop: false, dup: false, zero_sized: false];
1177+
1178+ libfunc u128_to_u32_guarantees = u128_to_u32_guarantees;
1179+ libfunc struct_construct<Tuple<BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>>> = struct_construct<Tuple<BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>>>;
1180+ libfunc store_temp<Tuple<BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>>> = store_temp<Tuple<BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>>>;
1181+
1182+ F0:
1183+ u128_to_u32_guarantees([0]) -> ([1], [2], [3], [4]);
1184+ struct_construct<Tuple<BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>>>([1], [2], [3], [4]) -> ([5]);
1185+ store_temp<Tuple<BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>>>([5]) -> ([5]);
1186+ return([5]);
1187+
1188+ test::foo@F0([0]: u128) -> (Tuple<BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>, BoundedIntGuarantee<0, 4294967295>>);
0 commit comments