#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 ceil(double);
double floor(double);
double h2h(double h) {
  if (h < 0.0) {
    h += ceil(h / -24.0) * 24.0;
  }
  if (h >= 24.0) {
    h -= floor(h / 24.0) * 24.0;
  }
  return (h);
}


x86 assembly (clang, -O0):
<h2h>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    116b <h2h+0x4b>
movsd  -0x8(%rbp),%xmm0
movsd  0xec0(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
movsd  -0x8(%rbp),%xmm1
movsd  0xea2(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe88(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11c9 <h2h+0xa9>
movsd  -0x8(%rbp),%xmm0
movsd  0xe71(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe44(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<h2h>:
push   %rax
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1156 <h2h+0x36>
movapd %xmm1,%xmm0
divsd  0xec5(%rip),%xmm0
movsd  %xmm1,(%rsp)
call   1030 <ceil@plt>
movsd  (%rsp),%xmm1
mulsd  0xeb6(%rip),%xmm0
addsd  %xmm0,%xmm1
ucomisd 0xeaa(%rip),%xmm1
jb     1187 <h2h+0x67>
movapd %xmm1,%xmm0
divsd  0xe9c(%rip),%xmm0
movsd  %xmm1,(%rsp)
call   1040 <floor@plt>
mulsd  0xe8a(%rip),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @h2h(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = fcmp olt double %3, 0.000000e+00
br i1 %4, label %5, label %11
5: ; preds = %1
%6 = load double, double* %2
%7 = fdiv double %6, -2.400000e+01
%8 = call double @llvm.ceil.f64(double %7)
%9 = load double, double* %2
%10 = call double @llvm.fmuladd.f64(double %8, double 2.400000e+01, double %9)
store double %10, double* %2
br label %11
11: ; preds = %5, %1
%12 = load double, double* %2
%13 = fcmp oge double %12, 2.400000e+01
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load double, double* %2
%16 = fdiv double %15, 2.400000e+01
%17 = call double @llvm.floor.f64(double %16)
%18 = load double, double* %2
%19 = fneg double %17
%20 = call double @llvm.fmuladd.f64(double %19, double 2.400000e+01, double %18)
store double %20, double* %2
br label %21
21: ; preds = %14, %11
%22 = load double, double* %2
ret double %22
}

LLVM IR (-O2):
define double @h2h(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = fdiv double %0, -2.400000e+01
%5 = tail call double @llvm.ceil.f64(double %4)
%6 = tail call double @llvm.fmuladd.f64(double %5, double 2.400000e+01, double %0)
br label %7
7: ; preds = %3, %1
%8 = phi double [ %6, %3 ], [ %0, %1 ]
%9 = fcmp ult double %8, 2.400000e+01
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = fdiv double %8, 2.400000e+01
%12 = tail call double @llvm.floor.f64(double %11)
%13 = fneg double %12
%14 = tail call double @llvm.fmuladd.f64(double %13, double 2.400000e+01, double %8)
br label %15
15: ; preds = %10, %7
%16 = phi double [ %14, %10 ], [ %8, %7 ]
ret double %16
}