#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*/ compareHands(int *, int *, int *, int *);
int /*<<< orphan*/ dealAHand(int **, int *);
int /*<<< orphan*/ printHand(int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rankHand(int **, int *, int *);
int /*<<< orphan*/ shuffle(int **);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main() {
  srand(time(0));
  int deck[4][13] = {{0}};
  int playerHand[5], dealerHand[5];
  int playerHandRank[3] = {0};
  int dealerHandRank[3] = {0};
  shuffle(deck);
  printf("---- DEALER HAND ----\n");
  dealAHand(deck, dealerHand);
  rankHand(deck, dealerHand, dealerHandRank);
  printHand(dealerHandRank);
  printf("\n---- PLAYER HAND ----\n");
  dealAHand(deck, playerHand);
  rankHand(deck, playerHand, playerHandRank);
  printHand(playerHandRank);
  compareHands(dealerHand, playerHand, dealerHandRank, playerHandRank);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0xd0,%edx
call   1050 <memset@plt>
lea    -0x12c(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1050 <memset@plt>
lea    -0x138(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1050 <memset@plt>
lea    -0xe0(%rbp),%rdi
call   1030 <shuffle@plt>
lea    0xe04(%rip),%rdi
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   10a0 <dealAHand@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x120(%rbp),%rsi
lea    -0x138(%rbp),%rdx
call   1080 <rankHand@plt>
lea    -0x138(%rbp),%rdi
call   1060 <printHand@plt>
lea    0xdd6(%rip),%rdi
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x100(%rbp),%rsi
call   10a0 <dealAHand@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x100(%rbp),%rsi
lea    -0x12c(%rbp),%rdx
call   1080 <rankHand@plt>
lea    -0x12c(%rbp),%rdi
call   1060 <printHand@plt>
lea    -0x120(%rbp),%rdi
lea    -0x100(%rbp),%rsi
lea    -0x138(%rbp),%rdx
lea    -0x12c(%rbp),%rcx
call   10b0 <compareHands@plt>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x130,%rsp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movl   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0x20(%rsp),%r13
mov    %r13,%rdi
call   1040 <shuffle@plt>
lea    0xdd4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0(%rsp),%r14
mov    %r13,%rdi
mov    %r14,%rsi
call   1090 <dealAHand@plt>
mov    %rsp,%r15
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <rankHand@plt>
mov    %r15,%rdi
call   1050 <printHand@plt>
lea    0xdb2(%rip),%rdi
call   1030 <puts@plt>
lea    0x110(%rsp),%r12
mov    %r13,%rdi
mov    %r12,%rsi
call   1090 <dealAHand@plt>
lea    0x10(%rsp),%rbx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1070 <rankHand@plt>
mov    %rbx,%rdi
call   1050 <printHand@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
call   10a0 <compareHands@plt>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"---- DEALER HAND ----\0A\00"
@.str.1 = [24 x i8] c"\0A---- PLAYER HAND ----\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x [13 x i32]]
%3 = alloca [5 x i32]
%4 = alloca [5 x i32]
%5 = alloca [3 x i32]
%6 = alloca [3 x i32]
store i32 0, i32* %1
%7 = call i32 @time(i32 0)
%8 = call i32 @srand(i32 %7)
%9 = bitcast [4 x [13 x i32]]* %2 to i8*
%10 = bitcast [3 x i32]* %5 to i8*
%11 = bitcast [3 x i32]* %6 to i8*
%12 = getelementptr inbounds [4 x [13 x i32]], [4 x [13 x i32]]* %2, i64 0, i64 0
%13 = bitcast [13 x i32]* %12 to i32**
%14 = call i32 @shuffle(i32** %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [4 x [13 x i32]], [4 x [13 x i32]]* %2, i64 0, i64 0
%17 = bitcast [13 x i32]* %16 to i32**
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%19 = call i32 @dealAHand(i32** %17, i32* %18)
%20 = getelementptr inbounds [4 x [13 x i32]], [4 x [13 x i32]]* %2, i64 0, i64 0
%21 = bitcast [13 x i32]* %20 to i32**
%22 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%23 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%24 = call i32 @rankHand(i32** %21, i32* %22, i32* %23)
%25 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%26 = call i32 @printHand(i32* %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%28 = getelementptr inbounds [4 x [13 x i32]], [4 x [13 x i32]]* %2, i64 0, i64 0
%29 = bitcast [13 x i32]* %28 to i32**
%30 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%31 = call i32 @dealAHand(i32** %29, i32* %30)
%32 = getelementptr inbounds [4 x [13 x i32]], [4 x [13 x i32]]* %2, i64 0, i64 0
%33 = bitcast [13 x i32]* %32 to i32**
%34 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%35 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%36 = call i32 @rankHand(i32** %33, i32* %34, i32* %35)
%37 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%38 = call i32 @printHand(i32* %37)
%39 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%40 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%41 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%42 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%43 = call i32 @compareHands(i32* %39, i32* %40, i32* %41, i32* %42)
ret i32 0
}

LLVM IR (-O2):
@str = [22 x i8] c"---- DEALER HAND ----\00"
@str.2 = [23 x i8] c"\0A---- PLAYER HAND ----\00"
define i32 @main() {
%1 = alloca [4 x [13 x i32]]
%2 = alloca [5 x i32]
%3 = alloca [5 x i32]
%4 = alloca [3 x i32]
%5 = alloca [3 x i32]
%6 = tail call i32 @time(i32 0)
%7 = tail call i32 @srand(i32 %6)
%8 = bitcast [4 x [13 x i32]]* %1 to i8*
%9 = bitcast [5 x i32]* %2 to i8*
%10 = bitcast [5 x i32]* %3 to i8*
%11 = bitcast [3 x i32]* %4 to i8*
%12 = bitcast [3 x i32]* %5 to i8*
%13 = bitcast [4 x [13 x i32]]* %1 to i32**
%14 = call i32 @shuffle(i32** %13)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%17 = call i32 @dealAHand(i32** %13, i32* %16)
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%19 = call i32 @rankHand(i32** %13, i32* %16, i32* %18)
%20 = call i32 @printHand(i32* %18)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.2, i64 0, i64 0))
%22 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%23 = call i32 @dealAHand(i32** %13, i32* %22)
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%25 = call i32 @rankHand(i32** %13, i32* %22, i32* %24)
%26 = call i32 @printHand(i32* %24)
%27 = call i32 @compareHands(i32* %16, i32* %22, i32* %18, i32* %24)
ret i32 0
}