#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__ FLT_GT(double, double, double);
int /*<<< orphan*/ debug(char *, double);
double manhattan(double *s, double *z, int len, double bsf, double epsilon) {
  double dist = 0;
  while (--len) {
    dist += (*s > *z ? *s - *z : *z - *s);
    s++;
    z++;
    if (FLT_GT(dist, bsf, epsilon)) {
      debug(" %.6f (early abandoned)\n", dist);
      return dist;
    }
  }
  debug(" %.6f\n", dist);
  return dist;
}


x86 assembly (clang, -O0):
<manhattan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
movsd  %xmm1,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     1206 <manhattan+0xe6>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    1187 <manhattan+0x67>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    119c <manhattan+0x7c>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
call   1040 <FLT_GT@plt>
cmp    $0x0,%rax
je     1201 <manhattan+0xe1>
movsd  -0x38(%rbp),%xmm0
lea    0xe13(%rip),%rdi
call   1030 <debug@plt>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1221 <manhattan+0x101>
jmp    1145 <manhattan+0x25>
movsd  -0x38(%rbp),%xmm0
lea    0xe07(%rip),%rdi
call   1030 <debug@plt>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manhattan>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r15
add    $0xffffffff,%r12d
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xor    %ebx,%ebx
nop
cmp    %ebx,%r12d
je     11b3 <manhattan+0x93>
movsd  (%r15,%rbx,8),%xmm0
movsd  (%r14,%rbx,8),%xmm1
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movapd %xmm1,%xmm3
subsd  %xmm0,%xmm3
cmpltsd %xmm0,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm3,%xmm1
orpd   %xmm2,%xmm1
movsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1040 <FLT_GT@plt>
add    $0x1,%rbx
test   %rax,%rax
je     1150 <manhattan+0x30>
lea    0xe4f(%rip),%rdi
jmp    11ba <manhattan+0x9a>
lea    0xe5f(%rip),%rdi
movsd  (%rsp),%xmm0
call   1030 <debug@plt>
movsd  (%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [25 x i8] c" %.6f (early abandoned)\0A\00"
@.str.1 = [7 x i8] c" %.6f\0A\00"
define double @manhattan(double* nocapture %0, double* nocapture %1, i32 %2, double %3, double %4) {
br label %6
6: ; preds = %13, %5
%7 = phi double* [ %1, %5 ], [ %22, %13 ]
%8 = phi i32 [ %2, %5 ], [ %11, %13 ]
%9 = phi double* [ %0, %5 ], [ %21, %13 ]
%10 = phi double [ 0.000000e+00, %5 ], [ %20, %13 ]
%11 = add nsw i32 %8, -1
%12 = icmp eq i32 %11, 0
br i1 %12, label %27, label %13
13: ; preds = %6
%14 = load double, double* %9
%15 = load double, double* %7
%16 = fcmp ogt double %14, %15
%17 = fsub double %14, %15
%18 = fsub double %15, %14
%19 = select i1 %16, double %17, double %18
%20 = fadd double %10, %19
%21 = getelementptr inbounds double, double* %9, i64 1
%22 = getelementptr inbounds double, double* %7, i64 1
%23 = tail call i64 @FLT_GT(double %20, double %3, double %4)
%24 = icmp eq i64 %23, 0
br i1 %24, label %6, label %25
25: ; preds = %13
%26 = tail call i32 @debug(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %20)
br label %29
27: ; preds = %6
%28 = tail call i32 @debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %10)
br label %29
29: ; preds = %27, %25
%30 = phi double [ %20, %25 ], [ %10, %27 ]
ret double %30
}