#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*/ printf(char *);
void double_matrix_multiplication(unsigned int i1, unsigned int j1,
                                  unsigned int i2, unsigned int j2,
                                  double m1[4][4], double m2[4][4],
                                  double m3[4][4]) {
  unsigned int i, j, k;
  if (j1 == i2) {
    for (i = 0; i < i1; i++) {
      for (j = 0; j < j2; j++) {
        m3[i][j] = 0;
      }
    }
    for (i = 0; i < i1; i++) {
      for (j = 0; j < j2; j++) {
        for (k = 0; k < j1; k++) {
          double mult = (m1[i][k] * m2[k][j]);
          m3[i][j] = m3[i][j] + (m1[i][k] * m2[k][j]);
        }
      }
    }
  } else {
    printf("\nError! Operation invalid, please enter with valid matrices.\n");
  }
}


x86 assembly (clang, -O0):
<double_matrix_multiplication>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    129f <double_matrix_multiplication+0x18f>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    119c <double_matrix_multiplication+0x8c>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    1189 <double_matrix_multiplication+0x79>
mov    0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x5,%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%ecx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1156 <double_matrix_multiplication+0x46>
jmp    118e <double_matrix_multiplication+0x7e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1143 <double_matrix_multiplication+0x33>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    129a <double_matrix_multiplication+0x18a>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    1287 <double_matrix_multiplication+0x177>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1274 <double_matrix_multiplication+0x164>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x5,%rcx
add    %rcx,%rax
mov    -0x2c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x5,%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%ecx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x5,%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x5,%rcx
add    %rcx,%rax
mov    -0x2c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x5,%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x5,%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c9 <double_matrix_multiplication+0xb9>
jmp    1279 <double_matrix_multiplication+0x169>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11b6 <double_matrix_multiplication+0xa6>
jmp    128c <double_matrix_multiplication+0x17c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a3 <double_matrix_multiplication+0x93>
jmp    12ab <double_matrix_multiplication+0x19b>
lea    0xd5a(%rip),%rdi
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_matrix_multiplication>:
cmp    %edx,%esi
jne    11e1 <double_matrix_multiplication+0xc1>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
test   %edi,%edi
je     12fe <double_matrix_multiplication+0x1de>
mov    %esi,%r15d
mov    %r9,0x38(%rsp)
mov    0x80(%rsp),%rdx
mov    %ecx,0xc(%rsp)
mov    %ecx,%r13d
lea    0x0(,%r13,8),%rax
mov    %rax,0x20(%rsp)
mov    %edi,0x1c(%rsp)
mov    %edi,%ebx
lea    -0x1(%rbx),%rax
mov    %ebx,%ecx
and    $0x3,%ecx
mov    %rcx,0x10(%rsp)
cmp    $0x3,%rax
mov    %rdx,0x28(%rsp)
mov    %rbx,0x40(%rsp)
mov    %r8,0x30(%rsp)
jae    130d <double_matrix_multiplication+0x1ed>
xor    %r14d,%r14d
cmpq   $0x0,0x10(%rsp)
mov    0x30(%rsp),%r12
mov    0xc(%rsp),%ebp
je     11ed <double_matrix_multiplication+0xcd>
shl    $0x5,%r14
add    0x28(%rsp),%r14
shlq   $0x5,0x10(%rsp)
xor    %ebx,%ebx
jmp    11cb <double_matrix_multiplication+0xab>
cs nopw 0x0(%rax,%rax,1)
add    $0x20,%rbx
cmp    %rbx,0x10(%rsp)
je     11ed <double_matrix_multiplication+0xcd>
test   %ebp,%ebp
je     11c0 <double_matrix_multiplication+0xa0>
lea    (%r14,%rbx,1),%rdi
xor    %esi,%esi
mov    0x20(%rsp),%rdx
call   1040 <memset@plt>
jmp    11c0 <double_matrix_multiplication+0xa0>
lea    0xe18(%rip),%rdi
jmp    1030 <puts@plt>
cmpl   $0x0,0x1c(%rsp)
mov    0x38(%rsp),%r14
je     12fe <double_matrix_multiplication+0x1de>
mov    %r15d,%r9d
mov    %r9d,%ecx
and    $0xfffffffe,%ecx
lea    0x8(%r12),%rdx
lea    0x20(%r14),%r8
xor    %r10d,%r10d
jmp    1237 <double_matrix_multiplication+0x117>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r10
add    $0x20,%rdx
cmp    0x40(%rsp),%r10
mov    0xc(%rsp),%ebp
je     12fe <double_matrix_multiplication+0x1de>
test   %ebp,%ebp
je     1220 <double_matrix_multiplication+0x100>
mov    %r8,%rdi
xor    %ebx,%ebx
jmp    125d <double_matrix_multiplication+0x13d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
add    $0x8,%rdi
cmp    %r13,%rbx
je     1220 <double_matrix_multiplication+0x100>
test   %r15d,%r15d
je     1250 <double_matrix_multiplication+0x130>
mov    %r10,%r11
shl    $0x5,%r11
mov    0x28(%rsp),%rax
lea    (%rax,%r11,1),%rsi
lea    (%rsi,%rbx,8),%rax
movsd  (%rsi,%rbx,8),%xmm0
cmp    $0x1,%r15d
jne    1290 <double_matrix_multiplication+0x170>
xor    %ebp,%ebp
jmp    12d1 <double_matrix_multiplication+0x1b1>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rdi,%rsi
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movsd  -0x8(%rdx,%rbp,8),%xmm1
mulsd  -0x20(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rax)
movsd  (%rdx,%rbp,8),%xmm0
mulsd  (%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
add    $0x2,%rbp
add    $0x40,%rsi
cmp    %rbp,%rcx
jne    12a0 <double_matrix_multiplication+0x180>
test   $0x1,%r9b
je     1250 <double_matrix_multiplication+0x130>
add    %r12,%r11
movsd  (%r11,%rbp,8),%xmm1
shl    $0x5,%rbp
add    %r14,%rbp
mulsd  0x0(%rbp,%rbx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rax)
jmp    1250 <double_matrix_multiplication+0x130>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
and    $0xfffffffc,%ebx
lea    0x60(%rdx),%r12
xor    %r14d,%r14d
mov    0x20(%rsp),%rbp
jmp    1331 <double_matrix_multiplication+0x211>
xchg   %ax,%ax
add    $0x4,%r14
sub    $0xffffffffffffff80,%r12
cmp    %r14,%rbx
je     1192 <double_matrix_multiplication+0x72>
cmpl   $0x0,0xc(%rsp)
je     1320 <double_matrix_multiplication+0x200>
lea    -0x60(%r12),%rdi
xor    %esi,%esi
mov    %rbp,%rdx
call   1040 <memset@plt>
lea    -0x40(%r12),%rdi
xor    %esi,%esi
mov    %rbp,%rdx
call   1040 <memset@plt>
lea    -0x20(%r12),%rdi
xor    %esi,%esi
mov    %rbp,%rdx
call   1040 <memset@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    %rbp,%rdx
call   1040 <memset@plt>
jmp    1320 <double_matrix_multiplication+0x200>

LLVM IR (-O0):
@.str = [62 x i8] c"\0AError! Operation invalid, please enter with valid matrices.\0A\00"
define void @double_matrix_multiplication(i32 %0, i32 %1, i32 %2, i32 %3, [4 x double]* %4, [4 x double]* %5, [4 x double]* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [4 x double]*
%13 = alloca [4 x double]*
%14 = alloca [4 x double]*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store [4 x double]* %4, [4 x double]** %12
store [4 x double]* %5, [4 x double]** %13
store [4 x double]* %6, [4 x double]** %14
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %124
22: ; preds = %7
store i32 0, i32* %15
br label %23
23: ; preds = %44, %22
%24 = load i32, i32* %15
%25 = load i32, i32* %8
%26 = icmp ult i32 %24, %25
br i1 %26, label %27, label %47
27: ; preds = %23
store i32 0, i32* %16
br label %28
28: ; preds = %40, %27
%29 = load i32, i32* %16
%30 = load i32, i32* %11
%31 = icmp ult i32 %29, %30
br i1 %31, label %32, label %43
32: ; preds = %28
%33 = load [4 x double]*, [4 x double]** %14
%34 = load i32, i32* %15
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds [4 x double], [4 x double]* %33, i64 %35
%37 = load i32, i32* %16
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds [4 x double], [4 x double]* %36, i64 0, i64 %38
store double 0.000000e+00, double* %39
br label %40
40: ; preds = %32
%41 = load i32, i32* %16
%42 = add i32 %41, 1
store i32 %42, i32* %16
br label %28
43: ; preds = %28
br label %44
44: ; preds = %43
%45 = load i32, i32* %15
%46 = add i32 %45, 1
store i32 %46, i32* %15
br label %23
47: ; preds = %23
store i32 0, i32* %15
br label %48
48: ; preds = %120, %47
%49 = load i32, i32* %15
%50 = load i32, i32* %8
%51 = icmp ult i32 %49, %50
br i1 %51, label %52, label %123
52: ; preds = %48
store i32 0, i32* %16
br label %53
53: ; preds = %116, %52
%54 = load i32, i32* %16
%55 = load i32, i32* %11
%56 = icmp ult i32 %54, %55
br i1 %56, label %57, label %119
57: ; preds = %53
store i32 0, i32* %17
br label %58
58: ; preds = %112, %57
%59 = load i32, i32* %17
%60 = load i32, i32* %9
%61 = icmp ult i32 %59, %60
br i1 %61, label %62, label %115
62: ; preds = %58
%63 = load [4 x double]*, [4 x double]** %12
%64 = load i32, i32* %15
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds [4 x double], [4 x double]* %63, i64 %65
%67 = load i32, i32* %17
%68 = zext i32 %67 to i64
%69 = getelementptr inbounds [4 x double], [4 x double]* %66, i64 0, i64 %68
%70 = load double, double* %69
%71 = load [4 x double]*, [4 x double]** %13
%72 = load i32, i32* %17
%73 = zext i32 %72 to i64
%74 = getelementptr inbounds [4 x double], [4 x double]* %71, i64 %73
%75 = load i32, i32* %16
%76 = zext i32 %75 to i64
%77 = getelementptr inbounds [4 x double], [4 x double]* %74, i64 0, i64 %76
%78 = load double, double* %77
%79 = fmul double %70, %78
store double %79, double* %18
%80 = load [4 x double]*, [4 x double]** %14
%81 = load i32, i32* %15
%82 = zext i32 %81 to i64
%83 = getelementptr inbounds [4 x double], [4 x double]* %80, i64 %82
%84 = load i32, i32* %16
%85 = zext i32 %84 to i64
%86 = getelementptr inbounds [4 x double], [4 x double]* %83, i64 0, i64 %85
%87 = load double, double* %86
%88 = load [4 x double]*, [4 x double]** %12
%89 = load i32, i32* %15
%90 = zext i32 %89 to i64
%91 = getelementptr inbounds [4 x double], [4 x double]* %88, i64 %90
%92 = load i32, i32* %17
%93 = zext i32 %92 to i64
%94 = getelementptr inbounds [4 x double], [4 x double]* %91, i64 0, i64 %93
%95 = load double, double* %94
%96 = load [4 x double]*, [4 x double]** %13
%97 = load i32, i32* %17
%98 = zext i32 %97 to i64
%99 = getelementptr inbounds [4 x double], [4 x double]* %96, i64 %98
%100 = load i32, i32* %16
%101 = zext i32 %100 to i64
%102 = getelementptr inbounds [4 x double], [4 x double]* %99, i64 0, i64 %101
%103 = load double, double* %102
%104 = call double @llvm.fmuladd.f64(double %95, double %103, double %87)
%105 = load [4 x double]*, [4 x double]** %14
%106 = load i32, i32* %15
%107 = zext i32 %106 to i64
%108 = getelementptr inbounds [4 x double], [4 x double]* %105, i64 %107
%109 = load i32, i32* %16
%110 = zext i32 %109 to i64
%111 = getelementptr inbounds [4 x double], [4 x double]* %108, i64 0, i64 %110
store double %104, double* %111
br label %112
112: ; preds = %62
%113 = load i32, i32* %17
%114 = add i32 %113, 1
store i32 %114, i32* %17
br label %58
115: ; preds = %58
br label %116
116: ; preds = %115
%117 = load i32, i32* %16
%118 = add i32 %117, 1
store i32 %118, i32* %16
br label %53
119: ; preds = %53
br label %120
120: ; preds = %119
%121 = load i32, i32* %15
%122 = add i32 %121, 1
store i32 %122, i32* %15
br label %48
123: ; preds = %48
br label %126
124: ; preds = %7
%125 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
br label %126
126: ; preds = %124, %123
ret void
}

LLVM IR (-O2):
@str = [61 x i8] c"\0AError! Operation invalid, please enter with valid matrices.\00"
define void @double_matrix_multiplication(i32 %0, i32 %1, i32 %2, i32 %3, [4 x double]* nocapture %4, [4 x double]* nocapture %5, [4 x double]* nocapture %6) {
%8 = icmp eq i32 %1, %2
br i1 %8, label %9, label %104
9: ; preds = %7
%10 = icmp eq i32 %0, 0
br i1 %10, label %106, label %11
11: ; preds = %9
%12 = icmp eq i32 %3, 0
%13 = zext i32 %3 to i64
%14 = shl nuw nsw i64 %13, 3
%15 = zext i32 %0 to i64
%16 = add nsw i64 %15, -1
%17 = and i64 %15, 3
%18 = icmp ult i64 %16, 3
br i1 %18, label %36, label %19
19: ; preds = %11
%20 = and i64 %15, 4294967292
br label %21
21: ; preds = %60, %19
%22 = phi i64 [ 0, %19 ], [ %61, %60 ]
%23 = phi i64 [ 0, %19 ], [ %62, %60 ]
br i1 %12, label %60, label %24
24: ; preds = %21
%25 = getelementptr [4 x double], [4 x double]* %6, i64 %22, i64 0
%26 = bitcast double* %25 to i8*
%27 = or i64 %22, 1
%28 = getelementptr [4 x double], [4 x double]* %6, i64 %27, i64 0
%29 = bitcast double* %28 to i8*
%30 = or i64 %22, 2
%31 = getelementptr [4 x double], [4 x double]* %6, i64 %30, i64 0
%32 = bitcast double* %31 to i8*
%33 = or i64 %22, 3
%34 = getelementptr [4 x double], [4 x double]* %6, i64 %33, i64 0
%35 = bitcast double* %34 to i8*
br label %60
36: ; preds = %60, %11
%37 = phi i64 [ 0, %11 ], [ %61, %60 ]
%38 = icmp eq i64 %17, 0
br i1 %38, label %49, label %39
39: ; preds = %36, %45
%40 = phi i64 [ %46, %45 ], [ %37, %36 ]
%41 = phi i64 [ %47, %45 ], [ 0, %36 ]
br i1 %12, label %45, label %42
42: ; preds = %39
%43 = getelementptr [4 x double], [4 x double]* %6, i64 %40, i64 0
%44 = bitcast double* %43 to i8*
br label %45
45: ; preds = %42, %39
%46 = add nuw nsw i64 %40, 1
%47 = add i64 %41, 1
%48 = icmp eq i64 %47, %17
br i1 %48, label %49, label %39
49: ; preds = %45, %36
br i1 %10, label %106, label %50
50: ; preds = %49
%51 = icmp eq i32 %3, 0
%52 = icmp eq i32 %1, 0
%53 = zext i32 %0 to i64
%54 = zext i32 %3 to i64
%55 = zext i32 %1 to i64
%56 = and i64 %55, 1
%57 = icmp eq i32 %1, 1
%58 = and i64 %55, 4294967294
%59 = icmp eq i64 %56, 0
br label %64
60: ; preds = %21, %24
%61 = add nuw nsw i64 %22, 4
%62 = add i64 %23, 4
%63 = icmp eq i64 %62, %20
br i1 %63, label %36, label %21
64: ; preds = %50, %101
%65 = phi i64 [ 0, %50 ], [ %102, %101 ]
br i1 %51, label %101, label %66
66: ; preds = %64, %98
%67 = phi i64 [ %99, %98 ], [ 0, %64 ]
br i1 %52, label %98, label %68
68: ; preds = %66
%69 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 %65, i64 %67
%70 = load double, double* %69
br i1 %57, label %89, label %71
71: ; preds = %68, %71
%72 = phi double [ %85, %71 ], [ %70, %68 ]
%73 = phi i64 [ %86, %71 ], [ 0, %68 ]
%74 = phi i64 [ %87, %71 ], [ 0, %68 ]
%75 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 %65, i64 %73
%76 = load double, double* %75
%77 = getelementptr inbounds [4 x double], [4 x double]* %5, i64 %73, i64 %67
%78 = load double, double* %77
%79 = tail call double @llvm.fmuladd.f64(double %76, double %78, double %72)
store double %79, double* %69
%80 = or i64 %73, 1
%81 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 %65, i64 %80
%82 = load double, double* %81
%83 = getelementptr inbounds [4 x double], [4 x double]* %5, i64 %80, i64 %67
%84 = load double, double* %83
%85 = tail call double @llvm.fmuladd.f64(double %82, double %84, double %79)
store double %85, double* %69
%86 = add nuw nsw i64 %73, 2
%87 = add i64 %74, 2
%88 = icmp eq i64 %87, %58
br i1 %88, label %89, label %71
89: ; preds = %71, %68
%90 = phi double [ %70, %68 ], [ %85, %71 ]
%91 = phi i64 [ 0, %68 ], [ %86, %71 ]
br i1 %59, label %98, label %92
92: ; preds = %89
%93 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 %65, i64 %91
%94 = load double, double* %93
%95 = getelementptr inbounds [4 x double], [4 x double]* %5, i64 %91, i64 %67
%96 = load double, double* %95
%97 = tail call double @llvm.fmuladd.f64(double %94, double %96, double %90)
store double %97, double* %69
br label %98
98: ; preds = %92, %89, %66
%99 = add nuw nsw i64 %67, 1
%100 = icmp eq i64 %99, %54
br i1 %100, label %101, label %66
101: ; preds = %98, %64
%102 = add nuw nsw i64 %65, 1
%103 = icmp eq i64 %102, %53
br i1 %103, label %106, label %64
104: ; preds = %7
%105 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
br label %106
106: ; preds = %101, %9, %49, %104
ret void
}