#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__ lrint(int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, double);
void time_clock_from_frames(int frames, double fps, char *s) {
  int hours, mins;
  double secs;
  int temp_frames;
  hours = frames / (fps * 3600);
  temp_frames = frames - hours * 3600 * fps;
  mins = temp_frames / (fps * 60);
  frames -= lrint((hours * 3600 + mins * 60) * fps);
  secs = (double)frames / fps;
  sprintf(s, "%02d:%02d:%06.3f", hours, mins, secs);
}


x86 assembly (clang, -O0):
<time_clock_from_frames>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xec7(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
imul   $0xe10,-0x1c(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  -0x10(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  0xe67(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
imul   $0xe10,-0x1c(%rbp),%eax
imul   $0x3c,-0x20(%rbp),%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <lrint@plt>
mov    %rax,%rcx
movslq -0x4(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
movsd  -0x28(%rbp),%xmm0
lea    0xe16(%rip),%rsi
call   1040 <sprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_clock_from_frames>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
cvtsi2sd %edi,%xmm3
movsd  0xecb(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm3,%xmm2
divsd  %xmm1,%xmm2
cvttsd2si %xmm2,%r14d
imul   $0xe10,%r14d,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd %xmm0,%xmm2
movsd  %xmm0,(%rsp)
mulsd  %xmm0,%xmm1
subsd  %xmm1,%xmm3
cvttpd2dq %xmm3,%xmm0
cvtdq2pd %xmm0,%xmm0
movsd  0xe93(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ebp
imul   $0x3c,%ebp,%ecx
add    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mov    %rsi,%r15
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <lrint@plt>
sub    %eax,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
divsd  (%rsp),%xmm0
lea    0xe5e(%rip),%rsi
mov    %r15,%rdi
mov    %r14d,%edx
mov    %ebp,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"%02d:%02d:%06.3f\00"
define void @time_clock_from_frames(i32 %0, double %1, i8* %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
store i32 %0, i32* %4
store double %1, double* %5
store i8* %2, i8** %6
%11 = load i32, i32* %4
%12 = sitofp i32 %11 to double
%13 = load double, double* %5
%14 = fmul double %13, 3.600000e+03
%15 = fdiv double %12, %14
%16 = fptosi double %15 to i32
store i32 %16, i32* %7
%17 = load i32, i32* %4
%18 = sitofp i32 %17 to double
%19 = load i32, i32* %7
%20 = mul nsw i32 %19, 3600
%21 = sitofp i32 %20 to double
%22 = load double, double* %5
%23 = fneg double %21
%24 = call double @llvm.fmuladd.f64(double %23, double %22, double %18)
%25 = fptosi double %24 to i32
store i32 %25, i32* %10
%26 = load i32, i32* %10
%27 = sitofp i32 %26 to double
%28 = load double, double* %5
%29 = fmul double %28, 6.000000e+01
%30 = fdiv double %27, %29
%31 = fptosi double %30 to i32
store i32 %31, i32* %8
%32 = load i32, i32* %7
%33 = mul nsw i32 %32, 3600
%34 = load i32, i32* %8
%35 = mul nsw i32 %34, 60
%36 = add nsw i32 %33, %35
%37 = sitofp i32 %36 to double
%38 = load double, double* %5
%39 = fmul double %37, %38
%40 = fptosi double %39 to i32
%41 = call i64 @lrint(i32 %40)
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = sub nsw i64 %43, %41
%45 = trunc i64 %44 to i32
store i32 %45, i32* %4
%46 = load i32, i32* %4
%47 = sitofp i32 %46 to double
%48 = load double, double* %5
%49 = fdiv double %47, %48
store double %49, double* %9
%50 = load i8*, i8** %6
%51 = load i32, i32* %7
%52 = load i32, i32* %8
%53 = load double, double* %9
%54 = call i32 @sprintf(i8* %50, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %51, i32 %52, double %53)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"%02d:%02d:%06.3f\00"
define void @time_clock_from_frames(i32 %0, double %1, i8* nocapture writeonly %2) {
%4 = sitofp i32 %0 to double
%5 = fmul double %1, 3.600000e+03
%6 = fdiv double %4, %5
%7 = fptosi double %6 to i32
%8 = mul nsw i32 %7, 3600
%9 = sitofp i32 %8 to double
%10 = fneg double %9
%11 = tail call double @llvm.fmuladd.f64(double %10, double %1, double %4)
%12 = fptosi double %11 to i32
%13 = sitofp i32 %12 to double
%14 = fmul double %1, 6.000000e+01
%15 = fdiv double %13, %14
%16 = fptosi double %15 to i32
%17 = mul nsw i32 %16, 60
%18 = add nsw i32 %17, %8
%19 = sitofp i32 %18 to double
%20 = fmul double %19, %1
%21 = fptosi double %20 to i32
%22 = tail call i64 @lrint(i32 %21)
%23 = trunc i64 %22 to i32
%24 = sub i32 %0, %23
%25 = sitofp i32 %24 to double
%26 = fdiv double %25, %1
%27 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %16, double %26)
ret void
}