-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c8a6d32
commit 8ca9dbb
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# ARGS: 46, 10007 | ||
@main(n: int, p: int) { | ||
v0: int = const 2; | ||
two: int = id v0; | ||
v1: int = id p; | ||
v2: int = id two; | ||
v3: int = sub v1 v2; | ||
m: int = id v3; | ||
v4: int = const 1; | ||
ans: int = id v4; | ||
v5: int = id n; | ||
a: int = id v5; | ||
v7: int = const 1; | ||
i: int = id v7; | ||
.for.cond.6: | ||
v8: int = id m; | ||
v9: int = const 0; | ||
v10: bool = gt v8 v9; | ||
br v10 .for.body.6 .for.end.6; | ||
.for.body.6: | ||
v12: int = id m; | ||
v13: int = id m; | ||
v14: int = id two; | ||
v15: int = div v13 v14; | ||
v16: int = id two; | ||
v17: int = mul v15 v16; | ||
v18: bool = eq v12 v17; | ||
br v18 .then.11 .else.11; | ||
.then.11: | ||
jmp .endif.11; | ||
.else.11: | ||
v19: int = id ans; | ||
v20: int = id a; | ||
v21: int = mul v19 v20; | ||
v22: int = id p; | ||
v23: int = call @mod v21 v22; | ||
ans: int = id v23; | ||
.endif.11: | ||
v24: int = id a; | ||
v25: int = id a; | ||
v26: int = mul v24 v25; | ||
v27: int = id p; | ||
v28: int = call @mod v26 v27; | ||
a: int = id v28; | ||
v29: int = id m; | ||
v30: int = id two; | ||
v31: int = div v29 v30; | ||
m: int = id v31; | ||
jmp .for.cond.6; | ||
.for.end.6: | ||
v32: int = id ans; | ||
print v32; | ||
v33: int = const 0; | ||
} | ||
@mod(n: int, p: int): int { | ||
v0: int = id n; | ||
v1: int = id n; | ||
v2: int = id p; | ||
v3: int = div v1 v2; | ||
v4: int = id p; | ||
v5: int = mul v3 v4; | ||
v6: int = sub v0 v5; | ||
ret v6; | ||
} | ||
|
||
# function main(n: bigint, p: bigint) { | ||
# var two: bigint = 2; | ||
# var m: bigint = p - two; | ||
# var ans: bigint = 1; | ||
# var a: bigint = n; | ||
# for (let i = 1; m > 0; m = m / two) { | ||
# if (m == m / two * two) { | ||
# } | ||
# else { | ||
# ans = mod(ans * a, p); | ||
# } | ||
# a = mod(a * a, p); | ||
# } | ||
# console.log(ans); | ||
# } | ||
# | ||
# function mod(n: bigint, p: bigint): bigint { | ||
# return n - n / p * p; | ||
# } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2393 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
total_dyn_inst: 558 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters