#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 */
unsigned int round(double);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int, unsigned int,
                           unsigned int, unsigned int);
void timetostr(char str[], double time) {
  unsigned int inttime = time;
  unsigned int tenths = round((time - inttime) * 10.0);
  unsigned int hours = inttime / 3600;
  inttime %= 3600;
  unsigned int minutes = inttime / 60;
  inttime %= 60;
  unsigned int seconds = inttime;
  sprintf(str, "%02d:%02d:%02d.%d", hours, minutes, seconds, tenths);
}


x86 assembly (clang, -O0):
<timetostr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%rax
mov    %eax,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
movsd  0xead(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <round@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x18(%rbp),%r9d
lea    0xe4e(%rip),%rsi
call   1040 <sprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timetostr>:
push   %r15
push   %r14
push   %rbx
cvttsd2si %xmm0,%rbx
mov    %ebx,%r15d
cvtsi2sd %r15,%xmm1
mov    %rdi,%r14
subsd  %xmm1,%xmm0
mulsd  0xebf(%rip),%xmm0
call   1030 <round@plt>
mov    $0x91a2b3c5,%edx
imul   %r15,%rdx
shr    $0x2b,%rdx
imul   $0xe10,%edx,%ecx
sub    %ecx,%ebx
imul   $0x8889,%ebx,%ecx
shr    $0x15,%ecx
imul   $0x3c,%ecx,%esi
sub    %esi,%ebx
movzwl %bx,%r8d
lea    0xe94(%rip),%rsi
mov    %r14,%rdi
mov    %eax,%r9d
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"%02d:%02d:%02d.%d\00"
define void @timetostr(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store double %1, double* %4
%10 = load double, double* %4
%11 = fptoui double %10 to i32
store i32 %11, i32* %5
%12 = load double, double* %4
%13 = load i32, i32* %5
%14 = uitofp i32 %13 to double
%15 = fsub double %12, %14
%16 = fmul double %15, 1.000000e+01
%17 = call i32 @round(double %16)
store i32 %17, i32* %6
%18 = load i32, i32* %5
%19 = udiv i32 %18, 3600
store i32 %19, i32* %7
%20 = load i32, i32* %5
%21 = urem i32 %20, 3600
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = udiv i32 %22, 60
store i32 %23, i32* %8
%24 = load i32, i32* %5
%25 = urem i32 %24, 60
store i32 %25, i32* %5
%26 = load i32, i32* %5
store i32 %26, i32* %9
%27 = load i8*, i8** %3
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = load i32, i32* %9
%31 = load i32, i32* %6
%32 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %28, i32 %29, i32 %30, i32 %31)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"%02d:%02d:%02d.%d\00"
define void @timetostr(i8* nocapture writeonly %0, double %1) {
%3 = fptoui double %1 to i32
%4 = uitofp i32 %3 to double
%5 = fsub double %1, %4
%6 = fmul double %5, 1.000000e+01
%7 = tail call i32 @round(double %6)
%8 = udiv i32 %3, 3600
%9 = urem i32 %3, 3600
%10 = trunc i32 %9 to i16
%11 = udiv i16 %10, 60
%12 = zext i16 %11 to i32
%13 = urem i16 %10, 60
%14 = zext i16 %13 to i32
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %12, i32 %14, i32 %7)
ret void
}