#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 *, float);
int /*<<< orphan*/ strcpy(char *, char *);
char *format_seconds(float seconds) {
  static char buffer[12];
  int minutes;
  minutes = (int)seconds / 60;
  seconds -= minutes * 60;
  if (minutes)
    sprintf(buffer, "%3d:", minutes);
  else
    strcpy(buffer, "    ");
  sprintf(buffer + 4, "%07.4f", seconds);
  return buffer;
}


x86 assembly (clang, -O0):
<format_seconds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
cvttss2si -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
imul   $0x3c,-0x8(%rbp),%eax
cvtsi2ss %eax,%xmm1
movss  -0x4(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     117a <format_seconds+0x5a>
cvtsi2ssl -0x8(%rbp),%xmm0
lea    0x2ec8(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1040 <sprintf@plt>
jmp    118d <format_seconds+0x6d>
lea    0x2eb0(%rip),%rdi
lea    0xe7d(%rip),%rsi
call   1030 <strcpy@plt>
movss  -0x4(%rbp),%xmm0
lea    0x2e98(%rip),%rdi
add    $0x4,%rdi
lea    0xe66(%rip),%rsi
call   1040 <sprintf@plt>
lea    0x2e81(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_seconds>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm0,0xc(%rsp)
cvttss2si %xmm0,%eax
cltq
imul   $0xffffffff88888889,%rax,%rbx
shr    $0x20,%rbx
add    %eax,%ebx
mov    %ebx,%ecx
shr    $0x1f,%ecx
sar    $0x5,%ebx
add    %ecx,%ebx
add    $0x3b,%eax
cmp    $0x77,%eax
jae    1165 <format_seconds+0x45>
lea    0x2eda(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1030 <strcpy@plt>
jmp    117f <format_seconds+0x5f>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
lea    0x2ebe(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1040 <sprintf@plt>
imul   $0x3c,%ebx,%eax
cvtsi2ss %eax,%xmm1
movss  0xc(%rsp),%xmm0
subss  %xmm1,%xmm0
lea    0x2e9e(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1040 <sprintf@plt>
lea    0x2e87(%rip),%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@format_seconds.buffer = internal global [12 x i8] zeroinitializer
@.str = [5 x i8] c"%3d:\00"
@.str.1 = [5 x i8] c" \00"
@.str.2 = [7 x i8] c"%07.4f\00"
define i8* @format_seconds(float %0) {
%2 = alloca float
%3 = alloca i32
store float %0, float* %2
%4 = load float, float* %2
%5 = fptosi float %4 to i32
%6 = sdiv i32 %5, 60
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = mul nsw i32 %7, 60
%9 = sitofp i32 %8 to float
%10 = load float, float* %2
%11 = fsub float %10, %9
store float %11, float* %2
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = load i32, i32* %3
%16 = sitofp i32 %15 to float
%17 = call i32 @sprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format_seconds.buffer, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float %16)
br label %20
18: ; preds = %1
%19 = call i32 @strcpy(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format_seconds.buffer, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = load float, float* %2
%22 = call i32 @sprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format_seconds.buffer, i64 0, i64 4), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float %21)
ret i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format_seconds.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@format_seconds.buffer = internal global [12 x i8] zeroinitializer
@.str = [5 x i8] c"%3d:\00"
@.str.1 = [5 x i8] c" \00"
@.str.2 = [7 x i8] c"%07.4f\00"
define i8* @format_seconds(float %0) {
%2 = fptosi float %0 to i32
%3 = sdiv i32 %2, 60
%4 = add i32 %2, 59
%5 = icmp ult i32 %4, 119
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = sitofp i32 %3 to float
%8 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @format_seconds.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float %7)
br label %11
9: ; preds = %1
%10 = tail call i32 @strcpy(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format_seconds.buffer, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = mul nsw i32 %3, 60
%13 = sitofp i32 %12 to float
%14 = fsub float %0, %13
%15 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @format_seconds.buffer, i64 0, i64 4), i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float %14)
ret i8* getelementptr inbounds ([12 x i8], [12 x i8]* @format_seconds.buffer, i64 0, i64 0)
}