#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, char *, int *);
int /*<<< orphan*/ printf(char *, char *, int);
int main(void) {
  char string[64];
  int num;
  FILE *fp;
  fp = fopen("file.txt", "r");
  if (fp != NULL) {
    while (!feof(fp)) {
      if (fscanf(fp, "%s %d", string, &num) != 2)
        break;
      printf("Read: %s\t%d\n", string, num);
    }
    fclose(fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     11eb <main+0x9b>
jmp    1186 <main+0x36>
mov    -0x60(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11a4 <main+0x54>
jmp    11e2 <main+0x92>
mov    -0x60(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xe58(%rip),%rsi
lea    -0x54(%rbp),%rcx
call   1050 <fscanf@plt>
cmp    $0x2,%eax
je     11ca <main+0x7a>
jmp    11e2 <main+0x92>
lea    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%edx
lea    0xe39(%rip),%rdi
call   1040 <printf@plt>
jmp    1186 <main+0x36>
mov    -0x60(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
lea    0xe9c(%rip),%rdi
lea    0xe9e(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11d9 <main+0x89>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11d1 <main+0x81>
lea    0xe80(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0xe75(%rip),%r13
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1050 <fscanf@plt>
cmp    $0x2,%eax
jne    11d1 <main+0x81>
mov    0xc(%rsp),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11a0 <main+0x50>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"file.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%s %d\00"
@.str.3 = [13 x i8] c"Read: %s\09%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca i32
%4 = alloca i32*
store i32 0, i32* %1
%5 = 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* %5, i32** %4
%6 = load i32*, i32** %4
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %27
8: ; preds = %0
br label %9
9: ; preds = %20, %8
%10 = load i32*, i32** %4
%11 = call i32 @feof(i32* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %24
14: ; preds = %9
%15 = load i32*, i32** %4
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%17 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %16, i32* %3)
%18 = icmp ne i32 %17, 2
br i1 %18, label %19, label %20
19: ; preds = %14
br label %24
20: ; preds = %14
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%22 = load i32, i32* %3
%23 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %21, i32 %22)
br label %9
24: ; preds = %19, %9
%25 = load i32*, i32** %4
%26 = call i32 @fclose(i32* %25)
br label %27
27: ; preds = %24, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"file.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%s %d\00"
@.str.3 = [13 x i8] c"Read: %s\09%d\0A\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = 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))
%6 = icmp eq i32* %5, null
br i1 %6, label %20, label %7
7: ; preds = %0
%8 = call i32 @feof(i32* %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %7, %13
%11 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %3, i32* %2)
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i32, i32* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %3, i32 %14)
%16 = call i32 @feof(i32* %5)
%17 = icmp eq i32 %16, 0
br i1 %17, label %10, label %18
18: ; preds = %13, %10, %7
%19 = call i32 @fclose(i32* %5)
br label %20
20: ; preds = %18, %0
ret i32 0
}