#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 decimal_part(double);
int round_up(double);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
char *convert_time(double seconds) {
  static char converted[12];
  double hr = seconds / 3600;
  double min = decimal_part(hr) * 60;
  double sec = decimal_part(min) * 60;
  if (!(int)hr && !(int)min) {
    sprintf(converted, "%ds", round_up(sec));
  } else if (!(int)hr) {
    sprintf(converted, "%dm %ds", (int)min, round_up(sec));
  } else {
    sprintf(converted, "%dh %dm %ds", (int)hr, (int)min, round_up(sec));
  }
  return converted;
}


x86 assembly (clang, -O0):
<convert_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xeb6(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <decimal_part@plt>
imul   $0x3c,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <decimal_part@plt>
imul   $0x3c,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvttsd2si -0x10(%rbp),%eax
cmp    $0x0,%eax
jne    11c1 <convert_time+0x91>
cvttsd2si -0x18(%rbp),%eax
cmp    $0x0,%eax
jne    11c1 <convert_time+0x91>
movsd  -0x20(%rbp),%xmm0
call   1030 <round_up@plt>
mov    %eax,%edx
lea    0x2e8b(%rip),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    123d <convert_time+0x10d>
cvttsd2si -0x10(%rbp),%eax
cmp    $0x0,%eax
jne    1200 <convert_time+0xd0>
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <round_up@plt>
mov    -0x24(%rbp),%edx
mov    %eax,%ecx
lea    0x2e4c(%rip),%rdi
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    1238 <convert_time+0x108>
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <round_up@plt>
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    %eax,%r8d
lea    0x2e0f(%rip),%rdi
lea    0xdd7(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    123d <convert_time+0x10d>
lea    0x2df5(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_time>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
divsd  0xec0(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <decimal_part@plt>
mov    %eax,%ebx
imul   $0x3c,%eax,%r14d
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
call   1040 <decimal_part@plt>
imul   $0x3c,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
cvttsd2si 0x8(%rsp),%ebp
call   1030 <round_up@plt>
lea    0x2ebf(%rip),%rdi
or     %ebp,%ebx
jne    1190 <convert_time+0x60>
lea    0xe8b(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    11bf <convert_time+0x8f>
test   %ebp,%ebp
je     11ac <convert_time+0x7c>
lea    0xe6d(%rip),%rsi
mov    %ebp,%edx
mov    %r14d,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    11bf <convert_time+0x8f>
lea    0xe59(%rip),%rsi
mov    %r14d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
lea    0x2e73(%rip),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@convert_time.converted = internal global [12 x i8] zeroinitializer
@.str = [4 x i8] c"%ds\00"
@.str.1 = [8 x i8] c"%dm %ds\00"
@.str.2 = [12 x i8] c"%dh %dm %ds\00"
define i8* @convert_time(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %2
%6 = load double, double* %2
%7 = fdiv double %6, 3.600000e+03
store double %7, double* %3
%8 = load double, double* %3
%9 = call i32 @decimal_part(double %8)
%10 = mul nsw i32 %9, 60
%11 = sitofp i32 %10 to double
store double %11, double* %4
%12 = load double, double* %4
%13 = call i32 @decimal_part(double %12)
%14 = mul nsw i32 %13, 60
%15 = sitofp i32 %14 to double
store double %15, double* %5
%16 = load double, double* %3
%17 = fptosi double %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %1
%20 = load double, double* %4
%21 = fptosi double %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load double, double* %5
%25 = call i32 @round_up(double %24)
%26 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @convert_time.converted, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
br label %46
27: ; preds = %19, %1
%28 = load double, double* %3
%29 = fptosi double %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %27
%32 = load double, double* %4
%33 = fptosi double %32 to i32
%34 = load double, double* %5
%35 = call i32 @round_up(double %34)
%36 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @convert_time.converted, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %35)
br label %45
37: ; preds = %27
%38 = load double, double* %3
%39 = fptosi double %38 to i32
%40 = load double, double* %4
%41 = fptosi double %40 to i32
%42 = load double, double* %5
%43 = call i32 @round_up(double %42)
%44 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @convert_time.converted, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %41, i32 %43)
br label %45
45: ; preds = %37, %31
br label %46
46: ; preds = %45, %23
ret i8* getelementptr inbounds ([12 x i8], [12 x i8]* @convert_time.converted, i64 0, i64 0)
}

LLVM IR (-O2):
@convert_time.converted = internal global [12 x i8] zeroinitializer
@.str = [4 x i8] c"%ds\00"
@.str.1 = [8 x i8] c"%dm %ds\00"
@.str.2 = [12 x i8] c"%dh %dm %ds\00"
define i8* @convert_time(double %0) {
%2 = fdiv double %0, 3.600000e+03
%3 = tail call i32 @decimal_part(double %2)
%4 = mul nsw i32 %3, 60
%5 = sitofp i32 %4 to double
%6 = tail call i32 @decimal_part(double %5)
%7 = mul nsw i32 %6, 60
%8 = sitofp i32 %7 to double
%9 = fptosi double %2 to i32
%10 = icmp eq i32 %9, 0
%11 = icmp eq i32 %3, 0
%12 = select i1 %10, i1 %11, i1 false
%13 = tail call i32 @round_up(double %8)
br i1 %12, label %14, label %16
14: ; preds = %1
%15 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @convert_time.converted, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %21
16: ; preds = %1
br i1 %10, label %17, label %19
17: ; preds = %16
%18 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @convert_time.converted, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %13)
br label %21
19: ; preds = %16
%20 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @convert_time.converted, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %4, i32 %13)
br label %21
21: ; preds = %17, %19, %14
ret i8* getelementptr inbounds ([12 x i8], [12 x i8]* @convert_time.converted, i64 0, i64 0)
}