#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 EOF;
int /*<<< orphan*/ dealerhand();
int getchar();
int /*<<< orphan*/ playerhand();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  srand((unsigned)time(NULL));
  int hold = 1;
  int num;
  int num2;
  int money = 500;
  printf("Welcome to Blackjack! You have $500. Play a hand? 1=y 2=n. ");
  while (hold == 1) {
    scanf("%d", &num);
    if (num == 1) {
      printf("Great! Ante is $20, here's your hand!");
      playerhand();
      playerhand();
      dealerhand();
      money = money - 20;
      printf("You have %d dollars. Hit? 1=y 2=n", money);
      scanf("%d", &num2);
      if (num2 == 1) {
        playerhand();
        break;
      }
      if (num2 == 2)
        ;
    }
    if (num == 2) {
      printf("Too bad, come back soon!");
      break;
    }
    if (num != 1 || num != 2) {
      printf("Sorry what was that? Play a hand? 1=y 2=n.");
      while (((num = getchar()) != EOF) && num != '\n')
        ;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x1,-0x14(%rbp)
movl   $0x1f4,-0x20(%rbp)
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    12d5 <main+0x165>
lea    0xe79(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <scanf@plt>
cmpl   $0x1,-0x18(%rbp)
jne    124d <main+0xdd>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <playerhand@plt>
mov    $0x0,%al
call   1030 <playerhand@plt>
mov    $0x0,%al
call   1080 <dealerhand@plt>
mov    -0x20(%rbp),%eax
sub    $0x14,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe22(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1090 <scanf@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    1239 <main+0xc9>
mov    $0x0,%al
call   1030 <playerhand@plt>
jmp    12d5 <main+0x165>
cmpl   $0x2,-0x1c(%rbp)
jne    1248 <main+0xd8>
jmp    1248 <main+0xd8>
jmp    124d <main+0xdd>
cmpl   $0x2,-0x18(%rbp)
jne    126a <main+0xfa>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d5 <main+0x165>
cmpl   $0x1,-0x18(%rbp)
jne    127e <main+0x10e>
cmpl   $0x2,-0x18(%rbp)
je     12d0 <main+0x160>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
xor    %eax,%eax
mov    0x2d47(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x21(%rbp)
je     12b6 <main+0x146>
cmpl   $0xa,-0x18(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    12c6 <main+0x156>
jmp    12cb <main+0x15b>
jmp    128c <main+0x11c>
jmp    12d0 <main+0x160>
jmp    11b2 <main+0x42>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1f4,%ebx
lea    0xe99(%rip),%r14
mov    %rsp,%r15
lea    0x4(%rsp),%rbp
lea    0xeee(%rip),%r12
mov    0x2e2f(%rip),%r13
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <scanf@plt>
mov    (%rsp),%eax
cmp    $0x1,%eax
jne    121e <main+0xae>
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <playerhand@plt>
xor    %eax,%eax
call   1030 <playerhand@plt>
xor    %eax,%eax
call   1080 <dealerhand@plt>
add    $0xffffffec,%ebx
lea    0xe65(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1090 <scanf@plt>
cmpl   $0x1,0x4(%rsp)
je     1260 <main+0xf0>
mov    (%rsp),%eax
cmp    $0x2,%eax
je     1250 <main+0xe0>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
nopl   (%rax)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,(%rsp)
mov    0x0(%r13),%ecx
cmp    $0xa,%eax
je     11c0 <main+0x50>
cmp    %ecx,%eax
jne    1230 <main+0xc0>
jmp    11c0 <main+0x50>
lea    0xe30(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1267 <main+0xf7>
xor    %eax,%eax
call   1030 <playerhand@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [60 x i8] c"Welcome to Blackjack! You have $500. Play a hand? 1=y 2=n. \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"Great! Ante is $20, here's your hand!\00"
@.str.3 = [34 x i8] c"You have %d dollars. Hit? 1=y 2=n\00"
@.str.4 = [25 x i8] c"Too bad, come back soon!\00"
@.str.5 = [43 x i8] c"Sorry what was that? Play a hand? 1=y 2=n.\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i64 @time(i32* null)
%11 = trunc i64 %10 to i32
%12 = call i32 @srand(i32 %11)
store i32 1, i32* %6
store i32 500, i32* %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %64, %2
%15 = load i32, i32* %6
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %65
17: ; preds = %14
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %40
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 (...) @playerhand()
%24 = call i32 (...) @playerhand()
%25 = call i32 (...) @dealerhand()
%26 = load i32, i32* %9
%27 = sub nsw i32 %26, 20
store i32 %27, i32* %9
%28 = load i32, i32* %9
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%31 = load i32, i32* %8
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %35
33: ; preds = %21
%34 = call i32 (...) @playerhand()
br label %65
35: ; preds = %21
%36 = load i32, i32* %8
%37 = icmp eq i32 %36, 2
br i1 %37, label %38, label %39
38: ; preds = %35
br label %39
39: ; preds = %38, %35
br label %40
40: ; preds = %39, %17
%41 = load i32, i32* %7
%42 = icmp eq i32 %41, 2
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %65
45: ; preds = %40
%46 = load i32, i32* %7
%47 = icmp ne i32 %46, 1
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = load i32, i32* %7
%50 = icmp ne i32 %49, 2
br i1 %50, label %51, label %64
51: ; preds = %48, %45
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %53
53: ; preds = %62, %51
%54 = call i32 (...) @getchar()
store i32 %54, i32* %7
%55 = load i32, i32* @EOF
%56 = icmp ne i32 %54, %55
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = load i32, i32* %7
%59 = icmp ne i32 %58, 10
br label %60
60: ; preds = %57, %53
%61 = phi i1 [ false, %53 ], [ %59, %57 ]
br i1 %61, label %62, label %63
62: ; preds = %60
br label %53
63: ; preds = %60
br label %64
64: ; preds = %63, %48
br label %14
65: ; preds = %43, %33, %14
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [60 x i8] c"Welcome to Blackjack! You have $500. Play a hand? 1=y 2=n. \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [38 x i8] c"Great! Ante is $20, here's your hand!\00"
@.str.3 = [34 x i8] c"You have %d dollars. Hit? 1=y 2=n\00"
@.str.4 = [25 x i8] c"Too bad, come back soon!\00"
@.str.5 = [43 x i8] c"Sorry what was that? Play a hand? 1=y 2=n.\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = tail call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = tail call i32 @srand(i32 %6)
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %38, %2
%12 = phi i32 [ 500, %2 ], [ %32, %38 ]
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %30
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (...) @playerhand()
%19 = call i32 (...) @playerhand()
%20 = call i32 (...) @dealerhand()
%21 = add nsw i32 %12, -20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %28
26: ; preds = %16
%27 = call i32 (...) @playerhand()
br label %44
28: ; preds = %16
%29 = load i32, i32* %3
br label %30
30: ; preds = %28, %11
%31 = phi i32 [ %29, %28 ], [ %14, %11 ]
%32 = phi i32 [ %21, %28 ], [ %12, %11 ]
%33 = icmp eq i32 %31, 2
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %44
36: ; preds = %30
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %38
38: ; preds = %38, %36
%39 = call i32 (...) @getchar()
store i32 %39, i32* %3
%40 = load i32, i32* @EOF
%41 = icmp ne i32 %39, %40
%42 = icmp ne i32 %39, 10
%43 = and i1 %42, %41
br i1 %43, label %38, label %11
44: ; preds = %34, %26
ret i32 0
}