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


x86 assembly (clang, -O0):
<frob_norm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11af <frob_norm+0x8f>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119c <frob_norm+0x7c>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1154 <frob_norm+0x34>
jmp    11a1 <frob_norm+0x81>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <frob_norm+0x21>
movsd  -0x18(%rbp),%xmm0
call   1040 <sqrt@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frob_norm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,0x14(%rsp)
xorpd  %xmm0,%xmm0
test   %esi,%esi
jle    12b7 <frob_norm+0x197>
mov    %rdi,%rbx
mov    %esi,%eax
mov    %rax,0x20(%rsp)
mov    0x14(%rsp),%ebp
lea    -0x1(%rbp),%rax
mov    %rax,0x18(%rsp)
mov    %ebp,%r15d
and    $0x3,%r15d
and    $0xfffffffc,%ebp
xorpd  %xmm0,%xmm0
xor    %r12d,%r12d
jmp    117f <frob_norm+0x5f>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    0x20(%rsp),%r12
je     12b7 <frob_norm+0x197>
cmpl   $0x0,0x14(%rsp)
jle    1170 <frob_norm+0x50>
cmpq   $0x3,0x18(%rsp)
jae    11a0 <frob_norm+0x80>
xor    %r14d,%r14d
jmp    1260 <frob_norm+0x140>
cs nopw 0x0(%rax,%rax,1)
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm0,0x8(%rsp)
mov    (%rbx,%r12,8),%rax
movsd  (%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    (%rbx,%r12,8),%rax
movsd  0x8(%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    (%rbx,%r12,8),%rax
movsd  0x10(%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    (%rbx,%r12,8),%rax
movsd  0x18(%rax,%r14,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x4,%r14
cmp    %r14,%rbp
jne    11b0 <frob_norm+0x90>
test   %r15,%r15
je     1170 <frob_norm+0x50>
mov    %r15,%r13
nopl   0x0(%rax)
movsd  %xmm0,0x8(%rsp)
mov    (%rbx,%r12,8),%rax
movsd  (%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
add    $0x1,%r14
add    $0xffffffffffffffff,%r13
jne    1270 <frob_norm+0x150>
jmp    1170 <frob_norm+0x50>
ucomisd 0xd41(%rip),%xmm0
jb     12d4 <frob_norm+0x1b4>
sqrtsd %xmm0,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <sqrt@plt>

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

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