char *timestr(t) {
  static char s[80];
  if (((t) / ((60 * 60) * 24)) > 0)
    (void)sprintf(s, "%dd+%02dhrs", ((t) / ((60 * 60) * 24)),
                  (((t) % ((60 * 60) * 24)) / (60 * 60)));
  else if ((((t) % ((60 * 60) * 24)) / (60 * 60)) > 0)
    (void)sprintf(s, "%d:%02d:%02d", (((t) % ((60 * 60) * 24)) / (60 * 60)),
                  (((t) % (60 * 60)) / 60), ((t) % 60));
  else if ((((t) % (60 * 60)) / 60) > 0)
    (void)sprintf(s, "%d:%02d", (((t) % (60 * 60)) / 60), ((t) % 60));
  else if (((t) % 60) > 0)
    (void)sprintf(s, ":%02d", ((t) % 60));
  else
    *s = '\0';
  return (s);
}


x86 assembly (clang, -O0):
<timestr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jle    1171 <timestr+0x61>
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    -0x8(%rbp),%edx
mov    %eax,%ecx
lea    0x2ee2(%rip),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1298 <timestr+0x188>
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jle    11e9 <timestr+0xd9>
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %edx,%r8d
mov    -0xc(%rbp),%edx
lea    0x2e6a(%rip),%rdi
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1293 <timestr+0x183>
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jle    1249 <timestr+0x139>
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x10(%rbp),%edx
lea    0x2e0a(%rip),%rdi
lea    0xddc(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    128e <timestr+0x17e>
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jle    1282 <timestr+0x172>
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
lea    0x2dd1(%rip),%rdi
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1289 <timestr+0x179>
movb   $0x0,0x2db7(%rip)
jmp    128e <timestr+0x17e>
jmp    1293 <timestr+0x183>
jmp    1298 <timestr+0x188>
lea    0x2da1(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestr>:
push   %rax
mov    %edi,%r8d
cmp    $0x15180,%edi
jl     115c <timestr+0x4c>
mov    %r8d,%eax
mov    $0xc22e4507,%edx
imul   %rax,%rdx
shr    $0x30,%rdx
imul   $0x15180,%edx,%eax
sub    %eax,%r8d
mov    $0x91a2b3c5,%ecx
imul   %r8,%rcx
shr    $0x2b,%rcx
lea    0x2ef7(%rip),%rdi
lea    0xeb0(%rip),%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    12c3 <timestr+0x1b3>
movslq %r8d,%rax
imul   $0xffffffffc22e4507,%rax,%rcx
shr    $0x20,%rcx
add    %r8d,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x10,%ecx
add    %edx,%ecx
imul   $0x15180,%ecx,%edx
mov    %r8d,%ecx
sub    %edx,%ecx
cmp    $0xe10,%ecx
jl     1217 <timestr+0x107>
mov    %ecx,%ecx
mov    $0x91a2b3c5,%edx
imul   %rcx,%rdx
shr    $0x2b,%rdx
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %r8d,%ecx
mov    %ecx,%esi
shr    $0x1f,%esi
sar    $0xb,%ecx
add    %esi,%ecx
imul   $0xe10,%ecx,%ecx
mov    %r8d,%esi
sub    %ecx,%esi
movswl %si,%ecx
imul   $0xffff8889,%ecx,%ecx
shr    $0x10,%ecx
add    %esi,%ecx
movzwl %cx,%ecx
movswl %cx,%esi
shr    $0xf,%ecx
sar    $0x5,%esi
add    %ecx,%esi
movswl %si,%ecx
imul   $0xffffffff88888889,%rax,%rax
shr    $0x20,%rax
add    %r8d,%eax
mov    %eax,%esi
shr    $0x1f,%esi
sar    $0x5,%eax
add    %esi,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%r8d
lea    0x2e3c(%rip),%rdi
lea    0xe01(%rip),%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    12c3 <timestr+0x1b3>
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %r8d,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xb,%ecx
add    %edx,%ecx
imul   $0xe10,%ecx,%edx
mov    %r8d,%ecx
sub    %edx,%ecx
cmp    $0x3c,%ecx
jl     127f <timestr+0x16f>
movzwl %cx,%ecx
imul   $0x8889,%ecx,%edx
shr    $0x15,%edx
imul   $0xffffffff88888889,%rax,%rax
shr    $0x20,%rax
add    %r8d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%r8d
lea    0x2dd0(%rip),%rdi
lea    0xda2(%rip),%rsi
mov    %r8d,%ecx
jmp    1150 <timestr+0x40>
imul   $0xffffffff88888889,%rax,%rax
shr    $0x20,%rax
add    %r8d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%r8d
test   %r8d,%r8d
jle    12bc <timestr+0x1ac>
lea    0x2d97(%rip),%rdi
lea    0xd6b(%rip),%rsi
mov    %r8d,%edx
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    12c3 <timestr+0x1b3>
movb   $0x0,0x2d7d(%rip)
lea    0x2d76(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@timestr.s = internal global [80 x i8] zeroinitializer
@.str = [12 x i8] c"%dd+%02dhrs\00"
@.str.1 = [13 x i8] c"%d:%02d:%02d\00"
@.str.2 = [8 x i8] c"%d:%02d\00"
@.str.3 = [6 x i8] c":%02d\00"
define i8* @timestr(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sdiv i32 %3, 86400
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = load i32, i32* %2
%8 = sdiv i32 %7, 86400
%9 = load i32, i32* %2
%10 = srem i32 %9, 86400
%11 = sdiv i32 %10, 3600
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11)
br label %52
13: ; preds = %1
%14 = load i32, i32* %2
%15 = srem i32 %14, 86400
%16 = sdiv i32 %15, 3600
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %13
%19 = load i32, i32* %2
%20 = srem i32 %19, 86400
%21 = sdiv i32 %20, 3600
%22 = load i32, i32* %2
%23 = srem i32 %22, 3600
%24 = sdiv i32 %23, 60
%25 = load i32, i32* %2
%26 = srem i32 %25, 60
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %24, i32 %26)
br label %51
28: ; preds = %13
%29 = load i32, i32* %2
%30 = srem i32 %29, 3600
%31 = sdiv i32 %30, 60
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %40
33: ; preds = %28
%34 = load i32, i32* %2
%35 = srem i32 %34, 3600
%36 = sdiv i32 %35, 60
%37 = load i32, i32* %2
%38 = srem i32 %37, 60
%39 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %36, i32 %38)
br label %50
40: ; preds = %28
%41 = load i32, i32* %2
%42 = srem i32 %41, 60
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i32, i32* %2
%46 = srem i32 %45, 60
%47 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %46)
br label %49
48: ; preds = %40
store i8 0, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0)
br label %49
49: ; preds = %48, %44
br label %50
50: ; preds = %49, %33
br label %51
51: ; preds = %50, %18
br label %52
52: ; preds = %51, %6
ret i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0)
}

