#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*/ cannon(int, int);
int /*<<< orphan*/ drive(int, int);
int loc_x();
int loc_y();
int scan(int, int);
scalar_t__ speed();
rmain() {
  int direction;
  direction = 90;
  while (1) {
    if (speed() == 0)
      drive(direction, 100);
    if ((direction == 90 && loc_y() > 575) ||
        (direction == 270 && loc_y() < 425) ||
        (direction == 180 && loc_x() < 150) ||
        (direction == 0 && loc_x() > 850)) {
      drive(direction, 0);
      direction = (direction + 90) % 360;
    } else {
      int range;
      if (range = scan(0, 10))
        cannon(0, range);
      else if (range = scan(30, 10))
        cannon(30, range);
      else if (range = scan(60, 10))
        cannon(60, range);
      else if (range = scan(90, 10))
        cannon(90, range);
      else if (range = scan(120, 10))
        cannon(120, range);
      else if (range = scan(150, 10))
        cannon(150, range);
      else if (range = scan(180, 10))
        cannon(180, range);
      else if (range = scan(210, 10))
        cannon(210, range);
      else if (range = scan(240, 10))
        cannon(240, range);
      else if (range = scan(270, 10))
        cannon(270, range);
      else if (range = scan(300, 10))
        cannon(300, range);
      else if (range = scan(330, 10))
        cannon(330, range);
    }
  }
}


x86 assembly (clang, -O0):
<rmain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x5a,-0x4(%rbp)
mov    $0x0,%al
call   1070 <speed@plt>
cmp    $0x0,%rax
jne    118d <rmain+0x2d>
mov    -0x4(%rbp),%edi
mov    $0x64,%esi
call   1080 <drive@plt>
cmpl   $0x5a,-0x4(%rbp)
jne    11a9 <rmain+0x49>
mov    $0x0,%al
call   1030 <loc_y@plt>
cmp    $0x23f,%eax
jg     1203 <rmain+0xa3>
cmpl   $0x10e,-0x4(%rbp)
jne    11c8 <rmain+0x68>
mov    $0x0,%al
call   1030 <loc_y@plt>
cmp    $0x1a9,%eax
jl     1203 <rmain+0xa3>
cmpl   $0xb4,-0x4(%rbp)
jne    11e7 <rmain+0x87>
mov    $0x0,%al
call   1040 <loc_x@plt>
cmp    $0x96,%eax
jl     1203 <rmain+0xa3>
cmpl   $0x0,-0x4(%rbp)
jne    1223 <rmain+0xc3>
mov    $0x0,%al
call   1040 <loc_x@plt>
cmp    $0x352,%eax
jle    1223 <rmain+0xc3>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1080 <drive@plt>
mov    -0x4(%rbp),%eax
add    $0x5a,%eax
mov    $0x168,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
jmp    1470 <rmain+0x310>
xor    %edi,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     124a <rmain+0xea>
mov    -0x8(%rbp),%esi
xor    %edi,%edi
call   1060 <cannon@plt>
jmp    146b <rmain+0x30b>
mov    $0x1e,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     1277 <rmain+0x117>
mov    -0x8(%rbp),%esi
mov    $0x1e,%edi
call   1060 <cannon@plt>
jmp    1466 <rmain+0x306>
mov    $0x3c,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     12a4 <rmain+0x144>
mov    -0x8(%rbp),%esi
mov    $0x3c,%edi
call   1060 <cannon@plt>
jmp    1461 <rmain+0x301>
mov    $0x5a,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     12d1 <rmain+0x171>
mov    -0x8(%rbp),%esi
mov    $0x5a,%edi
call   1060 <cannon@plt>
jmp    145c <rmain+0x2fc>
mov    $0x78,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     12fe <rmain+0x19e>
mov    -0x8(%rbp),%esi
mov    $0x78,%edi
call   1060 <cannon@plt>
jmp    1457 <rmain+0x2f7>
mov    $0x96,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     132b <rmain+0x1cb>
mov    -0x8(%rbp),%esi
mov    $0x96,%edi
call   1060 <cannon@plt>
jmp    1452 <rmain+0x2f2>
mov    $0xb4,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     1358 <rmain+0x1f8>
mov    -0x8(%rbp),%esi
mov    $0xb4,%edi
call   1060 <cannon@plt>
jmp    144d <rmain+0x2ed>
mov    $0xd2,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     1385 <rmain+0x225>
mov    -0x8(%rbp),%esi
mov    $0xd2,%edi
call   1060 <cannon@plt>
jmp    1448 <rmain+0x2e8>
mov    $0xf0,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     13b2 <rmain+0x252>
mov    -0x8(%rbp),%esi
mov    $0xf0,%edi
call   1060 <cannon@plt>
jmp    1443 <rmain+0x2e3>
mov    $0x10e,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     13df <rmain+0x27f>
mov    -0x8(%rbp),%esi
mov    $0x10e,%edi
call   1060 <cannon@plt>
jmp    143e <rmain+0x2de>
mov    $0x12c,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     140c <rmain+0x2ac>
mov    -0x8(%rbp),%esi
mov    $0x12c,%edi
call   1060 <cannon@plt>
jmp    1439 <rmain+0x2d9>
mov    $0x14a,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     1434 <rmain+0x2d4>
mov    -0x8(%rbp),%esi
mov    $0x14a,%edi
call   1060 <cannon@plt>
jmp    1439 <rmain+0x2d9>
jmp    143e <rmain+0x2de>
jmp    1443 <rmain+0x2e3>
jmp    1448 <rmain+0x2e8>
jmp    144d <rmain+0x2ed>
jmp    1452 <rmain+0x2f2>
jmp    1457 <rmain+0x2f7>
jmp    145c <rmain+0x2fc>
jmp    1461 <rmain+0x301>
jmp    1466 <rmain+0x306>
jmp    146b <rmain+0x30b>
jmp    1470 <rmain+0x310>
jmp    116f <rmain+0xf>

