#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*/ 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);
  system("pause");
  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   1070 <memset@plt>
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   10b0 <dealAHand@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x58(%rbp),%rdx
call   1090 <rankHand@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10b0 <dealAHand@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x4c(%rbp),%rdx
call   1090 <rankHand@plt>
lea    0xdf1(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <printBackOfHand@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x58(%rbp),%rdx
call   1060 <dealerDiscards@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x58(%rbp),%rdx
call   1090 <rankHand@plt>
lea    0xdd3(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <printHand@plt>
lea    -0x4c(%rbp),%rdi
call   10a0 <printHandRank@plt>
lea    0xdc9(%rip),%rdi
call   1040 <system@plt>
lea    0xdc3(%rip),%rdi
call   1040 <system@plt>
lea    0xd82(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1080 <printHand@plt>
lea    -0x58(%rbp),%rdi
call   10a0 <printHandRank@plt>
lea    0xd77(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <printHand@plt>
lea    -0x4c(%rbp),%rdi
call   10a0 <printHandRank@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x58(%rbp),%rcx
lea    -0x4c(%rbp),%r8
call   10c0 <compareHands@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x1,-0x5c(%rbp)
jne    12f2 <playAGame+0x152>
lea    0xd51(%rip),%rdi
call   1050 <printf@plt>
jmp    131e <playAGame+0x17e>
cmpl   $0x2,-0x5c(%rbp)
jne    130d <playAGame+0x16d>
lea    0xd44(%rip),%rdi
call   1050 <printf@plt>
jmp    1319 <playAGame+0x179>
lea    0xd41(%rip),%rdi
call   1050 <printf@plt>
jmp    131e <playAGame+0x17e>
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   10a0 <dealAHand@plt>
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1080 <rankHand@plt>
lea    0x40(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   10a0 <dealAHand@plt>
lea    0x10(%rsp),%r13
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1080 <rankHand@plt>
lea    0xe00(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <printBackOfHand@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <dealerDiscards@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1080 <rankHand@plt>
lea    0xde7(%rip),%rbp
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <printHand@plt>
mov    %r13,%rdi
call   1090 <printHandRank@plt>
lea    0xda5(%rip),%rdi
call   1050 <system@plt>
lea    0xd9f(%rip),%rdi
call   1050 <system@plt>
lea    0xd97(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <printHand@plt>
mov    %r15,%rdi
call   1090 <printHandRank@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <printHand@plt>
mov    %r13,%rdi
call   1090 <printHandRank@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r13,%r8
call   10b0 <compareHands@plt>
mov    %eax,%ebx
cmp    $0x2,%eax
lea    0xd7e(%rip),%rax
lea    0xd6a(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x1,%ebx
lea    0xd76(%rip),%rdi
cmovne %rcx,%rdi
call   1040 <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 = [6 x i8] c"pause\00"
@.str.3 = [4 x i8] c"cls\00"
@.str.4 = [14 x i8] c"Dealer wins!\0A\00"
@.str.5 = [14 x i8] c"Player wins!\0A\00"
@.str.6 = [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 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%48 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%49 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%50 = load [13 x i32]*, [13 x i32]** %2
%51 = bitcast [13 x i32]* %50 to i32**
%52 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%53 = call i32 @printHand(i32** %51, i32* %52)
%54 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%55 = call i32 @printHandRank(i32* %54)
%56 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%57 = load [13 x i32]*, [13 x i32]** %2
%58 = bitcast [13 x i32]* %57 to i32**
%59 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%60 = call i32 @printHand(i32** %58, i32* %59)
%61 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%62 = call i32 @printHandRank(i32* %61)
%63 = load [13 x i32]*, [13 x i32]** %2
%64 = bitcast [13 x i32]* %63 to i32**
%65 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%66 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%67 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%68 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%69 = call i32 @compareHands(i32** %64, i32* %65, i32* %66, i32* %67, i32* %68)
store i32 %69, i32* %7
%70 = load i32, i32* %7
%71 = icmp eq i32 %70, 1
br i1 %71, label %72, label %74
72: ; preds = %1
%73 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %82
74: ; preds = %1
%75 = load i32, i32* %7
%76 = icmp eq i32 %75, 2
br i1 %76, label %77, label %79
77: ; preds = %74
%78 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %81
79: ; preds = %74
%80 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %81
81: ; preds = %79, %77
br label %82
82: ; preds = %81, %72
%83 = load i32, i32* %7
ret i32 %83
}

LLVM IR (-O2):
@.str.2 = [6 x i8] c"pause\00"
@.str.3 = [4 x i8] c"cls\00"
@str.8 = [22 x i8] c"---- DEALER HAND ----\00"
@str.9 = [23 x i8] c"\0A---- PLAYER HAND ----\00"
@str.10 = [13 x i8] c"NOBODY WINS!\00"
@str.11 = [13 x i8] c"Player wins!\00"
@str.12 = [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.8, 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.9, i64 0, i64 0))
%24 = call i32 @printHand(i32** %10, i32* %15)
%25 = call i32 @printHandRank(i32* %17)
%26 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, 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.9, 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.11, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.10, i64 0, i64 0)
%37 = icmp eq i32 %34, 1
%38 = select i1 %37, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0), i8* %36
%39 = call i32 @puts(i8* dereferenceable(1) %38)
ret i32 %34
}