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


x86 assembly (clang, -O0):
<chebyshev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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     1229 <chebyshev+0x109>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    1187 <chebyshev+0x67>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    119c <chebyshev+0x7c>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
call   1040 <FLT_GT@plt>
cmp    $0x0,%rax
je     11e6 <chebyshev+0xc6>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
call   1040 <FLT_GT@plt>
cmp    $0x0,%rax
je     1224 <chebyshev+0x104>
movsd  -0x38(%rbp),%xmm0
lea    0xdf0(%rip),%rdi
call   1030 <debug@plt>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1244 <chebyshev+0x124>
jmp    1145 <chebyshev+0x25>
movsd  -0x38(%rbp),%xmm0
lea    0xde4(%rip),%rdi
call   1030 <debug@plt>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chebyshev>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r15
add    $0xffffffff,%r12d
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %ebx,%ebx
jmp    1180 <chebyshev+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1040 <FLT_GT@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    11db <chebyshev+0xbb>
cmp    %ebx,%r12d
je     11e4 <chebyshev+0xc4>
movsd  (%r15,%rbx,8),%xmm3
movsd  (%r14,%rbx,8),%xmm0
movapd %xmm3,%xmm1
subsd  %xmm0,%xmm1
movapd %xmm0,%xmm2
subsd  %xmm3,%xmm2
cmpltsd %xmm3,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
movapd %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1040 <FLT_GT@plt>
movsd  0x8(%rsp),%xmm0
test   %rax,%rax
je     1160 <chebyshev+0x40>
movaps 0x20(%rsp),%xmm0
jmp    1160 <chebyshev+0x40>
lea    0xe1e(%rip),%rdi
jmp    11eb <chebyshev+0xcb>
lea    0xe2e(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <debug@plt>
movsd  0x8(%rsp),%xmm0
add    $0x38,%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 @chebyshev(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
%13 = 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 %14
14: ; preds = %59, %5
%15 = load i32, i32* %9
%16 = add nsw i32 %15, -1
store i32 %16, i32* %9
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %60
18: ; preds = %14
%19 = load double*, double** %7
%20 = load double, double* %19
%21 = load double*, double** %8
%22 = load double, double* %21
%23 = fcmp ogt double %20, %22
br i1 %23, label %24, label %30
24: ; preds = %18
%25 = load double*, double** %7
%26 = load double, double* %25
%27 = load double*, double** %8
%28 = load double, double* %27
%29 = fsub double %26, %28
br label %36
30: ; preds = %18
%31 = load double*, double** %8
%32 = load double, double* %31
%33 = load double*, double** %7
%34 = load double, double* %33
%35 = fsub double %32, %34
br label %36
36: ; preds = %30, %24
%37 = phi double [ %29, %24 ], [ %35, %30 ]
store double %37, double* %13
%38 = load double*, double** %7
%39 = getelementptr inbounds double, double* %38, i32 1
store double* %39, double** %7
%40 = load double*, double** %8
%41 = getelementptr inbounds double, double* %40, i32 1
store double* %41, double** %8
%42 = load double, double* %13
%43 = load double, double* %12
%44 = load double, double* %11
%45 = call i64 @FLT_GT(double %42, double %43, double %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %36
%48 = load double, double* %13
store double %48, double* %12
br label %49
49: ; preds = %47, %36
%50 = load double, double* %12
%51 = load double, double* %10
%52 = load double, double* %11
%53 = call i64 @FLT_GT(double %50, double %51, double %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %49
%56 = load double, double* %12
%57 = call i32 @debug(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %56)
%58 = load double, double* %12
store double %58, double* %6
br label %64
59: ; preds = %49
br label %14
60: ; preds = %14
%61 = load double, double* %12
%62 = call i32 @debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %61)
%63 = load double, double* %12
store double %63, double* %6
br label %64
64: ; preds = %60, %55
%65 = load double, double* %6
ret double %65
}

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