#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 fabs(double);
int /*<<< orphan*/ printf(char *, double, double);
int sqrt(double);
double l2Norm(double *v1, double *v2, int size) {
  double myl2 = 0.;
#pragma omp parallel for reduction(+ : myl2)
  for (int ii = 0; ii < size; ++ii) {
    printf("%f %f\n", v1[ii], v2[ii]);
    myl2 += fabs(v1[ii] - v2[ii]) * (v1[ii] - v2[ii]);
  }
  return sqrt(myl2) / size;
}


x86 assembly (clang, -O0):
<l2Norm>:
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,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d3 <l2Norm+0xb3>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xe6b(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1142 <l2Norm+0x22>
movsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
cltd
idivl  -0x14(%rbp)
cvtsi2sd %eax,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<l2Norm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
test   %edx,%edx
jle    119b <l2Norm+0x7b>
mov    %rsi,%r13
mov    %rdi,%rbp
mov    %r14d,%r12d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
lea    0xec8(%rip),%r15
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
movsd  0x0(%rbp,%rbx,8),%xmm0
movsd  0x0(%r13,%rbx,8),%xmm1
mov    %r15,%rdi
call   1030 <printf@plt>
movsd  0x0(%rbp,%rbx,8),%xmm0
subsd  0x0(%r13,%rbx,8),%xmm0
movapd %xmm0,%xmm1
andpd  0xe7d(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <l2Norm+0x30>
jmp    119f <l2Norm+0x7f>
xorpd  %xmm0,%xmm0
call   1040 <sqrt@plt>
cltd
idiv   %r14d
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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