#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 */
scalar_t__ isSelected(int, int **);
int rand();
void initCardBoard(int cardBoard[3][4]) {
  int x, y, rnd;
  cardBoard[3][4] = 0;
  for (x = 0; x < 3; x++) {
    for (y = 0; y < 4; y++) {
      do {
        rnd = rand() % 81;
      } while (isSelected(rnd, cardBoard));
      cardBoard[x][y] = rnd;
    }
  }
}


x86 assembly (clang, -O0):
<initCardBoard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x0,0x40(%rax)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    11c0 <initCardBoard+0xa0>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    11ad <initCardBoard+0x8d>
jmp    115e <initCardBoard+0x3e>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x51,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <isSelected@plt>
cmp    $0x0,%rax
jne    115e <initCardBoard+0x3e>
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114f <initCardBoard+0x2f>
jmp    11b2 <initCardBoard+0x92>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113e <initCardBoard+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initCardBoard>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
movl   $0x0,0x40(%rdi)
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rbx
imul   $0x1948b0fd,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,8),%eax
lea    (%rax,%rax,8),%eax
sub    %eax,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <isSelected@plt>
test   %rax,%rax
jne    1140 <initCardBoard+0x20>
mov    %r15,%r12
shl    $0x4,%r12
mov    %ebx,(%r14,%r12,1)
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rbx
imul   $0x1948b0fd,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,8),%eax
lea    (%rax,%rax,8),%eax
sub    %eax,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <isSelected@plt>
test   %rax,%rax
jne    1180 <initCardBoard+0x60>
mov    %ebx,0x4(%r14,%r12,1)
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rbx
imul   $0x1948b0fd,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,8),%eax
lea    (%rax,%rax,8),%eax
sub    %eax,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <isSelected@plt>
test   %rax,%rax
jne    11c0 <initCardBoard+0xa0>
mov    %ebx,0x8(%r14,%r12,1)
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rbx
imul   $0x1948b0fd,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,8),%eax
lea    (%rax,%rax,8),%eax
sub    %eax,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1030 <isSelected@plt>
test   %rax,%rax
jne    1200 <initCardBoard+0xe0>
mov    %ebx,0xc(%r14,%r12,1)
add    $0x1,%r15
cmp    $0x3,%r15
jne    1140 <initCardBoard+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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