#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 */
double **allocateDoubleMatrix(int, int);
double **scalarMultiplyMatrix(double **A, double scalar, int n, int m) {
  int i, j;
  double **B;
  B = allocateDoubleMatrix(n, m);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      B[i][j] = scalar * A[i][j];
  return B;
}


x86 assembly (clang, -O0):
<scalarMultiplyMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <allocateDoubleMatrix@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ac <scalarMultiplyMatrix+0x9c>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1199 <scalarMultiplyMatrix+0x89>
movsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%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    1150 <scalarMultiplyMatrix+0x40>
jmp    119e <scalarMultiplyMatrix+0x8e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113d <scalarMultiplyMatrix+0x2d>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scalarMultiplyMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r13d
mov    %esi,%ebp
movapd %xmm0,0x10(%rsp)
mov    %rdi,%r14
mov    %esi,%edi
mov    %edx,%esi
call   1030 <allocateDoubleMatrix@plt>
movapd 0x10(%rsp),%xmm3
test   %ebp,%ebp
jle    12d7 <scalarMultiplyMatrix+0x1c7>
mov    %ebp,%r15d
mov    %r13d,%edx
mov    %edx,%r11d
and    $0xfffffffc,%r11d
lea    -0x4(%r11),%r9
mov    %r9,%r10
shr    $0x2,%r10
add    $0x1,%r10
movapd %xmm3,%xmm0
unpcklpd %xmm3,%xmm0
mov    %r10,%rcx
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x8(%rsp)
mov    %edx,%r8d
and    $0x3,%r8d
xor    %edi,%edi
jmp    118d <scalarMultiplyMatrix+0x7d>
xchg   %ax,%ax
add    $0x1,%rdi
cmp    %r15,%rdi
je     12d7 <scalarMultiplyMatrix+0x1c7>
test   %r13d,%r13d
jle    1180 <scalarMultiplyMatrix+0x70>
mov    (%r14,%rdi,8),%rsi
mov    (%rax,%rdi,8),%rcx
cmp    $0x4,%r13d
jb     11ba <scalarMultiplyMatrix+0xaa>
lea    (%rsi,%rdx,8),%rbx
cmp    %rbx,%rcx
jae    123c <scalarMultiplyMatrix+0x12c>
lea    (%rcx,%rdx,8),%rbx
cmp    %rbx,%rsi
jae    123c <scalarMultiplyMatrix+0x12c>
xor    %ebp,%ebp
mov    %rbp,%rbx
not    %rbx
add    %rdx,%rbx
test   %r8,%r8
je     11e8 <scalarMultiplyMatrix+0xd8>
mov    %r8,%r12
nopl   (%rax)
movsd  (%rsi,%rbp,8),%xmm1
mulsd  %xmm3,%xmm1
movsd  %xmm1,(%rcx,%rbp,8)
add    $0x1,%rbp
add    $0xffffffffffffffff,%r12
jne    11d0 <scalarMultiplyMatrix+0xc0>
cmp    $0x3,%rbx
jb     1180 <scalarMultiplyMatrix+0x70>
xchg   %ax,%ax
movsd  (%rsi,%rbp,8),%xmm1
mulsd  %xmm3,%xmm1
movsd  %xmm1,(%rcx,%rbp,8)
movsd  0x8(%rsi,%rbp,8),%xmm1
mulsd  %xmm3,%xmm1
movsd  %xmm1,0x8(%rcx,%rbp,8)
movsd  0x10(%rsi,%rbp,8),%xmm1
mulsd  %xmm3,%xmm1
movsd  %xmm1,0x10(%rcx,%rbp,8)
movsd  0x18(%rsi,%rbp,8),%xmm1
mulsd  %xmm3,%xmm1
movsd  %xmm1,0x18(%rcx,%rbp,8)
add    $0x4,%rbp
cmp    %rbp,%rdx
jne    11f0 <scalarMultiplyMatrix+0xe0>
jmp    1180 <scalarMultiplyMatrix+0x70>
test   %r9,%r9
je     12cd <scalarMultiplyMatrix+0x1bd>
mov    0x8(%rsp),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
movupd (%rsi,%rbp,8),%xmm1
movupd 0x10(%rsi,%rbp,8),%xmm2
mulpd  %xmm0,%xmm1
mulpd  %xmm0,%xmm2
movupd %xmm1,(%rcx,%rbp,8)
movupd %xmm2,0x10(%rcx,%rbp,8)
movupd 0x20(%rsi,%rbp,8),%xmm1
movupd 0x30(%rsi,%rbp,8),%xmm2
mulpd  %xmm0,%xmm1
mulpd  %xmm0,%xmm2
movupd %xmm1,0x20(%rcx,%rbp,8)
movupd %xmm2,0x30(%rcx,%rbp,8)
add    $0x8,%rbp
add    $0xfffffffffffffffe,%rbx
jne    1250 <scalarMultiplyMatrix+0x140>
test   $0x1,%r10b
je     12bc <scalarMultiplyMatrix+0x1ac>
movupd (%rsi,%rbp,8),%xmm1
movupd 0x10(%rsi,%rbp,8),%xmm2
mulpd  %xmm0,%xmm1
mulpd  %xmm0,%xmm2
movupd %xmm1,(%rcx,%rbp,8)
movupd %xmm2,0x10(%rcx,%rbp,8)
mov    %r11,%rbp
cmp    %rdx,%r11
je     1180 <scalarMultiplyMatrix+0x70>
jmp    11bc <scalarMultiplyMatrix+0xac>
xor    %ebp,%ebp
test   $0x1,%r10b
jne    129e <scalarMultiplyMatrix+0x18e>
jmp    12bc <scalarMultiplyMatrix+0x1ac>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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