#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 */

/* Variables and functions */
int /*<<< orphan*/ mEnter();
int menu();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ writeCatFile();
void menuLogic() {
  while (true) {
    int opt = menu();
    switch (opt) {
    case 0:
      printf("Wrong Option.\n");
      break;
    case 1:
      mEnter();
      break;
    case 2:
      printf("NOOP.\n");
      break;
    case 3:
      printf("NOOP.\n");
      break;
    case 4:
      return;
    case 5:
      if (writeCatFile() == 0) {
        printf("Wrote to Catalog file.\n");
      } else {
        printf("Failed to write to Catalog file!\n");
      }
      break;
    }
  }
}


x86 assembly (clang, -O0):
<menuLogic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <menu@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x5,%rax
ja     11ee <menuLogic+0xae>
mov    -0x10(%rbp),%rax
lea    0xe92(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
jmp    11ee <menuLogic+0xae>
mov    $0x0,%al
call   1050 <mEnter@plt>
jmp    11ee <menuLogic+0xae>
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
jmp    11ee <menuLogic+0xae>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
jmp    11ee <menuLogic+0xae>
add    $0x10,%rsp
pop    %rbp
ret
mov    $0x0,%al
call   1060 <writeCatFile@plt>
cmp    $0x0,%eax
jne    11dd <menuLogic+0x9d>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
jmp    11e9 <menuLogic+0xa9>
lea    0xe62(%rip),%rdi
call   1040 <printf@plt>
jmp    11ee <menuLogic+0xae>
jmp    1148 <menuLogic+0x8>

x86 assembly (clang, -O2):
<menuLogic>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xeb0(%rip),%rbx
lea    0xeff(%rip),%r14
lea    0xef2(%rip),%r13
lea    0xed4(%rip),%r15
lea    0xeac(%rip),%r12
jmp    1178 <menuLogic+0x38>
xchg   %ax,%ax
mov    %r13,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <menu@plt>
cmp    $0x5,%eax
ja     1178 <menuLogic+0x38>
mov    %eax,%eax
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    %r14,%rdi
call   1030 <puts@plt>
jmp    1178 <menuLogic+0x38>
xor    %eax,%eax
call   1050 <mEnter@plt>
jmp    1178 <menuLogic+0x38>
xor    %eax,%eax
call   1060 <writeCatFile@plt>
test   %eax,%eax
je     11b7 <menuLogic+0x77>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    1178 <menuLogic+0x38>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    1178 <menuLogic+0x38>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Wrong Option.\0A\00"
@.str.1 = [7 x i8] c"NOOP.\0A\00"
@.str.2 = [24 x i8] c"Wrote to Catalog file.\0A\00"
@.str.3 = [34 x i8] c"Failed to write to Catalog file!\0A\00"
define void @menuLogic() {
%1 = alloca i32
br label %2
2: ; preds = %0, %22
%3 = call i32 (...) @menu()
store i32 %3, i32* %1
%4 = load i32, i32* %1
switch i32 %4, label %22 [
i32 0, label %5
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %14
]
5: ; preds = %2
%6 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %22
7: ; preds = %2
%8 = call i32 (...) @mEnter()
br label %22
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %22
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %22
13: ; preds = %2
ret void
14: ; preds = %2
%15 = call i32 (...) @writeCatFile()
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %21
19: ; preds = %14
%20 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
br label %22
22: ; preds = %2, %21, %11, %9, %7, %5
br label %2
}

LLVM IR (-O2):
@str = [33 x i8] c"Failed to write to Catalog file!\00"
@str.4 = [23 x i8] c"Wrote to Catalog file.\00"
@str.6 = [6 x i8] c"NOOP.\00"
@str.7 = [14 x i8] c"Wrong Option.\00"
define void @menuLogic() {
br label %1
1: ; preds = %5, %0
%2 = tail call i32 (...) @menu()
switch i32 %2, label %5 [
i32 0, label %3
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 4, label %19
i32 5, label %12
]
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
br label %5
5: ; preds = %3, %6, %8, %10, %1, %17, %15
br label %1
6: ; preds = %1
%7 = tail call i32 (...) @mEnter()
br label %5
8: ; preds = %1
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.6, i64 0, i64 0))
br label %5
10: ; preds = %1
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.6, i64 0, i64 0))
br label %5
12: ; preds = %1
%13 = tail call i32 (...) @writeCatFile()
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.4, i64 0, i64 0))
br label %5
17: ; preds = %12
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %5
19: ; preds = %1
ret void
}