#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 */
scalar_t__ ceil(double const);
double fabs(scalar_t__);
scalar_t__ floor(double const);
double oddhs_frac_part(const double x) {
  return ((fabs(x - floor(x))) < (fabs(x - ceil(x))) ? (fabs(x - floor(x)))
                                                     : (fabs(x - ceil(x))));
}


x86 assembly (clang, -O0):
<oddhs_frac_part>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <floor@plt>
movsd  -0x20(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <fabs@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <ceil@plt>
movsd  -0x18(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <fabs@plt>
movsd  -0x10(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    11df <oddhs_frac_part+0xaf>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <floor@plt>
movsd  -0x30(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <fabs@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1210 <oddhs_frac_part+0xe0>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <ceil@plt>
movsd  -0x38(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1040 <fabs@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oddhs_frac_part>:
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
call   1050 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1040 <fabs@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <ceil@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
call   1040 <fabs@plt>
ucomisd 0x10(%rsp),%xmm0
jbe    119d <oddhs_frac_part+0x6d>
movsd  0x8(%rsp),%xmm0
call   1050 <floor@plt>
jmp    11a8 <oddhs_frac_part+0x78>
movsd  0x8(%rsp),%xmm0
call   1030 <ceil@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
add    $0x18,%rsp
jmp    1040 <fabs@plt>

LLVM IR (-O0):
define double @oddhs_frac_part(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = load double, double* %2
%5 = call i64 @floor(double %4)
%6 = sitofp i64 %5 to double
%7 = fsub double %3, %6
%8 = fptosi double %7 to i64
%9 = call double @fabs(i64 %8)
%10 = load double, double* %2
%11 = load double, double* %2
%12 = call i64 @ceil(double %11)
%13 = sitofp i64 %12 to double
%14 = fsub double %10, %13
%15 = fptosi double %14 to i64
%16 = call double @fabs(i64 %15)
%17 = fcmp olt double %9, %16
br i1 %17, label %18, label %26
18: ; preds = %1
%19 = load double, double* %2
%20 = load double, double* %2
%21 = call i64 @floor(double %20)
%22 = sitofp i64 %21 to double
%23 = fsub double %19, %22
%24 = fptosi double %23 to i64
%25 = call double @fabs(i64 %24)
br label %34
26: ; preds = %1
%27 = load double, double* %2
%28 = load double, double* %2
%29 = call i64 @ceil(double %28)
%30 = sitofp i64 %29 to double
%31 = fsub double %27, %30
%32 = fptosi double %31 to i64
%33 = call double @fabs(i64 %32)
br label %34
34: ; preds = %26, %18
%35 = phi double [ %25, %18 ], [ %33, %26 ]
ret double %35
}

LLVM IR (-O2):
define double @oddhs_frac_part(double %0) {
%2 = tail call i64 @floor(double %0)
%3 = sitofp i64 %2 to double
%4 = fsub double %0, %3
%5 = fptosi double %4 to i64
%6 = tail call double @fabs(i64 %5)
%7 = tail call i64 @ceil(double %0)
%8 = sitofp i64 %7 to double
%9 = fsub double %0, %8
%10 = fptosi double %9 to i64
%11 = tail call double @fabs(i64 %10)
%12 = fcmp olt double %6, %11
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = tail call i64 @floor(double %0)
br label %17
15: ; preds = %1
%16 = tail call i64 @ceil(double %0)
br label %17
17: ; preds = %15, %13
%18 = phi i64 [ %16, %15 ], [ %14, %13 ]
%19 = sitofp i64 %18 to double
%20 = fsub double %0, %19
%21 = fptosi double %20 to i64
%22 = tail call double @fabs(i64 %21)
ret double %22
}