#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 rand();
void shuffle(int wDeck[][13]) {
  int row;
  int column;
  int card;
  for (card = 1; card <= 52; card++) {
    do {
      row = rand() % 4;
      column = rand() % 13;
    } while (wDeck[row][column] != 0);
    wDeck[row][column] = card;
  }
}


x86 assembly (clang, -O0):
<shuffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x34,-0x14(%rbp)
jg     119a <shuffle+0x8a>
jmp    1132 <shuffle+0x22>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xd,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x34,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1132 <shuffle+0x22>
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x34,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <shuffle+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x1,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <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   1030 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%ecx
sub    %ecx,%eax
movslq %ebx,%rcx
cltq
imul   $0x34,%rcx,%rcx
add    %r14,%rcx
cmpl   $0x0,(%rcx,%rax,4)
jne    1120 <shuffle+0x10>
lea    (%rcx,%rax,4),%rax
mov    %ebp,(%rax)
add    $0x1,%ebp
cmp    $0x35,%ebp
jne    1120 <shuffle+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @shuffle([13 x i32]* %0) {
%2 = alloca [13 x i32]*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store [13 x i32]* %0, [13 x i32]** %2
store i32 1, i32* %5
br label %6
6: ; preds = %34, %1
%7 = load i32, i32* %5
%8 = icmp sle i32 %7, 52
br i1 %8, label %9, label %37
9: ; preds = %6
br label %10
10: ; preds = %15, %9
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 4
store i32 %12, i32* %3
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 13
store i32 %14, i32* %4
br label %15
15: ; preds = %10
%16 = load [13 x i32]*, [13 x i32]** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [13 x i32], [13 x i32]* %16, i64 %18
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [13 x i32], [13 x i32]* %19, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %10, label %25
25: ; preds = %15
%26 = load i32, i32* %5
%27 = load [13 x i32]*, [13 x i32]** %2
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [13 x i32], [13 x i32]* %27, i64 %29
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [13 x i32], [13 x i32]* %30, i64 0, i64 %32
store i32 %26, i32* %33
br label %34
34: ; preds = %25
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %6
37: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @shuffle([13 x i32]* nocapture %0) {
br label %2
2: ; preds = %1, %14
%3 = phi i32 [ 1, %1 ], [ %15, %14 ]
br label %4
4: ; preds = %2, %4
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 4
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 13
%9 = sext i32 %6 to i64
%10 = sext i32 %8 to i64
%11 = getelementptr inbounds [13 x i32], [13 x i32]* %0, i64 %9, i64 %10
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %4
14: ; preds = %4
store i32 %3, i32* %11
%15 = add nuw nsw i32 %3, 1
%16 = icmp eq i32 %15, 53
br i1 %16, label %17, label %2
17: ; preds = %14
ret void
}