#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 */
double sqrt(double);
double stub1(double, double, double);
double Norm_l2(double *a, int Dim, double *X, double *Y, double t,
               double (*f)(double tt, double x1, double x2)) {
  int m;
  double norm = 0.;
  double tmp;
  for (m = 0; m < Dim; m++) {
    tmp = a[m] - (*f)(t, X[m], Y[m]);
    norm += tmp * tmp;
  }
  return sqrt(norm / Dim);
}


x86 assembly (clang, -O0):
<Norm_l2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bd <Norm_l2+0xad>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x30(%rbp),%rax
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm1
mov    -0x20(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm2
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    113f <Norm_l2+0x2f>
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Norm_l2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xorpd  %xmm1,%xmm1
mov    %esi,0xc(%rsp)
test   %esi,%esi
jle    119a <Norm_l2+0x8a>
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rdi,%rbp
mov    0xc(%rsp),%ebx
xorpd  %xmm1,%xmm1
xor    %r14d,%r14d
movsd  %xmm0,0x10(%rsp)
nopw   0x0(%rax,%rax,1)
movsd  %xmm1,0x20(%rsp)
movsd  0x0(%rbp,%r14,8),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x0(%r13,%r14,8),%xmm1
movsd  (%r12,%r14,8),%xmm2
movsd  0x10(%rsp),%xmm0
call   *%r15
movsd  0x20(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
subsd  %xmm0,%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm2,%xmm1
add    $0x1,%r14
cmp    %r14,%rbx
jne    1150 <Norm_l2+0x40>
xorps  %xmm0,%xmm0
cvtsi2sdl 0xc(%rsp),%xmm0
divsd  %xmm0,%xmm1
ucomisd 0xe51(%rip),%xmm1
jb     11c7 <Norm_l2+0xb7>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movapd %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <sqrt@plt>

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

LLVM IR (-O2):
define double @Norm_l2(double* nocapture %0, i32 %1, double* nocapture %2, double* nocapture %3, double %4, double (double, double, double)* nocapture %5) {
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %24
8: ; preds = %6
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %22, %10 ]
%12 = phi double [ 0.000000e+00, %8 ], [ %21, %10 ]
%13 = getelementptr inbounds double, double* %0, i64 %11
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %2, i64 %11
%16 = load double, double* %15
%17 = getelementptr inbounds double, double* %3, i64 %11
%18 = load double, double* %17
%19 = tail call double %5(double %4, double %16, double %18)
%20 = fsub double %14, %19
%21 = tail call double @llvm.fmuladd.f64(double %20, double %20, double %12)
%22 = add nuw nsw i64 %11, 1
%23 = icmp eq i64 %22, %9
br i1 %23, label %24, label %10
24: ; preds = %10, %6
%25 = phi double [ 0.000000e+00, %6 ], [ %21, %10 ]
%26 = sitofp i32 %1 to double
%27 = fdiv double %25, %26
%28 = tail call double @sqrt(double %27)
ret double %28
}