#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 /*<<< orphan*/ printf(char *);
double **matrixSubtraction(double **matrixA, int rowA, int columnA,
                           double **matrixB, int rowB, int columnB) {
  double **result;
  if (columnA != columnB || rowA != rowB) {
    printf("matrixSubtraction error - indeces of first and second matrix are "
           "not okay");
    return result;
  }
  result = (double **)malloc(rowA * sizeof(double *));
  for (int i = 0; i < rowA; i++) {
    result[i] = (double *)malloc(columnB * sizeof(double));
    for (int j = 0; j < columnB; j++) {
      result[i][j] = matrixA[i][j] - matrixB[i][j];
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<matrixSubtraction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    1156 <matrixSubtraction+0x36>
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     116f <matrixSubtraction+0x4f>
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    122e <matrixSubtraction+0x10e>
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1226 <matrixSubtraction+0x106>
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1213 <matrixSubtraction+0xf3>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11ba <matrixSubtraction+0x9a>
jmp    1218 <matrixSubtraction+0xf8>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1189 <matrixSubtraction+0x69>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrixSubtraction>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,0x38(%rsp)
mov    %rdi,0x30(%rsp)
cmp    %r8d,%esi
jne    13b5 <matrixSubtraction+0x295>
mov    %edx,%r13d
cmp    %r9d,%edx
jne    13b5 <matrixSubtraction+0x295>
mov    %esi,%ebp
lea    0x0(,%rbp,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r12
test   %ebp,%ebp
jle    13c1 <matrixSubtraction+0x2a1>
lea    0x0(,%r13,8),%eax
mov    %eax,0xc(%rsp)
mov    %ebp,%eax
mov    %rax,0x40(%rsp)
mov    %r13d,%r14d
mov    %r14d,%eax
and    $0xfffffffc,%eax
mov    %rax,0x28(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x20(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,0x18(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x10(%rsp)
mov    %r14d,%r15d
and    $0x3,%r15d
xor    %ebp,%ebp
jmp    11cf <matrixSubtraction+0xaf>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    0x40(%rsp),%rbp
je     13c1 <matrixSubtraction+0x2a1>
mov    0xc(%rsp),%edi
call   1040 <malloc@plt>
mov    %rax,(%r12,%rbp,8)
test   %r13d,%r13d
jle    11c0 <matrixSubtraction+0xa0>
mov    0x30(%rsp),%rcx
mov    (%rcx,%rbp,8),%rcx
mov    0x38(%rsp),%rdx
mov    (%rdx,%rbp,8),%rdx
cmp    $0x4,%r13d
jb     1300 <matrixSubtraction+0x1e0>
lea    (%rax,%r14,8),%rsi
lea    (%rcx,%r14,8),%rdi
lea    (%rdx,%r14,8),%rbx
cmp    %rdi,%rax
setb   %r8b
cmp    %rsi,%rcx
setb   %r9b
cmp    %rbx,%rax
setb   %bl
cmp    %rsi,%rdx
setb   %dil
test   %r9b,%r8b
jne    1300 <matrixSubtraction+0x1e0>
mov    $0x0,%esi
and    %dil,%bl
jne    1302 <matrixSubtraction+0x1e2>
cmpq   $0x0,0x20(%rsp)
je     13a3 <matrixSubtraction+0x283>
mov    0x10(%rsp),%rdi
xor    %esi,%esi
xchg   %ax,%ax
movupd (%rcx,%rsi,8),%xmm0
movupd 0x10(%rcx,%rsi,8),%xmm1
movupd (%rdx,%rsi,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%rdx,%rsi,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,(%rax,%rsi,8)
movupd %xmm1,0x10(%rax,%rsi,8)
movupd 0x20(%rcx,%rsi,8),%xmm0
movupd 0x30(%rcx,%rsi,8),%xmm1
movupd 0x20(%rdx,%rsi,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x30(%rdx,%rsi,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,0x20(%rax,%rsi,8)
movupd %xmm1,0x30(%rax,%rsi,8)
add    $0x8,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1250 <matrixSubtraction+0x130>
testb  $0x1,0x18(%rsp)
je     12df <matrixSubtraction+0x1bf>
movupd (%rcx,%rsi,8),%xmm0
movupd 0x10(%rcx,%rsi,8),%xmm1
movupd (%rdx,%rsi,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%rdx,%rsi,8),%xmm2
subpd  %xmm2,%xmm1
movupd %xmm0,(%rax,%rsi,8)
movupd %xmm1,0x10(%rax,%rsi,8)
mov    0x28(%rsp),%rdi
mov    %rdi,%rsi
cmp    %r14,%rdi
je     11c0 <matrixSubtraction+0xa0>
jmp    1302 <matrixSubtraction+0x1e2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %esi,%esi
mov    %rsi,%rdi
not    %rdi
add    %r14,%rdi
test   %r15,%r15
je     1339 <matrixSubtraction+0x219>
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rcx,%rsi,8),%xmm0
subsd  (%rdx,%rsi,8),%xmm0
movsd  %xmm0,(%rax,%rsi,8)
add    $0x1,%rsi
add    $0xffffffffffffffff,%rbx
jne    1320 <matrixSubtraction+0x200>
cmp    $0x3,%rdi
jb     11c0 <matrixSubtraction+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rcx,%rsi,8),%xmm0
subsd  (%rdx,%rsi,8),%xmm0
movsd  %xmm0,(%rax,%rsi,8)
movsd  0x8(%rcx,%rsi,8),%xmm0
subsd  0x8(%rdx,%rsi,8),%xmm0
movsd  %xmm0,0x8(%rax,%rsi,8)
movsd  0x10(%rcx,%rsi,8),%xmm0
subsd  0x10(%rdx,%rsi,8),%xmm0
movsd  %xmm0,0x10(%rax,%rsi,8)
movsd  0x18(%rcx,%rsi,8),%xmm0
subsd  0x18(%rdx,%rsi,8),%xmm0
movsd  %xmm0,0x18(%rax,%rsi,8)
add    $0x4,%rsi
cmp    %rsi,%r14
jne    1350 <matrixSubtraction+0x230>
jmp    11c0 <matrixSubtraction+0xa0>
xor    %esi,%esi
testb  $0x1,0x18(%rsp)
jne    12b6 <matrixSubtraction+0x196>
jmp    12df <matrixSubtraction+0x1bf>
lea    0xc44(%rip),%rdi
call   1030 <printf@plt>
mov    %r12,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [74 x i8] c"matrixSubtraction error - indeces of first and second matrix are not okay\00"
define double** @matrixSubtraction(double** %0, i32 %1, i32 %2, double** %3, i32 %4, i32 %5) {
%7 = alloca double**
%8 = alloca double**
%9 = alloca i32
%10 = alloca i32
%11 = alloca double**
%12 = alloca i32
%13 = alloca i32
%14 = alloca double**
%15 = alloca i32
%16 = alloca i32
store double** %0, double*** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store double** %3, double*** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%17 = load i32, i32* %10
%18 = load i32, i32* %13
%19 = icmp ne i32 %17, %18
br i1 %19, label %24, label %20
20: ; preds = %6
%21 = load i32, i32* %9
%22 = load i32, i32* %12
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %20, %6
%25 = call i32 @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%26 = load double**, double*** %14
store double** %26, double*** %7
br label %90
27: ; preds = %20
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = mul i64 %29, 8
%31 = trunc i64 %30 to i32
%32 = call i64 @malloc(i32 %31)
%33 = inttoptr i64 %32 to double**
store double** %33, double*** %14
store i32 0, i32* %15
br label %34
34: ; preds = %85, %27
%35 = load i32, i32* %15
%36 = load i32, i32* %9
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %88
38: ; preds = %34
%39 = load i32, i32* %13
%40 = sext i32 %39 to i64
%41 = mul i64 %40, 8
%42 = trunc i64 %41 to i32
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to double*
%45 = load double**, double*** %14
%46 = load i32, i32* %15
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double*, double** %45, i64 %47
store double* %44, double** %48
store i32 0, i32* %16
br label %49
49: ; preds = %81, %38
%50 = load i32, i32* %16
%51 = load i32, i32* %13
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %84
53: ; preds = %49
%54 = load double**, double*** %8
%55 = load i32, i32* %15
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double*, double** %54, i64 %56
%58 = load double*, double** %57
%59 = load i32, i32* %16
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
%63 = load double**, double*** %11
%64 = load i32, i32* %15
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double*, double** %63, i64 %65
%67 = load double*, double** %66
%68 = load i32, i32* %16
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %67, i64 %69
%71 = load double, double* %70
%72 = fsub double %62, %71
%73 = load double**, double*** %14
%74 = load i32, i32* %15
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double*, double** %73, i64 %75
%77 = load double*, double** %76
%78 = load i32, i32* %16
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
store double %72, double* %80
br label %81
81: ; preds = %53
%82 = load i32, i32* %16
%83 = add nsw i32 %82, 1
store i32 %83, i32* %16
br label %49
84: ; preds = %49
br label %85
85: ; preds = %84
%86 = load i32, i32* %15
%87 = add nsw i32 %86, 1
store i32 %87, i32* %15
br label %34
88: ; preds = %34
%89 = load double**, double*** %14
store double** %89, double*** %7
br label %90
90: ; preds = %88, %24
%91 = load double**, double*** %7
ret double** %91
}

LLVM IR (-O2):
@.str = [74 x i8] c"matrixSubtraction error - indeces of first and second matrix are not okay\00"
define double** @matrixSubtraction(double** nocapture %0, i32 %1, i32 %2, double** nocapture %3, i32 %4, i32 %5) {
%7 = icmp eq i32 %2, %5
%8 = icmp eq i32 %1, %4
%9 = and i1 %8, %7
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
br label %178
12: ; preds = %6
%13 = shl i32 %1, 3
%14 = tail call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to double**
%16 = icmp sgt i32 %1, 0
br i1 %16, label %17, label %178
17: ; preds = %12
%18 = shl i32 %2, 3
%19 = icmp sgt i32 %2, 0
%20 = zext i32 %1 to i64
%21 = zext i32 %2 to i64
%22 = and i64 %21, 4294967292
%23 = add nsw i64 %22, -4
%24 = lshr exact i64 %23, 2
%25 = add nuw nsw i64 %24, 1
%26 = icmp ult i32 %2, 4
%27 = and i64 %21, 4294967292
%28 = and i64 %25, 1
%29 = icmp eq i64 %23, 0
%30 = and i64 %25, 9223372036854775806
%31 = icmp eq i64 %28, 0
%32 = icmp eq i64 %27, %21
%33 = and i64 %21, 3
%34 = icmp eq i64 %33, 0
br label %35
35: ; preds = %17, %144
%36 = phi i64 [ 0, %17 ], [ %145, %144 ]
%37 = tail call i64 @malloc(i32 %18)
%38 = inttoptr i64 %37 to double*
%39 = inttoptr i64 %37 to i8*
%40 = getelementptr inbounds double*, double** %15, i64 %36
store double* %38, double** %40
br i1 %19, label %41, label %144
41: ; preds = %35
%42 = getelementptr inbounds double*, double** %0, i64 %36
%43 = load double*, double** %42
%44 = getelementptr inbounds double*, double** %3, i64 %36
%45 = load double*, double** %44
br i1 %26, label %125, label %46
46: ; preds = %41
%47 = getelementptr double, double* %38, i64 %21
%48 = getelementptr double, double* %43, i64 %21
%49 = bitcast double* %48 to i8*
%50 = getelementptr double, double* %45, i64 %21
%51 = bitcast double* %50 to i8*
%52 = icmp ult i8* %39, %49
%53 = icmp ult double* %43, %47
%54 = and i1 %52, %53
%55 = icmp ult i8* %39, %51
%56 = icmp ult double* %45, %47
%57 = and i1 %55, %56
%58 = or i1 %54, %57
br i1 %58, label %125, label %59
59: ; preds = %46
br i1 %29, label %103, label %60
60: ; preds = %59, %60
%61 = phi i64 [ %100, %60 ], [ 0, %59 ]
%62 = phi i64 [ %101, %60 ], [ 0, %59 ]
%63 = getelementptr inbounds double, double* %43, i64 %61
%64 = bitcast double* %63 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = getelementptr inbounds double, double* %63, i64 2
%67 = bitcast double* %66 to <2 x double>*
%68 = load <2 x double>, <2 x double>* %67
%69 = getelementptr inbounds double, double* %45, i64 %61
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = getelementptr inbounds double, double* %69, i64 2
%73 = bitcast double* %72 to <2 x double>*
%74 = load <2 x double>, <2 x double>* %73
%75 = fsub <2 x double> %65, %71
%76 = fsub <2 x double> %68, %74
%77 = getelementptr inbounds double, double* %38, i64 %61
%78 = bitcast double* %77 to <2 x double>*
store <2 x double> %75, <2 x double>* %78
%79 = getelementptr inbounds double, double* %77, i64 2
%80 = bitcast double* %79 to <2 x double>*
store <2 x double> %76, <2 x double>* %80
%81 = or i64 %61, 4
%82 = getelementptr inbounds double, double* %43, i64 %81
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = getelementptr inbounds double, double* %82, i64 2
%86 = bitcast double* %85 to <2 x double>*
%87 = load <2 x double>, <2 x double>* %86
%88 = getelementptr inbounds double, double* %45, i64 %81
%89 = bitcast double* %88 to <2 x double>*
%90 = load <2 x double>, <2 x double>* %89
%91 = getelementptr inbounds double, double* %88, i64 2
%92 = bitcast double* %91 to <2 x double>*
%93 = load <2 x double>, <2 x double>* %92
%94 = fsub <2 x double> %84, %90
%95 = fsub <2 x double> %87, %93
%96 = getelementptr inbounds double, double* %38, i64 %81
%97 = bitcast double* %96 to <2 x double>*
store <2 x double> %94, <2 x double>* %97
%98 = getelementptr inbounds double, double* %96, i64 2
%99 = bitcast double* %98 to <2 x double>*
store <2 x double> %95, <2 x double>* %99
%100 = add nuw i64 %61, 8
%101 = add i64 %62, 2
%102 = icmp eq i64 %101, %30
br i1 %102, label %103, label %60
103: ; preds = %60, %59
%104 = phi i64 [ 0, %59 ], [ %100, %60 ]
br i1 %31, label %124, label %105
105: ; preds = %103
%106 = getelementptr inbounds double, double* %43, i64 %104
%107 = bitcast double* %106 to <2 x double>*
%108 = load <2 x double>, <2 x double>* %107
%109 = getelementptr inbounds double, double* %106, i64 2
%110 = bitcast double* %109 to <2 x double>*
%111 = load <2 x double>, <2 x double>* %110
%112 = getelementptr inbounds double, double* %45, i64 %104
%113 = bitcast double* %112 to <2 x double>*
%114 = load <2 x double>, <2 x double>* %113
%115 = getelementptr inbounds double, double* %112, i64 2
%116 = bitcast double* %115 to <2 x double>*
%117 = load <2 x double>, <2 x double>* %116
%118 = fsub <2 x double> %108, %114
%119 = fsub <2 x double> %111, %117
%120 = getelementptr inbounds double, double* %38, i64 %104
%121 = bitcast double* %120 to <2 x double>*
store <2 x double> %118, <2 x double>* %121
%122 = getelementptr inbounds double, double* %120, i64 2
%123 = bitcast double* %122 to <2 x double>*
store <2 x double> %119, <2 x double>* %123
br label %124
124: ; preds = %103, %105
br i1 %32, label %144, label %125
125: ; preds = %46, %41, %124
%126 = phi i64 [ 0, %46 ], [ 0, %41 ], [ %27, %124 ]
%127 = xor i64 %126, -1
%128 = add nsw i64 %127, %21
br i1 %34, label %141, label %129
129: ; preds = %125, %129
%130 = phi i64 [ %138, %129 ], [ %126, %125 ]
%131 = phi i64 [ %139, %129 ], [ 0, %125 ]
%132 = getelementptr inbounds double, double* %43, i64 %130
%133 = load double, double* %132
%134 = getelementptr inbounds double, double* %45, i64 %130
%135 = load double, double* %134
%136 = fsub double %133, %135
%137 = getelementptr inbounds double, double* %38, i64 %130
store double %136, double* %137
%138 = add nuw nsw i64 %130, 1
%139 = add i64 %131, 1
%140 = icmp eq i64 %139, %33
br i1 %140, label %141, label %129
141: ; preds = %129, %125
%142 = phi i64 [ %126, %125 ], [ %138, %129 ]
%143 = icmp ult i64 %128, 3
br i1 %143, label %144, label %147
144: ; preds = %141, %147, %124, %35
%145 = add nuw nsw i64 %36, 1
%146 = icmp eq i64 %145, %20
br i1 %146, label %178, label %35
147: ; preds = %141, %147
%148 = phi i64 [ %176, %147 ], [ %142, %141 ]
%149 = getelementptr inbounds double, double* %43, i64 %148
%150 = load double, double* %149
%151 = getelementptr inbounds double, double* %45, i64 %148
%152 = load double, double* %151
%153 = fsub double %150, %152
%154 = getelementptr inbounds double, double* %38, i64 %148
store double %153, double* %154
%155 = add nuw nsw i64 %148, 1
%156 = getelementptr inbounds double, double* %43, i64 %155
%157 = load double, double* %156
%158 = getelementptr inbounds double, double* %45, i64 %155
%159 = load double, double* %158
%160 = fsub double %157, %159
%161 = getelementptr inbounds double, double* %38, i64 %155
store double %160, double* %161
%162 = add nuw nsw i64 %148, 2
%163 = getelementptr inbounds double, double* %43, i64 %162
%164 = load double, double* %163
%165 = getelementptr inbounds double, double* %45, i64 %162
%166 = load double, double* %165
%167 = fsub double %164, %166
%168 = getelementptr inbounds double, double* %38, i64 %162
store double %167, double* %168
%169 = add nuw nsw i64 %148, 3
%170 = getelementptr inbounds double, double* %43, i64 %169
%171 = load double, double* %170
%172 = getelementptr inbounds double, double* %45, i64 %169
%173 = load double, double* %172
%174 = fsub double %171, %173
%175 = getelementptr inbounds double, double* %38, i64 %169
store double %174, double* %175
%176 = add nuw nsw i64 %148, 4
%177 = icmp eq i64 %176, %21
br i1 %177, label %144, label %147
178: ; preds = %144, %12, %10
%179 = phi double** [ undef, %10 ], [ %15, %12 ], [ %15, %144 ]
ret double** %179
}