#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 uint8_t;

/* Variables and functions */
int changeDir();
int /*<<< orphan*/ dumpImage();
scalar_t__ genMenu();
int loadHelp();
int /*<<< orphan*/ loadImage();
int selectImage(int);
int /*<<< orphan*/ setup();
int main(void) {
  uint8_t regen = 1;
  uint8_t sel = 0x00;
  setup();
  while (1) {
    if (regen && genMenu())
      break;
    sel = selectImage(0);
    if (sel == 0x00)
      break;
    else if (sel == 0x02)
      regen = loadHelp();
    else
      regen = changeDir();
  }
  while (1) {
    if (sel == 0x03)
      dumpImage();
    else
      loadImage();
    sel = selectImage(1);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1090 <setup@plt>
cmpl   $0x0,-0x8(%rbp)
je     11b4 <main+0x44>
mov    $0x0,%al
call   1060 <genMenu@plt>
cmp    $0x0,%rax
je     11b4 <main+0x44>
jmp    11fa <main+0x8a>
xor    %edi,%edi
call   1030 <selectImage@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11cd <main+0x5d>
jmp    11fa <main+0x8a>
cmpl   $0x2,-0xc(%rbp)
jne    11e6 <main+0x76>
mov    $0x0,%al
call   1040 <loadHelp@plt>
mov    %eax,-0x8(%rbp)
jmp    11f0 <main+0x80>
mov    $0x0,%al
call   1050 <changeDir@plt>
mov    %eax,-0x8(%rbp)
jmp    11f5 <main+0x85>
jmp    1194 <main+0x24>
jmp    11ff <main+0x8f>
cmpl   $0x3,-0xc(%rbp)
jne    1215 <main+0xa5>
mov    $0x0,%al
call   1080 <dumpImage@plt>
jmp    121c <main+0xac>
mov    $0x0,%al
call   1070 <loadImage@plt>
mov    $0x1,%edi
call   1030 <selectImage@plt>
mov    %eax,-0xc(%rbp)
jmp    11ff <main+0x8f>

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1090 <setup@plt>
mov    $0x1,%eax
xor    %ebx,%ebx
test   %eax,%eax
jne    119b <main+0x2b>
jmp    11a7 <main+0x37>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <loadHelp@plt>
test   %eax,%eax
je     11a7 <main+0x37>
xor    %eax,%eax
call   1060 <genMenu@plt>
test   %rax,%rax
jne    11e1 <main+0x71>
xor    %edi,%edi
call   1030 <selectImage@plt>
mov    %eax,%ebx
cmp    $0x2,%eax
je     1190 <main+0x20>
test   %ebx,%ebx
je     11e1 <main+0x71>
xor    %eax,%eax
call   1050 <changeDir@plt>
test   %eax,%eax
jne    119b <main+0x2b>
jmp    11a7 <main+0x37>
cs nopw 0x0(%rax,%rax,1)
call   1070 <loadImage@plt>
mov    $0x1,%edi
call   1030 <selectImage@plt>
mov    %eax,%ebx
xor    %eax,%eax
cmp    $0x3,%ebx
jne    11d0 <main+0x60>
call   1080 <dumpImage@plt>
jmp    11d5 <main+0x65>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 0, i32* %3
%4 = call i32 (...) @setup()
br label %5
5: ; preds = %0, %25
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = call i64 (...) @genMenu()
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
br label %26
12: ; preds = %8, %5
%13 = call i32 @selectImage(i32 0)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
br label %26
17: ; preds = %12
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (...) @loadHelp()
store i32 %21, i32* %2
br label %24
22: ; preds = %17
%23 = call i32 (...) @changeDir()
store i32 %23, i32* %2
br label %24
24: ; preds = %22, %20
br label %25
25: ; preds = %24
br label %5
26: ; preds = %16, %11
br label %27
27: ; preds = %26, %34
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 3
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (...) @dumpImage()
br label %34
32: ; preds = %27
%33 = call i32 (...) @loadImage()
br label %34
34: ; preds = %32, %30
%35 = call i32 @selectImage(i32 1)
store i32 %35, i32* %3
br label %27
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @setup()
br label %2
2: ; preds = %15, %0
%3 = phi i32 [ 1, %0 ], [ %16, %15 ]
%4 = phi i32 [ 0, %0 ], [ %12, %15 ]
%5 = icmp eq i32 %3, 0
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = tail call i64 (...) @genMenu()
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %11, %6
%10 = phi i32 [ %12, %11 ], [ %4, %6 ]
br label %19
11: ; preds = %6, %2
%12 = tail call i32 @selectImage(i32 0)
switch i32 %12, label %17 [
i32 0, label %9
i32 2, label %13
]
13: ; preds = %11
%14 = tail call i32 (...) @loadHelp()
br label %15
15: ; preds = %13, %17
%16 = phi i32 [ %14, %13 ], [ %18, %17 ]
br label %2
17: ; preds = %11
%18 = tail call i32 (...) @changeDir()
br label %15
19: ; preds = %9, %26
%20 = phi i32 [ %27, %26 ], [ %10, %9 ]
%21 = icmp eq i32 %20, 3
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 (...) @dumpImage()
br label %26
24: ; preds = %19
%25 = tail call i32 (...) @loadImage()
br label %26
26: ; preds = %24, %22
%27 = tail call i32 @selectImage(i32 1)
br label %19
}