#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*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ parser(char *);
void progScanner(char *filename) {
  char instruction_string[100];
  FILE *instFile = fopen(filename, "r");
  if (instFile == NULL) {
    assert(!"Invalid file");
  }
  while (fgets(instruction_string, 100, instFile)) {
    parser(instruction_string);
  }
  fclose(instFile);
}


x86 assembly (clang, -O0):
<progScanner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    1185 <progScanner+0x35>
xor    %edi,%edi
call   1050 <assert@plt>
jmp    118a <progScanner+0x3a>
lea    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rdx
mov    $0x64,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11b4 <progScanner+0x64>
lea    -0x70(%rbp),%rdi
call   1060 <parser@plt>
jmp    118a <progScanner+0x3a>
mov    -0x78(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<progScanner>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xea2(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1172 <progScanner+0x22>
xor    %edi,%edi
call   1050 <assert@plt>
mov    %rsp,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11ad <progScanner+0x5d>
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <parser@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    1190 <progScanner+0x40>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [13 x i8] c"Invalid file\00"
define void @progScanner(i8* %0) {
%2 = alloca i8*
%3 = alloca [100 x i8]
%4 = alloca i32*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %4
%7 = load i32*, i32** %4
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @assert(i32 0)
br label %11
11: ; preds = %9, %1
br label %12
12: ; preds = %17, %11
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%14 = load i32*, i32** %4
%15 = call i64 @fgets(i8* %13, i32 100, i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%19 = call i32 @parser(i8* %18)
br label %12
20: ; preds = %12
%21 = load i32*, i32** %4
%22 = call i32 @fclose(i32* %21)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define void @progScanner(i8* nocapture %0) {
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%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 = %1
%7 = tail call i32 @assert(i32 0)
br label %8
8: ; preds = %6, %1
%9 = call i64 @fgets(i8* %3, i32 100, i32* %4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8, %11
%12 = call i32 @parser(i8* %3)
%13 = call i64 @fgets(i8* %3, i32 100, i32* %4)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %11
15: ; preds = %11, %8
%16 = call i32 @fclose(i32* %4)
ret void
}