#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*/ printf(char *, char *, char *);
int randomInteger(int, int);
int /*<<< orphan*/ randomize();
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
void getCard(void) {
  int c;
  char cardNumber[20];
  char *suits;
  randomize();
  switch (randomInteger(1, 4)) {
  case 1:
    suits = "clubs";
    break;
  case 2:
    suits = "diamonds";
    break;
  case 3:
    suits = "hearts";
    break;
  case 4:
    suits = "spades";
    break;
  default:
    break;
  }
  switch (c = randomInteger(1, 13)) {
  case 1:
    strcpy(cardNumber, "A");
    break;
  case 11:
    strcpy(cardNumber, "Jack");
    break;
  case 12:
    strcpy(cardNumber, "Queen");
    break;
  case 13:
    strcpy(cardNumber, "King");
    break;
  default:
    sprintf(cardNumber, "%d", c);
    break;
  }
  printf("%s of %s\n", cardNumber, suits);
}


x86 assembly (clang, -O0):
<getCard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
xor    %eax,%eax
call   1060 <randomize@plt>
mov    $0x1,%edi
mov    $0x4,%esi
call   1050 <randomInteger@plt>
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     11d4 <getCard+0x84>
mov    -0x30(%rbp),%rax
lea    0xe75(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xea9(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11d9 <getCard+0x89>
lea    0xe9f(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11d9 <getCard+0x89>
lea    0xe98(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11d9 <getCard+0x89>
lea    0xe8f(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11d9 <getCard+0x89>
jmp    11d9 <getCard+0x89>
mov    $0x1,%edi
mov    $0xd,%esi
call   1050 <randomInteger@plt>
mov    %eax,-0x4(%rbp)
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0xc,%eax
ja     1265 <getCard+0x115>
mov    -0x38(%rbp),%rax
lea    0xe08(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x20(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1278 <getCard+0x128>
lea    -0x20(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1278 <getCard+0x128>
lea    -0x20(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1278 <getCard+0x128>
lea    -0x20(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1278 <getCard+0x128>
lea    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe00(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xdef(%rip),%rdi
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCard>:
push   %rbx
sub    $0x20,%rsp
xor    %eax,%eax
call   1060 <randomize@plt>
mov    $0x1,%edi
mov    $0x4,%esi
call   1050 <randomInteger@plt>
add    $0xfffffffe,%eax
cmp    $0x2,%eax
ja     1185 <getCard+0x35>
cltq
lea    0xeb8(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    118c <getCard+0x3c>
lea    0xeb4(%rip),%rbx
mov    $0x1,%edi
mov    $0xd,%esi
call   1050 <randomInteger@plt>
lea    -0x1(%rax),%ecx
cmp    $0xc,%ecx
ja     11bc <getCard+0x6c>
lea    0xe56(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xea3(%rip),%rsi
jmp    11e8 <getCard+0x98>
lea    0xeac(%rip),%rsi
mov    %rsp,%rdi
mov    %eax,%edx
call   1070 <sprintf@plt>
jmp    11f0 <getCard+0xa0>
lea    0xe89(%rip),%rsi
jmp    11e8 <getCard+0x98>
lea    0xe85(%rip),%rsi
jmp    11e8 <getCard+0x98>
lea    0xe82(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
lea    0xe7b(%rip),%rdi
mov    %rsp,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"clubs\00"
@.str.1 = [9 x i8] c"diamonds\00"
@.str.2 = [7 x i8] c"hearts\00"
@.str.3 = [7 x i8] c"spades\00"
@.str.4 = [2 x i8] c"A\00"
@.str.5 = [5 x i8] c"Jack\00"
@.str.6 = [6 x i8] c"Queen\00"
@.str.7 = [5 x i8] c"King\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [10 x i8] c"%s of %s\0A\00"
define void @getCard() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i8*
%4 = call i32 (...) @randomize()
%5 = call i32 @randomInteger(i32 1, i32 4)
switch i32 %5, label %10 [
i32 1, label %6
i32 2, label %7
i32 3, label %8
i32 4, label %9
]
6: ; preds = %0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %3
br label %11
7: ; preds = %0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %11
8: ; preds = %0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %11
9: ; preds = %0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %11
10: ; preds = %0
br label %11
11: ; preds = %10, %9, %8, %7, %6
%12 = call i32 @randomInteger(i32 1, i32 13)
store i32 %12, i32* %1
switch i32 %12, label %25 [
i32 1, label %13
i32 11, label %16
i32 12, label %19
i32 13, label %22
]
13: ; preds = %11
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %29
16: ; preds = %11
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %29
19: ; preds = %11
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %29
22: ; preds = %11
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %29
25: ; preds = %11
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%27 = load i32, i32* %1
%28 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %25, %22, %19, %16, %13
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%31 = load i8*, i8** %3
%32 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* %30, i8* %31)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"clubs\00"
@.str.1 = [9 x i8] c"diamonds\00"
@.str.2 = [7 x i8] c"hearts\00"
@.str.3 = [7 x i8] c"spades\00"
@.str.4 = [2 x i8] c"A\00"
@.str.5 = [5 x i8] c"Jack\00"
@.str.6 = [6 x i8] c"Queen\00"
@.str.7 = [5 x i8] c"King\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [10 x i8] c"%s of %s\0A\00"
@reltable.getCard = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.getCard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.getCard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.getCard to i64)) to i32)]
define void @getCard() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @randomize()
%4 = tail call i32 @randomInteger(i32 1, i32 4)
%5 = add i32 %4, -2
%6 = icmp ult i32 %5, 3
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.getCard to i8*), i64 %9)
br label %11
11: ; preds = %7, %0
%12 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %0 ], [ %10, %7 ]
%13 = tail call i32 @randomInteger(i32 1, i32 13)
switch i32 %13, label %22 [
i32 1, label %14
i32 11, label %16
i32 12, label %18
i32 13, label %20
]
14: ; preds = %11
%15 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %24
16: ; preds = %11
%17 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %24
18: ; preds = %11
%19 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %24
20: ; preds = %11
%21 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %24
22: ; preds = %11
%23 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %13)
br label %24
24: ; preds = %22, %20, %18, %16, %14
%25 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* %2, i8* %12)
ret void
}