#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__ bump_detect_back();
scalar_t__ bump_detect_front();
scalar_t__ line_detect();
scalar_t__ side_detect();
int sumo_chase_state() {
  while (1) {
    if (bump_detect_front())
      return 2;
    if (bump_detect_back())
      return 3;
    if (line_detect())
      return 0;
    if (side_detect())
      return 4;
  }
}


x86 assembly (clang, -O0):
<sumo_chase_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <bump_detect_front@plt>
cmp    $0x0,%rax
je     1165 <sumo_chase_state+0x25>
movl   $0x2,-0x4(%rbp)
jmp    11c1 <sumo_chase_state+0x81>
mov    $0x0,%al
call   1060 <bump_detect_back@plt>
cmp    $0x0,%rax
je     1182 <sumo_chase_state+0x42>
movl   $0x3,-0x4(%rbp)
jmp    11c1 <sumo_chase_state+0x81>
mov    $0x0,%al
call   1040 <line_detect@plt>
cmp    $0x0,%rax
je     119f <sumo_chase_state+0x5f>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <sumo_chase_state+0x81>
mov    $0x0,%al
call   1050 <side_detect@plt>
cmp    $0x0,%rax
je     11bc <sumo_chase_state+0x7c>
movl   $0x4,-0x4(%rbp)
jmp    11c1 <sumo_chase_state+0x81>
jmp    1148 <sumo_chase_state+0x8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sumo_chase_state>:
push   %rbx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1030 <bump_detect_front@plt>
test   %rax,%rax
jne    1187 <sumo_chase_state+0x47>
xor    %eax,%eax
call   1060 <bump_detect_back@plt>
test   %rax,%rax
jne    118e <sumo_chase_state+0x4e>
xor    %eax,%eax
call   1040 <line_detect@plt>
test   %rax,%rax
jne    1193 <sumo_chase_state+0x53>
xor    %eax,%eax
call   1050 <side_detect@plt>
test   %rax,%rax
je     1150 <sumo_chase_state+0x10>
mov    $0x4,%ebx
jmp    1193 <sumo_chase_state+0x53>
mov    $0x2,%ebx
jmp    1193 <sumo_chase_state+0x53>
mov    $0x3,%ebx
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @sumo_chase_state() {
br label %1
1: ; preds = %10, %0
%2 = tail call i64 (...) @bump_detect_front()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = tail call i64 (...) @bump_detect_back()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %4
%8 = tail call i64 (...) @line_detect()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = tail call i64 (...) @side_detect()
%12 = icmp eq i64 %11, 0
br i1 %12, label %1, label %13
13: ; preds = %10, %7, %4, %1
%14 = phi i32 [ 2, %1 ], [ 3, %4 ], [ 0, %7 ], [ 4, %10 ]
ret i32 %14
}