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


x86 assembly (clang, -O0):
<initialize_pop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    11bc <initialize_pop+0x9c>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a9 <initialize_pop+0x89>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %eax,-0x24(%rbp)
mov    $0x2,%edi
mov    $0x10,%esi
call   1030 <pow@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rcx
mov    -0x24(%rbp),%eax
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rsi,%rcx
shl    $0x1,%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    114e <initialize_pop+0x2e>
jmp    11ae <initialize_pop+0x8e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <initialize_pop+0x1d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialize_pop>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %edi,%r15d
lea    (%r15,%r15,1),%rax
mov    %rax,(%rsp)
xor    %r13d,%r13d
jmp    115e <initialize_pop+0x3e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
add    (%rsp),%rbx
cmp    $0x64,%r13
je     11a0 <initialize_pop+0x80>
test   %r14d,%r14d
jle    1150 <initialize_pop+0x30>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
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,(%rbx,%r12,2)
add    $0x1,%r12
cmp    %r12,%r15
jne    1170 <initialize_pop+0x50>
jmp    1150 <initialize_pop+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @initialize_pop(i32 %0, i16* %1) {
%3 = alloca i32
%4 = alloca i16*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i16* %1, i16** %4
%7 = load i32, i32* %3
%8 = zext i32 %7 to i64
store i32 0, i32* %5
br label %9
9: ; preds = %35, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 100
br i1 %11, label %12, label %38
12: ; preds = %9
store i32 0, i32* %6
br label %13
13: ; preds = %31, %12
%14 = load i32, i32* %6
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %34
17: ; preds = %13
%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 i16*, i16** %4
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = mul nsw i64 %25, %8
%27 = getelementptr inbounds i16, i16* %23, i64 %26
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i16, i16* %27, i64 %29
store i16 %22, i16* %30
br label %31
31: ; preds = %17
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %13
34: ; preds = %13
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %9
38: ; preds = %9
ret void
}

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