#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 */
scalar_t__ checkOne(char *, char *);
char *getInput();
int /*<<< orphan*/ printMessageC(char *, char *);
int fightMenu() {
  printMessageC("=============================", "\x1b[31m");
  printMessageC("1: Attack | 2: Rest | 3: Flee", "\x1b[33m");
  printMessageC("=============================", "\x1b[31m");
  char *choice = getInput();
  if (checkOne(choice, "1") == 0) {
    return 1;
  } else if (checkOne(choice, "2") == 0) {
    return 2;
  } else if (checkOne(choice, "3") == 0) {
    return 3;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<fightMenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xed8(%rip),%rsi
call   1040 <printMessageC@plt>
lea    0xed2(%rip),%rdi
lea    0xee9(%rip),%rsi
call   1040 <printMessageC@plt>
lea    0xe9b(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1040 <printMessageC@plt>
mov    $0x0,%al
call   1030 <getInput@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1050 <checkOne@plt>
cmp    $0x0,%rax
jne    11a2 <fightMenu+0x72>
movl   $0x1,-0x4(%rbp)
jmp    11f5 <fightMenu+0xc5>
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <checkOne@plt>
cmp    $0x0,%rax
jne    11c8 <fightMenu+0x98>
movl   $0x2,-0x4(%rbp)
jmp    11f5 <fightMenu+0xc5>
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1050 <checkOne@plt>
cmp    $0x0,%rax
jne    11ee <fightMenu+0xbe>
movl   $0x3,-0x4(%rbp)
jmp    11f5 <fightMenu+0xc5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fightMenu>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rbx
lea    0xedc(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <printMessageC@plt>
lea    0xed0(%rip),%rdi
lea    0xee7(%rip),%rsi
call   1040 <printMessageC@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <printMessageC@plt>
xor    %eax,%eax
call   1030 <getInput@plt>
mov    %rax,%rbx
lea    0xecc(%rip),%rsi
mov    %rax,%rdi
call   1050 <checkOne@plt>
test   %rax,%rax
je     11b9 <fightMenu+0x89>
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
call   1050 <checkOne@plt>
test   %rax,%rax
je     11c0 <fightMenu+0x90>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1050 <checkOne@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    (%rcx,%rcx,2),%eax
jmp    11c5 <fightMenu+0x95>
mov    $0x1,%eax
jmp    11c5 <fightMenu+0x95>
mov    $0x2,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [30 x i8] c"=============================\00"
@.str.1 = [6 x i8] c"\1B[31m\00"
@.str.2 = [30 x i8] c"1: Attack | 2: Rest | 3: Flee\00"
@.str.3 = [6 x i8] c"\1B[33m\00"
@.str.4 = [2 x i8] c"1\00"
@.str.5 = [2 x i8] c"2\00"
@.str.6 = [2 x i8] c"3\00"
define i32 @fightMenu() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i32 @printMessageC(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printMessageC(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32 @printMessageC(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%6 = call i8* (...) @getInput()
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i64 @checkOne(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 1, i32* %1
br label %22
11: ; preds = %0
%12 = load i8*, i8** %2
%13 = call i64 @checkOne(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 2, i32* %1
br label %22
16: ; preds = %11
%17 = load i8*, i8** %2
%18 = call i64 @checkOne(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 3, i32* %1
br label %22
21: ; preds = %16
store i32 0, i32* %1
br label %22
22: ; preds = %21, %20, %15, %10
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [30 x i8] c"=============================\00"
@.str.1 = [6 x i8] c"\1B[31m\00"
@.str.2 = [30 x i8] c"1: Attack | 2: Rest | 3: Flee\00"
@.str.3 = [6 x i8] c"\1B[33m\00"
@.str.4 = [2 x i8] c"1\00"
@.str.5 = [2 x i8] c"2\00"
@.str.6 = [2 x i8] c"3\00"
define i32 @fightMenu() {
%1 = tail call i32 @printMessageC(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @printMessageC(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%3 = tail call i32 @printMessageC(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i8* (...) @getInput()
%5 = tail call i64 @checkOne(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %0
%8 = tail call i64 @checkOne(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i64 @checkOne(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i32 3, i32 0
br label %14
14: ; preds = %10, %7, %0
%15 = phi i32 [ 1, %0 ], [ 2, %7 ], [ %13, %10 ]
ret i32 %15
}