#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__ pow(int, int);
int rand();
void initialize_ccga(int dimensions, unsigned short (*pop)[dimensions][100]) {
  for (int i = 0; i < dimensions; i++) {
    for (int j = 0; j < 100; j++) {
      (*pop)[i][j] = rand() % (int)pow(2, 16);
    }
  }
}


x86 assembly (clang, -O0):
<initialize_ccga>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b0 <initialize_ccga+0x90>
movl   $0x0,-0x18(%rbp)
cmpl   $0x64,-0x18(%rbp)
jge    119d <initialize_ccga+0x7d>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x2,%edi
mov    $0x10,%esi
call   1030 <pow@plt>
mov    %rax,%rcx
mov    -0x1c(%rbp),%eax
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xc8,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1149 <initialize_ccga+0x29>
jmp    11a2 <initialize_ccga+0x82>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1136 <initialize_ccga+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialize_ccga>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
jle    118f <initialize_ccga+0x6f>
mov    %rsi,%r12
mov    %edi,%r14d
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ebp
mov    $0x2,%edi
mov    $0x10,%esi
call   1030 <pow@plt>
mov    %rax,%rcx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %dx,(%r12,%rbx,2)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1150 <initialize_ccga+0x30>
add    $0x1,%r15
add    $0xc8,%r12
cmp    %r14,%r15
jne    1140 <initialize_ccga+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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