#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 compareHands(int const **, int *, int *, int *, int *);
int /*<<< orphan*/ dealAHand(int const **, int *);
int /*<<< orphan*/ dealerDiscards(int const **, int *, int *);
int /*<<< orphan*/ playerDiscards(int const **, int *, int *);
int /*<<< orphan*/ printBackOfHand();
int /*<<< orphan*/ printHand(int const **, int *);
int /*<<< orphan*/ printHandRank(int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rankHand(int const **, int *, int *);
int /*<<< orphan*/ system(char *);
int playAGame(const int deck[][13]) {
  int playerHand[5], dealerHand[5];
  int playerHandRank[3] = {0};
  int dealerHandRank[3] = {0};
  int winner;
  dealAHand(deck, dealerHand);
  rankHand(deck, dealerHand, dealerHandRank);
  dealAHand(deck, playerHand);
  rankHand(deck, playerHand, playerHandRank);
  printf("---- DEALER HAND ----\n");
  printBackOfHand();
  dealerDiscards(deck, dealerHand, dealerHandRank);
  rankHand(deck, dealerHand, dealerHandRank);
  printf("\n---- PLAYER HAND ----\n");
  printHand(deck, playerHand);
  printHandRank(playerHandRank);
  playerDiscards(deck, playerHand, playerHandRank);
  system("cls");
  printf("---- DEALER HAND ----\n");
  printHand(deck, dealerHand);
  printHandRank(dealerHandRank);
  printf("\n---- PLAYER HAND ----\n");
  printHand(deck, playerHand);
  printHandRank(playerHandRank);
  winner = compareHands(deck, dealerHand, playerHand, dealerHandRank,
                        playerHandRank);
  if (winner == 1)
    printf("Dealer wins!\n");
  else if (winner == 2)
    printf("Player wins!\n");
  else
    printf("NOBODY WINS!\n");
  return winner;
}


x86 assembly (clang, -O0):
<playAGame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x4c(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   10c0 <dealAHand@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x58(%rbp),%rdx
call   10a0 <rankHand@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10c0 <dealAHand@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
call   10a0 <rankHand@plt>
lea    0xde1(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <printBackOfHand@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x58(%rbp),%rdx
call   1070 <dealerDiscards@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x58(%rbp),%rdx
call   10a0 <rankHand@plt>
lea    0xdc3(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1090 <printHand@plt>
lea    -0x4c(%rbp),%rdi
call   10b0 <printHandRank@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
call   1030 <playerDiscards@plt>
lea    0xda8(%rip),%rdi
call   1050 <system@plt>
lea    0xd6d(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1090 <printHand@plt>
lea    -0x58(%rbp),%rdi
call   10b0 <printHandRank@plt>
lea    0xd62(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1090 <printHand@plt>
lea    -0x4c(%rbp),%rdi
call   10b0 <printHandRank@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x58(%rbp),%rcx
lea    -0x4c(%rbp),%r8
call   10d0 <compareHands@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x1,-0x5c(%rbp)
jne    1307 <playAGame+0x157>
lea    0xd36(%rip),%rdi
call   1060 <printf@plt>
jmp    1333 <playAGame+0x183>
cmpl   $0x2,-0x5c(%rbp)
jne    1322 <playAGame+0x172>
lea    0xd29(%rip),%rdi
call   1060 <printf@plt>
jmp    132e <playAGame+0x17e>
lea    0xd26(%rip),%rdi
call   1060 <printf@plt>
jmp    1333 <playAGame+0x183>
mov    -0x5c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<playAGame>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%rbx
movl   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movl   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0x20(%rsp),%r14
mov    %r14,%rsi
call   10b0 <dealAHand@plt>
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1090 <rankHand@plt>
lea    0x40(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   10b0 <dealAHand@plt>
lea    0x10(%rsp),%r13
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1090 <rankHand@plt>
lea    0xdea(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1040 <printBackOfHand@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <dealerDiscards@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1090 <rankHand@plt>
lea    0xdd1(%rip),%rbp
mov    %rbp,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <printHand@plt>
mov    %r13,%rdi
call   10a0 <printHandRank@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <playerDiscards@plt>
lea    0xd87(%rip),%rdi
call   1060 <system@plt>
lea    0xd7f(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <printHand@plt>
mov    %r15,%rdi
call   10a0 <printHandRank@plt>
mov    %rbp,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <printHand@plt>
mov    %r13,%rdi
call   10a0 <printHandRank@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r13,%r8
call   10c0 <compareHands@plt>
mov    %eax,%ebx
cmp    $0x2,%eax
lea    0xd66(%rip),%rax
lea    0xd52(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x1,%ebx
lea    0xd5e(%rip),%rdi
cmovne %rcx,%rdi
call   1050 <puts@plt>
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"---- DEALER HAND ----\0A\00"
@.str.1 = [24 x i8] c"\0A---- PLAYER HAND ----\0A\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.3 = [14 x i8] c"Dealer wins!\0A\00"
@.str.4 = [14 x i8] c"Player wins!\0A\00"
@.str.5 = [14 x i8] c"NOBODY WINS!\0A\00"
define i32 @playAGame([13 x i32]* %0) {
%2 = alloca [13 x i32]*
%3 = alloca [5 x i32]
%4 = alloca [5 x i32]
%5 = alloca [3 x i32]
%6 = alloca [3 x i32]
%7 = alloca i32
store [13 x i32]* %0, [13 x i32]** %2
%8 = bitcast [3 x i32]* %5 to i8*
%9 = bitcast [3 x i32]* %6 to i8*
%10 = load [13 x i32]*, [13 x i32]** %2
%11 = bitcast [13 x i32]* %10 to i32**
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%13 = call i32 @dealAHand(i32** %11, i32* %12)
%14 = load [13 x i32]*, [13 x i32]** %2
%15 = bitcast [13 x i32]* %14 to i32**
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%18 = call i32 @rankHand(i32** %15, i32* %16, i32* %17)
%19 = load [13 x i32]*, [13 x i32]** %2
%20 = bitcast [13 x i32]* %19 to i32**
%21 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%22 = call i32 @dealAHand(i32** %20, i32* %21)
%23 = load [13 x i32]*, [13 x i32]** %2
%24 = bitcast [13 x i32]* %23 to i32**
%25 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%27 = call i32 @rankHand(i32** %24, i32* %25, i32* %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%29 = call i32 (...) @printBackOfHand()
%30 = load [13 x i32]*, [13 x i32]** %2
%31 = bitcast [13 x i32]* %30 to i32**
%32 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%33 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%34 = call i32 @dealerDiscards(i32** %31, i32* %32, i32* %33)
%35 = load [13 x i32]*, [13 x i32]** %2
%36 = bitcast [13 x i32]* %35 to i32**
%37 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%38 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%39 = call i32 @rankHand(i32** %36, i32* %37, i32* %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%41 = load [13 x i32]*, [13 x i32]** %2
%42 = bitcast [13 x i32]* %41 to i32**
%43 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%44 = call i32 @printHand(i32** %42, i32* %43)
%45 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%46 = call i32 @printHandRank(i32* %45)
%47 = load [13 x i32]*, [13 x i32]** %2
%48 = bitcast [13 x i32]* %47 to i32**
%49 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%50 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%51 = call i32 @playerDiscards(i32** %48, i32* %49, i32* %50)
%52 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%53 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%54 = load [13 x i32]*, [13 x i32]** %2
%55 = bitcast [13 x i32]* %54 to i32**
%56 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%57 = call i32 @printHand(i32** %55, i32* %56)
%58 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%59 = call i32 @printHandRank(i32* %58)
%60 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%61 = load [13 x i32]*, [13 x i32]** %2
%62 = bitcast [13 x i32]* %61 to i32**
%63 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%64 = call i32 @printHand(i32** %62, i32* %63)
%65 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%66 = call i32 @printHandRank(i32* %65)
%67 = load [13 x i32]*, [13 x i32]** %2
%68 = bitcast [13 x i32]* %67 to i32**
%69 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%70 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%71 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%72 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%73 = call i32 @compareHands(i32** %68, i32* %69, i32* %70, i32* %71, i32* %72)
store i32 %73, i32* %7
%74 = load i32, i32* %7
%75 = icmp eq i32 %74, 1
br i1 %75, label %76, label %78
76: ; preds = %1
%77 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %86
78: ; preds = %1
%79 = load i32, i32* %7
%80 = icmp eq i32 %79, 2
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %85
83: ; preds = %78
%84 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %85
85: ; preds = %83, %81
br label %86
86: ; preds = %85, %76
%87 = load i32, i32* %7
ret i32 %87
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"cls\00"
@str.7 = [22 x i8] c"---- DEALER HAND ----\00"
@str.8 = [23 x i8] c"\0A---- PLAYER HAND ----\00"
@str.9 = [13 x i8] c"NOBODY WINS!\00"
@str.10 = [13 x i8] c"Player wins!\00"
@str.11 = [13 x i8] c"Dealer wins!\00"
define i32 @playAGame([13 x i32]* %0) {
%2 = alloca [5 x i32]
%3 = alloca [5 x i32]
%4 = alloca [3 x i32]
%5 = alloca [3 x i32]
%6 = bitcast [5 x i32]* %2 to i8*
%7 = bitcast [5 x i32]* %3 to i8*
%8 = bitcast [3 x i32]* %4 to i8*
%9 = bitcast [3 x i32]* %5 to i8*
%10 = bitcast [13 x i32]* %0 to i32**
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%12 = call i32 @dealAHand(i32** %10, i32* %11)
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%14 = call i32 @rankHand(i32** %10, i32* %11, i32* %13)
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%16 = call i32 @dealAHand(i32** %10, i32* %15)
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%18 = call i32 @rankHand(i32** %10, i32* %15, i32* %17)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0))
%20 = call i32 (...) @printBackOfHand()
%21 = call i32 @dealerDiscards(i32** %10, i32* %11, i32* %13)
%22 = call i32 @rankHand(i32** %10, i32* %11, i32* %13)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
%24 = call i32 @printHand(i32** %10, i32* %15)
%25 = call i32 @printHandRank(i32* %17)
%26 = call i32 @playerDiscards(i32** %10, i32* %15, i32* %17)
%27 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.7, i64 0, i64 0))
%29 = call i32 @printHand(i32** %10, i32* %11)
%30 = call i32 @printHandRank(i32* %13)
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
%32 = call i32 @printHand(i32** %10, i32* %15)
%33 = call i32 @printHandRank(i32* %17)
%34 = call i32 @compareHands(i32** %10, i32* %11, i32* %15, i32* %13, i32* %17)
%35 = icmp eq i32 %34, 2
%36 = select i1 %35, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0)
%37 = icmp eq i32 %34, 1
%38 = select i1 %37, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.11, i64 0, i64 0), i8* %36
%39 = call i32 @puts(i8* dereferenceable(1) %38)
ret i32 %34
}