#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);
int ceil(int);
int /*<<< orphan*/ copy_hdl(int);
int floor(int);
int /*<<< orphan*/ make_hdl(int, int, int);
void simple_ks(int n) {
  int l;
  int h;
  if (n < 2)
    return;
  else if (n == 2 || n == 3) {
    copy_hdl(n);
    add_to_array(n);
    return;
  }
  h = floor(n / 2.0);
  l = ceil(n / 2.0);
  add_to_array(n);
  make_hdl(n, l, h);
  simple_ks(l);
  simple_ks(h);
}


x86 assembly (clang, -O0):
<simple_ks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    117a <simple_ks+0x1a>
jmp    1208 <simple_ks+0xa8>
cmpl   $0x2,-0x4(%rbp)
je     118e <simple_ks+0x2e>
cmpl   $0x3,-0x4(%rbp)
jne    11a3 <simple_ks+0x43>
mov    -0x4(%rbp),%edi
call   1060 <copy_hdl@plt>
mov    -0x4(%rbp),%edi
call   1070 <add_to_array@plt>
jmp    1208 <simple_ks+0xa8>
jmp    11a8 <simple_ks+0x48>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe4b(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1080 <floor@plt>
mov    %eax,-0xc(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe2e(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ceil@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <add_to_array@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <make_hdl@plt>
mov    -0x8(%rbp),%edi
call   1050 <simple_ks@plt>
mov    -0xc(%rbp),%edi
call   1050 <simple_ks@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_ks>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x2,%edi
jl     11c3 <simple_ks+0x63>
mov    %edi,%ebx
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
je     11c8 <simple_ks+0x68>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe77(%rip),%xmm0
cvttsd2si %xmm0,%ebp
mov    %ebp,%edi
call   1080 <floor@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1030 <ceil@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1070 <add_to_array@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <make_hdl@plt>
mov    %ebp,%edi
call   1050 <simple_ks@plt>
mov    %r14d,%ebx
cmp    $0x1,%r14d
jg     1170 <simple_ks+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %ebx,%edi
call   1060 <copy_hdl@plt>
mov    %ebx,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <add_to_array@plt>

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

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