#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 *malloc(int);
int /*<<< orphan*/ set(int **, int /*<<< orphan*/, int, int);
void constructBoard(int **board, int dimension) {
  int i, j;
  for (i = 0; i < dimension; i++) {
    *(board + i) = malloc(sizeof(int) * dimension);
    for (j = 0; j < dimension; j++) {
      set(board, 0, i, j);
    }
  }
}


x86 assembly (clang, -O0):
<constructBoard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a5 <constructBoard+0x85>
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1192 <constructBoard+0x72>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
xor    %esi,%esi
call   1040 <set@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1167 <constructBoard+0x47>
jmp    1197 <constructBoard+0x77>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <constructBoard+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<constructBoard>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    117f <constructBoard+0x5f>
mov    %esi,%r14d
mov    %rdi,%r12
lea    0x0(,%r14,4),%r15d
mov    %esi,%r13d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%edi
call   1030 <malloc@plt>
mov    %rax,(%r12,%rbp,8)
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %r12,%rdi
xor    %esi,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1040 <set@plt>
add    $0x1,%ebx
cmp    %ebx,%r14d
jne    1160 <constructBoard+0x40>
add    $0x1,%rbp
cmp    %r13,%rbp
jne    1150 <constructBoard+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @constructBoard(i32** %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %20
4: ; preds = %2
%5 = shl i32 %1, 2
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %17, %4
%8 = phi i64 [ 0, %4 ], [ %18, %17 ]
%9 = tail call i32* @malloc(i32 %5)
%10 = getelementptr inbounds i32*, i32** %0, i64 %8
store i32* %9, i32** %10
%11 = trunc i64 %8 to i32
br label %12
12: ; preds = %7, %12
%13 = phi i32 [ %15, %12 ], [ 0, %7 ]
%14 = tail call i32 @set(i32** %0, i32 0, i32 %11, i32 %13)
%15 = add nuw nsw i32 %13, 1
%16 = icmp eq i32 %15, %1
br i1 %16, label %17, label %12
17: ; preds = %12
%18 = add nuw nsw i64 %8, 1
%19 = icmp eq i64 %18, %6
br i1 %19, label %20, label %7
20: ; preds = %17, %2
ret void
}