#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 /*<<< orphan*/ printf(char *);
int rand();
void colorLeft(int w, int b) {
  int choose;
  if (w == 1) {
    printf("left is white\n");
    return;
  }
  if (b == 1) {
    printf("left is black\n");
    return;
  }
  choose = rand() % 3;
  switch (choose) {
  case 0:
    b = b - 1;
    colorLeft(w, b);
    break;
  case 1:
    b = b - 1;
    colorLeft(w, b);
    break;
  case 2:
    w = w - 2;
    b = b + 1;
    colorLeft(w, b);
    break;
  }
}


x86 assembly (clang, -O0):
<colorLeft>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1159 <colorLeft+0x29>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
jmp    1220 <colorLeft+0xf0>
cmpl   $0x1,-0x8(%rbp)
jne    1174 <colorLeft+0x44>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
jmp    1220 <colorLeft+0xf0>
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rcx
imul   $0x55555556,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     11d1 <colorLeft+0xa1>
jmp    11af <colorLeft+0x7f>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     11ea <colorLeft+0xba>
jmp    11c0 <colorLeft+0x90>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     1203 <colorLeft+0xd3>
jmp    1220 <colorLeft+0xf0>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <colorLeft@plt>
jmp    1220 <colorLeft+0xf0>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <colorLeft@plt>
jmp    1220 <colorLeft+0xf0>
mov    -0x4(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <colorLeft@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<colorLeft>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xee0(%rip),%r14
cmp    $0x1,%edi
je     119f <colorLeft+0x7f>
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xec2(%rip),%r15
cmp    $0x1,%ebp
je     119c <colorLeft+0x7c>
add    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    $0x2,%eax
jae    1190 <colorLeft+0x70>
add    $0xffffffff,%ebp
cmp    $0x2,%ebp
jne    1150 <colorLeft+0x30>
jmp    119c <colorLeft+0x7c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
jne    11b1 <colorLeft+0x91>
add    $0xfffffffe,%ebx
cmp    $0x1,%ebx
jne    113e <colorLeft+0x1e>
jmp    119f <colorLeft+0x7f>
mov    %r15,%r14
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"left is white\0A\00"
@.str.1 = [15 x i8] c"left is black\0A\00"
define void @colorLeft(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %36
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %36
15: ; preds = %10
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 3
store i32 %17, i32* %5
%18 = load i32, i32* %5
switch i32 %18, label %36 [
i32 0, label %19
i32 1, label %24
i32 2, label %29
]
19: ; preds = %15
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, 1
store i32 %21, i32* %4
%22 = load i32, i32* %3
%23 = load i32, i32* %4
br label %36
24: ; preds = %15
%25 = load i32, i32* %4
%26 = sub nsw i32 %25, 1
store i32 %26, i32* %4
%27 = load i32, i32* %3
%28 = load i32, i32* %4
br label %36
29: ; preds = %15
%30 = load i32, i32* %3
%31 = sub nsw i32 %30, 2
store i32 %31, i32* %3
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
%34 = load i32, i32* %3
%35 = load i32, i32* %4
br label %36
36: ; preds = %8, %13, %15, %29, %24, %19
ret void
}

LLVM IR (-O2):
@str = [14 x i8] c"left is black\00"
@str.2 = [14 x i8] c"left is white\00"
define void @colorLeft(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %19, label %4
4: ; preds = %2, %15
%5 = phi i32 [ %17, %15 ], [ %1, %2 ]
%6 = phi i32 [ %16, %15 ], [ %0, %2 ]
%7 = icmp eq i32 %5, 1
br i1 %7, label %19, label %8
8: ; preds = %4, %12
%9 = phi i32 [ %13, %12 ], [ %5, %4 ]
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 3
switch i32 %11, label %22 [
i32 0, label %12
i32 1, label %12
i32 2, label %15
]
12: ; preds = %8, %8
%13 = add nsw i32 %9, -1
%14 = icmp eq i32 %13, 1
br i1 %14, label %19, label %8
15: ; preds = %8
%16 = add nsw i32 %6, -2
%17 = add nsw i32 %9, 1
%18 = icmp eq i32 %16, 1
br i1 %18, label %19, label %4
19: ; preds = %15, %4, %12, %2
%20 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0), %12 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.2, i64 0, i64 0), %15 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0), %4 ]
%21 = tail call i32 @puts(i8* dereferenceable(1) %20)
br label %22
22: ; preds = %8, %19
ret void
}