#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 doWeHaveAWinner(int, int);
scalar_t__ getHareMove();
scalar_t__ getTortoiseMove();
int /*<<< orphan*/ printField(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ tickOneSecond();
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main() {
  srand(time(0));
  int harePosition = 1, tortoisePosition = 1;
  int weHaveAWinner = 0;
  printf("BANG !!!!!\n");
  tickOneSecond();
  printf("AND THEY'RE OFF !!!!!\n");
  tickOneSecond();
  printField(harePosition, tortoisePosition);
  tickOneSecond();
  while (weHaveAWinner == 0) {
    harePosition += getHareMove();
    tortoisePosition += getTortoiseMove();
    if (harePosition < 1)
      harePosition = 1;
    if (tortoisePosition < 1)
      tortoisePosition = 1;
    printField(harePosition, tortoisePosition);
    weHaveAWinner = doWeHaveAWinner(harePosition, tortoisePosition);
    tickOneSecond();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <tickOneSecond@plt>
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <tickOneSecond@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <printField@plt>
mov    $0x0,%al
call   1080 <tickOneSecond@plt>
cmpl   $0x0,-0x10(%rbp)
jne    1263 <main+0xe3>
mov    $0x0,%al
call   1090 <getHareMove@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getTortoiseMove@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    122d <main+0xad>
movl   $0x1,-0x8(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    123e <main+0xbe>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <printField@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   10a0 <doWeHaveAWinner@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1080 <tickOneSecond@plt>
jmp    11ea <main+0x6a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe63(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <tickOneSecond@plt>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <tickOneSecond@plt>
mov    $0x1,%r15d
mov    $0x1,%edi
mov    $0x1,%esi
call   1060 <printField@plt>
xor    %eax,%eax
call   1080 <tickOneSecond@plt>
mov    $0x1,%r12d
mov    $0x1,%r14d
jmp    1214 <main+0x94>
cs nopw 0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %ebx,%esi
call   1060 <printField@plt>
mov    %r14d,%edi
mov    %ebx,%esi
call   10a0 <doWeHaveAWinner@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <tickOneSecond@plt>
mov    %ebx,%r12d
test   %ebp,%ebp
jne    1242 <main+0xc2>
xor    %eax,%eax
call   1090 <getHareMove@plt>
mov    %rax,%rbp
add    %r14d,%ebp
xor    %eax,%eax
call   1040 <getTortoiseMove@plt>
mov    %rax,%rbx
add    %r12d,%ebx
test   %ebp,%ebp
mov    %ebp,%r14d
cmovle %r15d,%r14d
test   %ebx,%ebx
jg     11f0 <main+0x70>
mov    $0x1,%ebx
jmp    11f0 <main+0x70>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"BANG !!!!!\0A\00"
@.str.1 = [23 x i8] c"AND THEY'RE OFF !!!!!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @time(i32 0)
%6 = call i32 @srand(i32 %5)
store i32 1, i32* %2
store i32 1, i32* %3
store i32 0, i32* %4
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (...) @tickOneSecond()
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (...) @tickOneSecond()
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 @printField(i32 %11, i32 %12)
%14 = call i32 (...) @tickOneSecond()
br label %15
15: ; preds = %36, %0
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %44
18: ; preds = %15
%19 = call i64 (...) @getHareMove()
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = add nsw i64 %21, %19
%23 = trunc i64 %22 to i32
store i32 %23, i32* %2
%24 = call i64 (...) @getTortoiseMove()
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = add nsw i64 %26, %24
%28 = trunc i64 %27 to i32
store i32 %28, i32* %3
%29 = load i32, i32* %2
%30 = icmp slt i32 %29, 1
br i1 %30, label %31, label %32
31: ; preds = %18
store i32 1, i32* %2
br label %32
32: ; preds = %31, %18
%33 = load i32, i32* %3
%34 = icmp slt i32 %33, 1
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 1, i32* %3
br label %36
36: ; preds = %35, %32
%37 = load i32, i32* %2
%38 = load i32, i32* %3
%39 = call i32 @printField(i32 %37, i32 %38)
%40 = load i32, i32* %2
%41 = load i32, i32* %3
%42 = call i32 @doWeHaveAWinner(i32 %40, i32 %41)
store i32 %42, i32* %4
%43 = call i32 (...) @tickOneSecond()
br label %15
44: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@str = [11 x i8] c"BANG !!!!!\00"
@str.2 = [22 x i8] c"AND THEY'RE OFF !!!!!\00"
define i32 @main() {
%1 = tail call i32 @time(i32 0)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @tickOneSecond()
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.2, i64 0, i64 0))
%6 = tail call i32 (...) @tickOneSecond()
%7 = tail call i32 @printField(i32 1, i32 1)
%8 = tail call i32 (...) @tickOneSecond()
br label %9
9: ; preds = %0, %9
%10 = phi i32 [ 1, %0 ], [ %21, %9 ]
%11 = phi i32 [ 1, %0 ], [ %19, %9 ]
%12 = tail call i64 (...) @getHareMove()
%13 = trunc i64 %12 to i32
%14 = add i32 %11, %13
%15 = tail call i64 (...) @getTortoiseMove()
%16 = trunc i64 %15 to i32
%17 = add i32 %10, %16
%18 = icmp sgt i32 %14, 1
%19 = select i1 %18, i32 %14, i32 1
%20 = icmp sgt i32 %17, 1
%21 = select i1 %20, i32 %17, i32 1
%22 = tail call i32 @printField(i32 %19, i32 %21)
%23 = tail call i32 @doWeHaveAWinner(i32 %19, i32 %21)
%24 = tail call i32 (...) @tickOneSecond()
%25 = icmp eq i32 %23, 0
br i1 %25, label %9, label %26
26: ; preds = %9
ret i32 0
}