#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__ floor(double);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
char *floattotime(double f) {
  static char buf[100];
  int hh, mm, ss, i;
  f -= floor(f);
  i = f * (24 * 60 * 60);
  hh = i / (60 * 60);
  i %= (60 * 60);
  mm = i / (60);
  i %= (60);
  ss = i;
  sprintf(buf, "%02d:%02d:%02d", hh, mm, ss);
  return (buf);
}


x86 assembly (clang, -O0):
<floattotime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
cvtsi2sd %rax,%xmm1
movsd  -0x8(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xeae(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0x2e93(%rip),%rdi
lea    0xe54(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2e80(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floattotime>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xeb6(%rip),%xmm1
cvttsd2si %xmm1,%eax
cltq
imul   $0xffffffff91a2b3c5,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%ecx
shr    $0x1f,%ecx
sar    $0xb,%edx
add    %ecx,%edx
imul   $0xe10,%edx,%ecx
sub    %ecx,%eax
movswl %ax,%ecx
imul   $0xffff8889,%ecx,%ecx
shr    $0x10,%ecx
add    %eax,%ecx
movzwl %cx,%ecx
movswl %cx,%esi
shr    $0xf,%ecx
sar    $0x5,%esi
add    %ecx,%esi
movswl %si,%ecx
imul   $0x3c,%esi,%esi
sub    %esi,%eax
movswl %ax,%r8d
lea    0x2ea2(%rip),%rbx
lea    0xe63(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@floattotime.buf = internal global [100 x i8] zeroinitializer
@.str = [15 x i8] c"%02d:%02d:%02d\00"
define i8* @floattotime(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store double %0, double* %2
%7 = load double, double* %2
%8 = call i64 @floor(double %7)
%9 = sitofp i64 %8 to double
%10 = load double, double* %2
%11 = fsub double %10, %9
store double %11, double* %2
%12 = load double, double* %2
%13 = fmul double %12, 8.640000e+04
%14 = fptosi double %13 to i32
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = sdiv i32 %15, 3600
store i32 %16, i32* %3
%17 = load i32, i32* %6
%18 = srem i32 %17, 3600
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = sdiv i32 %19, 60
store i32 %20, i32* %4
%21 = load i32, i32* %6
%22 = srem i32 %21, 60
store i32 %22, i32* %6
%23 = load i32, i32* %6
store i32 %23, i32* %5
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = call i32 @sprintf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @floattotime.buf, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25, i32 %26)
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @floattotime.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@floattotime.buf = internal global [100 x i8] zeroinitializer
@.str = [15 x i8] c"%02d:%02d:%02d\00"
define i8* @floattotime(double %0) {
%2 = tail call i64 @floor(double %0)
%3 = sitofp i64 %2 to double
%4 = fsub double %0, %3
%5 = fmul double %4, 8.640000e+04
%6 = fptosi double %5 to i32
%7 = sdiv i32 %6, 3600
%8 = srem i32 %6, 3600
%9 = trunc i32 %8 to i16
%10 = sdiv i16 %9, 60
%11 = sext i16 %10 to i32
%12 = srem i16 %9, 60
%13 = sext i16 %12 to i32
%14 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([100 x i8], [100 x i8]* @floattotime.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %11, i32 %13)
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @floattotime.buf, i64 0, i64 0)
}