#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(unsigned int wDeck[][13]) {
  size_t row;
  size_t column;
  size_t 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)
movq   $0x1,-0x20(%rbp)
cmpq   $0x34,-0x20(%rbp)
ja     11a4 <shuffle+0x94>
jmp    1134 <shuffle+0x24>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xd,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
imul   $0x34,-0x10(%rbp),%rcx
add    %rcx,%rax
mov    -0x18(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1134 <shuffle+0x24>
mov    -0x20(%rbp),%rax
mov    %eax,%edx
mov    -0x8(%rbp),%rax
imul   $0x34,-0x10(%rbp),%rcx
add    %rcx,%rax
mov    -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1124 <shuffle+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    $0x1,%r14d
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
movslq %eax,%rbx
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
cltq
imul   $0x34,%rbx,%rcx
add    %r15,%rcx
cmpl   $0x0,(%rcx,%rax,4)
jne    1120 <shuffle+0x10>
lea    (%rcx,%rax,4),%rax
mov    %r14d,(%rax)
add    $0x1,%r14
cmp    $0x35,%r14
jne    1120 <shuffle+0x10>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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