#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 f_ha(double, double);
int fabs(double);
double f_ha_prime(double x, double a, int k) {
  if (fabs(x) > 1. / (a - 1.))
    return 0.;
  if (k == 1) {
    if (x > 0.)
      return -a * a * 0.5 * f_ha(a * x - 1., a);
    else
      return a * a * 0.5 * f_ha(a * x + 1., a);
  } else {
    if (x > 0.)
      return -a * a * 0.5 * f_ha_prime(a * x - 1., a, k - 1);
    else
      return a * a * 0.5 * f_ha_prime(a * x + 1., a, k - 1);
  }
}


x86 assembly (clang, -O0):
<f_ha_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xea0(%rip),%xmm1
subsd  %xmm1,%xmm2
movsd  0xe94(%rip),%xmm1
divsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    1187 <f_ha_prime+0x57>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    133e <f_ha_prime+0x20e>
cmpl   $0x1,-0x1c(%rbp)
jne    1264 <f_ha_prime+0x134>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    120f <f_ha_prime+0xdf>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe3c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe25(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <f_ha@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    133e <f_ha_prime+0x20e>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xde7(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdc0(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <f_ha@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    133e <f_ha_prime+0x20e>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12e8 <f_ha_prime+0x1b8>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xd69(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd52(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
mov    -0x1c(%rbp),%edi
sub    $0x1,%edi
call   1040 <f_ha_prime@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    133e <f_ha_prime+0x20e>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xd0e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xce7(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
mov    -0x1c(%rbp),%edi
sub    $0x1,%edi
call   1040 <f_ha_prime@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_ha_prime>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1030 <fabs@plt>
movsd  0x18(%rsp),%xmm1
cvtsi2sd %eax,%xmm3
movsd  0xea6(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  0xea2(%rip),%xmm2
divsd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm3
ja     1239 <f_ha_prime+0x109>
xorpd  %xmm0,%xmm0
cmp    $0x1,%ebx
jne    11ba <f_ha_prime+0x8a>
movsd  0x10(%rsp),%xmm2
ucomisd %xmm0,%xmm2
movapd %xmm2,%xmm0
movapd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
jbe    11ee <f_ha_prime+0xbe>
mulsd  0xe77(%rip),%xmm2
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm1,%xmm0
addsd  0xe4d(%rip),%xmm0
call   1050 <f_ha@plt>
jmp    1233 <f_ha_prime+0x103>
movsd  0x10(%rsp),%xmm2
ucomisd %xmm0,%xmm2
movapd %xmm2,%xmm0
movapd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
jbe    120f <f_ha_prime+0xdf>
mulsd  0xe3e(%rip),%xmm2
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm1,%xmm0
addsd  0xe14(%rip),%xmm0
jmp    1229 <f_ha_prime+0xf9>
mulsd  0xe1a(%rip),%xmm2
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm1,%xmm0
addsd  0xe00(%rip),%xmm0
call   1050 <f_ha@plt>
jmp    1233 <f_ha_prime+0x103>
mulsd  0xdf9(%rip),%xmm2
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm1,%xmm0
addsd  0xddf(%rip),%xmm0
add    $0xffffffff,%ebx
mov    %ebx,%edi
call   1040 <f_ha_prime@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define double @f_ha_prime(double %0, double %1, i32 %2) {
%4 = tail call i32 @fabs(double %0)
%5 = sitofp i32 %4 to double
%6 = fadd double %1, -1.000000e+00
%7 = fdiv double 1.000000e+00, %6
%8 = fcmp olt double %7, %5
br i1 %8, label %27, label %9
9: ; preds = %3
%10 = icmp eq i32 %2, 1
%11 = fcmp ogt double %0, 0.000000e+00
br i1 %10, label %12, label %26
12: ; preds = %9
br i1 %11, label %13, label %20
13: ; preds = %12
%14 = fneg double %1
%15 = fmul double %14, %1
%16 = fmul double %15, 5.000000e-01
%17 = tail call double @llvm.fmuladd.f64(double %1, double %0, double -1.000000e+00)
%18 = tail call double @f_ha(double %17, double %1)
%19 = fmul double %16, %18
br label %27
20: ; preds = %12
%21 = fmul double %1, %1
%22 = fmul double %21, 5.000000e-01
%23 = tail call double @llvm.fmuladd.f64(double %1, double %0, double 1.000000e+00)
%24 = tail call double @f_ha(double %23, double %1)
%25 = fmul double %22, %24
br label %27
26: ; preds = %9
br i1 %11, label %29, label %37
27: ; preds = %13, %20, %3, %37, %29
%28 = phi double [ %36, %29 ], [ %43, %37 ], [ %19, %13 ], [ %25, %20 ], [ 0.000000e+00, %3 ]
ret double %28
29: ; preds = %26
%30 = fneg double %1
%31 = fmul double %30, %1
%32 = fmul double %31, 5.000000e-01
%33 = tail call double @llvm.fmuladd.f64(double %1, double %0, double -1.000000e+00)
%34 = add nsw i32 %2, -1
%35 = tail call double @f_ha_prime(double %33, double %1, i32 %34)
%36 = fmul double %32, %35
br label %27
37: ; preds = %26
%38 = fmul double %1, %1
%39 = fmul double %38, 5.000000e-01
%40 = tail call double @llvm.fmuladd.f64(double %1, double %0, double 1.000000e+00)
%41 = add nsw i32 %2, -1
%42 = tail call double @f_ha_prime(double %40, double %1, i32 %41)
%43 = fmul double %39, %42
br label %27
}