#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 */
struct t_squad {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ basemode_ui_free();
int /*<<< orphan*/ basemode_ui_init();
int /*<<< orphan*/ draw_basemode_menu();
int /*<<< orphan*/ mapmode(struct t_squad *);
int menugetch();
int /*<<< orphan*/ update_basemode(struct t_squad *);
int basemode(struct t_squad *squad) {
  bool loop = true;
  basemode_ui_init();
  draw_basemode_menu();
  do {
    update_basemode(squad);
    int ch = menugetch();
    switch (ch) {
    case 'q':
      loop = false;
      break;
    case 'm':
      mapmode(squad);
      break;
    }
    if (ch == 'q')
      loop = false;
  } while (loop);
  basemode_ui_free();
  return 0;
}


x86 assembly (clang, -O0):
<basemode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    $0x0,%al
call   1080 <basemode_ui_init@plt>
mov    $0x0,%al
call   1030 <draw_basemode_menu@plt>
mov    -0x8(%rbp),%rdi
call   1070 <update_basemode@plt>
xor    %eax,%eax
call   1050 <menugetch@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x6d,%eax
je     11c5 <basemode+0x65>
jmp    11a8 <basemode+0x48>
mov    -0x14(%rbp),%eax
sub    $0x71,%eax
jne    11ce <basemode+0x6e>
jmp    11b9 <basemode+0x59>
movl   $0x0,-0xc(%rbp)
jmp    11ce <basemode+0x6e>
mov    -0x8(%rbp),%rdi
call   1040 <mapmode@plt>
cmpl   $0x71,-0x10(%rbp)
jne    11df <basemode+0x7f>
movl   $0x0,-0xc(%rbp)
jmp    11e4 <basemode+0x84>
cmpl   $0x0,-0xc(%rbp)
jne    1181 <basemode+0x21>
mov    $0x0,%al
call   1060 <basemode_ui_free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<basemode>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1080 <basemode_ui_init@plt>
xor    %eax,%eax
call   1030 <draw_basemode_menu@plt>
jmp    1188 <basemode+0x28>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <mapmode@plt>
mov    %rbx,%rdi
call   1070 <update_basemode@plt>
xor    %eax,%eax
call   1050 <menugetch@plt>
cmp    $0x6d,%eax
je     1180 <basemode+0x20>
cmp    $0x71,%eax
jne    1188 <basemode+0x28>
xor    %eax,%eax
call   1060 <basemode_ui_free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.t_squad = type { i32 }
define i32 @basemode(%struct.t_squad* %0) {
%2 = alloca %struct.t_squad*
%3 = alloca i32
%4 = alloca i32
store %struct.t_squad* %0, %struct.t_squad** %2
store i32 1, i32* %3
%5 = call i32 (...) @basemode_ui_init()
%6 = call i32 (...) @draw_basemode_menu()
br label %7
7: ; preds = %21, %1
%8 = load %struct.t_squad*, %struct.t_squad** %2
%9 = call i32 @update_basemode(%struct.t_squad* %8)
%10 = call i32 (...) @menugetch()
store i32 %10, i32* %4
%11 = load i32, i32* %4
switch i32 %11, label %16 [
i32 113, label %12
i32 109, label %13
]
12: ; preds = %7
store i32 0, i32* %3
br label %16
13: ; preds = %7
%14 = load %struct.t_squad*, %struct.t_squad** %2
%15 = call i32 @mapmode(%struct.t_squad* %14)
br label %16
16: ; preds = %7, %13, %12
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 113
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 0, i32* %3
br label %20
20: ; preds = %19, %16
br label %21
21: ; preds = %20
%22 = load i32, i32* %3
%23 = icmp ne i32 %22, 0
br i1 %23, label %7, label %24
24: ; preds = %21
%25 = call i32 (...) @basemode_ui_free()
ret i32 0
}

LLVM IR (-O2):
%struct.t_squad = type { i32 }
define i32 @basemode(%struct.t_squad* %0) {
%2 = tail call i32 (...) @basemode_ui_init()
%3 = tail call i32 (...) @draw_basemode_menu()
br label %4
4: ; preds = %7, %1
%5 = tail call i32 @update_basemode(%struct.t_squad* %0)
%6 = tail call i32 (...) @menugetch()
switch i32 %6, label %7 [
i32 113, label %10
i32 109, label %8
]
7: ; preds = %4, %8
br label %4
8: ; preds = %4
%9 = tail call i32 @mapmode(%struct.t_squad* %0)
br label %7
10: ; preds = %4
%11 = tail call i32 (...) @basemode_ui_free()
ret i32 0
}