#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*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *);
int requestMenuOption();
int /*<<< orphan*/ selectOption(int);
int main() {
  int selectedOption;
  do {
    FILE *f;
    f = fopen("car.txt", "r");
    if (f != NULL) {
      selectedOption = requestMenuOption();
    } else {
      selectedOption = 0;
      printf("ERROR READING FILE\n");
    }
    fclose(f);
    selectOption(selectedOption);
  } while (selectedOption != 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1190 <main+0x40>
mov    $0x0,%al
call   1050 <requestMenuOption@plt>
mov    %eax,-0x8(%rbp)
jmp    11a3 <main+0x53>
movl   $0x0,-0x8(%rbp)
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x8(%rbp),%edi
call   1060 <selectOption@plt>
cmpl   $0x0,-0x8(%rbp)
jne    115f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xea1(%rip),%r14
lea    0xea2(%rip),%r12
lea    0xe9d(%rip),%r15
jmp    118d <main+0x3d>
nop
mov    %r15,%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %ebp,%edi
call   1060 <selectOption@plt>
test   %ebp,%ebp
je     11ab <main+0x5b>
mov    %r14,%rdi
mov    %r12,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1170 <main+0x20>
xor    %eax,%eax
call   1050 <requestMenuOption@plt>
mov    %eax,%ebp
jmp    117a <main+0x2a>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"car.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"ERROR READING FILE\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
br label %4
4: ; preds = %17, %0
%5 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 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** %3
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = call i32 (...) @requestMenuOption()
store i32 %9, i32* %2
br label %12
10: ; preds = %4
store i32 0, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = load i32*, i32** %3
%14 = call i32 @fclose(i32* %13)
%15 = load i32, i32* %2
%16 = call i32 @selectOption(i32 %15)
br label %17
17: ; preds = %12
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 0
br i1 %19, label %4, label %20
20: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"car.txt\00"
@.str.1 = [2 x i8] c"r\00"
@str = [19 x i8] c"ERROR READING FILE\00"
define i32 @main() {
br label %1
1: ; preds = %8, %0
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 (...) @requestMenuOption()
br label %8
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
%9 = phi i32 [ %5, %4 ], [ 0, %6 ]
%10 = tail call i32 @fclose(i32* %2)
%11 = tail call i32 @selectOption(i32 %9)
%12 = icmp eq i32 %9, 0
br i1 %12, label %13, label %1
13: ; preds = %8
ret i32 0
}