#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__ malloc(int);
int **aml_array_int_2d_variable_2nd_new(int s1, int *s2, int val) {
  int i, j;
  int **arr = (int **)malloc(s1 * sizeof(int *));
  for (i = 0; i < s1; i++) {
    arr[i] = (int *)malloc(s2[i] * sizeof(int));
    for (j = 0; j < s2[i]; j++)
      arr[i][j] = val;
  }
  return arr;
}


x86 assembly (clang, -O0):
<aml_array_int_2d_variable_2nd_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c0 <aml_array_int_2d_variable_2nd_new+0xb0>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movslq (%rax,%rcx,4),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    11ad <aml_array_int_2d_variable_2nd_new+0x9d>
mov    -0x14(%rbp),%edx
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1175 <aml_array_int_2d_variable_2nd_new+0x65>
jmp    11b2 <aml_array_int_2d_variable_2nd_new+0xa2>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113c <aml_array_int_2d_variable_2nd_new+0x2c>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aml_array_int_2d_variable_2nd_new>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %edi,%r15d
lea    0x0(,%r15,8),%edi
call   1030 <malloc@plt>
mov    %rax,%r14
test   %r15d,%r15d
jle    1173 <aml_array_int_2d_variable_2nd_new+0x63>
mov    %r15d,%r15d
xor    %ebp,%ebp
jmp    1149 <aml_array_int_2d_variable_2nd_new+0x39>
nopl   (%rax)
add    $0x1,%rbp
cmp    %r15,%rbp
je     1173 <aml_array_int_2d_variable_2nd_new+0x63>
mov    (%rbx,%rbp,4),%edi
shl    $0x2,%edi
call   1030 <malloc@plt>
mov    %rax,(%r14,%rbp,8)
cmpl   $0x0,(%rbx,%rbp,4)
jle    1140 <aml_array_int_2d_variable_2nd_new+0x30>
xor    %ecx,%ecx
mov    %r12d,(%rax,%rcx,4)
add    $0x1,%rcx
movslq (%rbx,%rbp,4),%rdx
cmp    %rdx,%rcx
jl     1160 <aml_array_int_2d_variable_2nd_new+0x50>
jmp    1140 <aml_array_int_2d_variable_2nd_new+0x30>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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