#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 ceil(double n) {
  int x;
  x = (int)(n * 10) / 10;
  if (x < n) {
    if ((x + 1) >= n) {
      return x + 1;
    }
  } else if (x == n) {
    return n;
  }
  return -1;
}


x86 assembly (clang, -O0):
<ceil>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  0xeef(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1161 <ceil+0x61>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     115c <ceil+0x5c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1190 <ceil+0x90>
jmp    1189 <ceil+0x89>
cvtsi2sdl -0x14(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jne    1184 <ceil+0x84>
jp     1184 <ceil+0x84>
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1190 <ceil+0x90>
jmp    1189 <ceil+0x89>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ceil>:
movsd  0xef8(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
ucomisd %xmm1,%xmm0
jbe    1144 <ceil+0x44>
add    $0x1,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
ucomisd %xmm0,%xmm1
jb     1151 <ceil+0x51>
ret
ucomisd %xmm0,%xmm1
jne    1151 <ceil+0x51>
jp     1151 <ceil+0x51>
cvttsd2si %xmm0,%eax
ret
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @ceil(double %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca i32
store double %0, double* %3
%5 = load double, double* %3
%6 = fmul double %5, 1.000000e+01
%7 = fptosi double %6 to i32
%8 = sdiv i32 %7, 10
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = sitofp i32 %9 to double
%11 = load double, double* %3
%12 = fcmp olt double %10, %11
br i1 %12, label %13, label %23
13: ; preds = %1
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
%16 = sitofp i32 %15 to double
%17 = load double, double* %3
%18 = fcmp oge double %16, %17
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %33
22: ; preds = %13
br label %32
23: ; preds = %1
%24 = load i32, i32* %4
%25 = sitofp i32 %24 to double
%26 = load double, double* %3
%27 = fcmp oeq double %25, %26
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = load double, double* %3
%30 = fptosi double %29 to i32
store i32 %30, i32* %2
br label %33
31: ; preds = %23
br label %32
32: ; preds = %31, %22
store i32 -1, i32* %2
br label %33
33: ; preds = %32, %28, %19
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @ceil(double %0) {
%2 = fmul double %0, 1.000000e+01
%3 = fptosi double %2 to i32
%4 = sdiv i32 %3, 10
%5 = sitofp i32 %4 to double
%6 = fcmp olt double %5, %0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = add nsw i32 %4, 1
%9 = sitofp i32 %8 to double
%10 = fcmp ult double %9, %0
br i1 %10, label %15, label %16
11: ; preds = %1
%12 = fcmp oeq double %5, %0
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = fptosi double %0 to i32
br label %16
15: ; preds = %11, %7
br label %16
16: ; preds = %7, %15, %13
%17 = phi i32 [ -1, %15 ], [ %14, %13 ], [ %8, %7 ]
ret i32 %17
}