#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);
int seconds_float_to_time_string(const float secs, char *str_res) {
  int sect = (int)secs;
  if (sect < 0) {
    return 0;
  } else {
    snprintf(str_res, 10, "%.02d:%.02d:%.02d", sect / 3600, (sect % 3600) / 60,
             sect % 60);
    return 1;
  }
}


x86 assembly (clang, -O0):
<seconds_float_to_time_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
cvttss2si -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    113f <seconds_float_to_time_string+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    118e <seconds_float_to_time_string+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
mov    $0xe10,%esi
cltd
idiv   %esi
mov    %edx,%eax
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %eax,%r8d
mov    -0x14(%rbp),%eax
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %edx,%r9d
mov    $0xa,%esi
lea    0xe7e(%rip),%rdx
call   1030 <snprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seconds_float_to_time_string>:
cvttss2si %xmm0,%r9d
test   %r9d,%r9d
js     116f <seconds_float_to_time_string+0x5f>
push   %rax
mov    %r9d,%eax
mov    $0x91a2b3c5,%ecx
imul   %rax,%rcx
shr    $0x2b,%rcx
imul   $0xe10,%ecx,%edx
mov    %r9d,%esi
sub    %edx,%esi
imul   $0x8889,%esi,%r8d
shr    $0x15,%r8d
mov    $0x88888889,%edx
imul   %rax,%rdx
shr    $0x25,%rdx
imul   $0x3c,%edx,%eax
sub    %eax,%r9d
lea    0xea5(%rip),%rdx
mov    $0xa,%esi
call   1030 <snprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%.02d:%.02d:%.02d\00"
define i32 @seconds_float_to_time_string(float %0, i8* %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca i8*
%6 = alloca i32
store float %0, float* %4
store i8* %1, i8** %5
%7 = load float, float* %4
%8 = fptosi float %7 to i32
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %22
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = load i32, i32* %6
%15 = sdiv i32 %14, 3600
%16 = load i32, i32* %6
%17 = srem i32 %16, 3600
%18 = sdiv i32 %17, 60
%19 = load i32, i32* %6
%20 = srem i32 %19, 60
%21 = call i32 @snprintf(i8* %13, i32 10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %18, i32 %20)
store i32 1, i32* %3
br label %22
22: ; preds = %12, %11
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [18 x i8] c"%.02d:%.02d:%.02d\00"
define i32 @seconds_float_to_time_string(float %0, i8* %1) {
%3 = fptosi float %0 to i32
%4 = icmp slt i32 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = udiv i32 %3, 3600
%7 = urem i32 %3, 3600
%8 = trunc i32 %7 to i16
%9 = udiv i16 %8, 60
%10 = zext i16 %9 to i32
%11 = urem i32 %3, 60
%12 = tail call i32 @snprintf(i8* %1, i32 10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %10, i32 %11)
br label %13
13: ; preds = %2, %5
%14 = phi i32 [ 1, %5 ], [ 0, %2 ]
ret i32 %14
}