#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__ EOF;
int /*<<< orphan*/ printf(char *, ...);
int rrange(int, int);
scalar_t__ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  int pile = rrange(10, 100);
  int turn = rrange(0, 1);
  int firstTurn = 1;
  printf("Welcome to the game of Nim (version B).\n");
  printf("In this game, two players alternatley take marbles from a pile.\n");
  printf("In each move, a player chooses how many marbles to take.\n");
  printf(
      "The player must take at least one but at most half of the marbles.\n");
  printf("Then the other player takes a turn.\n");
  printf("The player who takes the last marble wins.\n");
  printf("====================================================\n");
  printf("There are %i marbles on the pile.\n", pile);
  do {
    if (turn == 0)
      turn = 1;
    else
      turn = 0;
    if (turn == 0) {
      if (firstTurn == 1)
        printf("You have the first turn.\n");
      else
        printf("It is your turn.\n");
      do {
        printf("Please enter how many marbles you would like to remove from "
               "the pile: ");
        int howMany = 0;
        if (scanf("%i", &howMany) != EOF) {
          if (pile == 1) {
            if (howMany == 1) {
              pile = 0;
              printf("There are now %i marbles on the pile.\n", pile);
              break;
            } else {
              printf("Please enter a valid number.\n");
              printf("You must take at least one but at most half of the "
                     "marbles.\n");
            }
          } else if ((howMany >= 1) && (howMany <= (pile / 2))) {
            pile -= howMany;
            printf("There are now %i marbles on the pile.\n", pile);
            break;
          } else {
            printf("Please enter a valid number.\n");
            printf("You must take at least one but at most half of the "
                   "marbles.\n");
          }
        } else {
          printf("Please enter a number.\n");
        }
      } while (1);
    } else {
      if (firstTurn == 1)
        printf("The computer has the first turn.\n");
      else
        printf("It is the computers turn.\n");
      if (pile == 63 || pile == 31 || pile == 15 || pile == 7 || pile == 3)
        pile = pile - rrange(1, pile / 2);
      else if (pile > 63)
        pile = 63;
      else if (pile > 31)
        pile = 31;
      else if (pile > 15)
        pile = 15;
      else if (pile > 7)
        pile = 7;
      else if (pile > 3)
        pile = 3;
      else if (pile == 2)
        pile = 1;
      else if (pile == 1)
        pile = 0;
      printf("There are now %i marbles on the pile.\n", pile);
    }
    firstTurn = 0;
  } while (pile != 0);
  if (turn == 0) {
    printf("The computer has won.\n");
  } else {
    printf("You have won.\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0xa,%edi
mov    $0x64,%esi
call   1060 <rrange@plt>
mov    %eax,-0x8(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
call   1060 <rrange@plt>
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xf6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    1220 <main+0xd0>
movl   $0x1,-0xc(%rbp)
jmp    1227 <main+0xd7>
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    137e <main+0x22e>
cmpl   $0x1,-0x10(%rbp)
jne    124e <main+0xfe>
lea    0xf50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125c <main+0x10c>
lea    0xf57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1261 <main+0x111>
lea    0xf56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
lea    0xf88(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
mov    0x2d5b(%rip),%rcx
cmp    (%rcx),%rax
je     1357 <main+0x207>
cmpl   $0x1,-0x8(%rbp)
jne    12e8 <main+0x198>
cmpl   $0x1,-0x14(%rbp)
jne    12c7 <main+0x177>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xf4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1379 <main+0x229>
lea    0xf61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1352 <main+0x202>
cmpl   $0x1,-0x14(%rbp)
jl     1331 <main+0x1e1>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jg     1331 <main+0x1e1>
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1379 <main+0x229>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1352 <main+0x202>
jmp    1365 <main+0x215>
lea    0xf2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    136a <main+0x21a>
mov    $0x1,%al
test   $0x1,%al
jne    1261 <main+0x111>
jmp    1379 <main+0x229>
jmp    14d0 <main+0x380>
cmpl   $0x1,-0x10(%rbp)
jne    139b <main+0x24b>
lea    0xf13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13a9 <main+0x259>
lea    0xf22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3f,-0x8(%rbp)
je     13db <main+0x28b>
cmpl   $0x1f,-0x8(%rbp)
je     13db <main+0x28b>
cmpl   $0xf,-0x8(%rbp)
je     13db <main+0x28b>
cmpl   $0x7,-0x8(%rbp)
je     13db <main+0x28b>
cmpl   $0x3,-0x8(%rbp)
jne    1407 <main+0x2b7>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x1,%edi
call   1060 <rrange@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    14bf <main+0x36f>
cmpl   $0x3f,-0x8(%rbp)
jle    141d <main+0x2cd>
movl   $0x3f,-0x8(%rbp)
jmp    14ba <main+0x36a>
cmpl   $0x1f,-0x8(%rbp)
jle    1433 <main+0x2e3>
movl   $0x1f,-0x8(%rbp)
jmp    14b5 <main+0x365>
cmpl   $0xf,-0x8(%rbp)
jle    1449 <main+0x2f9>
movl   $0xf,-0x8(%rbp)
jmp    14b0 <main+0x360>
cmpl   $0x7,-0x8(%rbp)
jle    145f <main+0x30f>
movl   $0x7,-0x8(%rbp)
jmp    14ab <main+0x35b>
cmpl   $0x3,-0x8(%rbp)
jle    1475 <main+0x325>
movl   $0x3,-0x8(%rbp)
jmp    14a6 <main+0x356>
cmpl   $0x2,-0x8(%rbp)
jne    148b <main+0x33b>
movl   $0x1,-0x8(%rbp)
jmp    14a1 <main+0x351>
cmpl   $0x1,-0x8(%rbp)
jne    149c <main+0x34c>
movl   $0x0,-0x8(%rbp)
jmp    14a1 <main+0x351>
jmp    14a6 <main+0x356>
jmp    14ab <main+0x35b>
jmp    14b0 <main+0x360>
jmp    14b5 <main+0x365>
jmp    14ba <main+0x36a>
jmp    14bf <main+0x36f>
mov    -0x8(%rbp),%esi
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    120a <main+0xba>
cmpl   $0x0,-0xc(%rbp)
jne    14fe <main+0x3ae>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    150c <main+0x3bc>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0xa,%edi
mov    $0x64,%esi
call   1070 <rrange@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    $0x1,%esi
call   1070 <rrange@plt>
mov    %eax,(%rsp)
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf10(%rip),%rdi
call   1030 <puts@plt>
lea    0xf44(%rip),%rdi
call   1030 <puts@plt>
lea    0xf71(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa8(%rip),%rdi
call   1030 <puts@plt>
lea    0xfc0(%rip),%rdi
call   1030 <puts@plt>
lea    0xfdf(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r14b
lea    0xe1c(%rip),%r13
lea    0xe5c(%rip),%rbx
lea    0x4(%rsp),%r15
mov    0x2dce(%rip),%r12
cmpl   $0x0,(%rsp)
sete   %al
mov    $0x0,%ecx
mov    %al,%cl
mov    %ecx,(%rsp)
je     12d0 <main+0x170>
test   $0x1,%r14b
lea    0x101f(%rip),%rdi
lea    0x1099(%rip),%rax
cmovne %rax,%rdi
jmp    1257 <main+0xf7>
nopl   0x0(%rax)
lea    0x1015(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x0,0x4(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
cmp    (%r12),%rax
je     1250 <main+0xf0>
mov    0x4(%rsp),%r14d
cmp    $0x1,%ebp
jne    12a0 <main+0x140>
mov    $0x1,%ebp
cmp    $0x1,%r14d
jne    12b7 <main+0x157>
jmp    13c5 <main+0x265>
nopl   0x0(%rax)
test   %r14d,%r14d
jle    12b7 <main+0x157>
mov    %ebp,%eax
shr    $0x1f,%eax
add    %ebp,%eax
sar    %eax
cmp    %eax,%r14d
jle    1340 <main+0x1e0>
lea    0xfc5(%rip),%rdi
call   1030 <puts@plt>
lea    0xfd6(%rip),%rdi
jmp    1257 <main+0xf7>
nopl   0x0(%rax)
test   $0x1,%r14b
lea    0xf21(%rip),%rdi
lea    0xf58(%rip),%rax
cmovne %rax,%rdi
call   1030 <puts@plt>
cmp    $0x3f,%ebp
ja     1364 <main+0x204>
mov    %ebp,%eax
movabs $0x8000000080008088,%rcx
bt     %rax,%rcx
jae    1364 <main+0x204>
mov    %ebp,%esi
shr    %esi
mov    $0x1,%edi
call   1070 <rrange@plt>
sub    %eax,%ebp
xor    %r14d,%r14d
lea    0xd51(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jne    121a <main+0xba>
jmp    13f2 <main+0x292>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%esi
sub    %r14d,%esi
lea    0xd21(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
sub    %r14d,%ebp
mov    $0x0,%r14d
jne    121a <main+0xba>
jmp    13d5 <main+0x275>
mov    $0x3f,%eax
cmp    $0x3f,%ebp
jg     13ab <main+0x24b>
mov    $0x1f,%eax
cmp    $0x1f,%ebp
jg     13ab <main+0x24b>
mov    $0xf,%eax
cmp    $0xf,%ebp
jg     13ab <main+0x24b>
mov    $0x7,%eax
cmp    $0x7,%ebp
jg     13ab <main+0x24b>
mov    $0x3,%eax
cmp    $0x3,%ebp
jg     13ab <main+0x24b>
mov    $0x1,%eax
cmp    $0x2,%ebp
je     13ab <main+0x24b>
cmp    $0x1,%ebp
jne    1312 <main+0x1b2>
jmp    13fb <main+0x29b>
xor    %r14d,%r14d
lea    0xcb8(%rip),%rdi
mov    %eax,%ebp
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    121a <main+0xba>
lea    0xca1(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe48(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe1d(%rip),%rdi
jmp    13dc <main+0x27c>
lea    0xc6b(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe04(%rip),%rdi
jmp    13dc <main+0x27c>

LLVM IR (-O0):
@.str = [41 x i8] c"Welcome to the game of Nim (version B).\0A\00"
@.str.1 = [65 x i8] c"In this game, two players alternatley take marbles from a pile.\0A\00"
@.str.2 = [58 x i8] c"In each move, a player chooses how many marbles to take.\0A\00"
@.str.3 = [68 x i8] c"The player must take at least one but at most half of the marbles.\0A\00"
@.str.4 = [37 x i8] c"Then the other player takes a turn.\0A\00"
@.str.5 = [44 x i8] c"The player who takes the last marble wins.\0A\00"
@.str.6 = [54 x i8] c"====================================================\0A\00"
@.str.7 = [35 x i8] c"There are %i marbles on the pile.\0A\00"
@.str.8 = [26 x i8] c"You have the first turn.\0A\00"
@.str.9 = [18 x i8] c"It is your turn.\0A\00"
@.str.10 = [71 x i8] c"Please enter how many marbles you would like to remove from the pile: \00"
@.str.11 = [3 x i8] c"%i\00"
@EOF = global i64 0
@.str.12 = [39 x i8] c"There are now %i marbles on the pile.\0A\00"
@.str.13 = [30 x i8] c"Please enter a valid number.\0A\00"
@.str.14 = [61 x i8] c"You must take at least one but at most half of the marbles.\0A\00"
@.str.15 = [24 x i8] c"Please enter a number.\0A\00"
@.str.16 = [34 x i8] c"The computer has the first turn.\0A\00"
@.str.17 = [27 x i8] c"It is the computers turn.\0A\00"
@.str.18 = [23 x i8] c"The computer has won.\0A\00"
@.str.19 = [15 x i8] c"You have won.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @time(i32* null)
%7 = call i32 @srand(i32 %6)
%8 = call i32 @rrange(i32 10, i32 100)
store i32 %8, i32* %2
%9 = call i32 @rrange(i32 0, i32 1)
store i32 %9, i32* %3
store i32 1, i32* %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0))
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %144, %0
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 1, i32* %3
br label %24
23: ; preds = %19
store i32 0, i32* %3
br label %24
24: ; preds = %23, %22
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %77
27: ; preds = %24
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
br label %34
32: ; preds = %27
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
br label %35
35: ; preds = %75, %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %5
%37 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32* %5)
%38 = load i64, i64* @EOF
%39 = icmp ne i64 %37, %38
br i1 %39, label %40, label %72
40: ; preds = %35
%41 = load i32, i32* %2
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %53
43: ; preds = %40
%44 = load i32, i32* %5
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %49
46: ; preds = %43
store i32 0, i32* %2
%47 = load i32, i32* %2
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 %47)
br label %76
49: ; preds = %43
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0))
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.14, i64 0, i64 0))
br label %52
52: ; preds = %49
br label %71
53: ; preds = %40
%54 = load i32, i32* %5
%55 = icmp sge i32 %54, 1
br i1 %55, label %56, label %67
56: ; preds = %53
%57 = load i32, i32* %5
%58 = load i32, i32* %2
%59 = sdiv i32 %58, 2
%60 = icmp sle i32 %57, %59
br i1 %60, label %61, label %67
61: ; preds = %56
%62 = load i32, i32* %5
%63 = load i32, i32* %2
%64 = sub nsw i32 %63, %62
store i32 %64, i32* %2
%65 = load i32, i32* %2
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 %65)
br label %76
67: ; preds = %56, %53
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0))
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.14, i64 0, i64 0))
br label %70
70: ; preds = %67
br label %71
71: ; preds = %70, %52
br label %74
72: ; preds = %35
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0))
br label %74
74: ; preds = %72, %71
br label %75
75: ; preds = %74
br i1 true, label %35, label %76
76: ; preds = %75, %61, %46
br label %143
77: ; preds = %24
%78 = load i32, i32* %4
%79 = icmp eq i32 %78, 1
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.16, i64 0, i64 0))
br label %84
82: ; preds = %77
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.17, i64 0, i64 0))
br label %84
84: ; preds = %82, %80
%85 = load i32, i32* %2
%86 = icmp eq i32 %85, 63
br i1 %86, label %99, label %87
87: ; preds = %84
%88 = load i32, i32* %2
%89 = icmp eq i32 %88, 31
br i1 %89, label %99, label %90
90: ; preds = %87
%91 = load i32, i32* %2
%92 = icmp eq i32 %91, 15
br i1 %92, label %99, label %93
93: ; preds = %90
%94 = load i32, i32* %2
%95 = icmp eq i32 %94, 7
br i1 %95, label %99, label %96
96: ; preds = %93
%97 = load i32, i32* %2
%98 = icmp eq i32 %97, 3
br i1 %98, label %99, label %105
99: ; preds = %96, %93, %90, %87, %84
%100 = load i32, i32* %2
%101 = load i32, i32* %2
%102 = sdiv i32 %101, 2
%103 = call i32 @rrange(i32 1, i32 %102)
%104 = sub nsw i32 %100, %103
store i32 %104, i32* %2
br label %140
105: ; preds = %96
%106 = load i32, i32* %2
%107 = icmp sgt i32 %106, 63
br i1 %107, label %108, label %109
108: ; preds = %105
store i32 63, i32* %2
br label %139
109: ; preds = %105
%110 = load i32, i32* %2
%111 = icmp sgt i32 %110, 31
br i1 %111, label %112, label %113
112: ; preds = %109
store i32 31, i32* %2
br label %138
113: ; preds = %109
%114 = load i32, i32* %2
%115 = icmp sgt i32 %114, 15
br i1 %115, label %116, label %117
116: ; preds = %113
store i32 15, i32* %2
br label %137
117: ; preds = %113
%118 = load i32, i32* %2
%119 = icmp sgt i32 %118, 7
br i1 %119, label %120, label %121
120: ; preds = %117
store i32 7, i32* %2
br label %136
121: ; preds = %117
%122 = load i32, i32* %2
%123 = icmp sgt i32 %122, 3
br i1 %123, label %124, label %125
124: ; preds = %121
store i32 3, i32* %2
br label %135
125: ; preds = %121
%126 = load i32, i32* %2
%127 = icmp eq i32 %126, 2
br i1 %127, label %128, label %129
128: ; preds = %125
store i32 1, i32* %2
br label %134
129: ; preds = %125
%130 = load i32, i32* %2
%131 = icmp eq i32 %130, 1
br i1 %131, label %132, label %133
132: ; preds = %129
store i32 0, i32* %2
br label %133
133: ; preds = %132, %129
br label %134
134: ; preds = %133, %128
br label %135
135: ; preds = %134, %124
br label %136
136: ; preds = %135, %120
br label %137
137: ; preds = %136, %116
br label %138
138: ; preds = %137, %112
br label %139
139: ; preds = %138, %108
br label %140
140: ; preds = %139, %99
%141 = load i32, i32* %2
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 %141)
br label %143
143: ; preds = %140, %76
store i32 0, i32* %4
br label %144
144: ; preds = %143
%145 = load i32, i32* %2
%146 = icmp ne i32 %145, 0
br i1 %146, label %19, label %147
147: ; preds = %144
%148 = load i32, i32* %3
%149 = icmp eq i32 %148, 0
br i1 %149, label %150, label %152
150: ; preds = %147
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.18, i64 0, i64 0))
br label %154
152: ; preds = %147
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.19, i64 0, i64 0))
br label %154
154: ; preds = %152, %150
%155 = load i32, i32* %1
ret i32 %155
}

