#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_add(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 /*<<< orphan*/);
int /*<<< orphan*/ mpz_mod(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_powm(int /*<<< orphan*/, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_ui(int /*<<< orphan*/, unsigned int);
int main(void) {
  mpz_t a, t, _10;
  mpz_init(a);
  mpz_init_set_ui(t, 0);
  mpz_init_set_str(_10, "10000000000", 10);
  unsigned int i;
  for (i = 1; i <= 1000; ++i) {
    mpz_set_ui(a, i);
    mpz_powm(a, a, a, _10);
    mpz_add(t, t, a);
  }
  mpz_mod(t, t, _10);
  gmp_printf("%Zd\n", t);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1070 <mpz_init_set_ui@plt>
mov    -0x10(%rbp),%edi
lea    0xe55(%rip),%rsi
mov    $0xa,%edx
call   1040 <mpz_init_set_str@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
ja     1201 <main+0x81>
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1080 <mpz_set_ui@plt>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <mpz_powm@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1060 <mpz_add@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bc <main+0x3c>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1090 <mpz_mod@plt>
mov    -0xc(%rbp),%esi
lea    0xdf3(%rip),%rdi
call   10a0 <gmp_printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
call   1050 <mpz_init@plt>
xor    %esi,%esi
call   1070 <mpz_init_set_ui@plt>
lea    0xe6c(%rip),%rsi
mov    $0xa,%edx
call   1040 <mpz_init_set_str@plt>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%esi
call   1080 <mpz_set_ui@plt>
call   1030 <mpz_powm@plt>
call   1060 <mpz_add@plt>
add    $0x1,%ebx
cmp    $0x3e9,%ebx
jne    11b0 <main+0x30>
call   1090 <mpz_mod@plt>
lea    0xe34(%rip),%rdi
call   10a0 <gmp_printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"10000000000\00"
@.str.1 = [5 x i8] c"%Zd\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* %2
%7 = call i32 @mpz_init(i32 %6)
%8 = load i32, i32* %3
%9 = call i32 @mpz_init_set_ui(i32 %8, i32 0)
%10 = load i32, i32* %4
%11 = call i32 @mpz_init_set_str(i32 %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 10)
store i32 1, i32* %5
br label %12
12: ; preds = %28, %0
%13 = load i32, i32* %5
%14 = icmp ule i32 %13, 1000
br i1 %14, label %15, label %31
15: ; preds = %12
%16 = load i32, i32* %2
%17 = load i32, i32* %5
%18 = call i32 @mpz_set_ui(i32 %16, i32 %17)
%19 = load i32, i32* %2
%20 = load i32, i32* %2
%21 = load i32, i32* %2
%22 = load i32, i32* %4
%23 = call i32 @mpz_powm(i32 %19, i32 %20, i32 %21, i32 %22)
%24 = load i32, i32* %3
%25 = load i32, i32* %3
%26 = load i32, i32* %2
%27 = call i32 @mpz_add(i32 %24, i32 %25, i32 %26)
br label %28
28: ; preds = %15
%29 = load i32, i32* %5
%30 = add i32 %29, 1
store i32 %30, i32* %5
br label %12
31: ; preds = %12
%32 = load i32, i32* %3
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = call i32 @mpz_mod(i32 %32, i32 %33, i32 %34)
%36 = load i32, i32* %3
%37 = call i32 @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"10000000000\00"
@.str.1 = [5 x i8] c"%Zd\0A\00"
define i32 @main() {
%1 = tail call i32 @mpz_init(i32 undef)
%2 = tail call i32 @mpz_init_set_ui(i32 undef, i32 0)
%3 = tail call i32 @mpz_init_set_str(i32 undef, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 10)
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 1, %0 ], [ %9, %4 ]
%6 = tail call i32 @mpz_set_ui(i32 undef, i32 %5)
%7 = tail call i32 @mpz_powm(i32 undef, i32 undef, i32 undef, i32 undef)
%8 = tail call i32 @mpz_add(i32 undef, i32 undef, i32 undef)
%9 = add nuw nsw i32 %5, 1
%10 = icmp eq i32 %9, 1001
br i1 %10, label %11, label %4
11: ; preds = %4
%12 = tail call i32 @mpz_mod(i32 undef, i32 undef, i32 undef)
%13 = tail call i32 @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 undef)
ret i32 0
}