#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 manhattan_dist(double *x1, double *x2, int size) {
  double d = 0;
  for (int i = 0; i < size; i++)
    d += fabs(x1[i] - x2[i]);
  return (d);
}


x86 assembly (clang, -O0):
<manhattan_dist>:
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    117a <manhattan_dist+0x6a>
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
call   1030 <fabs@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1132 <manhattan_dist+0x22>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manhattan_dist>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %edx,%edx
jle    1137 <manhattan_dist+0x27>
mov    %rsi,%r14
mov    %rdi,%r12
mov    %edx,%r15d
cmp    $0x1,%edx
jne    1140 <manhattan_dist+0x30>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    11a5 <manhattan_dist+0x95>
xorpd  %xmm0,%xmm0
jmp    11e0 <manhattan_dist+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 <manhattan_dist+0x40>
test   $0x1,%r15b
je     11e0 <manhattan_dist+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 @manhattan_dist(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 = %29, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %32
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 = fsub double %18, %23
%25 = call i64 @fabs(double %24)
%26 = sitofp i64 %25 to double
%27 = load double, double* %7
%28 = fadd double %27, %26
store double %28, double* %7
br label %29
29: ; preds = %13
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %9
32: ; preds = %9
%33 = load double, double* %7
ret double %33
}

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