#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]) {
  void swap(int *element1Ptr, int *element2ptr);
  int row;
  int column;
  int card;
  int rowTemp, columnTemp;
  int countt = 0;
  for (row = 0; row < 4; row++) {
    for (column = 0; column < 13; column++) {
      rowTemp = rand() % 4;
      columnTemp = rand() % 13;
      if (rowTemp > row || columnTemp > column) {
        swap(&wDeck[row][column], &wDeck[rowTemp][columnTemp]);
        countt++;
      }
    }
  }
}


x86 assembly (clang, -O0):
<shuffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11f9 <shuffle+0xd9>
movl   $0x0,-0x10(%rbp)
cmpl   $0xd,-0x10(%rbp)
jge    11e6 <shuffle+0xc6>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0xd,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1191 <shuffle+0x71>
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11d3 <shuffle+0xb3>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
imul   $0x34,%rax,%rax
add    %rax,%rdi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x18(%rbp),%rax
imul   $0x34,%rax,%rax
add    %rax,%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <swap@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d8 <shuffle+0xb8>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114b <shuffle+0x2b>
jmp    11eb <shuffle+0xcb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113a <shuffle+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shuffle>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rdi,%r15
xor    %r12d,%r12d
jmp    1164 <shuffle+0x44>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %ebx,%rcx
imul   $0x34,%rcx,%rcx
add    %r14,%rcx
lea    (%rcx,%rax,4),%rsi
mov    %r15,%rdi
call   1030 <swap@plt>
add    $0x1,%r12
add    $0x4,%r15
cmp    $0xd,%r12
je     11ac <shuffle+0x8c>
xor    %eax,%eax
call   1040 <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   1040 <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
test   %ebx,%ebx
jg     1140 <shuffle+0x20>
cmp    %rax,%r12
jge    1156 <shuffle+0x36>
jmp    1140 <shuffle+0x20>
lea    0x34(%r14),%r15
xor    %r12d,%r12d
jmp    11e4 <shuffle+0xc4>
cs nopw 0x0(%rax,%rax,1)
nop
movslq %ebx,%rcx
imul   $0x34,%rcx,%rcx
add    %r14,%rcx
lea    (%rcx,%rax,4),%rsi
mov    %r15,%rdi
call   1030 <swap@plt>
add    $0x1,%r12
add    $0x4,%r15
cmp    $0xd,%r12
je     122d <shuffle+0x10d>
xor    %eax,%eax
call   1040 <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   1040 <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
cmp    $0x1,%ebx
jg     11c0 <shuffle+0xa0>
cmp    %rax,%r12
jge    11d6 <shuffle+0xb6>
jmp    11c0 <shuffle+0xa0>
lea    0x68(%r14),%r15
xor    %r12d,%r12d
jmp    1264 <shuffle+0x144>
cs nopw 0x0(%rax,%rax,1)
movslq %ebx,%rcx
imul   $0x34,%rcx,%rcx
add    %r14,%rcx
lea    (%rcx,%rax,4),%rsi
mov    %r15,%rdi
call   1030 <swap@plt>
add    $0x1,%r12
add    $0x4,%r15
cmp    $0xd,%r12
je     12ad <shuffle+0x18d>
xor    %eax,%eax
call   1040 <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   1040 <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
cmp    $0x2,%ebx
jg     1240 <shuffle+0x120>
cmp    %rax,%r12
jge    1256 <shuffle+0x136>
jmp    1240 <shuffle+0x120>
lea    0x9c(%r14),%r12
xor    %ebx,%ebx
jmp    12ce <shuffle+0x1ae>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
add    $0x4,%r12
cmp    $0xd,%rbx
je     132d <shuffle+0x20d>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1040 <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
cmp    %rax,%rbx
jge    12c0 <shuffle+0x1a0>
lea    0x3(%r15),%ecx
test   %r15d,%r15d
cmovns %r15d,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%r15d
movslq %r15d,%rcx
imul   $0x34,%rcx,%rcx
add    %r14,%rcx
lea    (%rcx,%rax,4),%rsi
mov    %r12,%rdi
call   1030 <swap@plt>
jmp    12c0 <shuffle+0x1a0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store [13 x i32]* %0, [13 x i32]** %2
store i32 0, i32* %8
store i32 0, i32* %3
br label %9
9: ; preds = %50, %1
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %53
12: ; preds = %9
store i32 0, i32* %4
br label %13
13: ; preds = %46, %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 13
br i1 %15, label %16, label %49
16: ; preds = %13
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 4
store i32 %18, i32* %6
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 13
store i32 %20, i32* %7
%21 = load i32, i32* %6
%22 = load i32, i32* %3
%23 = icmp sgt i32 %21, %22
br i1 %23, label %28, label %24
24: ; preds = %16
%25 = load i32, i32* %7
%26 = load i32, i32* %4
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %45
28: ; preds = %24, %16
%29 = load [13 x i32]*, [13 x i32]** %2
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [13 x i32], [13 x i32]* %29, i64 %31
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [13 x i32], [13 x i32]* %32, i64 0, i64 %34
%36 = load [13 x i32]*, [13 x i32]** %2
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [13 x i32], [13 x i32]* %36, i64 %38
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [13 x i32], [13 x i32]* %39, i64 0, i64 %41
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %45
45: ; preds = %28, %24
br label %46
46: ; preds = %45
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %13
49: ; preds = %13
br label %50
50: ; preds = %49
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %9
53: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @shuffle([13 x i32]* %0) {
br label %2
2: ; preds = %1, %16
%3 = phi i64 [ 0, %1 ], [ %17, %16 ]
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 4
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 13
%8 = icmp sgt i32 %5, 0
%9 = sext i32 %7 to i64
%10 = icmp slt i64 %3, %9
%11 = select i1 %8, i1 true, i1 %10
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = sext i32 %5 to i64
%14 = getelementptr inbounds [13 x i32], [13 x i32]* %0, i64 0, i64 %3
%15 = getelementptr inbounds [13 x i32], [13 x i32]* %0, i64 %13, i64 %9
tail call void @swap(i32* %14, i32* %15)
br label %16
16: ; preds = %2, %12
%17 = add nuw nsw i64 %3, 1
%18 = icmp eq i64 %17, 13
br i1 %18, label %19, label %2
19: ; preds = %16, %33
%20 = phi i64 [ %34, %33 ], [ 0, %16 ]
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 4
%23 = tail call i32 (...) @rand()
%24 = srem i32 %23, 13
%25 = icmp sgt i32 %22, 1
%26 = sext i32 %24 to i64
%27 = icmp slt i64 %20, %26
%28 = select i1 %25, i1 true, i1 %27
br i1 %28, label %29, label %33
29: ; preds = %19
%30 = sext i32 %22 to i64
%31 = getelementptr inbounds [13 x i32], [13 x i32]* %0, i64 1, i64 %20
%32 = getelementptr inbounds [13 x i32], [13 x i32]* %0, i64 %30, i64 %26
tail call void @swap(i32* %31, i32* %32)
br label %33
33: ; preds = %29, %19
%34 = add nuw nsw i64 %20, 1
%35 = icmp eq i64 %34, 13
br i1 %35, label %36, label %19
36: ; preds = %33, %50
%37 = phi i64 [ %51, %50 ], [ 0, %33 ]
%38 = tail call i32 (...) @rand()
%39 = srem i32 %38, 4
%40 = tail call i32 (...) @rand()
%41 = srem i32 %40, 13
%42 = icmp sgt i32 %39, 2
%43 = sext i32 %41 to i64
%44 = icmp slt i64 %37, %43
%45 = select i1 %42, i1 true, i1 %44
br i1 %45, label %46, label %50
46: ; preds = %36
%47 = sext i32 %39 to i64
%48 = getelementptr inbounds [13 x i32], [13 x i32]* %0, i64 2, i64 %37
%49 = getelementptr inbounds [13 x i32], [13 x i32]* %0, i64 %47, i64 %43
tail call void @swap(i32* %48, i32* %49)
br label %50
50: ; preds = %46, %36
%51 = add nuw nsw i64 %37, 1
%52 = icmp eq i64 %51, 13
br i1 %52, label %53, label %36
53: ; preds = %50, %65
%54 = phi i64 [ %66, %65 ], [ 0, %50 ]
%55 = tail call i32 (...) @rand()
%56 = tail call i32 (...) @rand()
%57 = srem i32 %56, 13
%58 = sext i32 %57 to i64
%59 = icmp slt i64 %54, %58
br i1 %59, label %60, label %65
60: ; preds = %53
%61 = srem i32 %55, 4
%62 = getelementptr inbounds [13 x i32], [13 x i32]* %0, i64 3, i64 %54
%63 = sext i32 %61 to i64
%64 = getelementptr inbounds [13 x i32], [13 x i32]* %0, i64 %63, i64 %58
tail call void @swap(i32* %62, i32* %64)
br label %65
65: ; preds = %60, %53
%66 = add nuw nsw i64 %54, 1
%67 = icmp eq i64 %66, 13
br i1 %67, label %68, label %53
68: ; preds = %65
ret void
}