#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 handaction_simple(int *, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ srand(int);
int main(int argc, char *argv[]) {
  int i, j;
  int hand[5] = {7, 10, 0, 0, 0};
  int ncards = 2;
  int dealercard = 1;
  srand(10);
  for (i = 0; i < 10; i++) {
    printf("Player hand: ");
    for (j = 0; j < ncards; j++) {
      printf("%d ", hand[j]);
    }
    printf("\t  Dealer hand: %d", dealercard);
    printf("\t  Basic strategy move: %d \n",
           handaction_simple(hand, dealercard, 1, 1, 0));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeae(%rip),%eax
mov    %eax,-0x20(%rbp)
movl   $0x2,-0x34(%rbp)
movl   $0x1,-0x38(%rbp)
mov    $0xa,%edi
call   1050 <srand@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1218 <main+0xe8>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11d3 <main+0xa3>
movslq -0x18(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a3 <main+0x73>
mov    -0x38(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    $0x1,%ecx
xor    %r8d,%r8d
mov    %ecx,%edx
call   1030 <handaction_simple@plt>
mov    %eax,%esi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1184 <main+0x54>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0xecc(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0xa,%ebp
mov    $0xa,%edi
call   1050 <srand@plt>
lea    0xeab(%rip),%r14
lea    0xeb2(%rip),%rbx
lea    0xeaf(%rip),%r15
mov    %rsp,%r12
lea    0xeb8(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
call   1030 <handaction_simple@plt>
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    1190 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.hand = [5 x i32] [i32 7, i32 10, i32 0, i32 0, i32 0]
@.str = [14 x i8] c"Player hand: \00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [19 x i8] c"\09 Dealer hand: %d\00"
@.str.3 = [29 x i8] c"\09 Basic strategy move: %d \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [5 x i32]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [5 x i32]* %8 to i8*
store i32 2, i32* %9
store i32 1, i32* %10
%12 = call i32 @srand(i32 10)
store i32 0, i32* %6
br label %13
13: ; preds = %38, %2
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 10
br i1 %15, label %16, label %41
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %18
18: ; preds = %28, %16
%19 = load i32, i32* %7
%20 = load i32, i32* %9
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [5 x i32], [5 x i32]* %8, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %22
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %18
31: ; preds = %18
%32 = load i32, i32* %10
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [5 x i32], [5 x i32]* %8, i64 0, i64 0
%35 = load i32, i32* %10
%36 = call i32 @handaction_simple(i32* %34, i32 %35, i32 1, i32 1, i32 0)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %31
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %13
41: ; preds = %13
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@__const.main.hand = [5 x i32] [i32 7, i32 10, i32 0, i32 0, i32 0]
@.str = [14 x i8] c"Player hand: \00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [19 x i8] c"\09 Dealer hand: %d\00"
@.str.3 = [29 x i8] c"\09 Basic strategy move: %d \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5 x i32]
%4 = bitcast [5 x i32]* %3 to i8*
%5 = tail call i32 @srand(i32 10)
%6 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 1
br label %8
8: ; preds = %2, %8
%9 = phi i32 [ 0, %2 ], [ %18, %8 ]
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* %6
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %7
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 1)
%16 = call i32 @handaction_simple(i32* %6, i32 1, i32 1, i32 1, i32 0)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i32 %9, 1
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %8
20: ; preds = %8
ret i32 0
}