#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 */
typedef double int32_t;

/* Variables and functions */
double const copysignk(double, double);
double fabsk(double);
scalar_t__ xisinf(double);
__attribute__((visibility("default"))) const double xceil(double x) {
  double fr = x - (double)(1LL << 31) * (int32_t)(x * (1.0 / (1LL << 31)));
  fr = fr - (int32_t)fr;
  fr = fr <= 0 ? fr : fr - 1.0;
  return (xisinf(x) || fabsk(x) >= (double)(1LL << 52)) ? x
                                                        : copysignk(x - fr, x);
}


x86 assembly (clang, -O0):
<xceil>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  0xebe(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xea9(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1190 <xceil+0x60>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11a6 <xceil+0x76>
movsd  -0x10(%rbp),%xmm0
movsd  0xe73(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <xisinf@plt>
cmp    $0x0,%rax
jne    11e0 <xceil+0xb0>
movsd  -0x8(%rbp),%xmm0
call   1050 <fabsk@plt>
movsd  0xe42(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11ef <xceil+0xbf>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1208 <xceil+0xd8>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1030 <copysignk@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xceil>:
push   %rax
movsd  %xmm0,(%rsp)
call   1040 <xisinf@plt>
test   %rax,%rax
jne    11a8 <xceil+0x78>
movsd  (%rsp),%xmm0
call   1050 <fabsk@plt>
ucomisd 0xec6(%rip),%xmm0
jae    11a8 <xceil+0x78>
movsd  0xea4(%rip),%xmm0
movsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  0xe9b(%rip),%xmm0
addsd  %xmm1,%xmm0
subsd  %xmm0,%xmm0
movsd  0xe93(%rip),%xmm4
addsd  %xmm0,%xmm4
xorpd  %xmm2,%xmm2
movapd %xmm0,%xmm3
cmplesd %xmm2,%xmm3
andpd  %xmm3,%xmm0
andnpd %xmm4,%xmm3
orpd   %xmm0,%xmm3
movapd %xmm1,%xmm0
subsd  %xmm3,%xmm0
pop    %rax
jmp    1030 <copysignk@plt>
movsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @xceil(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load double, double* %2
%5 = load double, double* %2
%6 = fmul double %5, 0x3E00000000000000
%7 = call double @llvm.fmuladd.f64(double 0xC1E0000000000000, double %6, double %4)
store double %7, double* %3
%8 = load double, double* %3
%9 = load double, double* %3
%10 = fsub double %8, %9
store double %10, double* %3
%11 = load double, double* %3
%12 = fcmp ole double %11, 0.000000e+00
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = load double, double* %3
br label %18
15: ; preds = %1
%16 = load double, double* %3
%17 = fsub double %16, 1.000000e+00
br label %18
18: ; preds = %15, %13
%19 = phi double [ %14, %13 ], [ %17, %15 ]
store double %19, double* %3
%20 = load double, double* %2
%21 = call i64 @xisinf(double %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %18
%24 = load double, double* %2
%25 = call double @fabsk(double %24)
%26 = fcmp oge double %25, 0x4330000000000000
br i1 %26, label %27, label %29
27: ; preds = %23, %18
%28 = load double, double* %2
br label %35
29: ; preds = %23
%30 = load double, double* %2
%31 = load double, double* %3
%32 = fsub double %30, %31
%33 = load double, double* %2
%34 = call double @copysignk(double %32, double %33)
br label %35
35: ; preds = %29, %27
%36 = phi double [ %28, %27 ], [ %34, %29 ]
ret double %36
}

LLVM IR (-O2):
define double @xceil(double %0) {
%2 = fmul double %0, 0x3E00000000000000
%3 = tail call double @llvm.fmuladd.f64(double %2, double 0xC1E0000000000000, double %0)
%4 = fsub double %3, %3
%5 = fcmp ole double %4, 0.000000e+00
%6 = fadd double %4, -1.000000e+00
%7 = select i1 %5, double %4, double %6
%8 = tail call i64 @xisinf(double %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = tail call double @fabsk(double %0)
%12 = fcmp ult double %11, 0x4330000000000000
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = fsub double %0, %7
%15 = tail call double @copysignk(double %14, double %0)
br label %16
16: ; preds = %1, %10, %13
%17 = phi double [ %15, %13 ], [ %0, %10 ], [ %0, %1 ]
ret double %17
}