#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 */
int /*<<< orphan*/ ai_moverobber(int);
scalar_t__ data_isai(int);
int /*<<< orphan*/ data_refresh(int);
int io_getkey();
int /*<<< orphan*/ io_printmap(int);
int map_getrobberhex();
int /*<<< orphan*/ map_setmessage(char *);
int /*<<< orphan*/ marker_hide();
int robber_down(int);
int robber_left(int);
int robber_right(int);
int /*<<< orphan*/ robber_stealroutine(int, int);
int robber_up(int);
void robber_routine(int player) {
  if (data_isai(player)) {
    ai_moverobber(player);
    return;
  }
  marker_hide();
  int hex = map_getrobberhex();
  int hexorig = hex;
  int rob = 1;
  while (rob) {
    data_refresh(player);
    io_printmap(1);
    switch (io_getkey()) {
    case 2:
      hex = robber_up(hex);
      break;
    case 3:
      hex = robber_down(hex);
      break;
    case 0:
      hex = robber_left(hex);
      break;
    case 1:
      hex = robber_right(hex);
      break;
    case 4:
    case 'r':
      if (hex != hexorig)
        rob = 0;
      else
        map_setmessage("Cannot rob same hex twice in a row.");
      break;
    default:
      break;
    }
  }
  robber_stealroutine(player, hex);
}


