#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__ pattern_edit_get_enable();
scalar_t__ song_edit_get_enable();
scalar_t__ step_edit_get_enable();
int panel_get_edit_mode(void) {
  if (song_edit_get_enable()) {
    return 2;
  } else if (step_edit_get_enable()) {
    return 1;
  } else if (pattern_edit_get_enable()) {
    return 3;
  }
  return 0;
}


x86 assembly (clang, -O0):
<panel_get_edit_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <song_edit_get_enable@plt>
cmp    $0x0,%rax
je     1155 <panel_get_edit_mode+0x25>
movl   $0x2,-0x4(%rbp)
jmp    11a0 <panel_get_edit_mode+0x70>
mov    $0x0,%al
call   1040 <step_edit_get_enable@plt>
cmp    $0x0,%rax
je     1172 <panel_get_edit_mode+0x42>
movl   $0x1,-0x4(%rbp)
jmp    11a0 <panel_get_edit_mode+0x70>
mov    $0x0,%al
call   1050 <pattern_edit_get_enable@plt>
cmp    $0x0,%rax
je     118f <panel_get_edit_mode+0x5f>
movl   $0x3,-0x4(%rbp)
jmp    11a0 <panel_get_edit_mode+0x70>
jmp    1194 <panel_get_edit_mode+0x64>
jmp    1199 <panel_get_edit_mode+0x69>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<panel_get_edit_mode>:
push   %rax
xor    %eax,%eax
call   1030 <song_edit_get_enable@plt>
mov    %rax,%rcx
mov    $0x2,%eax
test   %rcx,%rcx
je     1147 <panel_get_edit_mode+0x17>
pop    %rcx
ret
xor    %eax,%eax
call   1040 <step_edit_get_enable@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1145 <panel_get_edit_mode+0x15>
xor    %eax,%eax
call   1050 <pattern_edit_get_enable@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%rcx,%rcx,2),%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @panel_get_edit_mode() {
%1 = alloca i32
%2 = call i64 (...) @song_edit_get_enable()
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %5
4: ; preds = %0
store i32 2, i32* %1
br label %16
5: ; preds = %0
%6 = call i64 (...) @step_edit_get_enable()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %5
store i32 1, i32* %1
br label %16
9: ; preds = %5
%10 = call i64 (...) @pattern_edit_get_enable()
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 3, i32* %1
br label %16
13: ; preds = %9
br label %14
14: ; preds = %13
br label %15
15: ; preds = %14
store i32 0, i32* %1
br label %16
16: ; preds = %15, %12, %8, %4
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
define i32 @panel_get_edit_mode() {
%1 = tail call i64 (...) @song_edit_get_enable()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %10
3: ; preds = %0
%4 = tail call i64 (...) @step_edit_get_enable()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i64 (...) @pattern_edit_get_enable()
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i32 0, i32 3
br label %10
10: ; preds = %6, %3, %0
%11 = phi i32 [ 2, %0 ], [ 1, %3 ], [ %9, %6 ]
ret i32 %11
}