#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 getChoosing(int, int);
int /*<<< orphan*/ printf(char *, ...);
int firstComputer(int sticks) {
  int choosing, turn = 1;
  printf("\n sticks remaining :%d", sticks);
  printf("\n Computer takes 2");
  sticks = sticks - 2;
  while (sticks > 1) {
    turn = turn == 0 ? 1 : 0;
    choosing = getChoosing(turn, sticks);
    sticks -= choosing;
    printf("\nsticks left :%d\n", sticks);
  }
  if (turn == 0) {
    printf("\n computer lost\n");
  } else
    printf("\nuser lost\n");
  return 0;
}


x86 assembly (clang, -O0):
<firstComputer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x4(%rbp),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    11a6 <firstComputer+0x86>
mov    -0xc(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <getChoosing@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115a <firstComputer+0x3a>
cmpl   $0x0,-0xc(%rbp)
jne    11c3 <firstComputer+0xa3>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d1 <firstComputer+0xb1>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<firstComputer>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0xec3(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x4,%ebx
jl     1193 <firstComputer+0x63>
add    $0xfffffffe,%ebx
mov    $0x1,%ebp
lea    0xec2(%rip),%r14
nopl   0x0(%rax,%rax,1)
xor    $0x1,%ebp
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <getChoosing@plt>
sub    %eax,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebx
jg     1170 <firstComputer+0x40>
test   %ebp,%ebp
je     119c <firstComputer+0x6c>
lea    0xea2(%rip),%rdi
jmp    11a3 <firstComputer+0x73>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0A sticks remaining :%d\00"
@.str.1 = [19 x i8] c"\0A Computer takes 2\00"
@.str.2 = [18 x i8] c"\0Asticks left :%d\0A\00"
@.str.3 = [17 x i8] c"\0A computer lost\0A\00"
@.str.4 = [12 x i8] c"\0Auser lost\0A\00"
define i32 @firstComputer(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %4
%5 = load i32, i32* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = sub nsw i32 %8, 2
store i32 %9, i32* %2
br label %10
10: ; preds = %13, %1
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i32 1, i32 0
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = call i32 @getChoosing(i32 %18, i32 %19)
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = sub nsw i32 %22, %21
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %10
26: ; preds = %10
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %33
31: ; preds = %26
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %31, %29
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"\0A sticks remaining :%d\00"
@.str.1 = [19 x i8] c"\0A Computer takes 2\00"
@.str.2 = [18 x i8] c"\0Asticks left :%d\0A\00"
@str = [11 x i8] c"\0Auser lost\00"
@str.5 = [16 x i8] c"\0A computer lost\00"
define i32 @firstComputer(i32 %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp sgt i32 %0, 3
br i1 %4, label %5, label %17
5: ; preds = %1
%6 = add nsw i32 %0, -2
br label %7
7: ; preds = %5, %7
%8 = phi i32 [ %10, %7 ], [ 1, %5 ]
%9 = phi i32 [ %12, %7 ], [ %6, %5 ]
%10 = xor i32 %8, 1
%11 = tail call i32 @getChoosing(i32 %10, i32 %9)
%12 = sub nsw i32 %9, %11
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = icmp sgt i32 %12, 1
br i1 %14, label %7, label %15
15: ; preds = %7
%16 = icmp eq i32 %10, 0
br i1 %16, label %18, label %17
17: ; preds = %1, %15
br label %18
18: ; preds = %15, %17
%19 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0), %17 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.5, i64 0, i64 0), %15 ]
%20 = tail call i32 @puts(i8* dereferenceable(1) %19)
ret i32 0
}