LLVM IR (-O2):
@.str.7 = [35 x i8] c"There are %i marbles on the pile.\0A\00"
@.str.10 = [71 x i8] c"Please enter how many marbles you would like to remove from the pile: \00"
@.str.11 = [3 x i8] c"%i\00"
@EOF = global i64 0
@.str.12 = [39 x i8] c"There are now %i marbles on the pile.\0A\00"
@str = [40 x i8] c"Welcome to the game of Nim (version B).\00"
@str.20 = [64 x i8] c"In this game, two players alternatley take marbles from a pile.\00"
@str.21 = [57 x i8] c"In each move, a player chooses how many marbles to take.\00"
@str.22 = [67 x i8] c"The player must take at least one but at most half of the marbles.\00"
@str.23 = [36 x i8] c"Then the other player takes a turn.\00"
@str.24 = [43 x i8] c"The player who takes the last marble wins.\00"
@str.25 = [53 x i8] c"====================================================\00"
@str.26 = [26 x i8] c"It is the computers turn.\00"
@str.27 = [14 x i8] c"You have won.\00"
@str.28 = [22 x i8] c"The computer has won.\00"
@str.29 = [33 x i8] c"The computer has the first turn.\00"
@str.30 = [17 x i8] c"It is your turn.\00"
@str.31 = [23 x i8] c"Please enter a number.\00"
@str.34 = [29 x i8] c"Please enter a valid number.\00"
@str.35 = [60 x i8] c"You must take at least one but at most half of the marbles.\00"
@str.36 = [25 x i8] c"You have the first turn.\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @time(i32* null)
%3 = tail call i32 @srand(i32 %2)
%4 = tail call i32 @rrange(i32 10, i32 100)
%5 = tail call i32 @rrange(i32 0, i32 1)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.20, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.21, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.22, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.23, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.24, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.25, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i32 %4)
%14 = bitcast i32* %1 to i8*
br label %15
15: ; preds = %78, %0
%16 = phi i32 [ %4, %0 ], [ %79, %78 ]
%17 = phi i32 [ %5, %0 ], [ %20, %78 ]
%18 = phi i1 [ true, %0 ], [ false, %78 ]
%19 = icmp eq i32 %17, 0
%20 = zext i1 %19 to i32
br i1 %19, label %51, label %21
21: ; preds = %15
%22 = select i1 %18, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str.36, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.30, i64 0, i64 0)
%23 = call i32 @puts(i8* dereferenceable(1) %22)
br label %24
24: ; preds = %47, %21
%25 = phi i32 [ %16, %21 ], [ %49, %47 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %1
%27 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32* %1)
%28 = load i64, i64* @EOF
%29 = icmp eq i64 %27, %28
br i1 %29, label %47, label %30
30: ; preds = %24
%31 = icmp eq i32 %25, 1
%32 = load i32, i32* %1
br i1 %31, label %33, label %37
33: ; preds = %30
%34 = icmp eq i32 %32, 1
br i1 %34, label %35, label %42
35: ; preds = %33
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 0)
br label %84
37: ; preds = %30
%38 = icmp slt i32 %32, 1
%39 = sdiv i32 %25, 2
%40 = icmp sgt i32 %32, %39
%41 = select i1 %38, i1 true, i1 %40
br i1 %41, label %42, label %71
42: ; preds = %37, %33
%43 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @str.34, i64 0, i64 0), %33 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @str.34, i64 0, i64 0), %37 ]
%44 = phi i8* [ getelementptr inbounds ([60 x i8], [60 x i8]* @str.35, i64 0, i64 0), %33 ], [ getelementptr inbounds ([60 x i8], [60 x i8]* @str.35, i64 0, i64 0), %37 ]
%45 = phi i32 [ 1, %33 ], [ %25, %37 ]
%46 = call i32 @puts(i8* dereferenceable(1) %43)
br label %47
47: ; preds = %42, %24
%48 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.31, i64 0, i64 0), %24 ], [ %44, %42 ]
%49 = phi i32 [ %25, %24 ], [ %45, %42 ]
%50 = call i32 @puts(i8* dereferenceable(1) %48)
br label %24
51: ; preds = %15
%52 = select i1 %18, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str.29, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @str.26, i64 0, i64 0)
%53 = call i32 @puts(i8* dereferenceable(1) %52)
switch i32 %16, label %58 [
i32 63, label %54
i32 31, label %54
i32 15, label %54
i32 7, label %54
i32 3, label %54
]
54: ; preds = %51, %51, %51, %51, %51
%55 = lshr i32 %16, 1
%56 = call i32 @rrange(i32 1, i32 %55)
%57 = sub nsw i32 %16, %56
br label %80
58: ; preds = %51
%59 = icmp sgt i32 %16, 63
br i1 %59, label %75, label %60
60: ; preds = %58
%61 = icmp sgt i32 %16, 31
br i1 %61, label %75, label %62
62: ; preds = %60
%63 = icmp sgt i32 %16, 15
br i1 %63, label %75, label %64
64: ; preds = %62
%65 = icmp sgt i32 %16, 7
br i1 %65, label %75, label %66
66: ; preds = %64
%67 = icmp sgt i32 %16, 3
br i1 %67, label %75, label %68
68: ; preds = %66
switch i32 %16, label %80 [
i32 2, label %75
i32 1, label %69
]
69: ; preds = %68
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 0)
br label %84
71: ; preds = %37
%72 = sub nsw i32 %25, %32
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 %72)
%74 = icmp eq i32 %72, 0
br i1 %74, label %84, label %78
75: ; preds = %58, %60, %62, %64, %66, %68
%76 = phi i32 [ 1, %68 ], [ 3, %66 ], [ 7, %64 ], [ 15, %62 ], [ 31, %60 ], [ 63, %58 ]
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %75, %71, %80
%79 = phi i32 [ %72, %71 ], [ %81, %80 ], [ %76, %75 ]
br label %15
80: ; preds = %68, %54
%81 = phi i32 [ %57, %54 ], [ %16, %68 ]
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 %81)
%83 = icmp eq i32 %81, 0
br i1 %83, label %84, label %78
84: ; preds = %80, %71, %69, %35
%85 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.28, i64 0, i64 0), %35 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.27, i64 0, i64 0), %69 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.28, i64 0, i64 0), %71 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.27, i64 0, i64 0), %80 ]
%86 = call i32 @puts(i8* dereferenceable(1) %85)
ret i32 0
}