#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*/ snprintf(char *, int, char *, int, int, int);
char *time_formatting(double input, char *output) {
  int hours = input / 60 / 60;
  int minutes = (int)(input / 60) % 60;
  int seconds = (int)input % 60;
  snprintf(output, 50, "%i:%02i:%02i", hours, minutes, seconds);
  return output;
}


x86 assembly (clang, -O0):
<time_formatting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xed2(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xec6(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xeae(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
cvttsd2si -0x8(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    $0x32,%esi
lea    0xe78(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_formatting>:
push   %rbx
mov    %rdi,%rbx
movsd  0xee4(%rip),%xmm1
cvttsd2si %xmm0,%eax
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
movslq %edx,%r8
imul   $0xffffffff88888889,%r8,%rdx
shr    $0x20,%rdx
add    %r8d,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x5,%edx
add    %esi,%edx
imul   $0x3c,%edx,%edx
sub    %edx,%r8d
movslq %eax,%r9
imul   $0xffffffff88888889,%r9,%rax
shr    $0x20,%rax
add    %r9d,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x5,%eax
add    %edx,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%r9d
lea    0xe8f(%rip),%rdx
mov    $0x32,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%i:%02i:%02i\00"
define i8* @time_formatting(double %0, i8* %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store double %0, double* %3
store i8* %1, i8** %4
%8 = load double, double* %3
%9 = fdiv double %8, 6.000000e+01
%10 = fdiv double %9, 6.000000e+01
%11 = fptosi double %10 to i32
store i32 %11, i32* %5
%12 = load double, double* %3
%13 = fdiv double %12, 6.000000e+01
%14 = fptosi double %13 to i32
%15 = srem i32 %14, 60
store i32 %15, i32* %6
%16 = load double, double* %3
%17 = fptosi double %16 to i32
%18 = srem i32 %17, 60
store i32 %18, i32* %7
%19 = load i8*, i8** %4
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = call i32 @snprintf(i8* %19, i32 50, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21, i32 %22)
%24 = load i8*, i8** %4
ret i8* %24
}

LLVM IR (-O2):
@.str = [13 x i8] c"%i:%02i:%02i\00"
define i8* @time_formatting(double %0, i8* returned %1) {
%3 = fdiv double %0, 6.000000e+01
%4 = fdiv double %3, 6.000000e+01
%5 = fptosi double %4 to i32
%6 = fptosi double %3 to i32
%7 = srem i32 %6, 60
%8 = fptosi double %0 to i32
%9 = srem i32 %8, 60
%10 = tail call i32 @snprintf(i8* %1, i32 50, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7, i32 %9)
ret i8* %1
}