x86 assembly (clang, -O2):
<rmain>:
push   %rbx
mov    $0x5a,%ebx
jmp    119a <rmain+0x3a>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
xor    %esi,%esi
call   1080 <drive@plt>
mov    %ebx,%eax
add    $0x5a,%eax
movzwl %ax,%eax
imul   $0x2d83,%eax,%eax
shr    $0x16,%eax
imul   $0x168,%eax,%eax
neg    %eax
add    %ebx,%eax
add    $0x5a,%eax
movzwl %ax,%ebx
xor    %eax,%eax
call   1070 <speed@plt>
test   %rax,%rax
jne    11b2 <rmain+0x52>
mov    %ebx,%edi
mov    $0x64,%esi
call   1080 <drive@plt>
movswl %bx,%eax
cmp    $0xb3,%eax
jg     11e0 <rmain+0x80>
test   %bx,%bx
je     1210 <rmain+0xb0>
cmp    $0x5a,%bx
jne    1250 <rmain+0xf0>
xor    %eax,%eax
call   1030 <loc_y@plt>
cmp    $0x23f,%eax
jg     1170 <rmain+0x10>
jmp    1250 <rmain+0xf0>
nopl   0x0(%rax,%rax,1)
movzwl %bx,%eax
cmp    $0xb4,%eax
je     1230 <rmain+0xd0>
cmp    $0x10e,%eax
jne    1250 <rmain+0xf0>
xor    %eax,%eax
call   1030 <loc_y@plt>
cmp    $0x1a9,%eax
jl     1170 <rmain+0x10>
jmp    1250 <rmain+0xf0>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <loc_x@plt>
cmp    $0x353,%eax
jge    1170 <rmain+0x10>
jmp    1250 <rmain+0xf0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <loc_x@plt>
cmp    $0x96,%eax
jl     1170 <rmain+0x10>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %edi,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
test   %eax,%eax
je     1270 <rmain+0x110>
xor    %edi,%edi
jmp    13b0 <rmain+0x250>
nopw   0x0(%rax,%rax,1)
mov    $0x1e,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
test   %eax,%eax
je     128d <rmain+0x12d>
mov    $0x1e,%edi
jmp    13b0 <rmain+0x250>
mov    $0x3c,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
test   %eax,%eax
je     12aa <rmain+0x14a>
mov    $0x3c,%edi
jmp    13b0 <rmain+0x250>
mov    $0x5a,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
test   %eax,%eax
je     12c7 <rmain+0x167>
mov    $0x5a,%edi
jmp    13b0 <rmain+0x250>
mov    $0x78,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
test   %eax,%eax
je     12e4 <rmain+0x184>
mov    $0x78,%edi
jmp    13b0 <rmain+0x250>
mov    $0x96,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
test   %eax,%eax
je     1301 <rmain+0x1a1>
mov    $0x96,%edi
jmp    13b0 <rmain+0x250>
mov    $0xb4,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
test   %eax,%eax
je     131e <rmain+0x1be>
mov    $0xb4,%edi
jmp    13b0 <rmain+0x250>
mov    $0xd2,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
test   %eax,%eax
je     1338 <rmain+0x1d8>
mov    $0xd2,%edi
jmp    13b0 <rmain+0x250>
mov    $0xf0,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
test   %eax,%eax
je     1352 <rmain+0x1f2>
mov    $0xf0,%edi
jmp    13b0 <rmain+0x250>
mov    $0x10e,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
test   %eax,%eax
je     136c <rmain+0x20c>
mov    $0x10e,%edi
jmp    13b0 <rmain+0x250>
mov    $0x12c,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
test   %eax,%eax
je     1386 <rmain+0x226>
mov    $0x12c,%edi
jmp    13b0 <rmain+0x250>
mov    $0x14a,%edi
mov    $0xa,%esi
call   1050 <scan@plt>
test   %eax,%eax
je     119a <rmain+0x3a>
mov    $0x14a,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%esi
call   1060 <cannon@plt>
jmp    119a <rmain+0x3a>

