#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__ fabs(double);
double L1metric(int nd, double *x, double *y, void *data) {
  (void)data;
  double t = 0.0;
  for (int k = 0; k < nd; k++) {
    t += fabs(x[k] - y[k]);
  }
  return t;
}


x86 assembly (clang, -O0):
<L1metric>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117e <L1metric+0x6e>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1136 <L1metric+0x26>
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<L1metric>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
jle    1137 <L1metric+0x27>
mov    %rdx,%r14
mov    %rsi,%r12
mov    %edi,%r15d
cmp    $0x1,%edi
jne    1140 <L1metric+0x30>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    11a5 <L1metric+0x95>
xorpd  %xmm0,%xmm0
jmp    11e0 <L1metric+0xd0>
mov    %r15d,%r13d
and    $0xfffffffe,%r13d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
nopl   (%rax)
movsd  %xmm0,0x8(%rsp)
movsd  (%r12,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
call   1030 <fabs@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
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x2,%rbx
cmp    %rbx,%r13
jne    1150 <L1metric+0x40>
test   $0x1,%r15b
je     11e0 <L1metric+0xd0>
movsd  %xmm0,0x8(%rsp)
movsd  (%r12,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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