#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 min(int, int);
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 allowedToTake = rrange(1, pile / 3);
  int firstTurn = 1;
  printf("Welcome to the game of Nim (version A).\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 and at most %i marbles.\n",
         allowedToTake);
  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 %i marbles.\n",
                     min(allowedToTake, pile));
            }
          } else if ((howMany >= 1) && (howMany <= min(allowedToTake, pile))) {
            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 %i marbles.\n",
                   min(allowedToTake, pile));
          }
        } 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");
      int temp = rrange(1, allowedToTake);
      while (temp > pile) {
        temp = rrange(1, allowedToTake);
      }
      pile = pile - temp;
      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   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0xa,%edi
mov    $0x64,%esi
call   1070 <rrange@plt>
mov    %eax,-0x8(%rbp)
xor    %edi,%edi
mov    $0x1,%esi
call   1070 <rrange@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x1,%edi
call   1070 <rrange@plt>
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xf36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    124d <main+0xed>
movl   $0x1,-0xc(%rbp)
jmp    1254 <main+0xf4>
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    13c5 <main+0x265>
cmpl   $0x1,-0x14(%rbp)
jne    127b <main+0x11b>
lea    0xf1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1289 <main+0x129>
lea    0xf21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128e <main+0x12e>
lea    0xf20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
lea    0xf52(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1080 <scanf@plt>
mov    0x2d2e(%rip),%rcx
cmp    (%rcx),%rax
je     139e <main+0x23e>
cmpl   $0x1,-0x8(%rbp)
jne    1322 <main+0x1c2>
cmpl   $0x1,-0x18(%rbp)
jne    12f4 <main+0x194>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xf17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c0 <main+0x260>
lea    0xf2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <min@plt>
mov    %eax,%esi
lea    0xf2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1399 <main+0x239>
cmpl   $0x1,-0x18(%rbp)
jl     136b <main+0x20b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <min@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jg     136b <main+0x20b>
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13c0 <main+0x260>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <min@plt>
mov    %eax,%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1399 <main+0x239>
jmp    13ac <main+0x24c>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13b1 <main+0x251>
mov    $0x1,%al
test   $0x1,%al
jne    128e <main+0x12e>
jmp    13c0 <main+0x260>
jmp    143b <main+0x2db>
cmpl   $0x1,-0x14(%rbp)
jne    13e2 <main+0x282>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13f0 <main+0x290>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    $0x1,%edi
call   1070 <rrange@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1421 <main+0x2c1>
mov    -0x10(%rbp),%esi
mov    $0x1,%edi
call   1070 <rrange@plt>
mov    %eax,-0x1c(%rbp)
jmp    1400 <main+0x2a0>
mov    -0x8(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1237 <main+0xd7>
cmpl   $0x0,-0xc(%rbp)
jne    1469 <main+0x309>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1477 <main+0x317>
lea    0xe74(%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
sub    $0x18,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0xa,%edi
mov    $0x64,%esi
call   1080 <rrange@plt>
mov    %eax,%r13d
xor    %edi,%edi
mov    $0x1,%esi
call   1080 <rrange@plt>
mov    %eax,%r15d
movslq %r13d,%rbx
imul   $0x55555556,%rbx,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
shr    $0x20,%rsi
add    %eax,%esi
mov    $0x1,%edi
call   1080 <rrange@plt>
mov    %eax,%r14d
lea    0xf2b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf47(%rip),%rdi
call   1030 <puts@plt>
lea    0xf7b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe04(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf97(%rip),%rdi
call   1030 <puts@plt>
lea    0xfaf(%rip),%rdi
call   1030 <puts@plt>
lea    0xfce(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%ecx
mov    $0x1,%al
lea    0xe18(%rip),%r12
lea    0xe58(%rip),%r15
lea    0xc(%rsp),%rbx
mov    0x2d8f(%rip),%rbp
mov    %r14d,0x10(%rsp)
jmp    1294 <main+0x124>
xor    %r13d,%r13d
mov    %rbx,%r12
lea    0xe3b(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ecx,%ecx
lea    0xc(%rsp),%rbx
mov    0x10(%rsp),%r14d
mov    0xb(%rsp),%al
mov    %al,%cl
xor    %eax,%eax
test   %r13d,%r13d
je     1410 <main+0x2a0>
test   %ecx,%ecx
sete   %dl
mov    %ecx,0x14(%rsp)
mov    %dl,0xb(%rsp)
je     13b0 <main+0x240>
test   $0x1,%al
lea    0xfd7(%rip),%rdi
lea    0x1015(%rip),%rax
cmovne %rax,%rdi
jmp    12c7 <main+0x157>
nopl   (%rax)
lea    0xfd1(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x0,0xc(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
cmp    0x0(%rbp),%rax
je     12c0 <main+0x150>
mov    %r12,%rbx
mov    0xc(%rsp),%r12d
cmp    $0x1,%r13d
jne    1350 <main+0x1e0>
cmp    $0x1,%r12d
je     1260 <main+0xf0>
lea    0xfa1(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r13d
mov    0x10(%rsp),%edi
mov    $0x1,%esi
call   1050 <min@plt>
lea    0xda1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%r12
lea    0xc(%rsp),%rbx
jmp    12cc <main+0x15c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %r12d,%r12d
mov    %r13d,%r14d
mov    0x10(%rsp),%r13d
jle    1371 <main+0x201>
mov    %r13d,%edi
mov    %r14d,%esi
call   1050 <min@plt>
cmp    %eax,%r12d
jle    1400 <main+0x290>
lea    0xf37(%rip),%rdi
call   1030 <puts@plt>
mov    %r13d,%edi
mov    %r14d,%esi
call   1050 <min@plt>
lea    0xd40(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%r12
lea    0xc(%rsp),%rbx
mov    %r14d,%r13d
jmp    12cc <main+0x15c>
nopl   0x0(%rax,%rax,1)
test   $0x1,%al
lea    0xe6f(%rip),%rdi
lea    0xea6(%rip),%rax
cmovne %rax,%rdi
call   1030 <puts@plt>
nopl   0x0(%rax)
mov    $0x1,%edi
mov    %r14d,%esi
call   1080 <rrange@plt>
cmp    %eax,%r13d
jl     13d0 <main+0x260>
sub    %eax,%r13d
lea    0xcbc(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ecx,%ecx
jmp    1283 <main+0x113>
nopl   (%rax)
sub    0xc(%rsp),%r14d
mov    %rbx,%r12
mov    %r14d,%r13d
jmp    1266 <main+0xf6>
cmpl   $0x0,0x14(%rsp)
lea    0xe26(%rip),%rax
lea    0xe2d(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Welcome to the game of Nim (version A).\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 = [59 x i8] c"The player must take at least one and at most %i 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 = [52 x i8] c"You must take at least one but at most %i 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
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @time(i32* null)
%9 = call i32 @srand(i32 %8)
%10 = call i32 @rrange(i32 10, i32 100)
store i32 %10, i32* %2
%11 = call i32 @rrange(i32 0, i32 1)
store i32 %11, i32* %3
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 3
%14 = call i32 @rrange(i32 1, i32 %13)
store i32 %14, i32* %4
store i32 1, i32* %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* %4
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0))
%23 = load i32, i32* %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %114, %0
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 1, i32* %3
br label %30
29: ; preds = %25
store i32 0, i32* %3
br label %30
30: ; preds = %29, %28
%31 = load i32, i32* %3
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %90
33: ; preds = %30
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
br label %40
38: ; preds = %33
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %40
40: ; preds = %38, %36
br label %41
41: ; preds = %88, %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %6
%43 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32* %6)
%44 = load i64, i64* @EOF
%45 = icmp ne i64 %43, %44
br i1 %45, label %46, label %85
46: ; preds = %41
%47 = load i32, i32* %2
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %62
49: ; preds = %46
%50 = load i32, i32* %6
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %55
52: ; preds = %49
store i32 0, i32* %2
%53 = load i32, i32* %2
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 %53)
br label %89
55: ; preds = %49
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0))
%57 = load i32, i32* %4
%58 = load i32, i32* %2
%59 = call i32 @min(i32 %57, i32 %58)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.14, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %55
br label %84
62: ; preds = %46
%63 = load i32, i32* %6
%64 = icmp sge i32 %63, 1
br i1 %64, label %65, label %77
65: ; preds = %62
%66 = load i32, i32* %6
%67 = load i32, i32* %4
%68 = load i32, i32* %2
%69 = call i32 @min(i32 %67, i32 %68)
%70 = icmp sle i32 %66, %69
br i1 %70, label %71, label %77
71: ; preds = %65
%72 = load i32, i32* %6
%73 = load i32, i32* %2
%74 = sub nsw i32 %73, %72
store i32 %74, i32* %2
%75 = load i32, i32* %2
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 %75)
br label %89
77: ; preds = %65, %62
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0))
%79 = load i32, i32* %4
%80 = load i32, i32* %2
%81 = call i32 @min(i32 %79, i32 %80)
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.14, i64 0, i64 0), i32 %81)
br label %83
83: ; preds = %77
br label %84
84: ; preds = %83, %61
br label %87
85: ; preds = %41
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0))
br label %87
87: ; preds = %85, %84
br label %88
88: ; preds = %87
br i1 true, label %41, label %89
89: ; preds = %88, %71, %52
br label %113
90: ; preds = %30
%91 = load i32, i32* %5
%92 = icmp eq i32 %91, 1
br i1 %92, label %93, label %95
93: ; preds = %90
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.16, i64 0, i64 0))
br label %97
95: ; preds = %90
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.17, i64 0, i64 0))
br label %97
97: ; preds = %95, %93
%98 = load i32, i32* %4
%99 = call i32 @rrange(i32 1, i32 %98)
store i32 %99, i32* %7
br label %100
100: ; preds = %104, %97
%101 = load i32, i32* %7
%102 = load i32, i32* %2
%103 = icmp sgt i32 %101, %102
br i1 %103, label %104, label %107
104: ; preds = %100
%105 = load i32, i32* %4
%106 = call i32 @rrange(i32 1, i32 %105)
store i32 %106, i32* %7
br label %100
107: ; preds = %100
%108 = load i32, i32* %2
%109 = load i32, i32* %7
%110 = sub nsw i32 %108, %109
store i32 %110, i32* %2
%111 = load i32, i32* %2
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 %111)
br label %113
113: ; preds = %107, %89
store i32 0, i32* %5
br label %114
114: ; preds = %113
%115 = load i32, i32* %2
%116 = icmp ne i32 %115, 0
br i1 %116, label %25, label %117
117: ; preds = %114
%118 = load i32, i32* %3
%119 = icmp eq i32 %118, 0
br i1 %119, label %120, label %122
120: ; preds = %117
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.18, i64 0, i64 0))
br label %124
122: ; preds = %117
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.19, i64 0, i64 0))
br label %124
124: ; preds = %122, %120
%125 = load i32, i32* %1
ret i32 %125
}

