#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*/ deleteRecord(int /*<<< orphan*/ *);
int enterChoice();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ newRecord(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ textFile(int /*<<< orphan*/ *);
int /*<<< orphan*/ updateRecord(int /*<<< orphan*/ *);
int main(void) {
  FILE *cfPtr;
  int choice;
  if ((cfPtr = fopen("credit.dat", "rb+")) == NULL) {
    printf("File could not be opened.\n");
  } else {
    while ((choice = enterChoice()) != 5) {
      switch (choice) {
      case 1:
        textFile(cfPtr);
        break;
      case 2:
        updateRecord(cfPtr);
        break;
      case 3:
        newRecord(cfPtr);
        break;
      case 4:
        deleteRecord(cfPtr);
        break;
      default:
        printf("Incorrect choice\n");
        break;
      }
    }
    fclose(cfPtr);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11c1 <main+0x41>
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
jmp    1254 <main+0xd4>
jmp    11c6 <main+0x46>
mov    $0x0,%al
call   1050 <enterChoice@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x5,%eax
je     124b <main+0xcb>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     123a <main+0xba>
mov    -0x20(%rbp),%rax
lea    0xe07(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
call   10a0 <textFile@plt>
jmp    1246 <main+0xc6>
mov    -0x10(%rbp),%rdi
call   1070 <updateRecord@plt>
jmp    1246 <main+0xc6>
mov    -0x10(%rbp),%rdi
call   1080 <newRecord@plt>
jmp    1246 <main+0xc6>
mov    -0x10(%rbp),%rdi
call   1060 <deleteRecord@plt>
jmp    1246 <main+0xc6>
lea    0xdf9(%rip),%rdi
call   1040 <printf@plt>
jmp    11c6 <main+0x46>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xe88(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     120a <main+0x8a>
mov    %rax,%r15
lea    0xe7c(%rip),%r14
lea    0xe52(%rip),%rbx
jmp    11c0 <main+0x40>
mov    %r15,%rdi
call   1060 <deleteRecord@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <enterChoice@plt>
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     11e2 <main+0x62>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    %r15,%rdi
call   10a0 <textFile@plt>
jmp    11c0 <main+0x40>
mov    %r14,%rdi
call   1030 <puts@plt>
jmp    11c0 <main+0x40>
mov    %r15,%rdi
call   1070 <updateRecord@plt>
jmp    11c0 <main+0x40>
mov    %r15,%rdi
call   1080 <newRecord@plt>
jmp    11c0 <main+0x40>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    1216 <main+0x96>
lea    0xe23(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"credit.dat\00"
@.str.1 = [4 x i8] c"rb+\00"
@.str.2 = [27 x i8] c"File could not be opened.\0A\00"
@.str.3 = [18 x i8] c"Incorrect choice\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %32
8: ; preds = %0
br label %9
9: ; preds = %28, %8
%10 = call i32 (...) @enterChoice()
store i32 %10, i32* %3
%11 = icmp ne i32 %10, 5
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = load i32, i32* %3
switch i32 %13, label %26 [
i32 1, label %14
i32 2, label %17
i32 3, label %20
i32 4, label %23
]
14: ; preds = %12
%15 = load i32*, i32** %2
%16 = call i32 @textFile(i32* %15)
br label %28
17: ; preds = %12
%18 = load i32*, i32** %2
%19 = call i32 @updateRecord(i32* %18)
br label %28
20: ; preds = %12
%21 = load i32*, i32** %2
%22 = call i32 @newRecord(i32* %21)
br label %28
23: ; preds = %12
%24 = load i32*, i32** %2
%25 = call i32 @deleteRecord(i32* %24)
br label %28
26: ; preds = %12
%27 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %23, %20, %17, %14
br label %9
29: ; preds = %9
%30 = load i32*, i32** %2
%31 = call i32 @fclose(i32* %30)
br label %32
32: ; preds = %29, %6
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"credit.dat\00"
@.str.1 = [4 x i8] c"rb+\00"
@str = [17 x i8] c"Incorrect choice\00"
@str.4 = [26 x i8] c"File could not be opened.\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.4, i64 0, i64 0))
br label %20
5: ; preds = %0, %17
%6 = tail call i32 (...) @enterChoice()
switch i32 %6, label %15 [
i32 5, label %18
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
]
7: ; preds = %5
%8 = tail call i32 @textFile(i32* %1)
br label %17
9: ; preds = %5
%10 = tail call i32 @updateRecord(i32* %1)
br label %17
11: ; preds = %5
%12 = tail call i32 @newRecord(i32* %1)
br label %17
13: ; preds = %5
%14 = tail call i32 @deleteRecord(i32* %1)
br label %17
15: ; preds = %5
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %15, %13, %11, %9, %7
br label %5
18: ; preds = %5
%19 = tail call i32 @fclose(i32* %1)
br label %20
20: ; preds = %18, %3
ret i32 0
}