#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int matsum(double *a, int na, int ma, double *b, int nb, int mb, double *c) {
  int i;
  if ((na != nb) || (ma != mb)) {
    fprintf(stderr, "MATSUM: A and B matrices: Incompatible sizes\n");
    return -1;
  }
  for (i = 0; i < na * ma; i++)
    c[i] = a[i] + b[i];
  return 0;
}


x86 assembly (clang, -O0):
<matsum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
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    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    114a <matsum+0x3a>
mov    -0x18(%rbp),%eax
cmp    -0x28(%rbp),%eax
je     116b <matsum+0x5b>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c0 <matsum+0xb0>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
cmp    %ecx,%eax
jge    11b9 <matsum+0xa9>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1172 <matsum+0x62>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matsum>:
push   %rax
cmp    %r8d,%esi
jne    11e7 <matsum+0xd7>
cmp    %r9d,%edx
jne    11e7 <matsum+0xd7>
imul   %esi,%edx
test   %edx,%edx
jle    1203 <matsum+0xf3>
mov    0x10(%rsp),%r10
mov    %edx,%r8d
cmp    $0x4,%edx
jae    1207 <matsum+0xf7>
xor    %edx,%edx
mov    %rdx,%rsi
not    %rsi
add    %r8,%rsi
mov    %r8,%rax
and    $0x3,%rax
je     117a <matsum+0x6a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rdi,%rdx,8),%xmm0
addsd  (%rcx,%rdx,8),%xmm0
movsd  %xmm0,(%r10,%rdx,8)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rax
jne    1160 <matsum+0x50>
xor    %eax,%eax
cmp    $0x3,%rsi
jb     130f <matsum+0x1ff>
cs nopw 0x0(%rax,%rax,1)
movsd  (%rdi,%rdx,8),%xmm0
addsd  (%rcx,%rdx,8),%xmm0
movsd  %xmm0,(%r10,%rdx,8)
movsd  0x8(%rdi,%rdx,8),%xmm0
addsd  0x8(%rcx,%rdx,8),%xmm0
movsd  %xmm0,0x8(%r10,%rdx,8)
movsd  0x10(%rdi,%rdx,8),%xmm0
addsd  0x10(%rcx,%rdx,8),%xmm0
movsd  %xmm0,0x10(%r10,%rdx,8)
movsd  0x18(%rdi,%rdx,8),%xmm0
addsd  0x18(%rcx,%rdx,8),%xmm0
movsd  %xmm0,0x18(%r10,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%r8
jne    1190 <matsum+0x80>
jmp    130f <matsum+0x1ff>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
lea    0xe09(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret
lea    (%r10,%r8,8),%rdx
lea    (%rdi,%r8,8),%rax
cmp    %r10,%rax
seta   %r9b
lea    (%rcx,%r8,8),%rax
cmp    %rdi,%rdx
seta   %r11b
cmp    %r10,%rax
seta   %al
cmp    %rcx,%rdx
seta   %sil
xor    %edx,%edx
test   %r11b,%r9b
jne    1141 <matsum+0x31>
and    %sil,%al
jne    1141 <matsum+0x31>
mov    %r8d,%edx
and    $0xfffffffc,%edx
lea    -0x4(%rdx),%rax
mov    %rax,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rax,%rax
je     1311 <matsum+0x201>
mov    %r9,%rsi
and    $0xfffffffffffffffe,%rsi
xor    %eax,%eax
nopl   0x0(%rax)
movupd (%rdi,%rax,8),%xmm0
movupd 0x10(%rdi,%rax,8),%xmm1
movupd (%rcx,%rax,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x10(%rcx,%rax,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,(%r10,%rax,8)
movupd %xmm0,0x10(%r10,%rax,8)
movupd 0x20(%rdi,%rax,8),%xmm0
movupd 0x30(%rdi,%rax,8),%xmm1
movupd 0x20(%rcx,%rax,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x30(%rcx,%rax,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,0x20(%r10,%rax,8)
movupd %xmm0,0x30(%r10,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%rsi
jne    1270 <matsum+0x160>
test   $0x1,%r9b
je     1304 <matsum+0x1f4>
movupd (%rdi,%rax,8),%xmm0
movupd 0x10(%rdi,%rax,8),%xmm1
movupd (%rcx,%rax,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x10(%rcx,%rax,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,(%r10,%rax,8)
movupd %xmm0,0x10(%r10,%rax,8)
xor    %eax,%eax
cmp    %r8,%rdx
jne    1141 <matsum+0x31>
pop    %rcx
ret
xor    %eax,%eax
test   $0x1,%r9b
jne    12d9 <matsum+0x1c9>
jmp    1304 <matsum+0x1f4>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"MATSUM: A and B matrices: Incompatible sizes\0A\00"
define i32 @matsum(double* %0, i32 %1, i32 %2, double* %3, i32 %4, i32 %5, double* %6) {
%8 = alloca i32
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca double*
%16 = alloca i32
store double* %0, double** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store double* %3, double** %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store double* %6, double** %15
%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 = %7
%21 = load i32, i32* %11
%22 = load i32, i32* %14
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %20, %7
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %8
br label %54
27: ; preds = %20
store i32 0, i32* %16
br label %28
28: ; preds = %50, %27
%29 = load i32, i32* %16
%30 = load i32, i32* %10
%31 = load i32, i32* %11
%32 = mul nsw i32 %30, %31
%33 = icmp slt i32 %29, %32
br i1 %33, label %34, label %53
34: ; preds = %28
%35 = load double*, double** %9
%36 = load i32, i32* %16
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = load double*, double** %12
%41 = load i32, i32* %16
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load double, double* %43
%45 = fadd double %39, %44
%46 = load double*, double** %15
%47 = load i32, i32* %16
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
store double %45, double* %49
br label %50
50: ; preds = %34
%51 = load i32, i32* %16
%52 = add nsw i32 %51, 1
store i32 %52, i32* %16
br label %28
53: ; preds = %28
store i32 0, i32* %8
br label %54
54: ; preds = %53, %24
%55 = load i32, i32* %8
ret i32 %55
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"MATSUM: A and B matrices: Incompatible sizes\0A\00"
define i32 @matsum(double* nocapture %0, i32 %1, i32 %2, double* nocapture %3, i32 %4, i32 %5, double* nocapture writeonly %6) {
%8 = icmp eq i32 %1, %4
%9 = icmp eq i32 %2, %5
%10 = and i1 %8, %9
br i1 %10, label %11, label %125
11: ; preds = %7
%12 = mul i32 %2, %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %159
14: ; preds = %11
%15 = zext i32 %12 to i64
%16 = icmp ult i32 %12, 4
br i1 %16, label %104, label %17
17: ; preds = %14
%18 = getelementptr double, double* %6, i64 %15
%19 = getelementptr double, double* %0, i64 %15
%20 = getelementptr double, double* %3, i64 %15
%21 = icmp ugt double* %19, %6
%22 = icmp ugt double* %18, %0
%23 = and i1 %21, %22
%24 = icmp ugt double* %20, %6
%25 = icmp ugt double* %18, %3
%26 = and i1 %24, %25
%27 = or i1 %23, %26
br i1 %27, label %104, label %28
28: ; preds = %17
%29 = and i64 %15, 4294967292
%30 = add nsw i64 %29, -4
%31 = lshr exact i64 %30, 2
%32 = add nuw nsw i64 %31, 1
%33 = and i64 %32, 1
%34 = icmp eq i64 %30, 0
br i1 %34, label %80, label %35
35: ; preds = %28
%36 = and i64 %32, 9223372036854775806
br label %37
37: ; preds = %37, %35
%38 = phi i64 [ 0, %35 ], [ %77, %37 ]
%39 = phi i64 [ 0, %35 ], [ %78, %37 ]
%40 = getelementptr inbounds double, double* %0, i64 %38
%41 = bitcast double* %40 to <2 x double>*
%42 = load <2 x double>, <2 x double>* %41
%43 = getelementptr inbounds double, double* %40, i64 2
%44 = bitcast double* %43 to <2 x double>*
%45 = load <2 x double>, <2 x double>* %44
%46 = getelementptr inbounds double, double* %3, i64 %38
%47 = bitcast double* %46 to <2 x double>*
%48 = load <2 x double>, <2 x double>* %47
%49 = getelementptr inbounds double, double* %46, i64 2
%50 = bitcast double* %49 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = fadd <2 x double> %42, %48
%53 = fadd <2 x double> %45, %51
%54 = getelementptr inbounds double, double* %6, i64 %38
%55 = bitcast double* %54 to <2 x double>*
store <2 x double> %52, <2 x double>* %55
%56 = getelementptr inbounds double, double* %54, i64 2
%57 = bitcast double* %56 to <2 x double>*
store <2 x double> %53, <2 x double>* %57
%58 = or i64 %38, 4
%59 = getelementptr inbounds double, double* %0, i64 %58
%60 = bitcast double* %59 to <2 x double>*
%61 = load <2 x double>, <2 x double>* %60
%62 = getelementptr inbounds double, double* %59, i64 2
%63 = bitcast double* %62 to <2 x double>*
%64 = load <2 x double>, <2 x double>* %63
%65 = getelementptr inbounds double, double* %3, i64 %58
%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 = fadd <2 x double> %61, %67
%72 = fadd <2 x double> %64, %70
%73 = getelementptr inbounds double, double* %6, i64 %58
%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 %38, 8
%78 = add i64 %39, 2
%79 = icmp eq i64 %78, %36
br i1 %79, label %80, label %37
80: ; preds = %37, %28
%81 = phi i64 [ 0, %28 ], [ %77, %37 ]
%82 = icmp eq i64 %33, 0
br i1 %82, label %102, label %83
83: ; preds = %80
%84 = getelementptr inbounds double, double* %0, i64 %81
%85 = bitcast double* %84 to <2 x double>*
%86 = load <2 x double>, <2 x double>* %85
%87 = getelementptr inbounds double, double* %84, i64 2
%88 = bitcast double* %87 to <2 x double>*
%89 = load <2 x double>, <2 x double>* %88
%90 = getelementptr inbounds double, double* %3, i64 %81
%91 = bitcast double* %90 to <2 x double>*
%92 = load <2 x double>, <2 x double>* %91
%93 = getelementptr inbounds double, double* %90, i64 2
%94 = bitcast double* %93 to <2 x double>*
%95 = load <2 x double>, <2 x double>* %94
%96 = fadd <2 x double> %86, %92
%97 = fadd <2 x double> %89, %95
%98 = getelementptr inbounds double, double* %6, i64 %81
%99 = bitcast double* %98 to <2 x double>*
store <2 x double> %96, <2 x double>* %99
%100 = getelementptr inbounds double, double* %98, i64 2
%101 = bitcast double* %100 to <2 x double>*
store <2 x double> %97, <2 x double>* %101
br label %102
102: ; preds = %80, %83
%103 = icmp eq i64 %29, %15
br i1 %103, label %159, label %104
104: ; preds = %17, %14, %102
%105 = phi i64 [ 0, %17 ], [ 0, %14 ], [ %29, %102 ]
%106 = xor i64 %105, -1
%107 = add nsw i64 %106, %15
%108 = and i64 %15, 3
%109 = icmp eq i64 %108, 0
br i1 %109, label %122, label %110
110: ; preds = %104, %110
%111 = phi i64 [ %119, %110 ], [ %105, %104 ]
%112 = phi i64 [ %120, %110 ], [ 0, %104 ]
%113 = getelementptr inbounds double, double* %0, i64 %111
%114 = load double, double* %113
%115 = getelementptr inbounds double, double* %3, i64 %111
%116 = load double, double* %115
%117 = fadd double %114, %116
%118 = getelementptr inbounds double, double* %6, i64 %111
store double %117, double* %118
%119 = add nuw nsw i64 %111, 1
%120 = add i64 %112, 1
%121 = icmp eq i64 %120, %108
br i1 %121, label %122, label %110
122: ; preds = %110, %104
%123 = phi i64 [ %105, %104 ], [ %119, %110 ]
%124 = icmp ult i64 %107, 3
br i1 %124, label %159, label %128
125: ; preds = %7
%126 = load i32, i32* @stderr
%127 = tail call i32 @fprintf(i32 %126, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %159
128: ; preds = %122, %128
%129 = phi i64 [ %157, %128 ], [ %123, %122 ]
%130 = getelementptr inbounds double, double* %0, i64 %129
%131 = load double, double* %130
%132 = getelementptr inbounds double, double* %3, i64 %129
%133 = load double, double* %132
%134 = fadd double %131, %133
%135 = getelementptr inbounds double, double* %6, i64 %129
store double %134, double* %135
%136 = add nuw nsw i64 %129, 1
%137 = getelementptr inbounds double, double* %0, i64 %136
%138 = load double, double* %137
%139 = getelementptr inbounds double, double* %3, i64 %136
%140 = load double, double* %139
%141 = fadd double %138, %140
%142 = getelementptr inbounds double, double* %6, i64 %136
store double %141, double* %142
%143 = add nuw nsw i64 %129, 2
%144 = getelementptr inbounds double, double* %0, i64 %143
%145 = load double, double* %144
%146 = getelementptr inbounds double, double* %3, i64 %143
%147 = load double, double* %146
%148 = fadd double %145, %147
%149 = getelementptr inbounds double, double* %6, i64 %143
store double %148, double* %149
%150 = add nuw nsw i64 %129, 3
%151 = getelementptr inbounds double, double* %0, i64 %150
%152 = load double, double* %151
%153 = getelementptr inbounds double, double* %3, i64 %150
%154 = load double, double* %153
%155 = fadd double %152, %154
%156 = getelementptr inbounds double, double* %6, i64 %150
store double %155, double* %156
%157 = add nuw nsw i64 %129, 4
%158 = icmp eq i64 %157, %15
br i1 %158, label %159, label %128
159: ; preds = %122, %128, %102, %11, %125
%160 = phi i32 [ -1, %125 ], [ 0, %11 ], [ 0, %102 ], [ 0, %128 ], [ 0, %122 ]
ret i32 %160
}