#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 /*<<< orphan*/ scanf(char *, int *);
int firstUser(int sticks) {
  int choosing = 0, turn = 0;
  printf("\nusers turn :\n");
  scanf("%d", &choosing);
  sticks = sticks - choosing;
  printf("\nsticks left :%d\n", sticks);
  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):
<firstUser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
jle    11cd <firstUser+0x9d>
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    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1181 <firstUser+0x51>
cmpl   $0x0,-0xc(%rbp)
jne    11ea <firstUser+0xba>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f8 <firstUser+0xc8>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<firstUser>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movl   $0x0,0xc(%rsp)
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
sub    0xc(%rsp),%ebx
lea    0xe89(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebx
jl     11d9 <firstUser+0x99>
lea    0xe74(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    $0x1,%ebp
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <getChoosing@plt>
mov    %eax,0xc(%rsp)
sub    %eax,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebx
jg     11a0 <firstUser+0x60>
test   %ebp,%ebp
lea    0xe62(%rip),%rax
lea    0xe50(%rip),%rdi
cmove  %rax,%rdi
jmp    11e0 <firstUser+0xa0>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"\0Ausers turn :\0A\00"
@.str.1 = [3 x i8] c"%d\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 @firstUser(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = sub nsw i32 %7, %8
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %15, %1
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 1
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i32 1, i32 0
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = load i32, i32* %2
%22 = call i32 @getChoosing(i32 %20, i32 %21)
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = sub nsw i32 %24, %23
store i32 %25, i32* %2
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %12
28: ; preds = %12
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %35
33: ; preds = %28
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
ret i32 0
}

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