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

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int gmp_printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_add(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_str(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_set_ui(int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  FILE *file;
  char buffer[128];
  mpz_t rez, cnm;
  mpz_init(rez);
  mpz_init(cnm);
  mpz_set_ui(rez, 0);
  file = fopen("p13.txt", "r");
  if (file == NULL)
    return 0;
  while (fgets(buffer, sizeof(buffer), file) != NULL) {
    mpz_set_str(cnm, buffer, 0);
    mpz_add(rez, rez, cnm);
  }
  return gmp_printf("%Zd\n", rez);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x94(%rbp),%edi
call   1040 <mpz_init@plt>
mov    -0x98(%rbp),%edi
call   1040 <mpz_init@plt>
mov    -0x94(%rbp),%edi
xor    %esi,%esi
call   1070 <mpz_set_ui@plt>
lea    0xe54(%rip),%rdi
lea    0xe55(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d3 <main+0x63>
movl   $0x0,-0x4(%rbp)
jmp    123c <main+0xcc>
jmp    11d8 <main+0x68>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x80,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     1227 <main+0xb7>
mov    -0x98(%rbp),%edi
lea    -0x90(%rbp),%rsi
xor    %edx,%edx
call   1060 <mpz_set_str@plt>
mov    -0x94(%rbp),%edi
mov    -0x94(%rbp),%esi
mov    -0x98(%rbp),%edx
call   1050 <mpz_add@plt>
jmp    11d8 <main+0x68>
mov    -0x94(%rbp),%esi
lea    0xdd6(%rip),%rdi
call   1090 <gmp_printf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
call   1040 <mpz_init@plt>
call   1040 <mpz_init@plt>
xor    %ebx,%ebx
xor    %esi,%esi
call   1070 <mpz_set_ui@plt>
lea    0xe6c(%rip),%rdi
lea    0xe6d(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11f2 <main+0x82>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x80,%esi
mov    %rax,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     11e4 <main+0x74>
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %edx,%edx
call   1060 <mpz_set_str@plt>
call   1050 <mpz_add@plt>
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
jne    11c0 <main+0x50>
lea    0xe1f(%rip),%rdi
call   1090 <gmp_printf@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"p13.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"%Zd\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [128 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* %4
%7 = call i32 @mpz_init(i32 %6)
%8 = load i32, i32* %5
%9 = call i32 @mpz_init(i32 %8)
%10 = load i32, i32* %4
%11 = call i32 @mpz_set_ui(i32 %10, i32 0)
%12 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %2
%13 = load i32*, i32** %2
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %16
15: ; preds = %0
store i32 0, i32* %1
br label %33
16: ; preds = %0
br label %17
17: ; preds = %22, %16
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%19 = load i32*, i32** %2
%20 = call i32* @fgets(i8* %18, i32 128, i32* %19)
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %30
22: ; preds = %17
%23 = load i32, i32* %5
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%25 = call i32 @mpz_set_str(i32 %23, i8* %24, i32 0)
%26 = load i32, i32* %4
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = call i32 @mpz_add(i32 %26, i32 %27, i32 %28)
br label %17
30: ; preds = %17
%31 = load i32, i32* %4
%32 = call i32 @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %31)
store i32 %32, i32* %1
br label %33
33: ; preds = %30, %15
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str = [8 x i8] c"p13.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"%Zd\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @mpz_init(i32 undef)
%4 = tail call i32 @mpz_init(i32 undef)
%5 = tail call i32 @mpz_set_ui(i32 undef, i32 0)
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %18, label %8
8: ; preds = %0
%9 = call i32* @fgets(i8* %2, i32 128, i32* %6)
%10 = icmp eq i32* %9, null
br i1 %10, label %16, label %11
11: ; preds = %8, %11
%12 = call i32 @mpz_set_str(i32 undef, i8* %2, i32 0)
%13 = call i32 @mpz_add(i32 undef, i32 undef, i32 undef)
%14 = call i32* @fgets(i8* %2, i32 128, i32* %6)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %11
16: ; preds = %11, %8
%17 = call i32 @gmp_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 undef)
br label %18
18: ; preds = %0, %16
%19 = phi i32 [ %17, %16 ], [ 0, %0 ]
ret i32 %19
}