#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 /*<<< orphan*/ add_to_array(int);
double ceil(int);
double floor(int);
int /*<<< orphan*/ make_general_hdl(int);
int /*<<< orphan*/ make_hdl(int, double, double);
void hybrid1_ks(int n) {
  double l, h;
  if (n < 29) {
    add_to_array(n);
    make_general_hdl(n);
    return;
  }
  h = floor(n / 2.0);
  l = ceil(n / 2.0);
  add_to_array(n);
  make_hdl(n, l, h);
  hybrid1_ks(l);
  hybrid1_ks(h);
}


x86 assembly (clang, -O0):
<hybrid1_ks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1d,-0x4(%rbp)
jge    118a <hybrid1_ks+0x2a>
mov    -0x4(%rbp),%edi
call   1060 <add_to_array@plt>
mov    -0x4(%rbp),%edi
call   1070 <make_general_hdl@plt>
jmp    11f6 <hybrid1_ks+0x96>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe69(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1080 <floor@plt>
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe4a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ceil@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <add_to_array@plt>
mov    -0x4(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <make_hdl@plt>
cvttsd2si -0x10(%rbp),%edi
call   1050 <hybrid1_ks@plt>
cvttsd2si -0x18(%rbp),%edi
call   1050 <hybrid1_ks@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hybrid1_ks>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
cmp    $0x1d,%edi
jl     11cd <hybrid1_ks+0x6d>
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe81(%rip),%xmm0
cvttsd2si %xmm0,%ebp
mov    %ebp,%edi
call   1080 <floor@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
call   1030 <ceil@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1060 <add_to_array@plt>
mov    %ebx,%edi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1040 <make_hdl@plt>
cvttsd2si 0x8(%rsp),%edi
call   1050 <hybrid1_ks@plt>
cvttsd2si 0x10(%rsp),%ebx
cmp    $0x1d,%ebx
jge    1170 <hybrid1_ks+0x10>
mov    %ebx,%edi
call   1060 <add_to_array@plt>
mov    %ebx,%edi
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <make_general_hdl@plt>

LLVM IR (-O0):
define void @hybrid1_ks(i32 %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 29
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* %2
%9 = call i32 @add_to_array(i32 %8)
%10 = load i32, i32* %2
%11 = call i32 @make_general_hdl(i32 %10)
br label %33
12: ; preds = %1
%13 = load i32, i32* %2
%14 = sitofp i32 %13 to double
%15 = fdiv double %14, 2.000000e+00
%16 = fptosi double %15 to i32
%17 = call double @floor(i32 %16)
store double %17, double* %4
%18 = load i32, i32* %2
%19 = sitofp i32 %18 to double
%20 = fdiv double %19, 2.000000e+00
%21 = fptosi double %20 to i32
%22 = call double @ceil(i32 %21)
store double %22, double* %3
%23 = load i32, i32* %2
%24 = call i32 @add_to_array(i32 %23)
%25 = load i32, i32* %2
%26 = load double, double* %3
%27 = load double, double* %4
%28 = call i32 @make_hdl(i32 %25, double %26, double %27)
%29 = load double, double* %3
%30 = fptosi double %29 to i32
%31 = load double, double* %4
%32 = fptosi double %31 to i32
br label %33
33: ; preds = %12, %7
ret void
}

LLVM IR (-O2):
define void @hybrid1_ks(i32 %0) {
%2 = icmp slt i32 %0, 29
br i1 %2, label %3, label %7
3: ; preds = %7, %1
%4 = phi i32 [ %0, %1 ], [ %17, %7 ]
%5 = tail call i32 @add_to_array(i32 %4)
%6 = tail call i32 @make_general_hdl(i32 %4)
ret void
7: ; preds = %1, %7
%8 = phi i32 [ %17, %7 ], [ %0, %1 ]
%9 = sitofp i32 %8 to double
%10 = fmul double %9, 5.000000e-01
%11 = fptosi double %10 to i32
%12 = tail call double @floor(i32 %11)
%13 = tail call double @ceil(i32 %11)
%14 = tail call i32 @add_to_array(i32 %8)
%15 = tail call i32 @make_hdl(i32 %8, double %13, double %12)
%16 = fptosi double %13 to i32
tail call void @hybrid1_ks(i32 %16)
%17 = fptosi double %12 to i32
%18 = icmp slt i32 %17, 29
br i1 %18, label %3, label %7
}