#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 calculateHandValue(unsigned int *);
int /*<<< orphan*/ printHand(unsigned int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ removeCardsFromHand(unsigned int *);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int /*<<< orphan*/ shuffleDeck(unsigned int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  srand(time(NULL));
  unsigned deck[52] = {1,  1,  1,  1,  2,  2,  2,  2,  3,  3,  3,  3,  4,
                       4,  4,  4,  5,  5,  5,  5,  6,  6,  6,  6,  7,  7,
                       7,  7,  8,  8,  8,  8,  9,  9,  9,  9,  10, 10, 10,
                       10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
  unsigned quit = 0;
  unsigned player1_hand[26];
  unsigned computer_hand[26];
  do {
    removeCardsFromHand(player1_hand);
    removeCardsFromHand(computer_hand);
    shuffleDeck(deck);
    size_t deckIndex = 0;
    size_t player1Index = 0;
    player1_hand[player1Index] = deck[deckIndex];
    deckIndex++;
    player1Index++;
    player1_hand[player1Index] = deck[deckIndex];
    deckIndex++;
    player1Index++;
    size_t computerIndex = 0;
    computer_hand[computerIndex] = deck[deckIndex];
    deckIndex++;
    computerIndex++;
    computer_hand[computerIndex] = deck[deckIndex];
    deckIndex++;
    computerIndex++;
    do {
      printf("Player 1's hand: ");
      printHand(player1_hand);
      printf("Computer's hand: [unknown] ");
      printHand(computer_hand + 1);
      printf("0 for Hit, 1 for Stay: ");
      unsigned stay;
      scanf("%u", &stay);
      if (stay) {
        if (calculateHandValue(computer_hand) < 18) {
          computer_hand[computerIndex] = deck[deckIndex];
          deckIndex++;
          computerIndex++;
        }
        break;
      }
      player1_hand[player1Index] = deck[deckIndex];
      deckIndex++;
      player1Index++;
      if (calculateHandValue(computer_hand) < 18) {
        computer_hand[computerIndex] = deck[deckIndex];
        deckIndex++;
        computerIndex++;
      }
    } while (1);
    putchar('\n');
    printf("Player 1's hand: ");
    printHand(player1_hand);
    unsigned player1_value = calculateHandValue(player1_hand);
    printf("Player 1's Value: %u\n", player1_value);
    printf("Computer's hand: ");
    printHand(computer_hand);
    unsigned computer_value = calculateHandValue(computer_hand);
    printf("Computer's Value: %u\n", computer_value);
    putchar('\n');
    if (player1_value > 21) {
      printf("Player 1 bust!\n");
      if (computer_value > 21) {
        printf("Computer bust!\n");
      } else {
        printf("Computer wins!\n");
      }
    } else if (computer_value > 21) {
      printf("Computer bust!\n");
      if (player1_value > 21) {
        printf("Player 1 bust!\n");
      } else {
        printf("Player 1 wins!\n");
      }
    } else if (player1_value > computer_value) {
      printf("Player 1 wins!\n");
    } else {
      printf("Computer wins!\n");
    }
    putchar('\n');
    printf("0 for Quit, 1 for New Game: ");
    scanf("%u", &quit);
    putchar('\n');
  } while (quit != 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f0,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe30(%rip),%rsi
mov    $0xd0,%edx
call   1080 <memcpy@plt>
movl   $0x0,-0xe4(%rbp)
lea    -0x150(%rbp),%rdi
call   10c0 <removeCardsFromHand@plt>
lea    -0x1c0(%rbp),%rdi
call   10c0 <removeCardsFromHand@plt>
lea    -0xe0(%rbp),%rdi
call   10a0 <shuffleDeck@plt>
movq   $0x0,-0x1c8(%rbp)
movq   $0x0,-0x1d0(%rbp)
mov    -0x1c8(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%ecx
mov    -0x1d0(%rbp),%rax
mov    %ecx,-0x150(%rbp,%rax,4)
mov    -0x1c8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1c8(%rbp)
mov    -0x1d0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1d0(%rbp)
mov    -0x1c8(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%ecx
mov    -0x1d0(%rbp),%rax
mov    %ecx,-0x150(%rbp,%rax,4)
mov    -0x1c8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1c8(%rbp)
mov    -0x1d0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1d0(%rbp)
movq   $0x0,-0x1d8(%rbp)
mov    -0x1c8(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%ecx
mov    -0x1d8(%rbp),%rax
mov    %ecx,-0x1c0(%rbp,%rax,4)
mov    -0x1c8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1c8(%rbp)
mov    -0x1d8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1d8(%rbp)
mov    -0x1c8(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%ecx
mov    -0x1d8(%rbp),%rax
mov    %ecx,-0x1c0(%rbp,%rax,4)
mov    -0x1c8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1c8(%rbp)
mov    -0x1d8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1d8(%rbp)
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x150(%rbp),%rdi
call   1050 <printHand@plt>
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1c0(%rbp),%rdi
add    $0x4,%rdi
call   1050 <printHand@plt>
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xda0(%rip),%rdi
lea    -0x1dc(%rbp),%rsi
call   10b0 <scanf@plt>
cmpl   $0x0,-0x1dc(%rbp)
je     13e9 <main+0x249>
lea    -0x1c0(%rbp),%rdi
call   1060 <calculateHandValue@plt>
cmp    $0x12,%eax
jge    13e4 <main+0x244>
mov    -0x1c8(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%ecx
mov    -0x1d8(%rbp),%rax
mov    %ecx,-0x1c0(%rbp,%rax,4)
mov    -0x1c8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1c8(%rbp)
mov    -0x1d8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1d8(%rbp)
jmp    1492 <main+0x2f2>
mov    -0x1c8(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%ecx
mov    -0x1d0(%rbp),%rax
mov    %ecx,-0x150(%rbp,%rax,4)
mov    -0x1c8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1c8(%rbp)
mov    -0x1d0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1d0(%rbp)
lea    -0x1c0(%rbp),%rdi
call   1060 <calculateHandValue@plt>
cmp    $0x12,%eax
jge    147e <main+0x2de>
mov    -0x1c8(%rbp),%rax
mov    -0xe0(%rbp,%rax,4),%ecx
mov    -0x1d8(%rbp),%rax
mov    %ecx,-0x1c0(%rbp,%rax,4)
mov    -0x1c8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1c8(%rbp)
mov    -0x1d8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1d8(%rbp)
jmp    1483 <main+0x2e3>
mov    $0x1,%al
test   $0x1,%al
jne    1329 <main+0x189>
jmp    1492 <main+0x2f2>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x150(%rbp),%rdi
call   1050 <printHand@plt>
lea    -0x150(%rbp),%rdi
call   1060 <calculateHandValue@plt>
mov    %eax,-0x1e0(%rbp)
mov    -0x1e0(%rbp),%esi
lea    0xc44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1c0(%rbp),%rdi
call   1050 <printHand@plt>
lea    -0x1c0(%rbp),%rdi
call   1060 <calculateHandValue@plt>
mov    %eax,-0x1e4(%rbp)
mov    -0x1e4(%rbp),%esi
lea    0xc2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x15,-0x1e0(%rbp)
jbe    1574 <main+0x3d4>
lea    0xc1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x15,-0x1e4(%rbp)
jbe    1561 <main+0x3c1>
lea    0xc12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    156f <main+0x3cf>
lea    0xc0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    15ff <main+0x45f>
cmpl   $0x15,-0x1e4(%rbp)
jbe    15c2 <main+0x422>
lea    0xbdf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x15,-0x1e0(%rbp)
jbe    15af <main+0x40f>
lea    0xbb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    15bd <main+0x41d>
lea    0xbd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    15fa <main+0x45a>
mov    -0x1e0(%rbp),%eax
cmp    -0x1e4(%rbp),%eax
jbe    15e7 <main+0x447>
lea    0xbac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    15f5 <main+0x455>
lea    0xb89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    15fa <main+0x45a>
jmp    15ff <main+0x45f>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xb87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xaf8(%rip),%rdi
lea    -0xe4(%rbp),%rsi
call   10b0 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,-0xe4(%rbp)
jne    11e4 <main+0x44>
xor    %eax,%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1b8,%rsp
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
lea    0xe2a(%rip),%rsi
lea    0x80(%rsp),%rdi
mov    $0xd0,%edx
call   1090 <memcpy@plt>
movl   $0x0,0xc(%rsp)
lea    0x150(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0xf12(%rip),%r15
jmp    1270 <main+0xc0>
cs nopw 0x0(%rax,%rax,1)
lea    0xf6c(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x16,%ebp
lea    0xf6c(%rip),%rdi
lea    0xf74(%rip),%rax
cmovae %rax,%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xf10(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
lea    0xc(%rsp),%rsi
call   10c0 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0xc(%rsp)
je     149a <main+0x2ea>
mov    %r12,%rdi
call   10d0 <removeCardsFromHand@plt>
mov    %r13,%rdi
call   10d0 <removeCardsFromHand@plt>
lea    0x80(%rsp),%rdi
call   10b0 <shuffleDeck@plt>
mov    0x80(%rsp),%rax
mov    0x88(%rsp),%rcx
mov    %rax,0x150(%rsp)
mov    %rcx,0x10(%rsp)
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1060 <printHand@plt>
lea    0xe1b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x14(%rsp),%rdi
call   1060 <printHand@plt>
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
lea    0x8(%rsp),%rsi
call   10c0 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
je     13d0 <main+0x220>
mov    $0x4,%ebx
mov    $0x2,%r14d
mov    %r13,%rdi
call   1070 <calculateHandValue@plt>
cmp    $0x11,%eax
jg     1322 <main+0x172>
mov    0x80(%rsp,%rbx,4),%eax
mov    %eax,0x10(%rsp,%r14,4)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd9d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1060 <printHand@plt>
mov    %r12,%rdi
call   1070 <calculateHandValue@plt>
mov    %eax,%r14d
lea    0xdc5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdcb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
call   1060 <printHand@plt>
mov    %r13,%rdi
call   1070 <calculateHandValue@plt>
mov    %eax,%ebp
lea    0xdbd(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0x16,%r14d
jae    1210 <main+0x60>
cmp    $0x16,%ebp
jb     1480 <main+0x2d0>
lea    0xdf0(%rip),%rdi
call   1040 <puts@plt>
lea    0xdb7(%rip),%rdi
jmp    1231 <main+0x81>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2,%r14d
mov    $0x4,%ebx
lea    0x158(%rsp),%rbp
jmp    145c <main+0x2ac>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x84(%rsp,%rbx,4),%eax
mov    %eax,0x10(%rsp,%r14,4)
add    $0x2,%rbx
add    $0x1,%r14
lea    0xcc5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1060 <printHand@plt>
lea    0xcc1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x14(%rsp),%rdi
call   1060 <printHand@plt>
lea    0xcc5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
lea    0x8(%rsp),%rsi
call   10c0 <scanf@plt>
add    $0x4,%rbp
cmpl   $0x0,0x8(%rsp)
jne    1309 <main+0x159>
mov    0x80(%rsp,%rbx,4),%eax
mov    %eax,0x0(%rbp)
mov    %r13,%rdi
call   1070 <calculateHandValue@plt>
cmp    $0x11,%eax
jle    13f0 <main+0x240>
add    $0x1,%rbx
jmp    1404 <main+0x254>
nopl   (%rax)
cmp    %ebp,%r14d
lea    0xd08(%rip),%rdi
lea    0xce3(%rip),%rax
cmova  %rax,%rdi
jmp    1231 <main+0x81>
xor    %eax,%eax
add    $0x1b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.deck = [52 x i32] [i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 2, i32 2, i32 3, i32 3, i32 3, i32 3, i32 4, i32 4, i32 4, i32 4, i32 5, i32 5, i32 5, i32 5, i32 6, i32 6, i32 6, i32 6, i32 7, i32 7, i32 7, i32 7, i32 8, i32 8, i32 8, i32 8, i32 9, i32 9, i32 9, i32 9, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10]
@.str = [18 x i8] c"Player 1's hand: \00"
@.str.1 = [28 x i8] c"Computer's hand: [unknown] \00"
@.str.2 = [24 x i8] c"0 for Hit, 1 for Stay: \00"
@.str.3 = [3 x i8] c"%u\00"
@.str.4 = [22 x i8] c"Player 1's Value: %u\0A\00"
@.str.5 = [18 x i8] c"Computer's hand: \00"
@.str.6 = [22 x i8] c"Computer's Value: %u\0A\00"
@.str.7 = [16 x i8] c"Player 1 bust!\0A\00"
@.str.8 = [16 x i8] c"Computer bust!\0A\00"
@.str.9 = [16 x i8] c"Computer wins!\0A\00"
@.str.10 = [16 x i8] c"Player 1 wins!\0A\00"
@.str.11 = [29 x i8] c"0 for Quit, 1 for New Game: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [52 x i32]
%3 = alloca i32
%4 = alloca [26 x i32]
%5 = alloca [26 x i32]
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32 @time(i32* null)
%13 = call i32 @srand(i32 %12)
%14 = bitcast [52 x i32]* %2 to i8*
store i32 0, i32* %3
br label %15
15: ; preds = %165, %0
%16 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 0
%17 = call i32 @removeCardsFromHand(i32* %16)
%18 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 0
%19 = call i32 @removeCardsFromHand(i32* %18)
%20 = getelementptr inbounds [52 x i32], [52 x i32]* %2, i64 0, i64 0
%21 = call i32 @shuffleDeck(i32* %20)
store i64 0, i64* %6
store i64 0, i64* %7
%22 = load i64, i64* %6
%23 = getelementptr inbounds [52 x i32], [52 x i32]* %2, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = load i64, i64* %7
%26 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %25
store i32 %24, i32* %26
%27 = load i64, i64* %6
%28 = add i64 %27, 1
store i64 %28, i64* %6
%29 = load i64, i64* %7
%30 = add i64 %29, 1
store i64 %30, i64* %7
%31 = load i64, i64* %6
%32 = getelementptr inbounds [52 x i32], [52 x i32]* %2, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = load i64, i64* %7
%35 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %34
store i32 %33, i32* %35
%36 = load i64, i64* %6
%37 = add i64 %36, 1
store i64 %37, i64* %6
%38 = load i64, i64* %7
%39 = add i64 %38, 1
store i64 %39, i64* %7
store i64 0, i64* %8
%40 = load i64, i64* %6
%41 = getelementptr inbounds [52 x i32], [52 x i32]* %2, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = load i64, i64* %8
%44 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 %43
store i32 %42, i32* %44
%45 = load i64, i64* %6
%46 = add i64 %45, 1
store i64 %46, i64* %6
%47 = load i64, i64* %8
%48 = add i64 %47, 1
store i64 %48, i64* %8
%49 = load i64, i64* %6
%50 = getelementptr inbounds [52 x i32], [52 x i32]* %2, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = load i64, i64* %8
%53 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 %52
store i32 %51, i32* %53
%54 = load i64, i64* %6
%55 = add i64 %54, 1
store i64 %55, i64* %6
%56 = load i64, i64* %8
%57 = add i64 %56, 1
store i64 %57, i64* %8
br label %58
58: ; preds = %109, %15
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%60 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 0
%61 = call i32 @printHand(i32* %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%63 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 0
%64 = getelementptr inbounds i32, i32* %63, i64 1
%65 = call i32 @printHand(i32* %64)
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%67 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%68 = load i32, i32* %9
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %85
70: ; preds = %58
%71 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 0
%72 = call i32 @calculateHandValue(i32* %71)
%73 = icmp slt i32 %72, 18
br i1 %73, label %74, label %84
74: ; preds = %70
%75 = load i64, i64* %6
%76 = getelementptr inbounds [52 x i32], [52 x i32]* %2, i64 0, i64 %75
%77 = load i32, i32* %76
%78 = load i64, i64* %8
%79 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 %78
store i32 %77, i32* %79
%80 = load i64, i64* %6
%81 = add i64 %80, 1
store i64 %81, i64* %6
%82 = load i64, i64* %8
%83 = add i64 %82, 1
store i64 %83, i64* %8
br label %84
84: ; preds = %74, %70
br label %110
85: ; preds = %58
%86 = load i64, i64* %6
%87 = getelementptr inbounds [52 x i32], [52 x i32]* %2, i64 0, i64 %86
%88 = load i32, i32* %87
%89 = load i64, i64* %7
%90 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %89
store i32 %88, i32* %90
%91 = load i64, i64* %6
%92 = add i64 %91, 1
store i64 %92, i64* %6
%93 = load i64, i64* %7
%94 = add i64 %93, 1
store i64 %94, i64* %7
%95 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 0
%96 = call i32 @calculateHandValue(i32* %95)
%97 = icmp slt i32 %96, 18
br i1 %97, label %98, label %108
98: ; preds = %85
%99 = load i64, i64* %6
%100 = getelementptr inbounds [52 x i32], [52 x i32]* %2, i64 0, i64 %99
%101 = load i32, i32* %100
%102 = load i64, i64* %8
%103 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 %102
store i32 %101, i32* %103
%104 = load i64, i64* %6
%105 = add i64 %104, 1
store i64 %105, i64* %6
%106 = load i64, i64* %8
%107 = add i64 %106, 1
store i64 %107, i64* %8
br label %108
108: ; preds = %98, %85
br label %109
109: ; preds = %108
br i1 true, label %58, label %110
110: ; preds = %109, %84
%111 = call i32 @putchar(i8 signext 10)
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%113 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 0
%114 = call i32 @printHand(i32* %113)
%115 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 0
%116 = call i32 @calculateHandValue(i32* %115)
store i32 %116, i32* %10
%117 = load i32, i32* %10
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %117)
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%120 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 0
%121 = call i32 @printHand(i32* %120)
%122 = getelementptr inbounds [26 x i32], [26 x i32]* %5, i64 0, i64 0
%123 = call i32 @calculateHandValue(i32* %122)
store i32 %123, i32* %11
%124 = load i32, i32* %11
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %124)
%126 = call i32 @putchar(i8 signext 10)
%127 = load i32, i32* %10
%128 = icmp ugt i32 %127, 21
br i1 %128, label %129, label %138
129: ; preds = %110
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%131 = load i32, i32* %11
%132 = icmp ugt i32 %131, 21
br i1 %132, label %133, label %135
133: ; preds = %129
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %137
135: ; preds = %129
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %137
137: ; preds = %135, %133
br label %160
138: ; preds = %110
%139 = load i32, i32* %11
%140 = icmp ugt i32 %139, 21
br i1 %140, label %141, label %150
141: ; preds = %138
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%143 = load i32, i32* %10
%144 = icmp ugt i32 %143, 21
br i1 %144, label %145, label %147
145: ; preds = %141
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %149
147: ; preds = %141
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %149
149: ; preds = %147, %145
br label %159
150: ; preds = %138
%151 = load i32, i32* %10
%152 = load i32, i32* %11
%153 = icmp ugt i32 %151, %152
br i1 %153, label %154, label %156
154: ; preds = %150
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %158
156: ; preds = %150
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %158
158: ; preds = %156, %154
br label %159
159: ; preds = %158, %149
br label %160
160: ; preds = %159, %137
%161 = call i32 @putchar(i8 signext 10)
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
%163 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%164 = call i32 @putchar(i8 signext 10)
br label %165
165: ; preds = %160
%166 = load i32, i32* %3
%167 = icmp ne i32 %166, 0
br i1 %167, label %15, label %168
168: ; preds = %165
ret i32 0
}

LLVM IR (-O2):
@__const.main.deck = [52 x i32] [i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 2, i32 2, i32 3, i32 3, i32 3, i32 3, i32 4, i32 4, i32 4, i32 4, i32 5, i32 5, i32 5, i32 5, i32 6, i32 6, i32 6, i32 6, i32 7, i32 7, i32 7, i32 7, i32 8, i32 8, i32 8, i32 8, i32 9, i32 9, i32 9, i32 9, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10, i32 10]
@.str = [18 x i8] c"Player 1's hand: \00"
@.str.1 = [28 x i8] c"Computer's hand: [unknown] \00"
@.str.2 = [24 x i8] c"0 for Hit, 1 for Stay: \00"
@.str.3 = [3 x i8] c"%u\00"
@.str.4 = [22 x i8] c"Player 1's Value: %u\0A\00"
@.str.5 = [18 x i8] c"Computer's hand: \00"
@.str.6 = [22 x i8] c"Computer's Value: %u\0A\00"
@.str.11 = [29 x i8] c"0 for Quit, 1 for New Game: \00"
@str.14 = [15 x i8] c"Player 1 wins!\00"
@str.15 = [15 x i8] c"Player 1 bust!\00"
@str.16 = [15 x i8] c"Computer wins!\00"
@str.17 = [15 x i8] c"Computer bust!\00"
define i32 @main() {
%1 = alloca [52 x i32]
%2 = alloca i32
%3 = alloca [26 x i32]
%4 = alloca [26 x i32]
%5 = alloca i32
%6 = tail call i32 @time(i32* null)
%7 = tail call i32 @srand(i32 %6)
%8 = bitcast [52 x i32]* %1 to i8*
%9 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%10 = bitcast [26 x i32]* %3 to i8*
%11 = bitcast [26 x i32]* %4 to i8*
%12 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 0
%13 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 0
%14 = getelementptr inbounds [52 x i32], [52 x i32]* %1, i64 0, i64 0
%15 = getelementptr inbounds [52 x i32], [52 x i32]* %1, i64 0, i64 1
%16 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 1
%17 = getelementptr inbounds [52 x i32], [52 x i32]* %1, i64 0, i64 2
%18 = getelementptr inbounds [52 x i32], [52 x i32]* %1, i64 0, i64 3
%19 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 1
%20 = bitcast i32* %5 to i8*
br label %21
21: ; preds = %97, %0
%22 = call i32 @removeCardsFromHand(i32* %12)
%23 = call i32 @removeCardsFromHand(i32* %13)
%24 = call i32 @shuffleDeck(i32* %14)
%25 = load i32, i32* %14
store i32 %25, i32* %12
%26 = load i32, i32* %15
store i32 %26, i32* %16
%27 = load i32, i32* %17
store i32 %27, i32* %13
%28 = load i32, i32* %18
store i32 %28, i32* %19
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @printHand(i32* %12)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @printHand(i32* %19)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%35 = load i32, i32* %5
%36 = icmp eq i32 %35, 0
br i1 %36, label %46, label %37
37: ; preds = %63, %21
%38 = phi i64 [ 2, %21 ], [ %64, %63 ]
%39 = phi i64 [ 4, %21 ], [ %65, %63 ]
%40 = call i32 @calculateHandValue(i32* %13)
%41 = icmp slt i32 %40, 18
br i1 %41, label %42, label %74
42: ; preds = %37
%43 = getelementptr inbounds [52 x i32], [52 x i32]* %1, i64 0, i64 %39
%44 = load i32, i32* %43
%45 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %38
store i32 %44, i32* %45
br label %74
46: ; preds = %21, %63
%47 = phi i64 [ %65, %63 ], [ 4, %21 ]
%48 = phi i64 [ %64, %63 ], [ 2, %21 ]
%49 = phi i64 [ %54, %63 ], [ 2, %21 ]
%50 = getelementptr inbounds [52 x i32], [52 x i32]* %1, i64 0, i64 %47
%51 = load i32, i32* %50
%52 = getelementptr inbounds [26 x i32], [26 x i32]* %3, i64 0, i64 %49
store i32 %51, i32* %52
%53 = add i64 %47, 1
%54 = add i64 %49, 1
%55 = call i32 @calculateHandValue(i32* %13)
%56 = icmp slt i32 %55, 18
br i1 %56, label %57, label %63
57: ; preds = %46
%58 = getelementptr inbounds [52 x i32], [52 x i32]* %1, i64 0, i64 %53
%59 = load i32, i32* %58
%60 = getelementptr inbounds [26 x i32], [26 x i32]* %4, i64 0, i64 %48
store i32 %59, i32* %60
%61 = add i64 %47, 2
%62 = add i64 %48, 1
br label %63
63: ; preds = %46, %57
%64 = phi i64 [ %62, %57 ], [ %48, %46 ]
%65 = phi i64 [ %61, %57 ], [ %53, %46 ]
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%67 = call i32 @printHand(i32* %12)
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%69 = call i32 @printHand(i32* %19)
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%71 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%72 = load i32, i32* %5
%73 = icmp eq i32 %72, 0
br i1 %73, label %46, label %37
74: ; preds = %42, %37
%75 = call i32 @putchar(i8 signext 10)
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%77 = call i32 @printHand(i32* %12)
%78 = call i32 @calculateHandValue(i32* %12)
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %78)
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%81 = call i32 @printHand(i32* %13)
%82 = call i32 @calculateHandValue(i32* %13)
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %82)
%84 = call i32 @putchar(i8 signext 10)
%85 = icmp ugt i32 %78, 21
br i1 %85, label %86, label %90
86: ; preds = %74
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.15, i64 0, i64 0))
%88 = icmp ugt i32 %82, 21
%89 = select i1 %88, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.17, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.16, i64 0, i64 0)
br label %97
90: ; preds = %74
%91 = icmp ugt i32 %82, 21
br i1 %91, label %92, label %94
92: ; preds = %90
%93 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.17, i64 0, i64 0))
br label %97
94: ; preds = %90
%95 = icmp ugt i32 %78, %82
%96 = select i1 %95, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.16, i64 0, i64 0)
br label %97
97: ; preds = %94, %86, %92
%98 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0), %92 ], [ %89, %86 ], [ %96, %94 ]
%99 = call i32 @puts(i8* dereferenceable(1) %98)
%100 = call i32 @putchar(i8 signext 10)
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
%102 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%103 = call i32 @putchar(i8 signext 10)
%104 = load i32, i32* %2
%105 = icmp eq i32 %104, 0
br i1 %105, label %106, label %21
106: ; preds = %97
ret i32 0
}