#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*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *);
void read_header(char *filename, int *size, int *size_2) {
  FILE *fid;
  int i;
  char c;
  fid = fopen(filename, "r");
  if (fid == NULL) {
    printf("The file was not opened for reading\n");
    return;
  }
  i = 0;
  while (i < 1) {
    c = fgetc(fid);
    if (c == '\n') {
      i = i + 1;
    }
  };
  fscanf(fid, "%d", &size[0]);
  fscanf(fid, "%d", &size_2[0]);
  fclose(fid);
}


x86 assembly (clang, -O0):
<read_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1194 <read_header+0x44>
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
jmp    11fd <read_header+0xad>
movl   $0x0,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jge    11cc <read_header+0x7c>
mov    -0x20(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x25(%rbp)
movsbl -0x25(%rbp),%eax
cmp    $0xa,%eax
jne    11c7 <read_header+0x77>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119b <read_header+0x4b>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe4c(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe38(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_header>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c2 <read_header+0x72>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <fgetc@plt>
cmp    $0xa,%al
jne    1180 <read_header+0x30>
lea    0xe6f(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1050 <fscanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <fscanf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <fclose@plt>
lea    0xe3c(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [37 x i8] c"The file was not opened for reading\0A\00"
@.str.2 = [3 x i8] c"%d\00"
define void @read_header(i8* %0, i32* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
br label %41
16: ; preds = %3
store i32 0, i32* %8
br label %17
17: ; preds = %29, %16
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 1
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = load i32*, i32** %7
%22 = call signext i8 @fgetc(i32* %21)
store i8 %22, i8* %9
%23 = load i8, i8* %9
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %29
29: ; preds = %26, %20
br label %17
30: ; preds = %17
%31 = load i32*, i32** %7
%32 = load i32*, i32** %5
%33 = getelementptr inbounds i32, i32* %32, i64 0
%34 = call i32 @fscanf(i32* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %33)
%35 = load i32*, i32** %7
%36 = load i32*, i32** %6
%37 = getelementptr inbounds i32, i32* %36, i64 0
%38 = call i32 @fscanf(i32* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %37)
%39 = load i32*, i32** %7
%40 = call i32 @fclose(i32* %39)
br label %41
41: ; preds = %30, %14
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@str = [36 x i8] c"The file was not opened for reading\00"
define void @read_header(i8* nocapture %0, i32* %1, i32* %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
br label %15
8: ; preds = %3, %8
%9 = tail call signext i8 @fgetc(i32* %4)
%10 = icmp eq i8 %9, 10
br i1 %10, label %11, label %8
11: ; preds = %8
%12 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%13 = tail call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%14 = tail call i32 @fclose(i32* %4)
br label %15
15: ; preds = %11, %6
ret void
}