#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 *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(void) {
  int in_hand[4][13] = {{0}, {0}};
  int num_cards, rank, suit;
  const char *rank_code[] = {"Two",   "Three", "Four", "Five", "Six",
                             "Seven", "Eight", "Nine", "Ten",  "Jack",
                             "Queen", "King",  "Ace"};
  const char *suit_code[] = {"Clubs", "Diamonds", "Hearts", "Spades"};
  srand((unsigned)time(NULL));
  printf("Enter number of cards in hand: ");
  scanf("%d", &num_cards);
  printf("Your hand:\n");
  while (num_cards > 0) {
    suit = rand() % 4;
    rank = rand() % 13;
    if (!in_hand[suit][rank]) {
      in_hand[suit][rank] = 1;
      num_cards -= 1;
      printf("%s of %s\n", rank_code[rank], suit_code[suit]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0xd0,%edx
call   1040 <memset@plt>
lea    -0x160(%rbp),%rdi
lea    0x2bed(%rip),%rsi
mov    $0x68,%edx
call   1060 <memcpy@plt>
mov    0x2c4c(%rip),%rax
mov    %rax,-0x180(%rbp)
mov    0x2c46(%rip),%rax
mov    %rax,-0x178(%rbp)
mov    0x2c40(%rip),%rax
mov    %rax,-0x170(%rbp)
mov    0x2c3a(%rip),%rax
mov    %rax,-0x168(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe74(%rip),%rdi
lea    -0xe4(%rbp),%rsi
call   1080 <scanf@plt>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xe4(%rbp)
jle    12e4 <main+0x174>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0xec(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0xd,%ecx
cltd
idiv   %ecx
mov    %edx,-0xe8(%rbp)
movslq -0xec(%rbp),%rcx
lea    -0xe0(%rbp),%rax
imul   $0x34,%rcx,%rcx
add    %rcx,%rax
movslq -0xe8(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    12df <main+0x16f>
movslq -0xec(%rbp),%rcx
lea    -0xe0(%rbp),%rax
imul   $0x34,%rcx,%rcx
add    %rcx,%rax
movslq -0xe8(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0xe4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xe4(%rbp)
movslq -0xe8(%rbp),%rax
mov    -0x160(%rbp,%rax,8),%rsi
ff
movslq -0xec(%rbp),%rax
mov    -0x180(%rbp,%rax,8),%rdx
ff
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1224 <main+0xb4>
xor    %eax,%eax
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xe8,%rsp
xorps  %xmm0,%xmm0
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)
movaps %xmm0,0x10(%rsp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    12a6 <main+0x146>
lea    0xe89(%rip),%r15
lea    0xeb6(%rip),%r12
lea    0xe64(%rip),%r14
jmp    1227 <main+0xc7>
nop
cmpl   $0x0,0xc(%rsp)
jle    12a6 <main+0x146>
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebx
lea    0x3(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffffc,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rcx
imul   $0x4ec4ec4f,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
lea    (%rax,%rax,2),%edx
lea    (%rax,%rdx,4),%eax
sub    %eax,%ecx
movslq %ebx,%rax
movslq %ecx,%rcx
imul   $0x34,%rax,%rdx
add    %rsp,%rdx
add    $0x10,%rdx
cmpl   $0x0,(%rdx,%rcx,4)
jne    1220 <main+0xc0>
lea    (%rdx,%rcx,4),%rdx
movl   $0x1,(%rdx)
addl   $0xffffffff,0xc(%rsp)
movslq (%r15,%rcx,4),%rsi
add    %r15,%rsi
movslq (%r12,%rax,4),%rdx
add    %r12,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1220 <main+0xc0>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"Two\00"
@.str.1 = [6 x i8] c"Three\00"
@.str.2 = [5 x i8] c"Four\00"
@.str.3 = [5 x i8] c"Five\00"
@.str.4 = [4 x i8] c"Six\00"
@.str.5 = [6 x i8] c"Seven\00"
@.str.6 = [6 x i8] c"Eight\00"
@.str.7 = [5 x i8] c"Nine\00"
@.str.8 = [4 x i8] c"Ten\00"
@.str.9 = [5 x i8] c"Jack\00"
@.str.10 = [6 x i8] c"Queen\00"
@.str.11 = [5 x i8] c"King\00"
@.str.12 = [4 x i8] c"Ace\00"
@__const.main.rank_code = [13 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i32 0, i32 0)]
@.str.13 = [6 x i8] c"Clubs\00"
@.str.14 = [9 x i8] c"Diamonds\00"
@.str.15 = [7 x i8] c"Hearts\00"
@.str.16 = [7 x i8] c"Spades\00"
@__const.main.suit_code = [4 x i8*] [i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i32 0, i32 0)]
@.str.17 = [32 x i8] c"Enter number of cards in hand: \00"
@.str.18 = [3 x i8] c"%d\00"
@.str.19 = [12 x i8] c"Your hand:\0A\00"
@.str.20 = [10 x i8] c"%s of %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x [13 x i32]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [13 x i8*]
%7 = alloca [4 x i8*]
store i32 0, i32* %1
%8 = bitcast [4 x [13 x i32]]* %2 to i8*
%9 = bitcast [13 x i8*]* %6 to i8*
%10 = bitcast [4 x i8*]* %7 to i8*
%11 = call i64 @time(i32* null)
%12 = trunc i64 %11 to i32
%13 = call i32 @srand(i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.17, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0), i32* %3)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.19, i64 0, i64 0))
br label %17
17: ; preds = %51, %0
%18 = load i32, i32* %3
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %52
20: ; preds = %17
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 4
store i32 %22, i32* %5
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 13
store i32 %24, i32* %4
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [4 x [13 x i32]], [4 x [13 x i32]]* %2, i64 0, i64 %26
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [13 x i32], [13 x i32]* %27, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = icmp ne i32 %31, 0
br i1 %32, label %51, label %33
33: ; preds = %20
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4 x [13 x i32]], [4 x [13 x i32]]* %2, i64 0, i64 %35
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [13 x i32], [13 x i32]* %36, i64 0, i64 %38
store i32 1, i32* %39
%40 = load i32, i32* %3
%41 = sub nsw i32 %40, 1
store i32 %41, i32* %3
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [13 x i8*], [13 x i8*]* %6, i64 0, i64 %43
%45 = load i8*, i8** %44
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 %47
%49 = load i8*, i8** %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i64 0, i64 0), i8* %45, i8* %49)
br label %51
51: ; preds = %33, %20
br label %17
52: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"Two\00"
@.str.1 = [6 x i8] c"Three\00"
@.str.2 = [5 x i8] c"Four\00"
@.str.3 = [5 x i8] c"Five\00"
@.str.4 = [4 x i8] c"Six\00"
@.str.5 = [6 x i8] c"Seven\00"
@.str.6 = [6 x i8] c"Eight\00"
@.str.7 = [5 x i8] c"Nine\00"
@.str.8 = [4 x i8] c"Ten\00"
@.str.9 = [5 x i8] c"Jack\00"
@.str.10 = [6 x i8] c"Queen\00"
@.str.11 = [5 x i8] c"King\00"
@.str.12 = [4 x i8] c"Ace\00"
@reltable.main = [13 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.5 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.6 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.7 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.8 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.9 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.10 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.11 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.12 to i64), i64 ptrtoint ([13 x i32]* @reltable.main to i64)) to i32)]
@.str.13 = [6 x i8] c"Clubs\00"
@.str.14 = [9 x i8] c"Diamonds\00"
@.str.15 = [7 x i8] c"Hearts\00"
@.str.16 = [7 x i8] c"Spades\00"
@reltable.main.21 = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.13 to i64), i64 ptrtoint ([4 x i32]* @reltable.main.21 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.14 to i64), i64 ptrtoint ([4 x i32]* @reltable.main.21 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.15 to i64), i64 ptrtoint ([4 x i32]* @reltable.main.21 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.16 to i64), i64 ptrtoint ([4 x i32]* @reltable.main.21 to i64)) to i32)]
@.str.17 = [32 x i8] c"Enter number of cards in hand: \00"
@.str.18 = [3 x i8] c"%d\00"
@.str.20 = [10 x i8] c"%s of %s\0A\00"
@str = [11 x i8] c"Your hand:\00"
define i32 @main() {
%1 = alloca [4 x [13 x i32]]
%2 = alloca i32
%3 = bitcast [4 x [13 x i32]]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = tail call i32 @srand(i32 %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.17, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.18, i64 0, i64 0), i32* %2)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %34
13: ; preds = %0, %31
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 4
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 13
%18 = sext i32 %15 to i64
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds [4 x [13 x i32]], [4 x [13 x i32]]* %1, i64 0, i64 %18, i64 %19
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %13
store i32 1, i32* %20
%24 = load i32, i32* %2
%25 = add nsw i32 %24, -1
store i32 %25, i32* %2
%26 = shl i64 %19, 2
%27 = call i8* @llvm.load.relative.i64(i8* bitcast ([13 x i32]* @reltable.main to i8*), i64 %26)
%28 = shl i64 %18, 2
%29 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.main.21 to i8*), i64 %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.20, i64 0, i64 0), i8* %27, i8* %29)
br label %31
31: ; preds = %23, %13
%32 = load i32, i32* %2
%33 = icmp sgt i32 %32, 0
br i1 %33, label %13, label %34
34: ; preds = %31, %0
ret i32 0
}