#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 drawcard(int, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ printplayer(int);
int gofish(int askedfor, int player, int *hand) {
  printplayer((1 - (player)));
  (void)printf("say \"GO FISH!\"\n");
  if (askedfor == drawcard(player, hand)) {
    printplayer(player);
    (void)printf("drew the guess!\n");
    printplayer(player);
    (void)printf("get to ask again!\n");
    return (1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<gofish>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x1,%edi
sub    -0xc(%rbp),%edi
call   1050 <printplayer@plt>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <drawcard@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jne    11ae <gofish+0x7e>
mov    -0xc(%rbp),%edi
call   1050 <printplayer@plt>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
call   1050 <printplayer@plt>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b5 <gofish+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gofish>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebx
mov    %edi,%ebp
mov    $0x1,%edi
sub    %esi,%edi
call   1050 <printplayer@plt>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <drawcard@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ebp,%ecx
jne    1190 <gofish+0x60>
mov    %ebx,%edi
call   1050 <printplayer@plt>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1050 <printplayer@plt>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"say \22GO FISH!\22\0A\00"
@.str.1 = [17 x i8] c"drew the guess!\0A\00"
@.str.2 = [19 x i8] c"get to ask again!\0A\00"
define i32 @gofish(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%8 = load i32, i32* %6
%9 = sub nsw i32 1, %8
%10 = call i32 @printplayer(i32 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = load i32*, i32** %7
%15 = call i32 @drawcard(i32 %13, i32* %14)
%16 = icmp eq i32 %12, %15
br i1 %16, label %17, label %24
17: ; preds = %3
%18 = load i32, i32* %6
%19 = call i32 @printplayer(i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* %6
%22 = call i32 @printplayer(i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %4
br label %25
24: ; preds = %3
store i32 0, i32* %4
br label %25
25: ; preds = %24, %17
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
@str = [15 x i8] c"say \22GO FISH!\22\00"
@str.3 = [16 x i8] c"drew the guess!\00"
@str.4 = [18 x i8] c"get to ask again!\00"
define i32 @gofish(i32 %0, i32 %1, i32* %2) {
%4 = sub nsw i32 1, %1
%5 = tail call i32 @printplayer(i32 %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @drawcard(i32 %1, i32* %2)
%8 = icmp eq i32 %7, %0
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = tail call i32 @printplayer(i32 %1)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.3, i64 0, i64 0))
%12 = tail call i32 @printplayer(i32 %1)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
br label %14
14: ; preds = %3, %9
%15 = phi i32 [ 1, %9 ], [ 0, %3 ]
ret i32 %15
}