#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 /*<<< orphan*/ sprintf(char *, char *, int, int, double);
char const *str_time(double seconds) {
  static char string[16][50];
  static int i;
  int hours, mins = seconds / 60;
  seconds -= mins * 60;
  hours = mins / 60;
  mins -= hours * 60;
  i = (i + 1) & 15;
  sprintf(string[i], "%02i:%02i:%05.2f", hours, mins, seconds);
  return string[i];
}


x86 assembly (clang, -O0):
<str_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xed6(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
imul   $0x3c,-0x10(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  -0x8(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
imul   $0x3c,-0xc(%rbp),%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    0x31f5(%rip),%eax
add    $0x1,%eax
and    $0xf,%eax
mov    %eax,0x31e9(%rip)
movslq 0x31e2(%rip),%rax
lea    0x2ebb(%rip),%rdi
imul   $0x32,%rax,%rax
add    %rax,%rdi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
movsd  -0x8(%rbp),%xmm0
lea    0xe6a(%rip),%rsi
call   1030 <sprintf@plt>
movslq 0x31b6(%rip),%rcx
lea    0x2e8f(%rip),%rax
imul   $0x32,%rcx,%rcx
add    %rcx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_time>:
push   %rbx
movapd %xmm0,%xmm1
divsd  0xee3(%rip),%xmm1
cvttsd2si %xmm1,%eax
imul   $0x3c,%eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
subsd  %xmm1,%xmm0
cltq
imul   $0xffffffff88888889,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%ecx
shr    $0x1f,%ecx
sar    $0x5,%edx
add    %ecx,%edx
imul   $0xffffffc4,%edx,%ecx
add    %eax,%ecx
mov    0x320d(%rip),%eax
add    $0x1,%eax
and    $0xf,%eax
mov    %eax,0x3201(%rip)
imul   $0x32,%rax,%rdi
lea    0x2ed6(%rip),%rbx
add    %rbx,%rdi
lea    0xe94(%rip),%rsi
call   1030 <sprintf@plt>
movslq 0x31e0(%rip),%rax
imul   $0x32,%rax,%rax
add    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@str_time.string = internal global [16 x [50 x i8]] zeroinitializer
@str_time.i = internal global i32 0
@.str = [17 x i8] c"%02i:%02i:%05.2f\00"
define i8* @str_time(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
store double %0, double* %2
%5 = load double, double* %2
%6 = fdiv double %5, 6.000000e+01
%7 = fptosi double %6 to i32
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = mul nsw i32 %8, 60
%10 = sitofp i32 %9 to double
%11 = load double, double* %2
%12 = fsub double %11, %10
store double %12, double* %2
%13 = load i32, i32* %4
%14 = sdiv i32 %13, 60
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = mul nsw i32 %15, 60
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, %16
store i32 %18, i32* %4
%19 = load i32, i32* @str_time.i
%20 = add nsw i32 %19, 1
%21 = and i32 %20, 15
store i32 %21, i32* @str_time.i
%22 = load i32, i32* @str_time.i
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [16 x [50 x i8]], [16 x [50 x i8]]* @str_time.string, i64 0, i64 %23
%25 = getelementptr inbounds [50 x i8], [50 x i8]* %24, i64 0, i64 0
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = load double, double* %2
%29 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %27, double %28)
%30 = load i32, i32* @str_time.i
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [16 x [50 x i8]], [16 x [50 x i8]]* @str_time.string, i64 0, i64 %31
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %32, i64 0, i64 0
ret i8* %33
}

LLVM IR (-O2):
@str_time.string = internal global [16 x [50 x i8]] zeroinitializer
@str_time.i = internal unnamed_addr global i32 0
@.str = [17 x i8] c"%02i:%02i:%05.2f\00"
define i8* @str_time(double %0) {
%2 = fdiv double %0, 6.000000e+01
%3 = fptosi double %2 to i32
%4 = mul nsw i32 %3, 60
%5 = sitofp i32 %4 to double
%6 = fsub double %0, %5
%7 = sdiv i32 %3, 60
%8 = mul nsw i32 %7, -60
%9 = add i32 %8, %3
%10 = load i32, i32* @str_time.i
%11 = add nsw i32 %10, 1
%12 = and i32 %11, 15
store i32 %12, i32* @str_time.i
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds [16 x [50 x i8]], [16 x [50 x i8]]* @str_time.string, i64 0, i64 %13, i64 0
%15 = tail call i32 @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9, double %6)
%16 = load i32, i32* @str_time.i
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [16 x [50 x i8]], [16 x [50 x i8]]* @str_time.string, i64 0, i64 %17, i64 0
ret i8* %18
}