#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 cdiEncodeTime(int, int, int);
void conv_timeval(double timevalue, int *rvdate, int *rvtime) {
  int vdate = 0, vtime = 0;
  int hour, minute, second;
  int daysec;
  vdate = (int)timevalue;
  if (vdate < 0)
    daysec = (int)(-(timevalue - vdate) * 86400 + 0.01);
  else
    daysec = (int)((timevalue - vdate) * 86400 + 0.01);
  hour = daysec / 3600;
  minute = (daysec - hour * 3600) / 60;
  second = daysec - hour * 3600 - minute * 60;
  vtime = cdiEncodeTime(hour, minute, second);
  *rvdate = vdate;
  *rvtime = vtime;
}


x86 assembly (clang, -O0):
<conv_timeval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cvttsd2si -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    118e <conv_timeval+0x7e>
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
subsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe8e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8a(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
jmp    11bb <conv_timeval+0xab>
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe5c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe58(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%eax
imul   $0xe10,-0x24(%rbp),%ecx
sub    %ecx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%eax
imul   $0xe10,-0x24(%rbp),%ecx
sub    %ecx,%eax
imul   $0x3c,-0x28(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1030 <cdiEncodeTime@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_timeval>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
cvttsd2si %xmm0,%ebp
cvttpd2dq %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm0
test   %ebp,%ebp
jns    1136 <conv_timeval+0x26>
xorpd  0xeca(%rip),%xmm0
mulsd  0xed2(%rip),%xmm0
addsd  0xed2(%rip),%xmm0
cvttsd2si %xmm0,%eax
cltq
imul   $0xffffffff91a2b3c5,%rax,%rdi
shr    $0x20,%rdi
add    %eax,%edi
mov    %edi,%ecx
shr    $0x1f,%ecx
sar    $0xb,%edi
add    %ecx,%edi
imul   $0xfffff1f0,%edi,%ecx
add    %eax,%ecx
movslq %ecx,%rax
imul   $0xffffffff88888889,%rax,%rsi
shr    $0x20,%rsi
add    %eax,%esi
mov    %esi,%ecx
shr    $0x1f,%ecx
sar    $0x5,%esi
add    %ecx,%esi
imul   $0xffffffc4,%esi,%edx
add    %eax,%edx
call   1030 <cdiEncodeTime@plt>
mov    %ebp,(%rbx)
mov    %eax,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @conv_timeval(double %0, i32* %1, i32* %2) {
%4 = alloca double
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store double %0, double* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
store i32 0, i32* %7
store i32 0, i32* %8
%13 = load double, double* %4
%14 = fptosi double %13 to i32
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %3
%18 = load double, double* %4
%19 = load i32, i32* %7
%20 = sitofp i32 %19 to double
%21 = fsub double %18, %20
%22 = fneg double %21
%23 = call double @llvm.fmuladd.f64(double %22, double 8.640000e+04, double 1.000000e-02)
%24 = fptosi double %23 to i32
store i32 %24, i32* %12
br label %32
25: ; preds = %3
%26 = load double, double* %4
%27 = load i32, i32* %7
%28 = sitofp i32 %27 to double
%29 = fsub double %26, %28
%30 = call double @llvm.fmuladd.f64(double %29, double 8.640000e+04, double 1.000000e-02)
%31 = fptosi double %30 to i32
store i32 %31, i32* %12
br label %32
32: ; preds = %25, %17
%33 = load i32, i32* %12
%34 = sdiv i32 %33, 3600
store i32 %34, i32* %9
%35 = load i32, i32* %12
%36 = load i32, i32* %9
%37 = mul nsw i32 %36, 3600
%38 = sub nsw i32 %35, %37
%39 = sdiv i32 %38, 60
store i32 %39, i32* %10
%40 = load i32, i32* %12
%41 = load i32, i32* %9
%42 = mul nsw i32 %41, 3600
%43 = sub nsw i32 %40, %42
%44 = load i32, i32* %10
%45 = mul nsw i32 %44, 60
%46 = sub nsw i32 %43, %45
store i32 %46, i32* %11
%47 = load i32, i32* %9
%48 = load i32, i32* %10
%49 = load i32, i32* %11
%50 = call i32 @cdiEncodeTime(i32 %47, i32 %48, i32 %49)
store i32 %50, i32* %8
%51 = load i32, i32* %7
%52 = load i32*, i32** %5
store i32 %51, i32* %52
%53 = load i32, i32* %8
%54 = load i32*, i32** %6
store i32 %53, i32* %54
ret void
}

LLVM IR (-O2):
define void @conv_timeval(double %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = fptosi double %0 to i32
%5 = icmp slt i32 %4, 0
%6 = sitofp i32 %4 to double
%7 = fsub double %0, %6
%8 = fneg double %7
%9 = select i1 %5, double %8, double %7
%10 = tail call double @llvm.fmuladd.f64(double %9, double 8.640000e+04, double 1.000000e-02)
%11 = fptosi double %10 to i32
%12 = sdiv i32 %11, 3600
%13 = mul nsw i32 %12, -3600
%14 = add i32 %13, %11
%15 = sdiv i32 %14, 60
%16 = mul nsw i32 %15, -60
%17 = add i32 %16, %14
%18 = tail call i32 @cdiEncodeTime(i32 %12, i32 %15, i32 %17)
store i32 %4, i32* %1
store i32 %18, i32* %2
ret void
}