#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 calc_sum(char *);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_get_str(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_pow_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_set_str(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char str[1000];
  mpz_t base;
  mpz_t res;
  mpz_init(base);
  mpz_init(res);
  mpz_set_str(base, "2", 10);
  mpz_pow_ui(res, base, 1000);
  mpz_get_str(str, 10, res);
  mpz_clear(res);
  printf("2^1000 = \n\t %s\n\n", str);
  printf("Sum of the digits: %u\n", calc_sum(str));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x404(%rbp),%edi
call   1040 <mpz_init@plt>
mov    -0x408(%rbp),%edi
call   1040 <mpz_init@plt>
mov    -0x404(%rbp),%edi
lea    0xe54(%rip),%rsi
mov    $0xa,%edx
call   1070 <mpz_set_str@plt>
mov    -0x408(%rbp),%edi
mov    -0x404(%rbp),%esi
mov    $0x3e8,%edx
call   1080 <mpz_pow_ui@plt>
lea    -0x400(%rbp),%rdi
mov    -0x408(%rbp),%edx
mov    $0xa,%esi
call   1050 <mpz_get_str@plt>
mov    -0x408(%rbp),%edi
call   1090 <mpz_clear@plt>
lea    -0x400(%rbp),%rsi
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x400(%rbp),%rdi
call   1060 <calc_sum@plt>
mov    %eax,%esi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x3f0,%rsp
call   1040 <mpz_init@plt>
call   1040 <mpz_init@plt>
lea    0xe77(%rip),%rsi
mov    $0xa,%edx
call   1070 <mpz_set_str@plt>
mov    $0x3e8,%edx
call   1080 <mpz_pow_ui@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <mpz_get_str@plt>
call   1090 <mpz_clear@plt>
lea    0xe49(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1060 <calc_sum@plt>
lea    0xe41(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"2\00"
@.str.1 = [17 x i8] c"2^1000 = \0A\09 %s\0A\0A\00"
@.str.2 = [23 x i8] c"Sum of the digits: %u\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %7
%10 = call i32 @mpz_init(i32 %9)
%11 = load i32, i32* %8
%12 = call i32 @mpz_init(i32 %11)
%13 = load i32, i32* %7
%14 = call i32 @mpz_set_str(i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 10)
%15 = load i32, i32* %8
%16 = load i32, i32* %7
%17 = call i32 @mpz_pow_ui(i32 %15, i32 %16, i32 1000)
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%19 = load i32, i32* %8
%20 = call i32 @mpz_get_str(i8* %18, i32 10, i32 %19)
%21 = load i32, i32* %8
%22 = call i32 @mpz_clear(i32 %21)
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%26 = call i32 @calc_sum(i8* %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"2\00"
@.str.1 = [17 x i8] c"2^1000 = \0A\09 %s\0A\0A\00"
@.str.2 = [23 x i8] c"Sum of the digits: %u\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%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 = call i32 @mpz_get_str(i8* %4, i32 10, i32 undef)
%10 = call i32 @mpz_clear(i32 undef)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%12 = call i32 @calc_sum(i8* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %12)
ret i32 0
}