#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int modOfPower(int, int, int);
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  for (int i = 1; i < 10; i++) {
    int pow = i * 10000000;
    int value = modOfPower(324322, pow, 3724);
    printf("324322^(%i) mod 3724 = %i\n", pow, value);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    117f <main+0x5f>
imul   $0x989680,-0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x4f2e2,%edi
mov    $0xe8c,%edx
call   1030 <modOfPower@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x4f2e2,%edi
mov    $0x989680,%esi
mov    $0xe8c,%edx
call   1030 <modOfPower@plt>
lea    0xec4(%rip),%rbx
mov    %rbx,%rdi
mov    $0x989680,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x4f2e2,%edi
mov    $0x1312d00,%esi
mov    $0xe8c,%edx
call   1030 <modOfPower@plt>
mov    %rbx,%rdi
mov    $0x1312d00,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x4f2e2,%edi
mov    $0x1c9c380,%esi
mov    $0xe8c,%edx
call   1030 <modOfPower@plt>
mov    %rbx,%rdi
mov    $0x1c9c380,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x4f2e2,%edi
mov    $0x2625a00,%esi
mov    $0xe8c,%edx
call   1030 <modOfPower@plt>
mov    %rbx,%rdi
mov    $0x2625a00,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x4f2e2,%edi
mov    $0x2faf080,%esi
mov    $0xe8c,%edx
call   1030 <modOfPower@plt>
mov    %rbx,%rdi
mov    $0x2faf080,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x4f2e2,%edi
mov    $0x3938700,%esi
mov    $0xe8c,%edx
call   1030 <modOfPower@plt>
mov    %rbx,%rdi
mov    $0x3938700,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x4f2e2,%edi
mov    $0x42c1d80,%esi
mov    $0xe8c,%edx
call   1030 <modOfPower@plt>
mov    %rbx,%rdi
mov    $0x42c1d80,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x4f2e2,%edi
mov    $0x4c4b400,%esi
mov    $0xe8c,%edx
call   1030 <modOfPower@plt>
mov    %rbx,%rdi
mov    $0x4c4b400,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    $0x4f2e2,%edi
mov    $0x55d4a80,%esi
mov    $0xe8c,%edx
call   1030 <modOfPower@plt>
mov    %rbx,%rdi
mov    $0x55d4a80,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"324322^(%i) mod 3724 = %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
br label %5
5: ; preds = %16, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = load i32, i32* %2
%10 = mul nsw i32 %9, 10000000
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = call i32 @modOfPower(i32 324322, i32 %11, i32 3724)
store i32 %12, i32* %4
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
br label %16
16: ; preds = %8
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %5
19: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"324322^(%i) mod 3724 = %i\0A\00"
define i32 @main() {
%1 = tail call i32 @modOfPower(i32 324322, i32 10000000, i32 3724)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 10000000, i32 %1)
%3 = tail call i32 @modOfPower(i32 324322, i32 20000000, i32 3724)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 20000000, i32 %3)
%5 = tail call i32 @modOfPower(i32 324322, i32 30000000, i32 3724)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 30000000, i32 %5)
%7 = tail call i32 @modOfPower(i32 324322, i32 40000000, i32 3724)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 40000000, i32 %7)
%9 = tail call i32 @modOfPower(i32 324322, i32 50000000, i32 3724)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 50000000, i32 %9)
%11 = tail call i32 @modOfPower(i32 324322, i32 60000000, i32 3724)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 60000000, i32 %11)
%13 = tail call i32 @modOfPower(i32 324322, i32 70000000, i32 3724)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 70000000, i32 %13)
%15 = tail call i32 @modOfPower(i32 324322, i32 80000000, i32 3724)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 80000000, i32 %15)
%17 = tail call i32 @modOfPower(i32 324322, i32 90000000, i32 3724)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 90000000, i32 %17)
ret i32 0
}