#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 */
double **malloc(int);
void AllocArrays(int *POP_SIZE, int *DIM, double ***pop, double **fo,
                 double **best, double **U) {
  int j;
  double **aux = malloc((*POP_SIZE) * sizeof(double *));
  for (j = 0; j < *POP_SIZE; j++) {
    aux[j] = (double *)malloc(*DIM * sizeof(double));
  }
  *pop = aux;
  *fo = (double *)malloc(*POP_SIZE * sizeof(double));
  *best = (double *)malloc(*DIM * sizeof(double));
  *U = (double *)malloc(*DIM * sizeof(double));
}


x86 assembly (clang, -O0):
<AllocArrays>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    118b <AllocArrays+0x7b>
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x40(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    114d <AllocArrays+0x3d>
mov    -0x40(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AllocArrays>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,(%rsp)
mov    %rdx,%r13
mov    %rsi,%rbp
mov    (%rdi),%r15d
lea    0x0(,%r15,8),%ebx
mov    %ebx,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
mov    0x0(%rbp),%ebp
shl    $0x3,%ebp
test   %r15d,%r15d
jle    1174 <AllocArrays+0x64>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
call   1030 <malloc@plt>
mov    %rax,(%r14,%r12,8)
add    $0x1,%r12
cmp    %r12,%r15
jne    1160 <AllocArrays+0x50>
mov    %r14,0x0(%r13)
mov    %ebx,%edi
call   1030 <malloc@plt>
mov    (%rsp),%rcx
mov    %rax,(%rcx)
mov    %ebp,%edi
call   1030 <malloc@plt>
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx)
mov    %ebp,%edi
call   1030 <malloc@plt>
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @AllocArrays(i32* %0, i32* %1, double*** %2, double** %3, double** %4, double** %5) {
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca double***
%10 = alloca double**
%11 = alloca double**
%12 = alloca double**
%13 = alloca i32
%14 = alloca double**
store i32* %0, i32** %7
store i32* %1, i32** %8
store double*** %2, double**** %9
store double** %3, double*** %10
store double** %4, double*** %11
store double** %5, double*** %12
%15 = load i32*, i32** %7
%16 = load i32, i32* %15
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 8
%19 = trunc i64 %18 to i32
%20 = call double** @malloc(i32 %19)
store double** %20, double*** %14
store i32 0, i32* %13
br label %21
21: ; preds = %38, %6
%22 = load i32, i32* %13
%23 = load i32*, i32** %7
%24 = load i32, i32* %23
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %41
26: ; preds = %21
%27 = load i32*, i32** %8
%28 = load i32, i32* %27
%29 = sext i32 %28 to i64
%30 = mul i64 %29, 8
%31 = trunc i64 %30 to i32
%32 = call double** @malloc(i32 %31)
%33 = bitcast double** %32 to double*
%34 = load double**, double*** %14
%35 = load i32, i32* %13
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double*, double** %34, i64 %36
store double* %33, double** %37
br label %38
38: ; preds = %26
%39 = load i32, i32* %13
%40 = add nsw i32 %39, 1
store i32 %40, i32* %13
br label %21
41: ; preds = %21
%42 = load double**, double*** %14
%43 = load double***, double**** %9
store double** %42, double*** %43
%44 = load i32*, i32** %7
%45 = load i32, i32* %44
%46 = sext i32 %45 to i64
%47 = mul i64 %46, 8
%48 = trunc i64 %47 to i32
%49 = call double** @malloc(i32 %48)
%50 = bitcast double** %49 to double*
%51 = load double**, double*** %10
store double* %50, double** %51
%52 = load i32*, i32** %8
%53 = load i32, i32* %52
%54 = sext i32 %53 to i64
%55 = mul i64 %54, 8
%56 = trunc i64 %55 to i32
%57 = call double** @malloc(i32 %56)
%58 = bitcast double** %57 to double*
%59 = load double**, double*** %11
store double* %58, double** %59
%60 = load i32*, i32** %8
%61 = load i32, i32* %60
%62 = sext i32 %61 to i64
%63 = mul i64 %62, 8
%64 = trunc i64 %63 to i32
%65 = call double** @malloc(i32 %64)
%66 = bitcast double** %65 to double*
%67 = load double**, double*** %12
store double* %66, double** %67
ret void
}

LLVM IR (-O2):
define void @AllocArrays(i32* nocapture %0, i32* nocapture %1, double*** nocapture writeonly %2, double** nocapture writeonly %3, double** nocapture writeonly %4, double** nocapture writeonly %5) {
%7 = load i32, i32* %0
%8 = shl i32 %7, 3
%9 = tail call double** @malloc(i32 %8)
%10 = icmp sgt i32 %7, 0
%11 = load i32, i32* %1
%12 = shl i32 %11, 3
br i1 %10, label %13, label %22
13: ; preds = %6
%14 = zext i32 %7 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %20, %15 ]
%17 = tail call double** @malloc(i32 %12)
%18 = getelementptr inbounds double*, double** %9, i64 %16
%19 = bitcast double** %18 to double***
store double** %17, double*** %19
%20 = add nuw nsw i64 %16, 1
%21 = icmp eq i64 %20, %14
br i1 %21, label %22, label %15
22: ; preds = %15, %6
store double** %9, double*** %2
%23 = tail call double** @malloc(i32 %8)
%24 = bitcast double** %3 to double***
store double** %23, double*** %24
%25 = tail call double** @malloc(i32 %12)
%26 = bitcast double** %4 to double***
store double** %25, double*** %26
%27 = tail call double** @malloc(i32 %12)
%28 = bitcast double** %5 to double***
store double** %27, double*** %28
ret void
}