#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__ coco_allocate_memory(int);
double *coco_allocate_vector(size_t const);
double **bbob2009_allocate_matrix(const size_t n, const size_t m) {
  double **matrix = NULL;
  size_t i;
  matrix = (double **)coco_allocate_memory(sizeof(double *) * n);
  for (i = 0; i < n; ++i) {
    matrix[i] = coco_allocate_vector(m);
  }
  return matrix;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <coco_allocate_memory@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    118a <bbob2009_allocate_matrix+0x6a>
mov    -0x10(%rbp),%rdi
call   1040 <coco_allocate_vector@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1153 <bbob2009_allocate_matrix+0x33>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x0(,%rdi,8),%edi
call   1030 <coco_allocate_memory@plt>
mov    %rax,%r12
test   %r15,%r15
je     1165 <bbob2009_allocate_matrix+0x45>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <coco_allocate_vector@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1150 <bbob2009_allocate_matrix+0x30>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double** @bbob2009_allocate_matrix(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca double**
%6 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
store double** null, double*** %5
%7 = load i64, i64* %3
%8 = mul i64 8, %7
%9 = trunc i64 %8 to i32
%10 = call i64 @coco_allocate_memory(i32 %9)
%11 = inttoptr i64 %10 to double**
store double** %11, double*** %5
store i64 0, i64* %6
br label %12
12: ; preds = %22, %2
%13 = load i64, i64* %6
%14 = load i64, i64* %3
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i64, i64* %4
%18 = call double* @coco_allocate_vector(i64 %17)
%19 = load double**, double*** %5
%20 = load i64, i64* %6
%21 = getelementptr inbounds double*, double** %19, i64 %20
store double* %18, double** %21
br label %22
22: ; preds = %16
%23 = load i64, i64* %6
%24 = add i64 %23, 1
store i64 %24, i64* %6
br label %12
25: ; preds = %12
%26 = load double**, double*** %5
ret double** %26
}

LLVM IR (-O2):
define double** @bbob2009_allocate_matrix(i64 %0, i64 %1) {
%3 = trunc i64 %0 to i32
%4 = shl i32 %3, 3
%5 = tail call i64 @coco_allocate_memory(i32 %4)
%6 = inttoptr i64 %5 to double**
%7 = icmp eq i64 %0, 0
br i1 %7, label %14, label %8
8: ; preds = %2, %8
%9 = phi i64 [ %12, %8 ], [ 0, %2 ]
%10 = tail call double* @coco_allocate_vector(i64 %1)
%11 = getelementptr inbounds double*, double** %6, i64 %9
store double* %10, double** %11
%12 = add nuw i64 %9, 1
%13 = icmp eq i64 %12, %0
br i1 %13, label %14, label %8
14: ; preds = %8, %2
ret double** %6
}