#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__ RAND_MAX;
scalar_t__ cannon(int, int);
int /*<<< orphan*/ cycle();
int damage();
int /*<<< orphan*/ drive(int, int);
double rand();
int /*<<< orphan*/ run();
int scan(int, int);
int rmain() {
  int angle, range;
  int d;
  int i;
  while (1) {
    run();
    d = damage();
    angle = rand() / (double)RAND_MAX * 360;
    while (damage() < d + 1) {
      range = scan(angle, 3);
      if (range == 0)
        angle = (angle + 3 * 2) % 360;
      else if (range > 700) {
        drive(angle, 50);
        i = 1;
        while (i++ < 50)
          cycle();
        drive(angle, 0);
        angle -= 3;
      } else {
        while (cannon(angle, range) == 0)
          cycle();
        while (cannon(angle, range) == 0)
          cycle();
        angle -= 15;
      }
    }
  }
}


x86 assembly (clang, -O0):
<rmain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <run@plt>
mov    $0x0,%al
call   1080 <damage@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    0x2e51(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe58(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1080 <damage@plt>
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    12b0 <rmain+0x140>
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
call   1040 <scan@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11f8 <rmain+0x88>
mov    -0x4(%rbp),%eax
add    $0x6,%eax
mov    $0x168,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
jmp    12ab <rmain+0x13b>
cmpl   $0x2bc,-0x8(%rbp)
jle    1251 <rmain+0xe1>
mov    -0x4(%rbp),%edi
mov    $0x32,%esi
call   1060 <drive@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x32,%eax
jge    1239 <rmain+0xc9>
mov    $0x0,%al
call   1070 <cycle@plt>
jmp    1219 <rmain+0xa9>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1060 <drive@plt>
mov    -0x4(%rbp),%eax
sub    $0x3,%eax
mov    %eax,-0x4(%rbp)
jmp    12a6 <rmain+0x136>
jmp    1256 <rmain+0xe6>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <cannon@plt>
cmp    $0x0,%rax
jne    1277 <rmain+0x107>
mov    $0x0,%al
call   1070 <cycle@plt>
jmp    1256 <rmain+0xe6>
jmp    127c <rmain+0x10c>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <cannon@plt>
cmp    $0x0,%rax
jne    129d <rmain+0x12d>
mov    $0x0,%al
call   1070 <cycle@plt>
jmp    127c <rmain+0x10c>
mov    -0x4(%rbp),%eax
sub    $0xf,%eax
mov    %eax,-0x4(%rbp)
jmp    12ab <rmain+0x13b>
jmp    11b3 <rmain+0x43>
jmp    1178 <rmain+0x8>

x86 assembly (clang, -O2):
<rmain>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e6a(%rip),%r15
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <run@plt>
xor    %eax,%eax
call   1080 <damage@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1090 <rand@plt>
movsd  %xmm0,(%rsp)
mov    (%r15),%rbx
xor    %eax,%eax
call   1080 <damage@plt>
cmp    %r14d,%eax
jg     1180 <rmain+0x10>
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
mulsd  0xe3b(%rip),%xmm1
cvttsd2si %xmm1,%ebx
jmp    120b <rmain+0x9b>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
add    $0x6,%eax
cltq
imul   $0xffffffffb60b60b7,%rax,%rcx
shr    $0x20,%rcx
add    %ebx,%ecx
add    $0x6,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x8,%ecx
add    %edx,%ecx
imul   $0x168,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,%ebx
xor    %eax,%eax
call   1080 <damage@plt>
cmp    %r14d,%eax
jg     1180 <rmain+0x10>
mov    %ebx,%edi
mov    $0x3,%esi
call   1040 <scan@plt>
test   %eax,%eax
je     11d0 <rmain+0x60>
mov    %eax,%ebp
cmp    $0x2bc,%eax
jle    13a0 <rmain+0x230>
mov    %ebx,%edi
mov    $0x32,%esi
call   1060 <drive@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
xor    %eax,%eax
call   1070 <cycle@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   1060 <drive@plt>
add    $0xfffffffd,%ebx
jmp    11fb <rmain+0x8b>
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %ebp,%esi
call   1050 <cannon@plt>
test   %rax,%rax
jne    13c7 <rmain+0x257>
xor    %eax,%eax
call   1070 <cycle@plt>
jmp    13a0 <rmain+0x230>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <cycle@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1050 <cannon@plt>
test   %rax,%rax
je     13c0 <rmain+0x250>
add    $0xfffffff1,%ebx
jmp    11fb <rmain+0x8b>

LLVM IR (-O0):
@RAND_MAX = global i64 0
define i32 @rmain() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
br label %5
5: ; preds = %0, %66
%6 = call i32 (...) @run()
%7 = call i32 (...) @damage()
store i32 %7, i32* %3
%8 = call double (...) @rand()
%9 = load i64, i64* @RAND_MAX
%10 = sitofp i64 %9 to double
%11 = fdiv double %8, %10
%12 = fmul double %11, 3.600000e+02
%13 = fptosi double %12 to i32
store i32 %13, i32* %1
br label %14
14: ; preds = %65, %5
%15 = call i32 (...) @damage()
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %66
19: ; preds = %14
%20 = load i32, i32* %1
%21 = call i32 @scan(i32 %20, i32 3)
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = load i32, i32* %1
%26 = add nsw i32 %25, 6
%27 = srem i32 %26, 360
store i32 %27, i32* %1
br label %65
28: ; preds = %19
%29 = load i32, i32* %2
%30 = icmp sgt i32 %29, 700
br i1 %30, label %31, label %45
31: ; preds = %28
%32 = load i32, i32* %1
%33 = call i32 @drive(i32 %32, i32 50)
store i32 1, i32* %4
br label %34
34: ; preds = %38, %31
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
%37 = icmp slt i32 %35, 50
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 (...) @cycle()
br label %34
40: ; preds = %34
%41 = load i32, i32* %1
%42 = call i32 @drive(i32 %41, i32 0)
%43 = load i32, i32* %1
%44 = sub nsw i32 %43, 3
store i32 %44, i32* %1
br label %64
45: ; preds = %28
br label %46
46: ; preds = %51, %45
%47 = load i32, i32* %1
%48 = load i32, i32* %2
%49 = call i64 @cannon(i32 %47, i32 %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = call i32 (...) @cycle()
br label %46
53: ; preds = %46
br label %54
54: ; preds = %59, %53
%55 = load i32, i32* %1
%56 = load i32, i32* %2
%57 = call i64 @cannon(i32 %55, i32 %56)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %54
%60 = call i32 (...) @cycle()
br label %54
61: ; preds = %54
%62 = load i32, i32* %1
%63 = sub nsw i32 %62, 15
store i32 %63, i32* %1
br label %64
64: ; preds = %61, %40
br label %65
65: ; preds = %64, %24
br label %14
66: ; preds = %14
br label %5
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define i32 @rmain() {
br label %1
1: ; preds = %8, %0
%2 = tail call i32 (...) @run()
%3 = tail call i32 (...) @damage()
%4 = tail call double (...) @rand()
%5 = load i64, i64* @RAND_MAX
%6 = tail call i32 (...) @damage()
%7 = icmp sgt i32 %6, %3
br i1 %7, label %8, label %9
8: ; preds = %92, %1
br label %1
9: ; preds = %1
%10 = sitofp i64 %5 to double
%11 = fdiv double %4, %10
%12 = fmul double %11, 3.600000e+02
%13 = fptosi double %12 to i32
br label %14
14: ; preds = %9, %92
%15 = phi i32 [ %93, %92 ], [ %13, %9 ]
%16 = tail call i32 @scan(i32 %15, i32 3)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = add nsw i32 %15, 6
%20 = srem i32 %19, 360
br label %92
21: ; preds = %14
%22 = icmp sgt i32 %16, 700
br i1 %22, label %26, label %23
23: ; preds = %21
%24 = tail call i64 @cannon(i32 %15, i32 %16)
%25 = icmp eq i64 %24, 0
br i1 %25, label %82, label %79
26: ; preds = %21
%27 = tail call i32 @drive(i32 %15, i32 50)
%28 = tail call i32 (...) @cycle()
%29 = tail call i32 (...) @cycle()
%30 = tail call i32 (...) @cycle()
%31 = tail call i32 (...) @cycle()
%32 = tail call i32 (...) @cycle()
%33 = tail call i32 (...) @cycle()
%34 = tail call i32 (...) @cycle()
%35 = tail call i32 (...) @cycle()
%36 = tail call i32 (...) @cycle()
%37 = tail call i32 (...) @cycle()
%38 = tail call i32 (...) @cycle()
%39 = tail call i32 (...) @cycle()
%40 = tail call i32 (...) @cycle()
%41 = tail call i32 (...) @cycle()
%42 = tail call i32 (...) @cycle()
%43 = tail call i32 (...) @cycle()
%44 = tail call i32 (...) @cycle()
%45 = tail call i32 (...) @cycle()
%46 = tail call i32 (...) @cycle()
%47 = tail call i32 (...) @cycle()
%48 = tail call i32 (...) @cycle()
%49 = tail call i32 (...) @cycle()
%50 = tail call i32 (...) @cycle()
%51 = tail call i32 (...) @cycle()
%52 = tail call i32 (...) @cycle()
%53 = tail call i32 (...) @cycle()
%54 = tail call i32 (...) @cycle()
%55 = tail call i32 (...) @cycle()
%56 = tail call i32 (...) @cycle()
%57 = tail call i32 (...) @cycle()
%58 = tail call i32 (...) @cycle()
%59 = tail call i32 (...) @cycle()
%60 = tail call i32 (...) @cycle()
%61 = tail call i32 (...) @cycle()
%62 = tail call i32 (...) @cycle()
%63 = tail call i32 (...) @cycle()
%64 = tail call i32 (...) @cycle()
%65 = tail call i32 (...) @cycle()
%66 = tail call i32 (...) @cycle()
%67 = tail call i32 (...) @cycle()
%68 = tail call i32 (...) @cycle()
%69 = tail call i32 (...) @cycle()
%70 = tail call i32 (...) @cycle()
%71 = tail call i32 (...) @cycle()
%72 = tail call i32 (...) @cycle()
%73 = tail call i32 (...) @cycle()
%74 = tail call i32 (...) @cycle()
%75 = tail call i32 (...) @cycle()
%76 = tail call i32 (...) @cycle()
%77 = tail call i32 @drive(i32 %15, i32 0)
%78 = add nsw i32 %15, -3
br label %92
79: ; preds = %82, %23
%80 = tail call i64 @cannon(i32 %15, i32 %16)
%81 = icmp eq i64 %80, 0
br i1 %81, label %86, label %90
82: ; preds = %23, %82
%83 = tail call i32 (...) @cycle()
%84 = tail call i64 @cannon(i32 %15, i32 %16)
%85 = icmp eq i64 %84, 0
br i1 %85, label %82, label %79
86: ; preds = %79, %86
%87 = tail call i32 (...) @cycle()
%88 = tail call i64 @cannon(i32 %15, i32 %16)
%89 = icmp eq i64 %88, 0
br i1 %89, label %86, label %90
90: ; preds = %86, %79
%91 = add nsw i32 %15, -15
br label %92
92: ; preds = %26, %90, %18
%93 = phi i32 [ %20, %18 ], [ %78, %26 ], [ %91, %90 ]
%94 = tail call i32 (...) @damage()
%95 = icmp sgt i32 %94, %3
br i1 %95, label %8, label %14
}