LLVM IR (-O2):
@.str.3 = [59 x i8] c"The player must take at least one and at most %i marbles.\0A\00"
@.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.14 = [52 x i8] c"You must take at least one but at most %i marbles.\0A\00"
@str = [40 x i8] c"Welcome to the game of Nim (version A).\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 = [36 x i8] c"Then the other player takes a turn.\00"
@str.23 = [43 x i8] c"The player who takes the last marble wins.\00"
@str.24 = [53 x i8] c"====================================================\00"
@str.25 = [26 x i8] c"It is the computers turn.\00"
@str.26 = [14 x i8] c"You have won.\00"
@str.27 = [22 x i8] c"The computer has won.\00"
@str.28 = [33 x i8] c"The computer has the first turn.\00"
@str.29 = [17 x i8] c"It is your turn.\00"
@str.30 = [23 x i8] c"Please enter a number.\00"
@str.32 = [29 x i8] c"Please enter a valid number.\00"
@str.33 = [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 = sdiv i32 %4, 3
%7 = tail call i32 @rrange(i32 1, i32 %6)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str.20, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.21, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.22, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.23, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i32 %4)
%16 = bitcast i32* %1 to i8*
br label %17
17: ; preds = %72, %0
%18 = phi i32 [ %5, %0 ], [ %22, %72 ]
%19 = phi i32 [ %4, %0 ], [ %73, %72 ]
%20 = phi i1 [ true, %0 ], [ false, %72 ]
%21 = icmp eq i32 %18, 0
%22 = zext i1 %21 to i32
br i1 %21, label %60, label %23
23: ; preds = %17
%24 = select i1 %20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str.33, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str.29, i64 0, i64 0)
%25 = call i32 @puts(i8* dereferenceable(1) %24)
br label %26
26: ; preds = %58, %23
%27 = phi i32 [ %19, %23 ], [ %59, %58 ]
%28 = 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
%29 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i32* %1)
%30 = load i64, i64* @EOF
%31 = icmp eq i64 %29, %30
br i1 %31, label %53, label %32
32: ; preds = %26
%33 = icmp eq i32 %27, 1
%34 = load i32, i32* %1
br i1 %33, label %35, label %41
35: ; preds = %32
%36 = icmp eq i32 %34, 1
br i1 %36, label %55, label %37
37: ; preds = %35
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.32, i64 0, i64 0))
%39 = call i32 @min(i32 %7, i32 1)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.14, i64 0, i64 0), i32 %39)
br label %58
41: ; preds = %32
%42 = icmp sgt i32 %34, 0
br i1 %42, label %43, label %49
43: ; preds = %41
%44 = call i32 @min(i32 %7, i32 %27)
%45 = icmp sgt i32 %34, %44
br i1 %45, label %49, label %46
46: ; preds = %43
%47 = load i32, i32* %1
%48 = sub nsw i32 %27, %47
br label %55
49: ; preds = %43, %41
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.32, i64 0, i64 0))
%51 = call i32 @min(i32 %7, i32 %27)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.14, i64 0, i64 0), i32 %51)
br label %58
53: ; preds = %26
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.30, i64 0, i64 0))
br label %58
55: ; preds = %35, %46
%56 = phi i32 [ %48, %46 ], [ 0, %35 ]
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 %56)
br label %72
58: ; preds = %53, %49, %37
%59 = phi i32 [ 1, %37 ], [ %27, %49 ], [ %27, %53 ]
br label %26
60: ; preds = %17
%61 = select i1 %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str.28, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @str.25, i64 0, i64 0)
%62 = call i32 @puts(i8* dereferenceable(1) %61)
%63 = call i32 @rrange(i32 1, i32 %7)
%64 = icmp slt i32 %19, %63
br i1 %64, label %65, label %68
65: ; preds = %60, %65
%66 = call i32 @rrange(i32 1, i32 %7)
%67 = icmp slt i32 %19, %66
br i1 %67, label %65, label %68
68: ; preds = %65, %60
%69 = phi i32 [ %63, %60 ], [ %66, %65 ]
%70 = sub nsw i32 %19, %69
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %55, %68
%73 = phi i32 [ %70, %68 ], [ %56, %55 ]
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %17
75: ; preds = %72
%76 = select i1 %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str.26, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str.27, i64 0, i64 0)
%77 = call i32 @puts(i8* dereferenceable(1) %76)
ret i32 0
}