#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 const, int);
double sqrt(double);
double mo_get_norm(const double *first, const double *second,
                   const size_t dim) {
  size_t i;
  double norm = 0;
  for (i = 0; i < dim; i++) {
    norm += pow(first[i] - second[i], 2);
  }
  return sqrt(norm);
}


x86 assembly (clang, -O0):
<mo_get_norm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1196 <mo_get_norm+0x76>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -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),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1144 <mo_get_norm+0x24>
movsd  -0x28(%rbp),%xmm0
call   1040 <sqrt@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mo_get_norm>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
xorpd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
test   %rdx,%rdx
je     120b <mo_get_norm+0xeb>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
cmp    $0x1,%rdx
jne    1155 <mo_get_norm+0x35>
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
jmp    11cf <mo_get_norm+0xaf>
mov    %r15,%r13
and    $0xfffffffffffffffe,%r13
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm1,0x8(%rsp)
movsd  (%r12,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%r12,%rbx,8),%xmm0
subsd  0x8(%r14,%rbx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
addsd  0x8(%rsp),%xmm1
add    $0x2,%rbx
cmp    %rbx,%r13
jne    1170 <mo_get_norm+0x50>
test   $0x1,%r15b
xorpd  %xmm0,%xmm0
je     120b <mo_get_norm+0xeb>
movsd  (%r12,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
mov    $0x2,%edi
movsd  %xmm1,0x8(%rsp)
call   1030 <pow@plt>
movsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     1226 <mo_get_norm+0x106>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <sqrt@plt>

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

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