LLVM IR (-O0):
define i32 @rmain() {
%1 = alloca i32
%2 = alloca i32
store i32 90, i32* %1
br label %3
3: ; preds = %0, %123
%4 = call i64 (...) @speed()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = load i32, i32* %1
%8 = call i32 @drive(i32 %7, i32 100)
br label %9
9: ; preds = %6, %3
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, 90
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 (...) @loc_y()
%14 = icmp sgt i32 %13, 575
br i1 %14, label %33, label %15
15: ; preds = %12, %9
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 270
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i32 (...) @loc_y()
%20 = icmp slt i32 %19, 425
br i1 %20, label %33, label %21
21: ; preds = %18, %15
%22 = load i32, i32* %1
%23 = icmp eq i32 %22, 180
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = call i32 (...) @loc_x()
%26 = icmp slt i32 %25, 150
br i1 %26, label %33, label %27
27: ; preds = %24, %21
%28 = load i32, i32* %1
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %39
30: ; preds = %27
%31 = call i32 (...) @loc_x()
%32 = icmp sgt i32 %31, 850
br i1 %32, label %33, label %39
33: ; preds = %30, %24, %18, %12
%34 = load i32, i32* %1
%35 = call i32 @drive(i32 %34, i32 0)
%36 = load i32, i32* %1
%37 = add nsw i32 %36, 90
%38 = srem i32 %37, 360
store i32 %38, i32* %1
br label %123
39: ; preds = %30, %27
%40 = call i32 @scan(i32 0, i32 10)
store i32 %40, i32* %2
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* %2
%44 = call i32 @cannon(i32 0, i32 %43)
br label %122
45: ; preds = %39
%46 = call i32 @scan(i32 30, i32 10)
store i32 %46, i32* %2
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i32, i32* %2
%50 = call i32 @cannon(i32 30, i32 %49)
br label %121
51: ; preds = %45
%52 = call i32 @scan(i32 60, i32 10)
store i32 %52, i32* %2
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32, i32* %2
%56 = call i32 @cannon(i32 60, i32 %55)
br label %120
57: ; preds = %51
%58 = call i32 @scan(i32 90, i32 10)
store i32 %58, i32* %2
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = load i32, i32* %2
%62 = call i32 @cannon(i32 90, i32 %61)
br label %119
63: ; preds = %57
%64 = call i32 @scan(i32 120, i32 10)
store i32 %64, i32* %2
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load i32, i32* %2
%68 = call i32 @cannon(i32 120, i32 %67)
br label %118
69: ; preds = %63
%70 = call i32 @scan(i32 150, i32 10)
store i32 %70, i32* %2
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %69
%73 = load i32, i32* %2
%74 = call i32 @cannon(i32 150, i32 %73)
br label %117
75: ; preds = %69
%76 = call i32 @scan(i32 180, i32 10)
store i32 %76, i32* %2
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %75
%79 = load i32, i32* %2
%80 = call i32 @cannon(i32 180, i32 %79)
br label %116
81: ; preds = %75
%82 = call i32 @scan(i32 210, i32 10)
store i32 %82, i32* %2
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %81
%85 = load i32, i32* %2
%86 = call i32 @cannon(i32 210, i32 %85)
br label %115
87: ; preds = %81
%88 = call i32 @scan(i32 240, i32 10)
store i32 %88, i32* %2
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %93
90: ; preds = %87
%91 = load i32, i32* %2
%92 = call i32 @cannon(i32 240, i32 %91)
br label %114
93: ; preds = %87
%94 = call i32 @scan(i32 270, i32 10)
store i32 %94, i32* %2
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %93
%97 = load i32, i32* %2
%98 = call i32 @cannon(i32 270, i32 %97)
br label %113
99: ; preds = %93
%100 = call i32 @scan(i32 300, i32 10)
store i32 %100, i32* %2
%101 = icmp ne i32 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %99
%103 = load i32, i32* %2
%104 = call i32 @cannon(i32 300, i32 %103)
br label %112
105: ; preds = %99
%106 = call i32 @scan(i32 330, i32 10)
store i32 %106, i32* %2
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %105
%109 = load i32, i32* %2
%110 = call i32 @cannon(i32 330, i32 %109)
br label %111
111: ; preds = %108, %105
br label %112
112: ; preds = %111, %102
br label %113
113: ; preds = %112, %96
br label %114
114: ; preds = %113, %90
br label %115
115: ; preds = %114, %84
br label %116
116: ; preds = %115, %78
br label %117
117: ; preds = %116, %72
br label %118
118: ; preds = %117, %66
br label %119
119: ; preds = %118, %60
br label %120
120: ; preds = %119, %54
br label %121
121: ; preds = %120, %48
br label %122
122: ; preds = %121, %42
br label %123
123: ; preds = %122, %33
br label %3
}

