#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__ pow(double, int);
double matrixNorm(double **ma, double **mb, int dimension) {
  int i, j;
  double norm = 0;
  for (i = 0; i < dimension; i++) {
    for (j = 0; j < dimension; j++) {
      norm += pow((ma[i][j] - mb[i][j]), 2);
    }
  }
  return (norm);
}


x86 assembly (clang, -O0):
<matrixNorm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b5 <matrixNorm+0xa5>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a2 <matrixNorm+0x92>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1145 <matrixNorm+0x35>
jmp    11a7 <matrixNorm+0x97>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1132 <matrixNorm+0x22>
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrixNorm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
jle    1227 <matrixNorm+0x117>
mov    %rsi,%r13
mov    %rdi,%rbp
mov    %edx,%r12d
mov    %r12,0x10(%rsp)
and    $0xfffffffe,%r12d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    1152 <matrixNorm+0x42>
add    $0x1,%rbx
cmp    0x10(%rsp),%rbx
mov    %r15d,%edx
je     122b <matrixNorm+0x11b>
mov    %edx,%r15d
xor    %r14d,%r14d
cmp    $0x1,%edx
je     11d3 <matrixNorm+0xc3>
nopl   (%rax)
movsd  %xmm0,0x8(%rsp)
mov    0x0(%rbp,%rbx,8),%rax
movsd  (%rax,%r14,8),%xmm0
mov    0x0(%r13,%rbx,8),%rax
subsd  (%rax,%r14,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x0(%rbp,%rbx,8),%rax
movsd  0x8(%rax,%r14,8),%xmm0
mov    0x0(%r13,%rbx,8),%rax
subsd  0x8(%rax,%r14,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x2,%r14
cmp    %r14,%r12
jne    1160 <matrixNorm+0x50>
testb  $0x1,0x10(%rsp)
je     1140 <matrixNorm+0x30>
mov    0x0(%rbp,%rbx,8),%rax
movsd  %xmm0,0x8(%rsp)
movsd  (%rax,%r14,8),%xmm0
mov    0x0(%r13,%rbx,8),%rax
subsd  (%rax,%r14,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
jmp    1140 <matrixNorm+0x30>
xorpd  %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double @matrixNorm(double** nocapture %0, double** nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %63
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = and i64 %6, 1
%8 = icmp eq i32 %2, 1
%9 = and i64 %6, 4294967294
%10 = icmp eq i64 %7, 0
br label %11
11: ; preds = %59, %5
%12 = phi i64 [ 0, %5 ], [ %61, %59 ]
%13 = phi double [ 0.000000e+00, %5 ], [ %60, %59 ]
%14 = getelementptr inbounds double*, double** %0, i64 %12
%15 = getelementptr inbounds double*, double** %1, i64 %12
br i1 %8, label %44, label %16
16: ; preds = %11, %16
%17 = phi i64 [ %41, %16 ], [ 0, %11 ]
%18 = phi double [ %40, %16 ], [ %13, %11 ]
%19 = phi i64 [ %42, %16 ], [ 0, %11 ]
%20 = load double*, double** %14
%21 = getelementptr inbounds double, double* %20, i64 %17
%22 = load double, double* %21
%23 = load double*, double** %15
%24 = getelementptr inbounds double, double* %23, i64 %17
%25 = load double, double* %24
%26 = fsub double %22, %25
%27 = tail call i64 @pow(double %26, i32 2)
%28 = sitofp i64 %27 to double
%29 = fadd double %18, %28
%30 = or i64 %17, 1
%31 = load double*, double** %14
%32 = getelementptr inbounds double, double* %31, i64 %30
%33 = load double, double* %32
%34 = load double*, double** %15
%35 = getelementptr inbounds double, double* %34, i64 %30
%36 = load double, double* %35
%37 = fsub double %33, %36
%38 = tail call i64 @pow(double %37, i32 2)
%39 = sitofp i64 %38 to double
%40 = fadd double %29, %39
%41 = add nuw nsw i64 %17, 2
%42 = add i64 %19, 2
%43 = icmp eq i64 %42, %9
br i1 %43, label %44, label %16
44: ; preds = %16, %11
%45 = phi double [ undef, %11 ], [ %40, %16 ]
%46 = phi i64 [ 0, %11 ], [ %41, %16 ]
%47 = phi double [ %13, %11 ], [ %40, %16 ]
br i1 %10, label %59, label %48
48: ; preds = %44
%49 = load double*, double** %14
%50 = getelementptr inbounds double, double* %49, i64 %46
%51 = load double, double* %50
%52 = load double*, double** %15
%53 = getelementptr inbounds double, double* %52, i64 %46
%54 = load double, double* %53
%55 = fsub double %51, %54
%56 = tail call i64 @pow(double %55, i32 2)
%57 = sitofp i64 %56 to double
%58 = fadd double %47, %57
br label %59
59: ; preds = %44, %48
%60 = phi double [ %45, %44 ], [ %58, %48 ]
%61 = add nuw nsw i64 %12, 1
%62 = icmp eq i64 %61, %6
br i1 %62, label %63, label %11
63: ; preds = %59, %3
%64 = phi double [ 0.000000e+00, %3 ], [ %60, %59 ]
ret double %64
}