#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  FILE *fp;
  int a, b;
  fp = fopen("data.txt", "r");
  if (fp == NULL) {
    printf("can not open file to read\n");
    exit(1);
  }
  while (!feof(fp) && fscanf(fp, "%d %d", &a, &b) != -1) {
    printf("%d\n", a + b);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a0 <main+0x50>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11a5 <main+0x55>
mov    -0x18(%rbp),%rdi
call   1050 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
jne    11df <main+0x8f>
mov    -0x18(%rbp),%rdi
lea    0xe5d(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1040 <fscanf@plt>
cmp    $0xffffffff,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11ef <main+0x9f>
jmp    1208 <main+0xb8>
mov    -0x1c(%rbp),%esi
add    -0x20(%rbp),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a5 <main+0x55>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe8c(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11f4 <main+0x94>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11e4 <main+0x84>
lea    0xe70(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0xe65(%rip),%r13
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1050 <fscanf@plt>
cmp    $0xffffffff,%eax
je     11e4 <main+0x84>
mov    0x8(%rsp),%esi
add    0xc(%rsp),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11b0 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe1a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"data.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [27 x i8] c"can not open file to read\0A\00"
@.str.3 = [6 x i8] c"%d %d\00"
@.str.4 = [4 x i8] c"%d\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %6
%10 = load i32*, i32** %6
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
br label %16
16: ; preds = %26, %15
%17 = load i32*, i32** %6
%18 = call i32 @feof(i32* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %16
%21 = load i32*, i32** %6
%22 = call i32 @fscanf(i32* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %7, i32* %8)
%23 = icmp ne i32 %22, -1
br label %24
24: ; preds = %20, %16
%25 = phi i1 [ false, %16 ], [ %23, %20 ]
br i1 %25, label %26, label %31
26: ; preds = %24
%27 = load i32, i32* %7
%28 = load i32, i32* %8
%29 = add nsw i32 %27, %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %16
31: ; preds = %24
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"data.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [6 x i8] c"%d %d\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@str = [26 x i8] c"can not open file to read\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = call i32 @feof(i32* %7)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %25
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %9, %18
%16 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4)
%17 = icmp eq i32 %16, -1
br i1 %17, label %25, label %18
18: ; preds = %15
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = add nsw i32 %20, %19
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = call i32 @feof(i32* %7)
%24 = icmp eq i32 %23, 0
br i1 %24, label %15, label %25
25: ; preds = %15, %18, %9
ret i32 0
}