LLVM IR (-O2):
@timestr.s = internal global [80 x i8] zeroinitializer
@.str = [12 x i8] c"%dd+%02dhrs\00"
@.str.1 = [13 x i8] c"%d:%02d:%02d\00"
@.str.2 = [8 x i8] c"%d:%02d\00"
@.str.3 = [6 x i8] c":%02d\00"
define i8* @timestr(i32 %0) {
%2 = icmp sgt i32 %0, 86399
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = udiv i32 %0, 86400
%5 = urem i32 %0, 86400
%6 = udiv i32 %5, 3600
%7 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6)
br label %34
8: ; preds = %1
%9 = srem i32 %0, 86400
%10 = icmp sgt i32 %9, 3599
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = udiv i32 %9, 3600
%13 = srem i32 %0, 3600
%14 = trunc i32 %13 to i16
%15 = sdiv i16 %14, 60
%16 = sext i16 %15 to i32
%17 = srem i32 %0, 60
%18 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %16, i32 %17)
br label %34
19: ; preds = %8
%20 = srem i32 %0, 3600
%21 = icmp sgt i32 %20, 59
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = trunc i32 %20 to i16
%24 = udiv i16 %23, 60
%25 = zext i16 %24 to i32
%26 = srem i32 %0, 60
%27 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %26)
br label %34
28: ; preds = %19
%29 = srem i32 %0, 60
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %29)
br label %34
33: ; preds = %28
store i8 0, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0)
br label %34
34: ; preds = %11, %31, %33, %22, %3
ret i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0)
}