char *format_time(seconds)
long seconds;
{
  register int value;
  register int digit;
  register char *ptr;
  static char result[10];
  if (seconds < 0 || seconds > (99999l * 360l)) {
    strcpy(result, "   ???");
  } else if (seconds >= (1000l * 60l)) {
    sprintf(result, "%5.1fH", (double)seconds / (double)(60l * 60l));
    result[6] = '\0';
  } else {
    sprintf(result, "%3d:%02d", seconds / 60l, seconds % 60l);
  }
  return (result);
}


x86 assembly (clang, -O0):
<format_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jl     1145 <format_time+0x25>
cmpq   $0x2254f98,-0x8(%rbp)
02
jle    115d <format_time+0x3d>
lea    0x2ee5(%rip),%rdi
lea    0xeb5(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11df <format_time+0xbf>
cmpq   $0xea60,-0x8(%rbp)
jl     119e <format_time+0x7e>
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xe87(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0x2ead(%rip),%rdi
lea    0xe84(%rip),%rsi
mov    $0x1,%al
call   1040 <sprintf@plt>
movb   $0x0,0x2e9e(%rip)
jmp    11da <format_time+0xba>
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rdx,%rcx
mov    -0x20(%rbp),%rdx
lea    0x2e65(%rip),%rdi
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11df <format_time+0xbf>
lea    0x2e4b(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_time>:
push   %rax
cmp    $0x2254f99,%rdi
jb     1130 <format_time+0x20>
movl   $0x3f3f3f,0x2f08(%rip)
movl   $0x3f202020,0x2efb(%rip)
20 20 3f
jmp    118d <format_time+0x7d>
cmp    $0xea60,%rdi
jb     1164 <format_time+0x54>
cvtsi2sd %rdi,%xmm0
divsd  0xeba(%rip),%xmm0
lea    0x2edc(%rip),%rdi
lea    0xebb(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
movb   $0x0,0x2ecd(%rip)
jmp    118d <format_time+0x7d>
movzwl %di,%eax
imul   $0x8889,%eax,%edx
shr    $0x15,%edx
imul   $0x3c,%edx,%eax
sub    %eax,%edi
movzwl %di,%ecx
lea    0x2eaa(%rip),%rdi
lea    0xe90(%rip),%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
lea    0x2e95(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@format_time.result = internal global [10 x i8] zeroinitializer
@.str = [7 x i8] c" ???\00"
@.str.1 = [7 x i8] c"%5.1fH\00"
@.str.2 = [9 x i8] c"%3d:%02d\00"
define i8* @format_time(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = icmp slt i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i64, i64* %2
%10 = icmp sgt i64 %9, 35999640
br i1 %10, label %11, label %13
11: ; preds = %8, %1
%12 = call i8* @strcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_time.result, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %28
13: ; preds = %8
%14 = load i64, i64* %2
%15 = icmp sge i64 %14, 60000
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i64, i64* %2
%18 = sitofp i64 %17 to double
%19 = fdiv double %18, 3.600000e+03
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_time.result, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %19)
store i8 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_time.result, i64 0, i64 6)
br label %27
21: ; preds = %13
%22 = load i64, i64* %2
%23 = sdiv i64 %22, 60
%24 = load i64, i64* %2
%25 = srem i64 %24, 60
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_time.result, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i64 %23, i64 %25)
br label %27
27: ; preds = %21, %16
br label %28
28: ; preds = %27, %11
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_time.result, i64 0, i64 0)
}

LLVM IR (-O2):
@format_time.result = internal global [10 x i8] zeroinitializer
@.str = [7 x i8] c" ???\00"
@.str.1 = [7 x i8] c"%5.1fH\00"
@.str.2 = [9 x i8] c"%3d:%02d\00"
define i8* @format_time(i64 %0) {
%2 = icmp ugt i64 %0, 35999640
br i1 %2, label %3, label %4
3: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(7) getelementptr inbounds ([10 x i8], [10 x i8]* @format_time.result, i64 0, i64 0), i8* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 7, i1 false)
br label %17
4: ; preds = %1
%5 = icmp ugt i64 %0, 59999
br i1 %5, label %6, label %10
6: ; preds = %4
%7 = sitofp i64 %0 to double
%8 = fdiv double %7, 3.600000e+03
%9 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @format_time.result, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %8)
store i8 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_time.result, i64 0, i64 6)
br label %17
10: ; preds = %4
%11 = trunc i64 %0 to i16
%12 = udiv i16 %11, 60
%13 = zext i16 %12 to i64
%14 = urem i16 %11, 60
%15 = zext i16 %14 to i64
%16 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @format_time.result, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i64 %13, i64 %15)
br label %17
17: ; preds = %6, %10, %3
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @format_time.result, i64 0, i64 0)
}