#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(unsigned int);
double **AllocateValueMatrix(unsigned int N, double value) {
  double **M;
  M = (double **)malloc(N * sizeof(double *));
  for (int i = 0; i < N; ++i) {
    M[i] = (double *)malloc(N * sizeof(double));
    for (int j = 0; j < N; ++j) {
      M[i][j] = value;
    }
  }
  return M;
}


x86 assembly (clang, -O0):
<AllocateValueMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    11b0 <AllocateValueMatrix+0xa0>
mov    -0x4(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    119d <AllocateValueMatrix+0x8d>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1169 <AllocateValueMatrix+0x59>
jmp    11a2 <AllocateValueMatrix+0x92>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1139 <AllocateValueMatrix+0x29>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AllocateValueMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movaps %xmm0,0x10(%rsp)
mov    %edi,%r12d
lea    0x0(,%r12,8),%edi
mov    %edi,0xc(%rsp)
call   1030 <malloc@plt>
movaps 0x10(%rsp),%xmm0
mov    %rax,%r15
test   %r12d,%r12d
je     12c3 <AllocateValueMatrix+0x1b3>
mov    %r12d,%ebp
mov    %ebp,%ebx
and    $0xfffffffc,%ebx
lea    -0x4(%rbx),%rax
mov    %rax,0x38(%rsp)
shr    $0x2,%rax
add    $0x1,%rax
movaps %xmm0,%xmm1
movlhps %xmm0,%xmm1
mov    %eax,%r13d
and    $0x7,%r13d
and    $0xfffffffffffffff8,%rax
mov    %rax,0x28(%rsp)
mov    %r13,0x30(%rsp)
shl    $0x5,%r13
xor    %r14d,%r14d
movaps %xmm1,0x40(%rsp)
jmp    119d <AllocateValueMatrix+0x8d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %rbp,%r14
je     12c3 <AllocateValueMatrix+0x1b3>
mov    0xc(%rsp),%edi
call   1030 <malloc@plt>
mov    %rax,(%r15,%r14,8)
cmp    $0x4,%r12d
jae    11c0 <AllocateValueMatrix+0xb0>
xor    %ecx,%ecx
movaps 0x10(%rsp),%xmm0
jmp    12b0 <AllocateValueMatrix+0x1a0>
nopl   0x0(%rax)
cmpq   $0x1c,0x38(%rsp)
jae    11e0 <AllocateValueMatrix+0xd0>
xor    %ecx,%ecx
movaps 0x10(%rsp),%xmm0
movaps 0x40(%rsp),%xmm1
jmp    1271 <AllocateValueMatrix+0x161>
nopl   0x0(%rax)
mov    0x28(%rsp),%rdx
xor    %ecx,%ecx
movaps 0x10(%rsp),%xmm0
movaps 0x40(%rsp),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   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 <AllocateValueMatrix+0xf0>
cmpq   $0x0,0x30(%rsp)
je     12a2 <AllocateValueMatrix+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 <AllocateValueMatrix+0x180>
mov    %rbx,%rcx
cmp    %rbp,%rbx
je     1190 <AllocateValueMatrix+0x80>
xchg   %ax,%ax
movsd  %xmm0,(%rax,%rcx,8)
add    $0x1,%rcx
cmp    %rcx,%rbp
jne    12b0 <AllocateValueMatrix+0x1a0>
jmp    1190 <AllocateValueMatrix+0x80>
mov    %r15,%rax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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