#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*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ engine_emit(unsigned int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int sscanf(char *, char *, unsigned int *);
void loader_load_file(char *file_name) {
  FILE *file = fopen(file_name, "r");
  assert(file != NULL);
  for (;;) {
    char line[1000];
    if (fgets(line, sizeof(line), file) == NULL)
      break;
    unsigned int instr;
    int read_count = sscanf(line, "%8x", &instr);
    assert(read_count == 1);
    engine_emit(instr);
  }
  fclose(file);
}


x86 assembly (clang, -O0):
<loader_load_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x400(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3e8,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    11b9 <loader_load_file+0x59>
jmp    11fd <loader_load_file+0x9d>
lea    -0x400(%rbp),%rdi
lea    0xe3b(%rip),%rsi
lea    -0x404(%rbp),%rdx
call   1060 <sscanf@plt>
mov    %eax,-0x408(%rbp)
cmpl   $0x1,-0x408(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x404(%rbp),%edi
call   1080 <engine_emit@plt>
jmp    1195 <loader_load_file+0x35>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loader_load_file>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3f8,%rsp
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
lea    0x10(%rsp),%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11fa <loader_load_file+0x9a>
lea    0xe59(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1060 <sscanf@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1050 <assert@plt>
mov    0xc(%rsp),%edi
call   1080 <engine_emit@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    11c0 <loader_load_file+0x60>
mov    %r15,%rdi
call   1030 <fclose@plt>
add    $0x3f8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%8x\00"
define void @loader_load_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [1000 x i8]
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = icmp ne i32* %9, null
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
br label %13
13: ; preds = %19, %1
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%15 = load i32*, i32** %3
%16 = call i32* @fgets(i8* %14, i32 1000, i32* %15)
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %19
18: ; preds = %13
br label %28
19: ; preds = %13
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%21 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %5)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 1
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i32, i32* %5
%27 = call i32 @engine_emit(i32 %26)
br label %13
28: ; preds = %18
%29 = load i32*, i32** %3
%30 = call i32 @fclose(i32* %29)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [4 x i8] c"%8x\00"
define void @loader_load_file(i8* nocapture %0) {
%2 = alloca [1000 x i8]
%3 = alloca i32
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i32* %4, null
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%9 = call i32* @fgets(i8* %8, i32 1000, i32* %4)
%10 = icmp eq i32* %9, null
br i1 %10, label %22, label %11
11: ; preds = %1
%12 = bitcast i32* %3 to i8*
br label %13
13: ; preds = %11, %13
%14 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = icmp eq i32 %14, 1
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32, i32* %3
%19 = call i32 @engine_emit(i32 %18)
%20 = call i32* @fgets(i8* %8, i32 1000, i32* %4)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %13
22: ; preds = %13, %1
%23 = call i32 @fclose(i32* %4)
ret void
}