#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 */
struct gameState {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ discardCard(int, int, struct gameState *,
                               int /*<<< orphan*/);
int /*<<< orphan*/ drawCard(int, struct gameState *);
int whoseTurn(struct gameState *);
int playSmithy(struct gameState *state, int handPos) {
  int currentPlayer = whoseTurn(state);
  int i;
  for (i = 0; i < 4; i++) {
    drawCard(currentPlayer, state);
  }
  discardCard(handPos, currentPlayer, state, 0);
  return 0;
}


x86 assembly (clang, -O0):
<playSmithy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <whoseTurn@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1176 <playSmithy+0x46>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <drawCard@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1152 <playSmithy+0x22>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rdx
xor    %ecx,%ecx
call   1030 <discardCard@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<playSmithy>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
call   1050 <whoseTurn@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <drawCard@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <drawCard@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <drawCard@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <drawCard@plt>
mov    %r14d,%edi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1030 <discardCard@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.gameState = type { i32 }
define i32 @playSmithy(%struct.gameState* %0, i32 %1) {
%3 = alloca %struct.gameState*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store %struct.gameState* %0, %struct.gameState** %3
store i32 %1, i32* %4
%7 = load %struct.gameState*, %struct.gameState** %3
%8 = call i32 @whoseTurn(%struct.gameState* %7)
store i32 %8, i32* %5
store i32 0, i32* %6
br label %9
9: ; preds = %16, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* %5
%14 = load %struct.gameState*, %struct.gameState** %3
%15 = call i32 @drawCard(i32 %13, %struct.gameState* %14)
br label %16
16: ; preds = %12
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %9
19: ; preds = %9
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = load %struct.gameState*, %struct.gameState** %3
%23 = call i32 @discardCard(i32 %20, i32 %21, %struct.gameState* %22, i32 0)
ret i32 0
}

LLVM IR (-O2):
%struct.gameState = type { i32 }
define i32 @playSmithy(%struct.gameState* %0, i32 %1) {
%3 = tail call i32 @whoseTurn(%struct.gameState* %0)
%4 = tail call i32 @drawCard(i32 %3, %struct.gameState* %0)
%5 = tail call i32 @drawCard(i32 %3, %struct.gameState* %0)
%6 = tail call i32 @drawCard(i32 %3, %struct.gameState* %0)
%7 = tail call i32 @drawCard(i32 %3, %struct.gameState* %0)
%8 = tail call i32 @discardCard(i32 %1, i32 %3, %struct.gameState* %0, i32 0)
ret i32 0
}