LLVM IR (-O2):
define i32 @rmain() {
br label %1
1: ; preds = %32, %0
%2 = phi i32 [ 90, %0 ], [ %33, %32 ]
%3 = tail call i64 (...) @speed()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @drive(i32 %2, i32 100)
br label %7
7: ; preds = %5, %1
%8 = trunc i32 %2 to i16
switch i16 %8, label %27 [
i16 90, label %9
i16 270, label %12
i16 180, label %15
i16 0, label %18
]
9: ; preds = %7
%10 = tail call i32 (...) @loc_y()
%11 = icmp sgt i32 %10, 575
br i1 %11, label %21, label %27
12: ; preds = %7
%13 = tail call i32 (...) @loc_y()
%14 = icmp slt i32 %13, 425
br i1 %14, label %21, label %27
15: ; preds = %7
%16 = tail call i32 (...) @loc_x()
%17 = icmp slt i32 %16, 150
br i1 %17, label %21, label %27
18: ; preds = %7
%19 = tail call i32 (...) @loc_x()
%20 = icmp sgt i32 %19, 850
br i1 %20, label %21, label %27
21: ; preds = %18, %15, %12, %9
%22 = tail call i32 @drive(i32 %2, i32 0)
%23 = trunc i32 %2 to i16
%24 = add nuw nsw i16 %23, 90
%25 = urem i16 %24, 360
%26 = zext i16 %25 to i32
br label %32
27: ; preds = %15, %12, %9, %7, %18
%28 = tail call i32 @scan(i32 0, i32 10)
%29 = icmp eq i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = tail call i32 @cannon(i32 0, i32 %28)
br label %32
32: ; preds = %30, %42, %52, %62, %72, %82, %87, %84, %77, %67, %57, %47, %37, %21
%33 = phi i32 [ %26, %21 ], [ %2, %37 ], [ %2, %47 ], [ %2, %57 ], [ %2, %67 ], [ %2, %77 ], [ %2, %84 ], [ %2, %87 ], [ %2, %82 ], [ %2, %72 ], [ %2, %62 ], [ %2, %52 ], [ %2, %42 ], [ %2, %30 ]
br label %1
34: ; preds = %27
%35 = tail call i32 @scan(i32 30, i32 10)
%36 = icmp eq i32 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = tail call i32 @cannon(i32 30, i32 %35)
br label %32
39: ; preds = %34
%40 = tail call i32 @scan(i32 60, i32 10)
%41 = icmp eq i32 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = tail call i32 @cannon(i32 60, i32 %40)
br label %32
44: ; preds = %39
%45 = tail call i32 @scan(i32 90, i32 10)
%46 = icmp eq i32 %45, 0
br i1 %46, label %49, label %47
47: ; preds = %44
%48 = tail call i32 @cannon(i32 90, i32 %45)
br label %32
49: ; preds = %44
%50 = tail call i32 @scan(i32 120, i32 10)
%51 = icmp eq i32 %50, 0
br i1 %51, label %54, label %52
52: ; preds = %49
%53 = tail call i32 @cannon(i32 120, i32 %50)
br label %32
54: ; preds = %49
%55 = tail call i32 @scan(i32 150, i32 10)
%56 = icmp eq i32 %55, 0
br i1 %56, label %59, label %57
57: ; preds = %54
%58 = tail call i32 @cannon(i32 150, i32 %55)
br label %32
59: ; preds = %54
%60 = tail call i32 @scan(i32 180, i32 10)
%61 = icmp eq i32 %60, 0
br i1 %61, label %64, label %62
62: ; preds = %59
%63 = tail call i32 @cannon(i32 180, i32 %60)
br label %32
64: ; preds = %59
%65 = tail call i32 @scan(i32 210, i32 10)
%66 = icmp eq i32 %65, 0
br i1 %66, label %69, label %67
67: ; preds = %64
%68 = tail call i32 @cannon(i32 210, i32 %65)
br label %32
69: ; preds = %64
%70 = tail call i32 @scan(i32 240, i32 10)
%71 = icmp eq i32 %70, 0
br i1 %71, label %74, label %72
72: ; preds = %69
%73 = tail call i32 @cannon(i32 240, i32 %70)
br label %32
74: ; preds = %69
%75 = tail call i32 @scan(i32 270, i32 10)
%76 = icmp eq i32 %75, 0
br i1 %76, label %79, label %77
77: ; preds = %74
%78 = tail call i32 @cannon(i32 270, i32 %75)
br label %32
79: ; preds = %74
%80 = tail call i32 @scan(i32 300, i32 10)
%81 = icmp eq i32 %80, 0
br i1 %81, label %84, label %82
82: ; preds = %79
%83 = tail call i32 @cannon(i32 300, i32 %80)
br label %32
84: ; preds = %79
%85 = tail call i32 @scan(i32 330, i32 10)
%86 = icmp eq i32 %85, 0
br i1 %86, label %32, label %87
87: ; preds = %84
%88 = tail call i32 @cannon(i32 330, i32 %85)
br label %32
}