#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*/ assert(char *);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
char *getim(double elps) {
  int hh, mm, ss;
  char *data;
  data = malloc(32 * sizeof(char));
  assert(data);
  if (elps < 60.0)
    sprintf(data, "%5.3lfs", elps);
  else if (elps < 3600.0) {
    mm = elps / 60.0;
    ss = (int)elps - mm * 60;
    sprintf(data, "%dm%ds (%7.3lfs)", mm, ss, elps);
  } else {
    hh = elps / 3600;
    mm = (elps - hh * 3600) / 60;
    ss = elps - mm * 60 - hh * 3600;
    sprintf(data, "%dh%dm%ds", hh, mm, ss);
  }
  return (data);
}


x86 assembly (clang, -O0):
<getim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    $0x20,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <assert@plt>
movsd  0xea4(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1183 <getim+0x53>
mov    -0x20(%rbp),%rdi
cvttsd2si -0x8(%rbp),%edx
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    1265 <getim+0x135>
movsd  0xe7d(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11de <getim+0xae>
movsd  -0x8(%rbp),%xmm0
movsd  0xe5d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
cvttsd2si -0x8(%rbp),%eax
imul   $0x3c,-0x10(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
movsd  -0x8(%rbp),%xmm0
lea    0xe46(%rip),%rsi
mov    $0x1,%al
call   1050 <sprintf@plt>
jmp    1260 <getim+0x130>
movsd  -0x8(%rbp),%xmm0
movsd  0xe1d(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm0
imul   $0xe10,-0xc(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  0xdee(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
imul   $0x3c,-0x10(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
imul   $0xe10,-0xc(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    1265 <getim+0x135>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getim>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    $0x20,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <assert@plt>
movsd  0x8(%rsp),%xmm0
movsd  0xea2(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    117e <getim+0x4e>
cvttsd2si %xmm0,%edx
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    120e <getim+0xde>
movsd  0xe82(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11b8 <getim+0x88>
movapd %xmm0,%xmm1
divsd  0xe68(%rip),%xmm1
cvttsd2si %xmm1,%edx
cvttsd2si %xmm0,%eax
imul   $0xffffffc4,%edx,%ecx
add    %eax,%ecx
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <sprintf@plt>
jmp    120e <getim+0xde>
movapd %xmm0,%xmm1
divsd  0xe44(%rip),%xmm1
cvttsd2si %xmm1,%edx
imul   $0xe10,%edx,%eax
cvtsi2sd %eax,%xmm2
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
divsd  0xe1e(%rip),%xmm1
cvttsd2si %xmm1,%ecx
imul   $0x3c,%ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
subsd  %xmm2,%xmm0
cvttsd2si %xmm0,%r8d
lea    0xe25(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

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

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 i8* @getim(double %0) {
%2 = tail call dereferenceable_or_null(32) i8* @malloc(i32 32)
%3 = tail call i32 @assert(i8* %2)
%4 = fcmp olt double %0, 6.000000e+01
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = fptosi double %0 to i32
%7 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %31
8: ; preds = %1
%9 = fcmp olt double %0, 3.600000e+03
br i1 %9, label %10, label %17
10: ; preds = %8
%11 = fdiv double %0, 6.000000e+01
%12 = fptosi double %11 to i32
%13 = fptosi double %0 to i32
%14 = mul i32 %12, -60
%15 = add i32 %14, %13
%16 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %15, double %0)
br label %31
17: ; preds = %8
%18 = fdiv double %0, 3.600000e+03
%19 = fptosi double %18 to i32
%20 = mul nsw i32 %19, 3600
%21 = sitofp i32 %20 to double
%22 = fsub double %0, %21
%23 = fdiv double %22, 6.000000e+01
%24 = fptosi double %23 to i32
%25 = mul nsw i32 %24, 60
%26 = sitofp i32 %25 to double
%27 = fsub double %0, %26
%28 = fsub double %27, %21
%29 = fptosi double %28 to i32
%30 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %24, i32 %29)
br label %31
31: ; preds = %10, %17, %5
ret i8* %2
}