#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 */
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ gmp_printf(char *, int /*<<< orphan*/, ...);
int /*<<< orphan*/ mpz_clears(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set_str(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ mpz_init_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_powm(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int main(const int argc, const char **argv) {
  mpz_t x, y, z, o;
  mpz_init_set_str(x, "17", 10);
  mpz_init_set_ui(y, 1729);
  mpz_init_set_ui(z, 7);
  mpz_init(o);
  mpz_powm(o, x, y, z);
  gmp_printf("x = %Zd\ny = %Zd\nz = %Zd\n", x, y, z);
  gmp_printf("x^y (mod z) = %Zd\n", o);
  mpz_clears(x, y, z, o);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x14(%rbp),%edi
lea    0xe80(%rip),%rsi
mov    $0xa,%edx
call   1050 <mpz_init_set_str@plt>
mov    -0x18(%rbp),%edi
mov    $0x6c1,%esi
call   1070 <mpz_init_set_ui@plt>
mov    -0x1c(%rbp),%edi
mov    $0x7,%esi
call   1070 <mpz_init_set_ui@plt>
mov    -0x20(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0x20(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1030 <mpz_powm@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1080 <gmp_printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1080 <gmp_printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1040 <mpz_clears@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xe98(%rip),%rsi
mov    $0xa,%edx
call   1050 <mpz_init_set_str@plt>
mov    $0x6c1,%esi
call   1070 <mpz_init_set_ui@plt>
mov    $0x7,%esi
call   1070 <mpz_init_set_ui@plt>
call   1060 <mpz_init@plt>
call   1030 <mpz_powm@plt>
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1080 <gmp_printf@plt>
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1080 <gmp_printf@plt>
call   1040 <mpz_clears@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"17\00"
@.str.1 = [25 x i8] c"x = %Zd\0Ay = %Zd\0Az = %Zd\0A\00"
@.str.2 = [19 x i8] c"x^y (mod z) = %Zd\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %6
%11 = call i32 @mpz_init_set_str(i32 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 10)
%12 = load i32, i32* %7
%13 = call i32 @mpz_init_set_ui(i32 %12, i32 1729)
%14 = load i32, i32* %8
%15 = call i32 @mpz_init_set_ui(i32 %14, i32 7)
%16 = load i32, i32* %9
%17 = call i32 @mpz_init(i32 %16)
%18 = load i32, i32* %9
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = call i32 @mpz_powm(i32 %18, i32 %19, i32 %20, i32 %21)
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = call i32 (i8*, i32, ...) @gmp_printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %24, i32 %25)
%27 = load i32, i32* %9
%28 = call i32 (i8*, i32, ...) @gmp_printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %6
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = call i32 @mpz_clears(i32 %29, i32 %30, i32 %31, i32 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"17\00"
@.str.1 = [25 x i8] c"x = %Zd\0Ay = %Zd\0Az = %Zd\0A\00"
@.str.2 = [19 x i8] c"x^y (mod z) = %Zd\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @mpz_init_set_str(i32 undef, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 10)
%4 = tail call i32 @mpz_init_set_ui(i32 undef, i32 1729)
%5 = tail call i32 @mpz_init_set_ui(i32 undef, i32 7)
%6 = tail call i32 @mpz_init(i32 undef)
%7 = tail call i32 @mpz_powm(i32 undef, i32 undef, i32 undef, i32 undef)
%8 = tail call i32 (i8*, i32, ...) @gmp_printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 undef, i32 undef, i32 undef)
%9 = tail call i32 (i8*, i32, ...) @gmp_printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 undef)
%10 = tail call i32 @mpz_clears(i32 undef, i32 undef, i32 undef, i32 undef)
ret i32 0
}