#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 /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, ...);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  FILE *f_pointer = NULL;
  int id, marks;
  f_pointer = fopen("backup21.txt", "r");
  if (!f_pointer) {
    printf("\nError opening file %s", "backup21.txt");
  }
  fscanf(f_pointer, "%d", &id);
  printf("\n%d read", id);
  fscanf(f_pointer, "%d", &marks);
  printf("\n%d read marks: ", marks);
  while (!feof(f_pointer)) {
    fscanf(f_pointer, "%d %d\n", &id, &marks);
    printf("\nRead id: %d marks: %d", id, marks);
  }
  fclose(f_pointer);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe92(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119e <main+0x4e>
lea    0xe7f(%rip),%rdi
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x14(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x18(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    120a <main+0xba>
jmp    123d <main+0xed>
mov    -0x10(%rbp),%rdi
lea    0xe2b(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ec <main+0x9c>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9c(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    118d <main+0x3d>
lea    0xe90(%rip),%rdi
lea    0xe7a(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec7(%rip),%r14
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0xc(%rsp),%esi
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0x8(%rsp),%esi
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    1231 <main+0xe1>
lea    0xe51(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0xe47(%rip),%r13
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     1200 <main+0xb0>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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