#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*/ assert(int);
void doubles_mat_add(const double *A, int Arows, int Acols, const double *B,
                     int Brows, int Bcols, double *R, int Rrows, int Rcols) {
  assert(Arows == Brows);
  assert(Arows == Rrows);
  assert(Bcols == Bcols);
  assert(Bcols == Rcols);
  for (int i = 0; i < Arows; i++)
    for (int j = 0; j < Bcols; j++)
      R[i * Acols + j] = A[i * Acols + j] + B[i * Acols + j];
}


x86 assembly (clang, -O0):
<doubles_mat_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xc(%rbp),%eax
cmp    0x18(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x20(%rbp),%eax
cmp    -0x20(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x20(%rbp),%eax
cmp    0x20(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120d <doubles_mat_add+0xfd>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11fa <doubles_mat_add+0xea>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    119e <doubles_mat_add+0x8e>
jmp    11ff <doubles_mat_add+0xef>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118b <doubles_mat_add+0x7b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubles_mat_add>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9d,%ebx
mov    %rcx,0x10(%rsp)
mov    %edx,%r12d
mov    %esi,%ebp
mov    %rdi,0x8(%rsp)
xor    %edi,%edi
cmp    %r8d,%esi
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    0xa8(%rsp),%ebp
sete   %dil
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %edi,%edi
mov    %ebx,0x4(%rsp)
cmp    0xb0(%rsp),%ebx
sete   %dil
call   1030 <assert@plt>
test   %ebp,%ebp
jle    1425 <doubles_mat_add+0x315>
mov    0xa0(%rsp),%r11
movslq %r12d,%rax
mov    %ebp,%ebx
mov    0x4(%rsp),%esi
mov    %esi,%ecx
and    $0xfffffffc,%ecx
mov    %rcx,0x38(%rsp)
add    $0xfffffffffffffffc,%rcx
mov    %rcx,0x30(%rsp)
mov    %rcx,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
mov    %rdx,%rcx
mov    %rdx,0x28(%rsp)
and    $0xfffffffffffffffe,%rdx
mov    %rdx,0x20(%rsp)
mov    %rsi,%rcx
neg    %rcx
mov    %rcx,0x40(%rsp)
lea    0x30(%r11),%rdi
mov    %rax,0x60(%rsp)
lea    0x0(,%rax,8),%r15
mov    0x10(%rsp),%rdx
lea    0x30(%rdx),%rcx
mov    0x8(%rsp),%rax
lea    0x30(%rax),%r9
lea    0x8(%rax),%r8
lea    0x8(%rdx),%r10
add    $0x8,%r11
xor    %r13d,%r13d
mov    %rbx,0x18(%rsp)
jmp    121f <doubles_mat_add+0x10f>
nopl   0x0(%rax)
add    $0x1,%r13
add    %r15,%rdi
add    %r15,%rcx
add    %r15,%r9
add    %r15,%r8
add    %r15,%r10
add    %r15,%r11
cmp    %rbx,%r13
je     1425 <doubles_mat_add+0x315>
cmpl   $0x0,0x4(%rsp)
jle    1200 <doubles_mat_add+0xf0>
mov    %r13,%r12
imul   0x60(%rsp),%r12
cmpl   $0x4,0x4(%rsp)
jae    1240 <doubles_mat_add+0x130>
xor    %edx,%edx
jmp    13a0 <doubles_mat_add+0x290>
nopl   (%rax)
lea    (%r12,%rsi,1),%rdx
mov    0xa0(%rsp),%rax
lea    (%rax,%r12,8),%rbx
lea    (%rax,%rdx,8),%rax
mov    %rax,0x48(%rsp)
mov    0x8(%rsp),%rax
lea    (%rax,%r12,8),%rbp
mov    %rbp,0x50(%rsp)
lea    (%rax,%rdx,8),%rbp
mov    0x10(%rsp),%rax
lea    (%rax,%r12,8),%r14
mov    %r14,0x58(%rsp)
lea    (%rax,%rdx,8),%rdx
cmp    %rbp,%rbx
setb   %al
mov    0x48(%rsp),%rbp
cmp    %rbp,0x50(%rsp)
setb   %r14b
cmp    %rdx,%rbx
setb   %bl
cmp    %rbp,0x58(%rsp)
setb   %bpl
test   %r14b,%al
jne    1335 <doubles_mat_add+0x225>
mov    $0x0,%edx
and    %bpl,%bl
mov    0x18(%rsp),%rbx
jne    13a0 <doubles_mat_add+0x290>
cmpq   $0x0,0x30(%rsp)
je     133e <doubles_mat_add+0x22e>
mov    0x20(%rsp),%r14
xor    %ebp,%ebp
nop
movupd -0x30(%r9,%rbp,8),%xmm0
movupd -0x20(%r9,%rbp,8),%xmm1
movupd -0x30(%rcx,%rbp,8),%xmm2
addpd  %xmm0,%xmm2
movupd -0x20(%rcx,%rbp,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,-0x30(%rdi,%rbp,8)
movupd %xmm0,-0x20(%rdi,%rbp,8)
movupd -0x10(%r9,%rbp,8),%xmm0
movupd (%r9,%rbp,8),%xmm1
movupd -0x10(%rcx,%rbp,8),%xmm2
addpd  %xmm0,%xmm2
movupd (%rcx,%rbp,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,-0x10(%rdi,%rbp,8)
movupd %xmm0,(%rdi,%rbp,8)
add    $0x8,%rbp
add    $0xfffffffffffffffe,%r14
jne    12d0 <doubles_mat_add+0x1c0>
jmp    1340 <doubles_mat_add+0x230>
xor    %edx,%edx
mov    0x18(%rsp),%rbx
jmp    13a0 <doubles_mat_add+0x290>
xor    %ebp,%ebp
testb  $0x1,0x28(%rsp)
mov    0x18(%rsp),%rbx
je     138a <doubles_mat_add+0x27a>
add    %r12,%rbp
mov    0x8(%rsp),%rax
movupd (%rax,%rbp,8),%xmm0
movupd 0x10(%rax,%rbp,8),%xmm1
mov    0x10(%rsp),%rax
movupd (%rax,%rbp,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x10(%rax,%rbp,8),%xmm0
addpd  %xmm1,%xmm0
mov    0xa0(%rsp),%rax
movupd %xmm2,(%rax,%rbp,8)
movupd %xmm0,0x10(%rax,%rbp,8)
mov    0x38(%rsp),%rax
mov    %rax,%rdx
cmp    %rsi,%rax
je     1200 <doubles_mat_add+0xf0>
nopl   0x0(%rax,%rax,1)
mov    %rdx,%rbp
test   $0x1,%sil
je     13d8 <doubles_mat_add+0x2c8>
add    %rdx,%r12
mov    0x8(%rsp),%rax
movsd  (%rax,%r12,8),%xmm0
mov    0x10(%rsp),%rbp
addsd  0x0(%rbp,%r12,8),%xmm0
mov    0xa0(%rsp),%rax
movsd  %xmm0,(%rax,%r12,8)
mov    %rdx,%rbp
or     $0x1,%rbp
not    %rdx
cmp    0x40(%rsp),%rdx
je     1200 <doubles_mat_add+0xf0>
cs nopw 0x0(%rax,%rax,1)
movsd  -0x8(%r8,%rbp,8),%xmm0
addsd  -0x8(%r10,%rbp,8),%xmm0
movsd  %xmm0,-0x8(%r11,%rbp,8)
movsd  (%r8,%rbp,8),%xmm0
addsd  (%r10,%rbp,8),%xmm0
movsd  %xmm0,(%r11,%rbp,8)
add    $0x2,%rbp
cmp    %rbp,%rsi
jne    13f0 <doubles_mat_add+0x2e0>
jmp    1200 <doubles_mat_add+0xf0>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @doubles_mat_add(double* %0, i32 %1, i32 %2, double* %3, i32 %4, i32 %5, double* %6, i32 %7, i32 %8) {
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca double*
%14 = alloca i32
%15 = alloca i32
%16 = alloca double*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store double* %0, double** %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store double* %3, double** %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store double* %6, double** %16
store i32 %7, i32* %17
store i32 %8, i32* %18
%21 = load i32, i32* %11
%22 = load i32, i32* %14
%23 = icmp eq i32 %21, %22
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i32, i32* %11
%27 = load i32, i32* %17
%28 = icmp eq i32 %26, %27
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i32, i32* %15
%32 = load i32, i32* %15
%33 = icmp eq i32 %31, %32
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load i32, i32* %15
%37 = load i32, i32* %18
%38 = icmp eq i32 %36, %37
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
store i32 0, i32* %19
br label %41
41: ; preds = %82, %9
%42 = load i32, i32* %19
%43 = load i32, i32* %11
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %85
45: ; preds = %41
store i32 0, i32* %20
br label %46
46: ; preds = %78, %45
%47 = load i32, i32* %20
%48 = load i32, i32* %15
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %81
50: ; preds = %46
%51 = load double*, double** %10
%52 = load i32, i32* %19
%53 = load i32, i32* %12
%54 = mul nsw i32 %52, %53
%55 = load i32, i32* %20
%56 = add nsw i32 %54, %55
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %51, i64 %57
%59 = load double, double* %58
%60 = load double*, double** %13
%61 = load i32, i32* %19
%62 = load i32, i32* %12
%63 = mul nsw i32 %61, %62
%64 = load i32, i32* %20
%65 = add nsw i32 %63, %64
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %60, i64 %66
%68 = load double, double* %67
%69 = fadd double %59, %68
%70 = load double*, double** %16
%71 = load i32, i32* %19
%72 = load i32, i32* %12
%73 = mul nsw i32 %71, %72
%74 = load i32, i32* %20
%75 = add nsw i32 %73, %74
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds double, double* %70, i64 %76
store double %69, double* %77
br label %78
78: ; preds = %50
%79 = load i32, i32* %20
%80 = add nsw i32 %79, 1
store i32 %80, i32* %20
br label %46
81: ; preds = %46
br label %82
82: ; preds = %81
%83 = load i32, i32* %19
%84 = add nsw i32 %83, 1
store i32 %84, i32* %19
br label %41
85: ; preds = %41
ret void
}

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