#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 floor_double(double);
double ceiling_double(double d) {
  if (d >= 0.0) {
    if (d < 0.05)
      return 0.05;
    else if (d < 0.1)
      return 0.1;
    else if (d < 0.2)
      return 0.2;
    else if (d < 0.5)
      return 0.5;
    else
      return (double)(int)(d + 0.99);
  } else {
    return -floor_double(-d);
  }
}


x86 assembly (clang, -O0):
<ceiling_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11e2 <ceiling_double+0xd2>
movsd  0xec9(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1154 <ceiling_double+0x44>
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121f <ceiling_double+0x10f>
movsd  0xeac(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1179 <ceiling_double+0x69>
movsd  0xe99(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121f <ceiling_double+0x10f>
movsd  0xe8f(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    119e <ceiling_double+0x8e>
movsd  0xe7c(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121f <ceiling_double+0x10f>
movsd  0xe72(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11c3 <ceiling_double+0xb3>
movsd  0xe5f(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121f <ceiling_double+0x10f>
movsd  0xe55(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121f <ceiling_double+0x10f>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <floor_double@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ceiling_double>:
push   %rax
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jae    1136 <ceiling_double+0x26>
xorpd  0xf0d(%rip),%xmm0
call   1030 <floor_double@plt>
movapd %xmm0,%xmm1
xorpd  0xefc(%rip),%xmm1
jmp    117e <ceiling_double+0x6e>
movsd  0xec2(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     117e <ceiling_double+0x6e>
movsd  0xebc(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     117e <ceiling_double+0x6e>
movsd  0xeb6(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     117e <ceiling_double+0x6e>
movsd  0xeb0(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     117e <ceiling_double+0x6e>
addsd  0xeaa(%rip),%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @ceiling_double(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp oge double %4, 0.000000e+00
br i1 %5, label %6, label %27
6: ; preds = %1
%7 = load double, double* %3
%8 = fcmp olt double %7, 5.000000e-02
br i1 %8, label %9, label %10
9: ; preds = %6
store double 5.000000e-02, double* %2
br label %32
10: ; preds = %6
%11 = load double, double* %3
%12 = fcmp olt double %11, 1.000000e-01
br i1 %12, label %13, label %14
13: ; preds = %10
store double 1.000000e-01, double* %2
br label %32
14: ; preds = %10
%15 = load double, double* %3
%16 = fcmp olt double %15, 2.000000e-01
br i1 %16, label %17, label %18
17: ; preds = %14
store double 2.000000e-01, double* %2
br label %32
18: ; preds = %14
%19 = load double, double* %3
%20 = fcmp olt double %19, 5.000000e-01
br i1 %20, label %21, label %22
21: ; preds = %18
store double 5.000000e-01, double* %2
br label %32
22: ; preds = %18
%23 = load double, double* %3
%24 = fadd double %23, 0x3FEFAE147AE147AE
%25 = fptosi double %24 to i32
%26 = sitofp i32 %25 to double
store double %26, double* %2
br label %32
27: ; preds = %1
%28 = load double, double* %3
%29 = fneg double %28
%30 = call double @floor_double(double %29)
%31 = fneg double %30
store double %31, double* %2
br label %32
32: ; preds = %27, %22, %21, %17, %13, %9
%33 = load double, double* %2
ret double %33
}

LLVM IR (-O2):
define double @ceiling_double(double %0) {
%2 = fcmp ult double %0, 0.000000e+00
br i1 %2, label %15, label %3
3: ; preds = %1
%4 = fcmp olt double %0, 5.000000e-02
br i1 %4, label %19, label %5
5: ; preds = %3
%6 = fcmp olt double %0, 1.000000e-01
br i1 %6, label %19, label %7
7: ; preds = %5
%8 = fcmp olt double %0, 2.000000e-01
br i1 %8, label %19, label %9
9: ; preds = %7
%10 = fcmp olt double %0, 5.000000e-01
br i1 %10, label %19, label %11
11: ; preds = %9
%12 = fadd double %0, 0x3FEFAE147AE147AE
%13 = fptosi double %12 to i32
%14 = sitofp i32 %13 to double
br label %19
15: ; preds = %1
%16 = fneg double %0
%17 = tail call double @floor_double(double %16)
%18 = fneg double %17
br label %19
19: ; preds = %9, %7, %5, %3, %15, %11
%20 = phi double [ %14, %11 ], [ %18, %15 ], [ 5.000000e-02, %3 ], [ 1.000000e-01, %5 ], [ 2.000000e-01, %7 ], [ 5.000000e-01, %9 ]
ret double %20
}