#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();
int /*<<< orphan*/ side_detect();
int sumo_spin_state() {
  while (1) {
    if (bump_detect_front())
      return 2;
    if (bump_detect_back())
      return 3;
    if (line_detect())
      return 0;
    if (!side_detect())
      return 0;
  }
}


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

x86 assembly (clang, -O2):
<sumo_spin_state>:
push   %rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <bump_detect_front@plt>
test   %rax,%rax
jne    1185 <sumo_spin_state+0x45>
xor    %eax,%eax
call   1060 <bump_detect_back@plt>
test   %rax,%rax
jne    118c <sumo_spin_state+0x4c>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <line_detect@plt>
test   %rax,%rax
jne    1191 <sumo_spin_state+0x51>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <side_detect@plt>
test   %eax,%eax
jne    1150 <sumo_spin_state+0x10>
jmp    1191 <sumo_spin_state+0x51>
mov    $0x2,%ebx
jmp    1191 <sumo_spin_state+0x51>
mov    $0x3,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @sumo_spin_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 i32 (...) @side_detect()
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %14
store i32 0, 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_spin_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 i32 (...) @side_detect()
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %1
13: ; preds = %10, %7, %4, %1
%14 = phi i32 [ 2, %1 ], [ 3, %4 ], [ 0, %7 ], [ 0, %10 ]
ret i32 %14
}