#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 *, int, ...);
void printim(double elps, char *stim) {
  int hh, mm, ss;
  if (elps < 60.0)
    sprintf(stim, "%5.3lfs", elps);
  else if (elps < 3600.0) {
    mm = elps / 60.0;
    ss = (int)elps - mm * 60;
    sprintf(stim, "%dm%ds (%7.3lfs)", mm, ss, elps);
  } else {
    hh = elps / 3600;
    mm = (elps - hh * 3600) / 60;
    ss = elps - mm * 60 - hh * 3600;
    sprintf(stim, "%dh%dm%ds", hh, mm, ss);
  }
}


x86 assembly (clang, -O0):
<printim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  0xed7(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1150 <printim+0x40>
mov    -0x10(%rbp),%rdi
cvttsd2si -0x8(%rbp),%edx
lea    0xecc(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1232 <printim+0x122>
movsd  0xeb0(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11ab <printim+0x9b>
movsd  -0x8(%rbp),%xmm0
movsd  0xe90(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
cvttsd2si -0x8(%rbp),%eax
imul   $0x3c,-0x18(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
movsd  -0x8(%rbp),%xmm0
lea    0xe79(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
jmp    122d <printim+0x11d>
movsd  -0x8(%rbp),%xmm0
movsd  0xe50(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x8(%rbp),%xmm0
imul   $0xe10,-0x14(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe21(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
imul   $0x3c,-0x18(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
imul   $0xe10,-0x14(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe03(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1232 <printim+0x122>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printim>:
movsd  0xee8(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1130 <printim+0x20>
cvttsd2si %xmm0,%edx
lea    0xee7(%rip),%rsi
xor    %eax,%eax
jmp    1030 <sprintf@plt>
movsd  0xed0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1165 <printim+0x55>
movapd %xmm0,%xmm1
divsd  0xeb6(%rip),%xmm1
cvttsd2si %xmm1,%edx
cvttsd2si %xmm0,%eax
imul   $0xffffffc4,%edx,%ecx
add    %eax,%ecx
lea    0xeba(%rip),%rsi
mov    $0x1,%al
jmp    1030 <sprintf@plt>
movapd %xmm0,%xmm1
divsd  0xe97(%rip),%xmm1
cvttsd2si %xmm1,%edx
imul   $0xe10,%edx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
divsd  0xe6e(%rip),%xmm2
cvttsd2si %xmm2,%ecx
imul   $0x3c,%ecx,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
subsd  %xmm2,%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r8d
lea    0xe75(%rip),%rsi
xor    %eax,%eax
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%5.3lfs\00"
@.str.1 = [17 x i8] c"%dm%ds (%7.3lfs)\00"
@.str.2 = [10 x i8] c"%dh%dm%ds\00"
define void @printim(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 = fcmp olt double %8, 6.000000e+01
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = load double, double* %3
%13 = fptosi double %12 to i32
%14 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %59
15: ; preds = %2
%16 = load double, double* %3
%17 = fcmp olt double %16, 3.600000e+03
br i1 %17, label %18, label %32
18: ; preds = %15
%19 = load double, double* %3
%20 = fdiv double %19, 6.000000e+01
%21 = fptosi double %20 to i32
store i32 %21, i32* %6
%22 = load double, double* %3
%23 = fptosi double %22 to i32
%24 = load i32, i32* %6
%25 = mul nsw i32 %24, 60
%26 = sub nsw i32 %23, %25
store i32 %26, i32* %7
%27 = load i8*, i8** %4
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = load double, double* %3
%31 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %27, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %29, double %30)
br label %58
32: ; preds = %15
%33 = load double, double* %3
%34 = fdiv double %33, 3.600000e+03
%35 = fptosi double %34 to i32
store i32 %35, i32* %5
%36 = load double, double* %3
%37 = load i32, i32* %5
%38 = mul nsw i32 %37, 3600
%39 = sitofp i32 %38 to double
%40 = fsub double %36, %39
%41 = fdiv double %40, 6.000000e+01
%42 = fptosi double %41 to i32
store i32 %42, i32* %6
%43 = load double, double* %3
%44 = load i32, i32* %6
%45 = mul nsw i32 %44, 60
%46 = sitofp i32 %45 to double
%47 = fsub double %43, %46
%48 = load i32, i32* %5
%49 = mul nsw i32 %48, 3600
%50 = sitofp i32 %49 to double
%51 = fsub double %47, %50
%52 = fptosi double %51 to i32
store i32 %52, i32* %7
%53 = load i8*, i8** %4
%54 = load i32, i32* %5
%55 = load i32, i32* %6
%56 = load i32, i32* %7
%57 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %53, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %54, i32 %55, i32 %56)
br label %58
58: ; preds = %32, %18
br label %59
59: ; preds = %58, %10
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%5.3lfs\00"
@.str.1 = [17 x i8] c"%dm%ds (%7.3lfs)\00"
@.str.2 = [10 x i8] c"%dh%dm%ds\00"
define void @printim(double %0, i8* nocapture writeonly %1) {
%3 = fcmp olt double %0, 6.000000e+01
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = fptosi double %0 to i32
%6 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %30
7: ; preds = %2
%8 = fcmp olt double %0, 3.600000e+03
br i1 %8, label %9, label %16
9: ; preds = %7
%10 = fdiv double %0, 6.000000e+01
%11 = fptosi double %10 to i32
%12 = fptosi double %0 to i32
%13 = mul i32 %11, -60
%14 = add i32 %13, %12
%15 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %14, double %0)
br label %30
16: ; preds = %7
%17 = fdiv double %0, 3.600000e+03
%18 = fptosi double %17 to i32
%19 = mul nsw i32 %18, 3600
%20 = sitofp i32 %19 to double
%21 = fsub double %0, %20
%22 = fdiv double %21, 6.000000e+01
%23 = fptosi double %22 to i32
%24 = mul nsw i32 %23, 60
%25 = sitofp i32 %24 to double
%26 = fsub double %0, %25
%27 = fsub double %26, %20
%28 = fptosi double %27 to i32
%29 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %23, i32 %28)
br label %30
30: ; preds = %9, %16, %4
ret void
}