#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*/ deal(unsigned int **, char const **, char const **);
int /*<<< orphan*/ shuffle(unsigned int **);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void fig07_24() {
  const char *suit[4] = {"Hearts", "Diamonds", "Clubs", "Spades"};
  const char *face[13] = {"Ace",  "Deuce", "Three", "Four", "Five",
                          "Six",  "Seven", "Eight", "Nine", "Ten",
                          "Jack", "Queen", "King"};
  unsigned int deck[4][13] = {{0}};
  srand(time(NULL));
  shuffle(deck);
  deal(deck, face, suit);
}


x86 assembly (clang, -O0):
<fig07_24>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    0x2c1e(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c1b(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c18(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2c15(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    -0x90(%rbp),%rdi
lea    0x2c0b(%rip),%rsi
mov    $0x68,%edx
call   1070 <memcpy@plt>
lea    -0x160(%rbp),%rdi
xor    %esi,%esi
mov    $0xd0,%edx
call   1040 <memset@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    -0x160(%rbp),%rdi
call   1030 <shuffle@plt>
lea    -0x160(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1060 <deal@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig07_24>:
push   %rbx
sub    $0x160,%rsp
movaps 0x2c51(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2c35(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x2caa(%rip),%rax
mov    %rax,0x80(%rsp)
movaps 0x2c8b(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0x2c6f(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0x2c53(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0x2c37(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x2c1b(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0x2bff(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <shuffle@plt>
lea    0x20(%rsp),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
call   1050 <deal@plt>
add    $0x160,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Hearts\00"
@.str.1 = [9 x i8] c"Diamonds\00"
@.str.2 = [6 x i8] c"Clubs\00"
@.str.3 = [7 x i8] c"Spades\00"
@__const.fig07_24.suit = [4 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [4 x i8] c"Ace\00"
@.str.5 = [6 x i8] c"Deuce\00"
@.str.6 = [6 x i8] c"Three\00"
@.str.7 = [5 x i8] c"Four\00"
@.str.8 = [5 x i8] c"Five\00"
@.str.9 = [4 x i8] c"Six\00"
@.str.10 = [6 x i8] c"Seven\00"
@.str.11 = [6 x i8] c"Eight\00"
@.str.12 = [5 x i8] c"Nine\00"
@.str.13 = [4 x i8] c"Ten\00"
@.str.14 = [5 x i8] c"Jack\00"
@.str.15 = [6 x i8] c"Queen\00"
@.str.16 = [5 x i8] c"King\00"
@__const.fig07_24.face = [13 x i8*] [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 ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 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 ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i32 0, i32 0)]
define void @fig07_24() {
%1 = alloca [4 x i8*]
%2 = alloca [13 x i8*]
%3 = alloca [4 x [13 x i32]]
%4 = bitcast [4 x i8*]* %1 to i8*
%5 = bitcast [13 x i8*]* %2 to i8*
%6 = bitcast [4 x [13 x i32]]* %3 to i8*
%7 = call i32 @time(i32* null)
%8 = call i32 @srand(i32 %7)
%9 = getelementptr inbounds [4 x [13 x i32]], [4 x [13 x i32]]* %3, i64 0, i64 0
%10 = bitcast [13 x i32]* %9 to i32**
%11 = call i32 @shuffle(i32** %10)
%12 = getelementptr inbounds [4 x [13 x i32]], [4 x [13 x i32]]* %3, i64 0, i64 0
%13 = bitcast [13 x i32]* %12 to i32**
%14 = getelementptr inbounds [13 x i8*], [13 x i8*]* %2, i64 0, i64 0
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%16 = call i32 @deal(i32** %13, i8** %14, i8** %15)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"Hearts\00"
@.str.1 = [9 x i8] c"Diamonds\00"
@.str.2 = [6 x i8] c"Clubs\00"
@.str.3 = [7 x i8] c"Spades\00"
@__const.fig07_24.suit = [4 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [4 x i8] c"Ace\00"
@.str.5 = [6 x i8] c"Deuce\00"
@.str.6 = [6 x i8] c"Three\00"
@.str.7 = [5 x i8] c"Four\00"
@.str.8 = [5 x i8] c"Five\00"
@.str.9 = [4 x i8] c"Six\00"
@.str.10 = [6 x i8] c"Seven\00"
@.str.11 = [6 x i8] c"Eight\00"
@.str.12 = [5 x i8] c"Nine\00"
@.str.13 = [4 x i8] c"Ten\00"
@.str.14 = [5 x i8] c"Jack\00"
@.str.15 = [6 x i8] c"Queen\00"
@.str.16 = [5 x i8] c"King\00"
@__const.fig07_24.face = [13 x i8*] [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 ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 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 ([6 x i8], [6 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i32 0, i32 0)]
define void @fig07_24() {
%1 = alloca [4 x i8*]
%2 = alloca [13 x i8*]
%3 = alloca [4 x [13 x i32]]
%4 = bitcast [4 x i8*]* %1 to i8*
%5 = bitcast [13 x i8*]* %2 to i8*
%6 = bitcast [4 x [13 x i32]]* %3 to i8*
%7 = tail call i32 @time(i32* null)
%8 = tail call i32 @srand(i32 %7)
%9 = bitcast [4 x [13 x i32]]* %3 to i32**
%10 = call i32 @shuffle(i32** %9)
%11 = getelementptr inbounds [13 x i8*], [13 x i8*]* %2, i64 0, i64 0
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%13 = call i32 @deal(i32** %9, i8** %11, i8** %12)
ret void
}