#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 EXIT_SUCCESS;
int /*<<< orphan*/ gmp_printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_div_ui(int /*<<< orphan*/, int /*<<< orphan*/,
                              unsigned long);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mod_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_pow_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_set_str(int /*<<< orphan*/, char *, int);
scalar_t__ mpz_sgn(int /*<<< orphan*/);
int main(int argc, const char *argv[]) {
  mpz_t base;
  mpz_t result;
  mpz_t sum;
  mpz_t aux;
  mpz_init(base);
  mpz_init(result);
  mpz_init(sum);
  mpz_init(aux);
  mpz_set_str(base, "2", 10);
  mpz_pow_ui(result, base, 1000);
  while (mpz_sgn(result) > 0) {
    mpz_mod_ui(aux, result, 10);
    mpz_add(sum, sum, aux);
    mpz_div_ui(result, result, (unsigned long int)10);
  }
  gmp_printf("%Zd\n", sum);
  mpz_clear(base);
  mpz_clear(sum);
  mpz_clear(aux);
  mpz_clear(result);
  return EXIT_SUCCESS;
}


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
call   1050 <mpz_init@plt>
mov    -0x18(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x1c(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x20(%rbp),%edi
call   1050 <mpz_init@plt>
mov    -0x14(%rbp),%edi
lea    0xe30(%rip),%rsi
mov    $0xa,%edx
call   1070 <mpz_set_str@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x3e8,%edx
call   1080 <mpz_pow_ui@plt>
mov    -0x18(%rbp),%edi
call   10b0 <mpz_sgn@plt>
cmp    $0x0,%rax
jle    122f <main+0x9f>
mov    -0x20(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0xa,%edx
call   1040 <mpz_mod_ui@plt>
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1060 <mpz_add@plt>
mov    -0x18(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0xa,%edx
call   1030 <mpz_div_ui@plt>
jmp    11ea <main+0x5a>
mov    -0x1c(%rbp),%esi
lea    0xdc9(%rip),%rdi
call   10a0 <gmp_printf@plt>
mov    -0x14(%rbp),%edi
call   1090 <mpz_clear@plt>
mov    -0x1c(%rbp),%edi
call   1090 <mpz_clear@plt>
mov    -0x20(%rbp),%edi
call   1090 <mpz_clear@plt>
mov    -0x18(%rbp),%edi
call   1090 <mpz_clear@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1050 <mpz_init@plt>
call   1050 <mpz_init@plt>
call   1050 <mpz_init@plt>
call   1050 <mpz_init@plt>
lea    0xe54(%rip),%rsi
mov    $0xa,%edx
call   1070 <mpz_set_str@plt>
mov    $0x3e8,%edx
call   1080 <mpz_pow_ui@plt>
call   10b0 <mpz_sgn@plt>
test   %rax,%rax
jle    11e5 <main+0x55>
mov    $0xa,%edx
call   1040 <mpz_mod_ui@plt>
call   1060 <mpz_add@plt>
mov    $0xa,%edx
call   1030 <mpz_div_ui@plt>
jmp    11c0 <main+0x30>
lea    0xe16(%rip),%rdi
call   10a0 <gmp_printf@plt>
call   1090 <mpz_clear@plt>
call   1090 <mpz_clear@plt>
call   1090 <mpz_clear@plt>
call   1090 <mpz_clear@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"2\00"
@.str.1 = [5 x i8] c"%Zd\0A\00"
@EXIT_SUCCESS = global i32 0
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(i32 %10)
%12 = load i32, i32* %7
%13 = call i32 @mpz_init(i32 %12)
%14 = load i32, i32* %8
%15 = call i32 @mpz_init(i32 %14)
%16 = load i32, i32* %9
%17 = call i32 @mpz_init(i32 %16)
%18 = load i32, i32* %6
%19 = call i32 @mpz_set_str(i32 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 10)
%20 = load i32, i32* %7
%21 = load i32, i32* %6
%22 = call i32 @mpz_pow_ui(i32 %20, i32 %21, i32 1000)
br label %23
23: ; preds = %27, %2
%24 = load i32, i32* %7
%25 = call i64 @mpz_sgn(i32 %24)
%26 = icmp sgt i64 %25, 0
br i1 %26, label %27, label %38
27: ; preds = %23
%28 = load i32, i32* %9
%29 = load i32, i32* %7
%30 = call i32 @mpz_mod_ui(i32 %28, i32 %29, i32 10)
%31 = load i32, i32* %8
%32 = load i32, i32* %8
%33 = load i32, i32* %9
%34 = call i32 @mpz_add(i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* %7
%36 = load i32, i32* %7
%37 = call i32 @mpz_div_ui(i32 %35, i32 %36, i64 10)
br label %23
38: ; preds = %23
%39 = load i32, i32* %8
%40 = call i32 @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %6
%42 = call i32 @mpz_clear(i32 %41)
%43 = load i32, i32* %8
%44 = call i32 @mpz_clear(i32 %43)
%45 = load i32, i32* %9
%46 = call i32 @mpz_clear(i32 %45)
%47 = load i32, i32* %7
%48 = call i32 @mpz_clear(i32 %47)
%49 = load i32, i32* @EXIT_SUCCESS
ret i32 %49
}

LLVM IR (-O2):
@.str = [2 x i8] c"2\00"
@.str.1 = [5 x i8] c"%Zd\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @mpz_init(i32 undef)
%4 = tail call i32 @mpz_init(i32 undef)
%5 = tail call i32 @mpz_init(i32 undef)
%6 = tail call i32 @mpz_init(i32 undef)
%7 = tail call i32 @mpz_set_str(i32 undef, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 10)
%8 = tail call i32 @mpz_pow_ui(i32 undef, i32 undef, i32 1000)
%9 = tail call i64 @mpz_sgn(i32 undef)
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %2, %11
%12 = tail call i32 @mpz_mod_ui(i32 undef, i32 undef, i32 10)
%13 = tail call i32 @mpz_add(i32 undef, i32 undef, i32 undef)
%14 = tail call i32 @mpz_div_ui(i32 undef, i32 undef, i64 10)
%15 = tail call i64 @mpz_sgn(i32 undef)
%16 = icmp sgt i64 %15, 0
br i1 %16, label %11, label %17
17: ; preds = %11, %2
%18 = tail call i32 @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 undef)
%19 = tail call i32 @mpz_clear(i32 undef)
%20 = tail call i32 @mpz_clear(i32 undef)
%21 = tail call i32 @mpz_clear(i32 undef)
%22 = tail call i32 @mpz_clear(i32 undef)
%23 = load i32, i32* @EXIT_SUCCESS
ret i32 %23
}