#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 */
typedef int /*<<< orphan*/ decimalpart;

/* Variables and functions */
int atoi(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
char *strchr(char *, char);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *seconds_to_time(float raw_seconds) {
  char *hms;
  int hours, hours_residue, minutes, seconds, milliseconds;
  hms = (char *)malloc(100);
  sprintf(hms, "%f", raw_seconds);
  hours = (int)raw_seconds / 3600;
  hours_residue = (int)raw_seconds % 3600;
  minutes = hours_residue / 60;
  seconds = hours_residue % 60;
  milliseconds = 0;
  char *pos;
  pos = strchr(hms, '.');
  int ipos = (int)(pos - hms);
  char decimalpart[15];
  memset(decimalpart, ' ', sizeof(decimalpart));
  strncpy(decimalpart, &hms[ipos + 1], 3);
  milliseconds = atoi(decimalpart);
  sprintf(hms, "%d:%d:%d.%d", hours, minutes, seconds, milliseconds);
  return hms;
}


x86 assembly (clang, -O0):
<seconds_to_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0x4(%rbp)
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
cvttss2si -0x4(%rbp),%edx
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
cvttss2si -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cvttss2si -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x34(%rbp)
lea    -0x43(%rbp),%rdi
mov    $0x20,%esi
mov    $0xf,%edx
call   1050 <memset@plt>
lea    -0x43(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
add    %rax,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
lea    -0x43(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x24(%rbp),%r9d
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seconds_to_time>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movss  %xmm0,0x4(%rsp)
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
cvttss2si 0x4(%rsp),%ebx
lea    0xe72(%rip),%rsi
mov    %rax,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <sprintf@plt>
movslq %ebx,%rax
imul   $0xffffffff91a2b3c5,%rax,%rbx
shr    $0x20,%rbx
add    %eax,%ebx
mov    %ebx,%ecx
shr    $0x1f,%ecx
sar    $0xb,%ebx
add    %ecx,%ebx
imul   $0xe10,%ebx,%ecx
sub    %ecx,%eax
movswl %ax,%ecx
imul   $0xffff8889,%ecx,%ecx
shr    $0x10,%ecx
add    %eax,%ecx
movzwl %cx,%ecx
movswl %cx,%edx
shr    $0xf,%ecx
sar    $0x5,%edx
add    %ecx,%edx
movswl %dx,%r15d
imul   $0x3c,%edx,%ecx
sub    %ecx,%eax
movswl %ax,%r12d
mov    %r14,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,%rbp
sub    %r14d,%ebp
lea    0x9(%rsp),%r13
mov    %r13,%rdi
mov    $0x20,%esi
mov    $0xf,%edx
call   1050 <memset@plt>
add    $0x1,%ebp
movslq %ebp,%rsi
add    %r14,%rsi
mov    %r13,%rdi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    %r13,%rdi
call   1070 <atoi@plt>
lea    0xdcf(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
mov    %r15d,%ecx
mov    %r12d,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
@.str.1 = [12 x i8] c"%d:%d:%d.%d\00"
define i8* @seconds_to_time(float %0) {
%2 = alloca float
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [15 x i8]
store float %0, float* %2
%12 = call i64 @malloc(i32 100)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %3
%14 = load i8*, i8** %3
%15 = load float, float* %2
%16 = fptosi float %15 to i32
%17 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load float, float* %2
%19 = fptosi float %18 to i32
%20 = sdiv i32 %19, 3600
store i32 %20, i32* %4
%21 = load float, float* %2
%22 = fptosi float %21 to i32
%23 = srem i32 %22, 3600
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = sdiv i32 %24, 60
store i32 %25, i32* %6
%26 = load i32, i32* %5
%27 = srem i32 %26, 60
store i32 %27, i32* %7
store i32 0, i32* %8
%28 = load i8*, i8** %3
%29 = call i8* @strchr(i8* %28, i8 signext 46)
store i8* %29, i8** %9
%30 = load i8*, i8** %9
%31 = load i8*, i8** %3
%32 = ptrtoint i8* %30 to i64
%33 = ptrtoint i8* %31 to i64
%34 = sub i64 %32, %33
%35 = trunc i64 %34 to i32
store i32 %35, i32* %10
%36 = getelementptr inbounds [15 x i8], [15 x i8]* %11, i64 0, i64 0
%37 = call i32 @memset(i8* %36, i8 signext 32, i32 15)
%38 = getelementptr inbounds [15 x i8], [15 x i8]* %11, i64 0, i64 0
%39 = load i8*, i8** %3
%40 = load i32, i32* %10
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %39, i64 %42
%44 = call i32 @strncpy(i8* %38, i8* %43, i32 3)
%45 = getelementptr inbounds [15 x i8], [15 x i8]* %11, i64 0, i64 0
%46 = call i32 @atoi(i8* %45)
store i32 %46, i32* %8
%47 = load i8*, i8** %3
%48 = load i32, i32* %4
%49 = load i32, i32* %6
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %47, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %48, i32 %49, i32 %50, i32 %51)
%53 = load i8*, i8** %3
ret i8* %53
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@.str.1 = [12 x i8] c"%d:%d:%d.%d\00"
define i8* @seconds_to_time(float %0) {
%2 = alloca [15 x i8]
%3 = tail call i64 @malloc(i32 100)
%4 = inttoptr i64 %3 to i8*
%5 = fptosi float %0 to i32
%6 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = sdiv i32 %5, 3600
%8 = srem i32 %5, 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 i8* @strchr(i8* dereferenceable(1) %4, i8 signext 46)
%15 = ptrtoint i8* %14 to i64
%16 = sub i64 %15, %3
%17 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%18 = call i32 @memset(i8* %17, i8 signext 32, i32 15)
%19 = shl i64 %16, 32
%20 = add i64 %19, 4294967296
%21 = ashr exact i64 %20, 32
%22 = getelementptr inbounds i8, i8* %4, i64 %21
%23 = call i32 @strncpy(i8* %17, i8* %22, i32 3)
%24 = call i32 @atoi(i8* %17)
%25 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %11, i32 %13, i32 %24)
ret i8* %4
}