x86 assembly (clang, -O0):
<robber_routine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <data_isai@plt>
cmp    $0x0,%rax
je     11fa <robber_routine+0x2a>
mov    -0x4(%rbp),%edi
call   1060 <ai_moverobber@plt>
jmp    1320 <robber_routine+0x150>
mov    $0x0,%al
call   10c0 <marker_hide@plt>
mov    $0x0,%al
call   1040 <map_getrobberhex@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1315 <robber_routine+0x145>
mov    -0x4(%rbp),%edi
call   1070 <data_refresh@plt>
mov    $0x1,%edi
call   10e0 <io_printmap@plt>
xor    %eax,%eax
call   1090 <io_getkey@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
test   %eax,%eax
je     12c2 <robber_routine+0xf2>
jmp    124d <robber_routine+0x7d>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     12d2 <robber_routine+0x102>
jmp    125e <robber_routine+0x8e>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     12a2 <robber_routine+0xd2>
jmp    126f <robber_routine+0x9f>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     12b2 <robber_routine+0xe2>
jmp    1280 <robber_routine+0xb0>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
je     12e2 <robber_routine+0x112>
jmp    1291 <robber_routine+0xc1>
mov    -0x14(%rbp),%eax
sub    $0x72,%eax
je     12e2 <robber_routine+0x112>
jmp    130b <robber_routine+0x13b>
mov    -0x8(%rbp),%edi
call   10a0 <robber_up@plt>
mov    %eax,-0x8(%rbp)
jmp    1310 <robber_routine+0x140>
mov    -0x8(%rbp),%edi
call   10d0 <robber_down@plt>
mov    %eax,-0x8(%rbp)
jmp    1310 <robber_routine+0x140>
mov    -0x8(%rbp),%edi
call   1030 <robber_left@plt>
mov    %eax,-0x8(%rbp)
jmp    1310 <robber_routine+0x140>
mov    -0x8(%rbp),%edi
call   1080 <robber_right@plt>
mov    %eax,-0x8(%rbp)
jmp    1310 <robber_routine+0x140>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     12fa <robber_routine+0x12a>
movl   $0x0,-0x10(%rbp)
jmp    1306 <robber_routine+0x136>
lea    0xcff(%rip),%rdi
call   10b0 <map_setmessage@plt>
jmp    1310 <robber_routine+0x140>
jmp    1310 <robber_routine+0x140>
jmp    1218 <robber_routine+0x48>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   10f0 <robber_stealroutine@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<robber_routine>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%ebx
call   1050 <data_isai@plt>
test   %rax,%rax
je     11f3 <robber_routine+0x23>
mov    %ebx,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <ai_moverobber@plt>
xor    %eax,%eax
call   10c0 <marker_hide@plt>
xor    %eax,%eax
call   1040 <map_getrobberhex@plt>
mov    %eax,%r15d
lea    0xe09(%rip),%r14
lea    0xdee(%rip),%r12
jmp    1227 <robber_routine+0x57>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
call   1080 <robber_right@plt>
mov    %eax,%ebp
nopl   0x0(%rax)
mov    %ebx,%edi
call   1070 <data_refresh@plt>
mov    $0x1,%edi
call   10e0 <io_printmap@plt>
xor    %eax,%eax
call   1090 <io_getkey@plt>
cmp    $0x4,%eax
jbe    1254 <robber_routine+0x84>
cmp    $0x72,%eax
jne    1230 <robber_routine+0x60>
jmp    125f <robber_routine+0x8f>
mov    %eax,%eax
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
cmp    %r15d,%ebp
jne    12ac <robber_routine+0xdc>
mov    %r14,%rdi
call   10b0 <map_setmessage@plt>
mov    %r15d,%ebp
jmp    1230 <robber_routine+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <robber_left@plt>
jmp    1227 <robber_routine+0x57>
nopl   0x0(%rax)
mov    %ebp,%edi
call   10a0 <robber_up@plt>
jmp    1227 <robber_routine+0x57>
nopl   0x0(%rax)
mov    %ebp,%edi
call   10d0 <robber_down@plt>
jmp    1227 <robber_routine+0x57>
mov    %ebx,%edi
mov    %ebp,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10f0 <robber_stealroutine@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"Cannot rob same hex twice in a row.\00"
define void @robber_routine(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i64 @data_isai(i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* %2
%11 = call i32 @ai_moverobber(i32 %10)
br label %50
12: ; preds = %1
%13 = call i32 (...) @marker_hide()
%14 = call i32 (...) @map_getrobberhex()
store i32 %14, i32* %3
%15 = load i32, i32* %3
store i32 %15, i32* %4
store i32 1, i32* %5
br label %16
16: ; preds = %45, %12
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %46
19: ; preds = %16
%20 = load i32, i32* %2
%21 = call i32 @data_refresh(i32 %20)
%22 = call i32 @io_printmap(i32 1)
%23 = call i32 (...) @io_getkey()
switch i32 %23, label %44 [
i32 2, label %24
i32 3, label %27
i32 0, label %30
i32 1, label %33
i32 4, label %36
i32 114, label %36
]
24: ; preds = %19
%25 = load i32, i32* %3
%26 = call i32 @robber_up(i32 %25)
store i32 %26, i32* %3
br label %45
27: ; preds = %19
%28 = load i32, i32* %3
%29 = call i32 @robber_down(i32 %28)
store i32 %29, i32* %3
br label %45
30: ; preds = %19
%31 = load i32, i32* %3
%32 = call i32 @robber_left(i32 %31)
store i32 %32, i32* %3
br label %45
33: ; preds = %19
%34 = load i32, i32* %3
%35 = call i32 @robber_right(i32 %34)
store i32 %35, i32* %3
br label %45
36: ; preds = %19, %19
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = icmp ne i32 %37, %38
br i1 %39, label %40, label %41
40: ; preds = %36
store i32 0, i32* %5
br label %43
41: ; preds = %36
%42 = call i32 @map_setmessage(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %41, %40
br label %45
44: ; preds = %19
br label %45
45: ; preds = %44, %43, %33, %30, %27, %24
br label %16
46: ; preds = %16
%47 = load i32, i32* %2
%48 = load i32, i32* %3
%49 = call i32 @robber_stealroutine(i32 %47, i32 %48)
br label %50
50: ; preds = %46, %9
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"Cannot rob same hex twice in a row.\00"
define void @robber_routine(i32 %0) {
%2 = tail call i64 @data_isai(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @ai_moverobber(i32 %0)
br label %31
6: ; preds = %1
%7 = tail call i32 (...) @marker_hide()
%8 = tail call i32 (...) @map_getrobberhex()
br label %9
9: ; preds = %27, %6
%10 = phi i32 [ %8, %6 ], [ %28, %27 ]
br label %11
11: ; preds = %9, %11
%12 = tail call i32 @data_refresh(i32 %0)
%13 = tail call i32 @io_printmap(i32 1)
%14 = tail call i32 (...) @io_getkey()
switch i32 %14, label %11 [
i32 2, label %15
i32 3, label %17
i32 0, label %19
i32 1, label %21
i32 4, label %23
i32 114, label %23
]
15: ; preds = %11
%16 = tail call i32 @robber_up(i32 %10)
br label %27
17: ; preds = %11
%18 = tail call i32 @robber_down(i32 %10)
br label %27
19: ; preds = %11
%20 = tail call i32 @robber_left(i32 %10)
br label %27
21: ; preds = %11
%22 = tail call i32 @robber_right(i32 %10)
br label %27
23: ; preds = %11, %11
%24 = icmp eq i32 %10, %8
br i1 %24, label %25, label %29
25: ; preds = %23
%26 = tail call i32 @map_setmessage(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %21, %19, %17, %15
%28 = phi i32 [ %16, %15 ], [ %18, %17 ], [ %20, %19 ], [ %22, %21 ], [ %8, %25 ]
br label %9
29: ; preds = %23
%30 = tail call i32 @robber_stealroutine(i32 %0, i32 %10)
br label %31
31: ; preds = %29, %4
ret void
}