#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 */
struct tm {
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
double Frac(double);
double Round(double);
int floor(double);
void Time_of_Day(double jd, struct tm *cdate) {
  int hr, mn, sc;
  double _time;
  _time = Frac(jd - 0.5) * 8.6400E4;
  _time = Round(_time);
  hr = floor(_time / 3600.0);
  _time = _time - 3600.0 * hr;
  if (hr == 24)
    hr = 0;
  mn = floor(_time / 60.0);
  sc = _time - 60.0 * mn;
  cdate->tm_hour = hr;
  cdate->tm_min = mn;
  cdate->tm_sec = sc;
}


x86 assembly (clang, -O0):
<Time_of_Day>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xeca(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <Frac@plt>
movsd  0xeb1(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <Round@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe84(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <floor@plt>
mov    %eax,-0x14(%rbp)
movsd  -0x28(%rbp),%xmm1
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe5e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x18,-0x14(%rbp)
jne    11c0 <Time_of_Day+0x90>
movl   $0x0,-0x14(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe5b(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <floor@plt>
mov    %eax,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm1
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xe35(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Time_of_Day>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
addsd  0xec2(%rip),%xmm0
call   1030 <Frac@plt>
mulsd  0xebd(%rip),%xmm0
call   1040 <Round@plt>
movsd  %xmm0,(%rsp)
divsd  0xeb3(%rip),%xmm0
call   1050 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xea7(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %ebp,%ebp
cmp    $0x18,%eax
cmovne %eax,%ebp
divsd  0xe95(%rip),%xmm0
call   1050 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe89(%rip),%xmm0
addsd  (%rsp),%xmm0
cvttsd2si %xmm0,%ecx
mov    %ebp,(%rbx)
mov    %eax,0x4(%rbx)
mov    %ecx,0x8(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
define void @Time_of_Day(double %0, %struct.tm* %1) {
%3 = alloca double
%4 = alloca %struct.tm*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store double %0, double* %3
store %struct.tm* %1, %struct.tm** %4
%9 = load double, double* %3
%10 = fsub double %9, 5.000000e-01
%11 = call double @Frac(double %10)
%12 = fmul double %11, 8.640000e+04
store double %12, double* %8
%13 = load double, double* %8
%14 = call double @Round(double %13)
store double %14, double* %8
%15 = load double, double* %8
%16 = fdiv double %15, 3.600000e+03
%17 = call i32 @floor(double %16)
store i32 %17, i32* %5
%18 = load double, double* %8
%19 = load i32, i32* %5
%20 = sitofp i32 %19 to double
%21 = call double @llvm.fmuladd.f64(double -3.600000e+03, double %20, double %18)
store double %21, double* %8
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 24
br i1 %23, label %24, label %25
24: ; preds = %2
store i32 0, i32* %5
br label %25
25: ; preds = %24, %2
%26 = load double, double* %8
%27 = fdiv double %26, 6.000000e+01
%28 = call i32 @floor(double %27)
store i32 %28, i32* %6
%29 = load double, double* %8
%30 = load i32, i32* %6
%31 = sitofp i32 %30 to double
%32 = call double @llvm.fmuladd.f64(double -6.000000e+01, double %31, double %29)
%33 = fptosi double %32 to i32
store i32 %33, i32* %7
%34 = load i32, i32* %5
%35 = load %struct.tm*, %struct.tm** %4
%36 = getelementptr inbounds %struct.tm, %struct.tm* %35, i32 0, i32 0
store i32 %34, i32* %36
%37 = load i32, i32* %6
%38 = load %struct.tm*, %struct.tm** %4
%39 = getelementptr inbounds %struct.tm, %struct.tm* %38, i32 0, i32 1
store i32 %37, i32* %39
%40 = load i32, i32* %7
%41 = load %struct.tm*, %struct.tm** %4
%42 = getelementptr inbounds %struct.tm, %struct.tm* %41, i32 0, i32 2
store i32 %40, i32* %42
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
define void @Time_of_Day(double %0, %struct.tm* nocapture writeonly %1) {
%3 = fadd double %0, -5.000000e-01
%4 = tail call double @Frac(double %3)
%5 = fmul double %4, 8.640000e+04
%6 = tail call double @Round(double %5)
%7 = fdiv double %6, 3.600000e+03
%8 = tail call i32 @floor(double %7)
%9 = sitofp i32 %8 to double
%10 = tail call double @llvm.fmuladd.f64(double %9, double -3.600000e+03, double %6)
%11 = icmp eq i32 %8, 24
%12 = select i1 %11, i32 0, i32 %8
%13 = fdiv double %10, 6.000000e+01
%14 = tail call i32 @floor(double %13)
%15 = sitofp i32 %14 to double
%16 = tail call double @llvm.fmuladd.f64(double %15, double -6.000000e+01, double %10)
%17 = fptosi double %16 to i32
%18 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 0
store i32 %12, i32* %18
%19 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 1
store i32 %14, i32* %19
%20 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 2
store i32 %17, i32* %20
ret void
}