#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 sqrt(double);
double mat_norm_diff(double **X1, double **X2, int m, int n) {
  int i;
  int j;
  double r = 0.0;
  for (i = 0; i < m; i++)
    for (j = 0; j < n; j++)
      r += pow(X1[i][j] - X2[i][j], 2);
  return (sqrt(r));
}


x86 assembly (clang, -O0):
<mat_norm_diff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c8 <mat_norm_diff+0xa8>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b5 <mat_norm_diff+0x95>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%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    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1158 <mat_norm_diff+0x38>
jmp    11ba <mat_norm_diff+0x9a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1145 <mat_norm_diff+0x25>
movsd  -0x28(%rbp),%xmm0
call   1040 <sqrt@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat_norm_diff>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xorpd  %xmm0,%xmm0
test   %edx,%edx
jle    123c <mat_norm_diff+0x11c>
mov    %ecx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %edx,%eax
mov    %rax,0x10(%rsp)
mov    %ecx,%r13d
mov    %r13,0x8(%rsp)
and    $0xfffffffe,%r13d
xorpd  %xmm0,%xmm0
xor    %r12d,%r12d
jmp    116f <mat_norm_diff+0x4f>
nop
add    $0x1,%r12
cmp    0x10(%rsp),%r12
je     123c <mat_norm_diff+0x11c>
test   %r14d,%r14d
jle    1160 <mat_norm_diff+0x40>
xor    %r15d,%r15d
cmp    $0x1,%r14d
je     11ed <mat_norm_diff+0xcd>
nopl   (%rax)
movsd  %xmm0,(%rsp)
mov    0x0(%rbp,%r12,8),%rax
movsd  (%rax,%r15,8),%xmm0
mov    (%rbx,%r12,8),%rax
subsd  (%rax,%r15,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    0x0(%rbp,%r12,8),%rax
movsd  0x8(%rax,%r15,8),%xmm0
mov    (%rbx,%r12,8),%rax
subsd  0x8(%rax,%r15,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
add    $0x2,%r15
cmp    %r15,%r13
jne    1180 <mat_norm_diff+0x60>
testb  $0x1,0x8(%rsp)
je     1160 <mat_norm_diff+0x40>
mov    0x0(%rbp,%r12,8),%rax
movsd  %xmm0,(%rsp)
movsd  (%rax,%r15,8),%xmm0
mov    (%rbx,%r12,8),%rax
subsd  (%rax,%r15,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
jmp    1160 <mat_norm_diff+0x40>
ucomisd 0xdbc(%rip),%xmm0
jb     1259 <mat_norm_diff+0x139>
sqrtsd %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <sqrt@plt>

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

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