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


x86 assembly (clang, -O0):
<f_up_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xeaa(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    116d <f_up_prime+0x3d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1278 <f_up_prime+0x148>
cmpl   $0x1,-0x14(%rbp)
jne    11f9 <f_up_prime+0xc9>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11c1 <f_up_prime+0x91>
movsd  -0x10(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xe7e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <f_up@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe5d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1278 <f_up_prime+0x148>
movsd  -0x10(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xe2e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <f_up@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe1d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1278 <f_up_prime+0x148>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1244 <f_up_prime+0x114>
movsd  -0x10(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xdfc(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
call   1050 <f_up_prime@plt>
movaps %xmm0,%xmm1
movsd  0xdda(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1278 <f_up_prime+0x148>
movsd  -0x10(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xdab(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x14(%rbp),%edi
sub    $0x1,%edi
call   1050 <f_up_prime@plt>
movaps %xmm0,%xmm1
movsd  0xd99(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_up_prime>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movsd  %xmm0,0x8(%rsp)
call   1040 <fabs@plt>
xorpd  %xmm0,%xmm0
cmp    $0x1,%eax
jg     11ee <f_up_prime+0xbe>
xorpd  %xmm0,%xmm0
cmp    $0x1,%ebx
jne    118e <f_up_prime+0x5e>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
addsd  %xmm1,%xmm0
jbe    11be <f_up_prime+0x8e>
addsd  0xe94(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <f_up@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe84(%rip),%xmm0
jmp    11ee <f_up_prime+0xbe>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
addsd  %xmm1,%xmm0
jbe    11d8 <f_up_prime+0xa8>
addsd  0xe5e(%rip),%xmm0
add    $0xffffffff,%ebx
mov    %ebx,%edi
call   1050 <f_up_prime@plt>
mulsd  0xe54(%rip),%xmm0
jmp    11ee <f_up_prime+0xbe>
addsd  0xe3a(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <f_up@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
jmp    11ea <f_up_prime+0xba>
addsd  0xe20(%rip),%xmm0
add    $0xffffffff,%ebx
mov    %ebx,%edi
call   1050 <f_up_prime@plt>
addsd  %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @f_up_prime(double %0, i32 %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store double %0, double* %4
store i32 %1, i32* %5
%6 = load double, double* %4
%7 = call i32 @fabs(double %6)
%8 = sitofp i32 %7 to double
%9 = fcmp ogt double %8, 1.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %2
store double 0.000000e+00, double* %3
br label %48
11: ; preds = %2
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %31
14: ; preds = %11
%15 = load double, double* %4
%16 = fcmp ogt double %15, 0.000000e+00
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load double, double* %4
%19 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %18, double -1.000000e+00)
%20 = fptosi double %19 to i32
%21 = call i32 @f_up(i32 %20)
%22 = sitofp i32 %21 to double
%23 = fmul double -2.000000e+00, %22
store double %23, double* %3
br label %48
24: ; preds = %14
%25 = load double, double* %4
%26 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %25, double 1.000000e+00)
%27 = fptosi double %26 to i32
%28 = call i32 @f_up(i32 %27)
%29 = sitofp i32 %28 to double
%30 = fmul double 2.000000e+00, %29
store double %30, double* %3
br label %48
31: ; preds = %11
%32 = load double, double* %4
%33 = fcmp ogt double %32, 0.000000e+00
br i1 %33, label %34, label %41
34: ; preds = %31
%35 = load double, double* %4
%36 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %35, double -1.000000e+00)
%37 = load i32, i32* %5
%38 = sub nsw i32 %37, 1
%39 = call double @f_up_prime(double %36, i32 %38)
%40 = fmul double -2.000000e+00, %39
store double %40, double* %3
br label %48
41: ; preds = %31
%42 = load double, double* %4
%43 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %42, double 1.000000e+00)
%44 = load i32, i32* %5
%45 = sub nsw i32 %44, 1
%46 = call double @f_up_prime(double %43, i32 %45)
%47 = fmul double 2.000000e+00, %46
store double %47, double* %3
br label %48
48: ; preds = %41, %34, %24, %17, %10
%49 = load double, double* %3
ret double %49
}

LLVM IR (-O2):
define double @f_up_prime(double %0, i32 %1) {
%3 = tail call i32 @fabs(double %0)
%4 = icmp sgt i32 %3, 1
br i1 %4, label %22, label %5
5: ; preds = %2
%6 = icmp eq i32 %1, 1
%7 = fcmp ogt double %0, 0.000000e+00
br i1 %6, label %8, label %21
8: ; preds = %5
br i1 %7, label %9, label %15
9: ; preds = %8
%10 = tail call double @llvm.fmuladd.f64(double %0, double 2.000000e+00, double -1.000000e+00)
%11 = fptosi double %10 to i32
%12 = tail call i32 @f_up(i32 %11)
%13 = sitofp i32 %12 to double
%14 = fmul double %13, -2.000000e+00
br label %22
15: ; preds = %8
%16 = tail call double @llvm.fmuladd.f64(double %0, double 2.000000e+00, double 1.000000e+00)
%17 = fptosi double %16 to i32
%18 = tail call i32 @f_up(i32 %17)
%19 = sitofp i32 %18 to double
%20 = fmul double %19, 2.000000e+00
br label %22
21: ; preds = %5
br i1 %7, label %24, label %29
22: ; preds = %9, %15, %2, %29, %24
%23 = phi double [ %28, %24 ], [ %33, %29 ], [ %14, %9 ], [ %20, %15 ], [ 0.000000e+00, %2 ]
ret double %23
24: ; preds = %21
%25 = tail call double @llvm.fmuladd.f64(double %0, double 2.000000e+00, double -1.000000e+00)
%26 = add nsw i32 %1, -1
%27 = tail call double @f_up_prime(double %25, i32 %26)
%28 = fmul double %27, -2.000000e+00
br label %22
29: ; preds = %21
%30 = tail call double @llvm.fmuladd.f64(double %0, double 2.000000e+00, double 1.000000e+00)
%31 = add nsw i32 %1, -1
%32 = tail call double @f_up_prime(double %30, i32 %31)
%33 = fmul double %32, 2.000000e+00
br label %22
}