#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 */
double fabs(double);
double log(double);
double bd0(double x, double np) {
  double ej, s, s1, v;
  if (fabs(x - np) < 0.1 * (x + np)) {
    v = (x - np) / (x + np);
    s = (x - np) * v;
    ej = 2 * x * v;
    v = v * v;
    for (int j = 1;; j++) {
      ej *= v;
      s1 = s + ej / ((j << 1) + 1);
      if (s1 == s)
        return (s1);
      s = s1;
    }
  }
  return (x * log(x / np) + np - x);
}


x86 assembly (clang, -O0):
<bd0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movaps 0xedd(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm2
addsd  -0x18(%rbp),%xmm2
movsd  0xeb7(%rip),%xmm0
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    1225 <bd0+0x115>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
addsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe78(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x3c(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jne    120d <bd0+0xfd>
jp     120d <bd0+0xfd>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125d <bd0+0x14d>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11b5 <bd0+0xa5>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bd0>:
sub    $0x18,%rsp
movapd %xmm0,%xmm4
movapd %xmm0,%xmm5
subsd  %xmm1,%xmm5
movapd 0xed8(%rip),%xmm2
andpd  %xmm5,%xmm2
addsd  %xmm1,%xmm0
movsd  0xed8(%rip),%xmm3
mulsd  %xmm0,%xmm3
ucomisd %xmm2,%xmm3
jbe    118b <bd0+0x7b>
movapd %xmm5,%xmm2
divsd  %xmm0,%xmm2
mulsd  %xmm2,%xmm5
addsd  %xmm4,%xmm4
mulsd  %xmm2,%xmm4
mulsd  %xmm2,%xmm2
mov    $0x3,%eax
nop
mulsd  %xmm2,%xmm4
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
movapd %xmm4,%xmm0
divsd  %xmm3,%xmm0
addsd  %xmm5,%xmm0
add    $0x2,%eax
ucomisd %xmm5,%xmm0
movapd %xmm0,%xmm5
jne    1160 <bd0+0x50>
jp     1160 <bd0+0x50>
add    $0x18,%rsp
ret
movapd %xmm4,%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm4,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
call   1030 <log@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm0
addsd  0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @bd0(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
store double %0, double* %4
store double %1, double* %5
%11 = load double, double* %4
%12 = load double, double* %5
%13 = fsub double %11, %12
%14 = call double @llvm.fabs.f64(double %13)
%15 = load double, double* %4
%16 = load double, double* %5
%17 = fadd double %15, %16
%18 = fmul double 1.000000e-01, %17
%19 = fcmp olt double %14, %18
br i1 %19, label %20, label %62
20: ; preds = %2
%21 = load double, double* %4
%22 = load double, double* %5
%23 = fsub double %21, %22
%24 = load double, double* %4
%25 = load double, double* %5
%26 = fadd double %24, %25
%27 = fdiv double %23, %26
store double %27, double* %9
%28 = load double, double* %4
%29 = load double, double* %5
%30 = fsub double %28, %29
%31 = load double, double* %9
%32 = fmul double %30, %31
store double %32, double* %7
%33 = load double, double* %4
%34 = fmul double 2.000000e+00, %33
%35 = load double, double* %9
%36 = fmul double %34, %35
store double %36, double* %6
%37 = load double, double* %9
%38 = load double, double* %9
%39 = fmul double %37, %38
store double %39, double* %9
store i32 1, i32* %10
br label %40
40: ; preds = %59, %20
%41 = load double, double* %9
%42 = load double, double* %6
%43 = fmul double %42, %41
store double %43, double* %6
%44 = load double, double* %7
%45 = load double, double* %6
%46 = load i32, i32* %10
%47 = shl i32 %46, 1
%48 = add nsw i32 %47, 1
%49 = sitofp i32 %48 to double
%50 = fdiv double %45, %49
%51 = fadd double %44, %50
store double %51, double* %8
%52 = load double, double* %8
%53 = load double, double* %7
%54 = fcmp oeq double %52, %53
br i1 %54, label %55, label %57
55: ; preds = %40
%56 = load double, double* %8
store double %56, double* %3
br label %72
57: ; preds = %40
%58 = load double, double* %8
store double %58, double* %7
br label %59
59: ; preds = %57
%60 = load i32, i32* %10
%61 = add nsw i32 %60, 1
store i32 %61, i32* %10
br label %40
62: ; preds = %2
%63 = load double, double* %4
%64 = load double, double* %4
%65 = load double, double* %5
%66 = fdiv double %64, %65
%67 = call double @log(double %66)
%68 = load double, double* %5
%69 = call double @llvm.fmuladd.f64(double %63, double %67, double %68)
%70 = load double, double* %4
%71 = fsub double %69, %70
store double %71, double* %3
br label %72
72: ; preds = %62, %55
%73 = load double, double* %3
ret double %73
}

LLVM IR (-O2):
define double @bd0(double %0, double %1) {
%3 = fsub double %0, %1
%4 = tail call double @llvm.fabs.f64(double %3)
%5 = fadd double %0, %1
%6 = fmul double %5, 1.000000e-01
%7 = fcmp olt double %4, %6
br i1 %7, label %8, label %26
8: ; preds = %2
%9 = fdiv double %3, %5
%10 = fmul double %3, %9
%11 = fmul double %0, 2.000000e+00
%12 = fmul double %11, %9
%13 = fmul double %9, %9
br label %14
14: ; preds = %14, %8
%15 = phi double [ %12, %8 ], [ %18, %14 ]
%16 = phi double [ %10, %8 ], [ %23, %14 ]
%17 = phi i32 [ 1, %8 ], [ %25, %14 ]
%18 = fmul double %13, %15
%19 = shl nuw i32 %17, 1
%20 = or i32 %19, 1
%21 = sitofp i32 %20 to double
%22 = fdiv double %18, %21
%23 = fadd double %16, %22
%24 = fcmp oeq double %23, %16
%25 = add nuw nsw i32 %17, 1
br i1 %24, label %31, label %14
26: ; preds = %2
%27 = fdiv double %0, %1
%28 = tail call double @log(double %27)
%29 = tail call double @llvm.fmuladd.f64(double %0, double %28, double %1)
%30 = fsub double %29, %0
br label %31
31: ; preds = %14, %26
%32 = phi double [ %30, %26 ], [ %23, %14 ]
ret double %32
}