#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 **scalarMultiplication(double scalar, double **matrix, int row,
                              int column) {
  double **result = (double **)malloc(row * sizeof(double *));
  for (int i = 0; i < row; i++) {
    result[i] = (double *)malloc(column * sizeof(double));
    for (int j = 0; j < column; j++) {
      result[i][j] = scalar * matrix[i][j];
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<scalarMultiplication>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ce <scalarMultiplication+0xbe>
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11bb <scalarMultiplication+0xab>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1172 <scalarMultiplication+0x62>
jmp    11c0 <scalarMultiplication+0xb0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1141 <scalarMultiplication+0x31>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scalarMultiplication>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %edx,%ebx
mov    %esi,%r12d
mov    %rdi,0x20(%rsp)
movapd %xmm0,0x30(%rsp)
lea    0x0(,%r12,8),%edi
call   1030 <malloc@plt>
movapd 0x30(%rsp),%xmm2
mov    %rax,%r15
test   %r12d,%r12d
jle    133e <scalarMultiplication+0x22e>
lea    0x0(,%rbx,8),%r13d
mov    %r12d,%eax
mov    %rax,0x28(%rsp)
mov    %ebx,%ebp
mov    %ebp,%eax
and    $0xfffffffc,%eax
mov    %rax,0x18(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x10(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
movapd %xmm2,%xmm3
unpcklpd %xmm2,%xmm3
mov    %rcx,%rax
mov    %rcx,0x8(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,(%rsp)
mov    %ebp,%r14d
and    $0x3,%r14d
xor    %r12d,%r12d
movapd %xmm3,0x40(%rsp)
jmp    11bf <scalarMultiplication+0xaf>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    0x28(%rsp),%r12
je     133e <scalarMultiplication+0x22e>
mov    %r13d,%edi
call   1030 <malloc@plt>
movapd 0x40(%rsp),%xmm3
movapd 0x30(%rsp),%xmm2
mov    %rax,(%r15,%r12,8)
test   %ebx,%ebx
jle    11b0 <scalarMultiplication+0xa0>
mov    0x20(%rsp),%rcx
mov    (%rcx,%r12,8),%rcx
cmp    $0x4,%ebx
jb     1203 <scalarMultiplication+0xf3>
lea    (%rcx,%rbp,8),%rdx
cmp    %rdx,%rax
jae    129c <scalarMultiplication+0x18c>
lea    (%rax,%rbp,8),%rdx
cmp    %rdx,%rcx
jae    129c <scalarMultiplication+0x18c>
xor    %edx,%edx
mov    %rdx,%rsi
not    %rsi
add    %rbp,%rsi
test   %r14,%r14
je     1238 <scalarMultiplication+0x128>
mov    %r14,%rdi
cs nopw 0x0(%rax,%rax,1)
movsd  (%rcx,%rdx,8),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%rax,%rdx,8)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rdi
jne    1220 <scalarMultiplication+0x110>
cmp    $0x3,%rsi
jb     11b0 <scalarMultiplication+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rcx,%rdx,8),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%rax,%rdx,8)
movsd  0x8(%rcx,%rdx,8),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rax,%rdx,8)
movsd  0x10(%rcx,%rdx,8),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rax,%rdx,8)
movsd  0x18(%rcx,%rdx,8),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x18(%rax,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%rbp
jne    1250 <scalarMultiplication+0x140>
jmp    11b0 <scalarMultiplication+0xa0>
cmpq   $0x0,0x10(%rsp)
je     1333 <scalarMultiplication+0x223>
mov    (%rsp),%rsi
xor    %edx,%edx
xchg   %ax,%ax
movupd (%rcx,%rdx,8),%xmm0
movupd 0x10(%rcx,%rdx,8),%xmm1
mulpd  %xmm3,%xmm0
mulpd  %xmm3,%xmm1
movupd %xmm0,(%rax,%rdx,8)
movupd %xmm1,0x10(%rax,%rdx,8)
movupd 0x20(%rcx,%rdx,8),%xmm0
movupd 0x30(%rcx,%rdx,8),%xmm1
mulpd  %xmm3,%xmm0
mulpd  %xmm3,%xmm1
movupd %xmm0,0x20(%rax,%rdx,8)
movupd %xmm1,0x30(%rax,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rsi
jne    12b0 <scalarMultiplication+0x1a0>
testb  $0x1,0x8(%rsp)
je     131d <scalarMultiplication+0x20d>
movupd (%rcx,%rdx,8),%xmm0
movupd 0x10(%rcx,%rdx,8),%xmm1
mulpd  %xmm3,%xmm0
mulpd  %xmm3,%xmm1
movupd %xmm0,(%rax,%rdx,8)
movupd %xmm1,0x10(%rax,%rdx,8)
mov    0x18(%rsp),%rsi
mov    %rsi,%rdx
cmp    %rbp,%rsi
je     11b0 <scalarMultiplication+0xa0>
jmp    1205 <scalarMultiplication+0xf5>
xor    %edx,%edx
testb  $0x1,0x8(%rsp)
jne    12ff <scalarMultiplication+0x1ef>
jmp    131d <scalarMultiplication+0x20d>
mov    %r15,%rax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double** @scalarMultiplication(double %0, double** nocapture %1, i32 %2, i32 %3) {
%5 = shl i32 %2, 3
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to double**
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %31
9: ; preds = %4
%10 = shl i32 %3, 3
%11 = icmp sgt i32 %3, 0
%12 = zext i32 %2 to i64
%13 = zext i32 %3 to i64
%14 = and i64 %13, 4294967292
%15 = add nsw i64 %14, -4
%16 = lshr exact i64 %15, 2
%17 = add nuw nsw i64 %16, 1
%18 = icmp ult i32 %3, 4
%19 = and i64 %13, 4294967292
%20 = insertelement <2 x double> poison, double %0, i64 0
%21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
%22 = insertelement <2 x double> poison, double %0, i64 0
%23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
%24 = and i64 %17, 1
%25 = icmp eq i64 %15, 0
%26 = and i64 %17, 9223372036854775806
%27 = icmp eq i64 %24, 0
%28 = icmp eq i64 %19, %13
%29 = and i64 %13, 3
%30 = icmp eq i64 %29, 0
br label %32
31: ; preds = %113, %4
ret double** %7
32: ; preds = %9, %113
%33 = phi i64 [ 0, %9 ], [ %114, %113 ]
%34 = tail call i64 @malloc(i32 %10)
%35 = inttoptr i64 %34 to double*
%36 = inttoptr i64 %34 to i8*
%37 = getelementptr inbounds double*, double** %7, i64 %33
store double* %35, double** %37
br i1 %11, label %38, label %113
38: ; preds = %32
%39 = getelementptr inbounds double*, double** %1, i64 %33
%40 = load double*, double** %39
br i1 %18, label %96, label %41
41: ; preds = %38
%42 = getelementptr double, double* %35, i64 %13
%43 = getelementptr double, double* %40, i64 %13
%44 = bitcast double* %43 to i8*
%45 = icmp ult i8* %36, %44
%46 = icmp ult double* %40, %42
%47 = and i1 %45, %46
br i1 %47, label %96, label %48
48: ; preds = %41
br i1 %25, label %80, label %49
49: ; preds = %48, %49
%50 = phi i64 [ %77, %49 ], [ 0, %48 ]
%51 = phi i64 [ %78, %49 ], [ 0, %48 ]
%52 = getelementptr inbounds double, double* %40, i64 %50
%53 = bitcast double* %52 to <2 x double>*
%54 = load <2 x double>, <2 x double>* %53
%55 = getelementptr inbounds double, double* %52, i64 2
%56 = bitcast double* %55 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = fmul <2 x double> %54, %21
%59 = fmul <2 x double> %57, %23
%60 = getelementptr inbounds double, double* %35, i64 %50
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> %58, <2 x double>* %61
%62 = getelementptr inbounds double, double* %60, i64 2
%63 = bitcast double* %62 to <2 x double>*
store <2 x double> %59, <2 x double>* %63
%64 = or i64 %50, 4
%65 = getelementptr inbounds double, double* %40, i64 %64
%66 = bitcast double* %65 to <2 x double>*
%67 = load <2 x double>, <2 x double>* %66
%68 = getelementptr inbounds double, double* %65, i64 2
%69 = bitcast double* %68 to <2 x double>*
%70 = load <2 x double>, <2 x double>* %69
%71 = fmul <2 x double> %67, %21
%72 = fmul <2 x double> %70, %23
%73 = getelementptr inbounds double, double* %35, i64 %64
%74 = bitcast double* %73 to <2 x double>*
store <2 x double> %71, <2 x double>* %74
%75 = getelementptr inbounds double, double* %73, i64 2
%76 = bitcast double* %75 to <2 x double>*
store <2 x double> %72, <2 x double>* %76
%77 = add nuw i64 %50, 8
%78 = add i64 %51, 2
%79 = icmp eq i64 %78, %26
br i1 %79, label %80, label %49
80: ; preds = %49, %48
%81 = phi i64 [ 0, %48 ], [ %77, %49 ]
br i1 %27, label %95, label %82
82: ; preds = %80
%83 = getelementptr inbounds double, double* %40, i64 %81
%84 = bitcast double* %83 to <2 x double>*
%85 = load <2 x double>, <2 x double>* %84
%86 = getelementptr inbounds double, double* %83, i64 2
%87 = bitcast double* %86 to <2 x double>*
%88 = load <2 x double>, <2 x double>* %87
%89 = fmul <2 x double> %85, %21
%90 = fmul <2 x double> %88, %23
%91 = getelementptr inbounds double, double* %35, i64 %81
%92 = bitcast double* %91 to <2 x double>*
store <2 x double> %89, <2 x double>* %92
%93 = getelementptr inbounds double, double* %91, i64 2
%94 = bitcast double* %93 to <2 x double>*
store <2 x double> %90, <2 x double>* %94
br label %95
95: ; preds = %80, %82
br i1 %28, label %113, label %96
96: ; preds = %41, %38, %95
%97 = phi i64 [ 0, %41 ], [ 0, %38 ], [ %19, %95 ]
%98 = xor i64 %97, -1
%99 = add nsw i64 %98, %13
br i1 %30, label %110, label %100
100: ; preds = %96, %100
%101 = phi i64 [ %107, %100 ], [ %97, %96 ]
%102 = phi i64 [ %108, %100 ], [ 0, %96 ]
%103 = getelementptr inbounds double, double* %40, i64 %101
%104 = load double, double* %103
%105 = fmul double %104, %0
%106 = getelementptr inbounds double, double* %35, i64 %101
store double %105, double* %106
%107 = add nuw nsw i64 %101, 1
%108 = add i64 %102, 1
%109 = icmp eq i64 %108, %29
br i1 %109, label %110, label %100
110: ; preds = %100, %96
%111 = phi i64 [ %97, %96 ], [ %107, %100 ]
%112 = icmp ult i64 %99, 3
br i1 %112, label %113, label %116
113: ; preds = %110, %116, %95, %32
%114 = add nuw nsw i64 %33, 1
%115 = icmp eq i64 %114, %12
br i1 %115, label %31, label %32
116: ; preds = %110, %116
%117 = phi i64 [ %137, %116 ], [ %111, %110 ]
%118 = getelementptr inbounds double, double* %40, i64 %117
%119 = load double, double* %118
%120 = fmul double %119, %0
%121 = getelementptr inbounds double, double* %35, i64 %117
store double %120, double* %121
%122 = add nuw nsw i64 %117, 1
%123 = getelementptr inbounds double, double* %40, i64 %122
%124 = load double, double* %123
%125 = fmul double %124, %0
%126 = getelementptr inbounds double, double* %35, i64 %122
store double %125, double* %126
%127 = add nuw nsw i64 %117, 2
%128 = getelementptr inbounds double, double* %40, i64 %127
%129 = load double, double* %128
%130 = fmul double %129, %0
%131 = getelementptr inbounds double, double* %35, i64 %127
store double %130, double* %131
%132 = add nuw nsw i64 %117, 3
%133 = getelementptr inbounds double, double* %40, i64 %132
%134 = load double, double* %133
%135 = fmul double %134, %0
%136 = getelementptr inbounds double, double* %35, i64 %132
store double %135, double* %136
%137 = add nuw nsw i64 %117, 4
%138 = icmp eq i64 %137, %13
br i1 %138, label %113, label %116
}