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


x86 assembly (clang, -O0):
<aml_array_dbl_2d_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b5 <aml_array_dbl_2d_new+0xa5>
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a2 <aml_array_dbl_2d_new+0x92>
movsd  -0x10(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116e <aml_array_dbl_2d_new+0x5e>
jmp    11a7 <aml_array_dbl_2d_new+0x97>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <aml_array_dbl_2d_new+0x2d>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aml_array_dbl_2d_new>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movaps %xmm0,0x30(%rsp)
mov    %esi,%ebx
mov    %edi,%r15d
lea    0x0(,%r15,8),%edi
call   1030 <malloc@plt>
movaps 0x30(%rsp),%xmm0
mov    %rax,%r14
test   %r15d,%r15d
jle    12d3 <aml_array_dbl_2d_new+0x1c3>
lea    0x0(,%rbx,8),%r12d
mov    %r15d,%eax
mov    %rax,0x28(%rsp)
mov    %ebx,%ebp
mov    %ebp,%eax
and    $0xfffffffc,%eax
mov    %rax,0x20(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x18(%rsp)
shr    $0x2,%rax
add    $0x1,%rax
movaps %xmm0,%xmm1
movlhps %xmm0,%xmm1
mov    %eax,%r13d
and    $0x7,%r13d
and    $0xfffffffffffffff8,%rax
mov    %rax,0x8(%rsp)
mov    %r13,0x10(%rsp)
shl    $0x5,%r13
xor    %r15d,%r15d
movaps %xmm1,0x40(%rsp)
jmp    11af <aml_array_dbl_2d_new+0x9f>
nopl   0x0(%rax)
add    $0x1,%r15
cmp    0x28(%rsp),%r15
je     12d3 <aml_array_dbl_2d_new+0x1c3>
mov    %r12d,%edi
call   1030 <malloc@plt>
movaps 0x40(%rsp),%xmm1
movaps 0x30(%rsp),%xmm0
mov    %rax,(%r14,%r15,8)
test   %ebx,%ebx
jle    11a0 <aml_array_dbl_2d_new+0x90>
cmp    $0x4,%ebx
jae    11e0 <aml_array_dbl_2d_new+0xd0>
xor    %ecx,%ecx
jmp    12c0 <aml_array_dbl_2d_new+0x1b0>
cs nopw 0x0(%rax,%rax,1)
nop
cmpq   $0x1c,0x18(%rsp)
jae    11ef <aml_array_dbl_2d_new+0xdf>
xor    %ecx,%ecx
jmp    1271 <aml_array_dbl_2d_new+0x161>
mov    0x8(%rsp),%rdx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
movups %xmm1,(%rax,%rcx,8)
movups %xmm1,0x10(%rax,%rcx,8)
movups %xmm1,0x20(%rax,%rcx,8)
movups %xmm1,0x30(%rax,%rcx,8)
movups %xmm1,0x40(%rax,%rcx,8)
movups %xmm1,0x50(%rax,%rcx,8)
movups %xmm1,0x60(%rax,%rcx,8)
movups %xmm1,0x70(%rax,%rcx,8)
movups %xmm1,0x80(%rax,%rcx,8)
movups %xmm1,0x90(%rax,%rcx,8)
movups %xmm1,0xa0(%rax,%rcx,8)
movups %xmm1,0xb0(%rax,%rcx,8)
movups %xmm1,0xc0(%rax,%rcx,8)
movups %xmm1,0xd0(%rax,%rcx,8)
movups %xmm1,0xe0(%rax,%rcx,8)
movups %xmm1,0xf0(%rax,%rcx,8)
add    $0x20,%rcx
add    $0xfffffffffffffff8,%rdx
jne    1200 <aml_array_dbl_2d_new+0xf0>
cmpq   $0x0,0x10(%rsp)
je     12a2 <aml_array_dbl_2d_new+0x192>
lea    (%rax,%rcx,8),%rcx
add    $0x10,%rcx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups %xmm1,-0x10(%rcx,%rdx,1)
movups %xmm1,(%rcx,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%r13
jne    1290 <aml_array_dbl_2d_new+0x180>
mov    0x20(%rsp),%rdx
mov    %rdx,%rcx
cmp    %rbp,%rdx
je     11a0 <aml_array_dbl_2d_new+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm0,(%rax,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rbp
jne    12c0 <aml_array_dbl_2d_new+0x1b0>
jmp    11a0 <aml_array_dbl_2d_new+0x90>
mov    %r14,%rax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double** @aml_array_dbl_2d_new(i32 %0, i32 %1, double %2) {
%4 = shl i32 %0, 3
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to double**
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %103
8: ; preds = %3
%9 = shl i32 %1, 3
%10 = icmp sgt i32 %1, 0
%11 = zext i32 %0 to i64
%12 = zext i32 %1 to i64
%13 = and i64 %12, 4294967292
%14 = add nsw i64 %13, -4
%15 = lshr exact i64 %14, 2
%16 = add nuw nsw i64 %15, 1
%17 = icmp ult i32 %1, 4
%18 = and i64 %12, 4294967292
%19 = insertelement <2 x double> poison, double %2, i64 0
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
%21 = insertelement <2 x double> poison, double %2, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = and i64 %16, 7
%24 = icmp ult i64 %14, 28
%25 = and i64 %16, 9223372036854775800
%26 = icmp eq i64 %23, 0
%27 = icmp eq i64 %18, %12
br label %28
28: ; preds = %8, %100
%29 = phi i64 [ 0, %8 ], [ %101, %100 ]
%30 = tail call i64 @malloc(i32 %9)
%31 = inttoptr i64 %30 to double*
%32 = getelementptr inbounds double*, double** %6, i64 %29
store double* %31, double** %32
br i1 %10, label %33, label %100
33: ; preds = %28
br i1 %17, label %93, label %34
34: ; preds = %33
br i1 %24, label %80, label %35
35: ; preds = %34, %35
%36 = phi i64 [ %77, %35 ], [ 0, %34 ]
%37 = phi i64 [ %78, %35 ], [ 0, %34 ]
%38 = getelementptr inbounds double, double* %31, i64 %36
%39 = bitcast double* %38 to <2 x double>*
store <2 x double> %20, <2 x double>* %39
%40 = getelementptr inbounds double, double* %38, i64 2
%41 = bitcast double* %40 to <2 x double>*
store <2 x double> %22, <2 x double>* %41
%42 = or i64 %36, 4
%43 = getelementptr inbounds double, double* %31, i64 %42
%44 = bitcast double* %43 to <2 x double>*
store <2 x double> %20, <2 x double>* %44
%45 = getelementptr inbounds double, double* %43, i64 2
%46 = bitcast double* %45 to <2 x double>*
store <2 x double> %22, <2 x double>* %46
%47 = or i64 %36, 8
%48 = getelementptr inbounds double, double* %31, i64 %47
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> %20, <2 x double>* %49
%50 = getelementptr inbounds double, double* %48, i64 2
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %22, <2 x double>* %51
%52 = or i64 %36, 12
%53 = getelementptr inbounds double, double* %31, i64 %52
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> %20, <2 x double>* %54
%55 = getelementptr inbounds double, double* %53, i64 2
%56 = bitcast double* %55 to <2 x double>*
store <2 x double> %22, <2 x double>* %56
%57 = or i64 %36, 16
%58 = getelementptr inbounds double, double* %31, i64 %57
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> %20, <2 x double>* %59
%60 = getelementptr inbounds double, double* %58, i64 2
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> %22, <2 x double>* %61
%62 = or i64 %36, 20
%63 = getelementptr inbounds double, double* %31, i64 %62
%64 = bitcast double* %63 to <2 x double>*
store <2 x double> %20, <2 x double>* %64
%65 = getelementptr inbounds double, double* %63, i64 2
%66 = bitcast double* %65 to <2 x double>*
store <2 x double> %22, <2 x double>* %66
%67 = or i64 %36, 24
%68 = getelementptr inbounds double, double* %31, i64 %67
%69 = bitcast double* %68 to <2 x double>*
store <2 x double> %20, <2 x double>* %69
%70 = getelementptr inbounds double, double* %68, i64 2
%71 = bitcast double* %70 to <2 x double>*
store <2 x double> %22, <2 x double>* %71
%72 = or i64 %36, 28
%73 = getelementptr inbounds double, double* %31, i64 %72
%74 = bitcast double* %73 to <2 x double>*
store <2 x double> %20, <2 x double>* %74
%75 = getelementptr inbounds double, double* %73, i64 2
%76 = bitcast double* %75 to <2 x double>*
store <2 x double> %22, <2 x double>* %76
%77 = add nuw i64 %36, 32
%78 = add i64 %37, 8
%79 = icmp eq i64 %78, %25
br i1 %79, label %80, label %35
80: ; preds = %35, %34
%81 = phi i64 [ 0, %34 ], [ %77, %35 ]
br i1 %26, label %92, label %82
82: ; preds = %80, %82
%83 = phi i64 [ %89, %82 ], [ %81, %80 ]
%84 = phi i64 [ %90, %82 ], [ 0, %80 ]
%85 = getelementptr inbounds double, double* %31, i64 %83
%86 = bitcast double* %85 to <2 x double>*
store <2 x double> %20, <2 x double>* %86
%87 = getelementptr inbounds double, double* %85, i64 2
%88 = bitcast double* %87 to <2 x double>*
store <2 x double> %22, <2 x double>* %88
%89 = add nuw i64 %83, 4
%90 = add i64 %84, 1
%91 = icmp eq i64 %90, %23
br i1 %91, label %92, label %82
92: ; preds = %82, %80
br i1 %27, label %100, label %93
93: ; preds = %33, %92
%94 = phi i64 [ 0, %33 ], [ %18, %92 ]
br label %95
95: ; preds = %93, %95
%96 = phi i64 [ %98, %95 ], [ %94, %93 ]
%97 = getelementptr inbounds double, double* %31, i64 %96
store double %2, double* %97
%98 = add nuw nsw i64 %96, 1
%99 = icmp eq i64 %98, %12
br i1 %99, label %100, label %95
100: ; preds = %95, %92, %28
%101 = add nuw nsw i64 %29, 1
%102 = icmp eq i64 %101, %11
br i1 %102, label %103, label %28
103: ; preds = %100, %3
ret double** %6
}