#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 */
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int, ...);
const char *timestr(int t) {
  static char s[80];
  if (((t) / ((60 * 60) * 24)) > 0)
    (void)snprintf(s, sizeof(s), "%dd+%02dhrs", ((t) / ((60 * 60) * 24)),
                   (((t) % ((60 * 60) * 24)) / (60 * 60)));
  else if ((((t) % ((60 * 60) * 24)) / (60 * 60)) > 0)
    (void)snprintf(s, sizeof(s), "%d:%02d:%02d",
                   (((t) % ((60 * 60) * 24)) / (60 * 60)),
                   (((t) % (60 * 60)) / 60), ((t) % 60));
  else if ((((t) % (60 * 60)) / 60) > 0)
    (void)snprintf(s, sizeof(s), "%d:%02d", (((t) % (60 * 60)) / 60),
                   ((t) % 60));
  else if (((t) % 60) > 0)
    (void)snprintf(s, sizeof(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    1173 <timestr+0x63>
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
mov    $0x15180,%esi
cltd
idiv   %esi
mov    %edx,%eax
mov    $0xe10,%esi
cltd
idiv   %esi
mov    %eax,%r8d
lea    0x2ee5(%rip),%rdi
mov    $0x50,%esi
lea    0xe99(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    12a5 <timestr+0x195>
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jle    11ed <timestr+0xdd>
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
mov    $0xe10,%esi
cltd
idiv   %esi
mov    %edx,%eax
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %eax,%r8d
mov    -0x4(%rbp),%eax
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %edx,%r9d
lea    0x2e6b(%rip),%rdi
mov    $0x50,%esi
lea    0xe2b(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    12a0 <timestr+0x190>
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jle    124f <timestr+0x13f>
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
lea    0x2e09(%rip),%rdi
mov    $0x50,%esi
lea    0xdd6(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    129b <timestr+0x18b>
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jle    128f <timestr+0x17f>
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
lea    0x2dc9(%rip),%rdi
mov    $0x50,%esi
lea    0xd98(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    1296 <timestr+0x186>
movb   $0x0,0x2daa(%rip)
jmp    129b <timestr+0x18b>
jmp    12a0 <timestr+0x190>
jmp    12a5 <timestr+0x195>
lea    0x2d94(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestr>:
push   %rax
mov    %edi,%r9d
cmp    $0x15180,%edi
jl     1162 <timestr+0x52>
mov    %r9d,%eax
mov    $0xc22e4507,%ecx
imul   %rax,%rcx
shr    $0x30,%rcx
imul   $0x15180,%ecx,%eax
sub    %eax,%r9d
mov    $0x91a2b3c5,%r8d
imul   %r9,%r8
shr    $0x2b,%r8
lea    0x2ef6(%rip),%rdi
lea    0xeaf(%rip),%rdx
mov    $0x50,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    12d9 <timestr+0x1c9>
movslq %r9d,%rax
imul   $0xffffffffc22e4507,%rax,%rcx
shr    $0x20,%rcx
add    %r9d,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x10,%ecx
add    %edx,%ecx
imul   $0x15180,%ecx,%edx
mov    %r9d,%ecx
sub    %edx,%ecx
cmp    $0xe10,%ecx
jl     1223 <timestr+0x113>
mov    %ecx,%edx
mov    $0x91a2b3c5,%ecx
imul   %rdx,%rcx
shr    $0x2b,%rcx
imul   $0xffffffff91a2b3c5,%rax,%rdx
shr    $0x20,%rdx
add    %r9d,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0xb,%edx
add    %esi,%edx
imul   $0xe10,%edx,%edx
mov    %r9d,%esi
sub    %edx,%esi
movswl %si,%edx
imul   $0xffff8889,%edx,%edx
shr    $0x10,%edx
add    %esi,%edx
movzwl %dx,%edx
movswl %dx,%esi
shr    $0xf,%edx
sar    $0x5,%esi
add    %edx,%esi
movswl %si,%r8d
imul   $0xffffffff88888889,%rax,%rax
shr    $0x20,%rax
add    %r9d,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x5,%eax
add    %edx,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%r9d
lea    0x2e35(%rip),%rdi
lea    0xdfa(%rip),%rdx
mov    $0x50,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    12d9 <timestr+0x1c9>
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %r9d,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xb,%ecx
add    %edx,%ecx
imul   $0xe10,%ecx,%edx
mov    %r9d,%ecx
sub    %edx,%ecx
cmp    $0x3c,%ecx
jl     1290 <timestr+0x180>
movzwl %cx,%ecx
imul   $0x8889,%ecx,%ecx
shr    $0x15,%ecx
imul   $0xffffffff88888889,%rax,%rax
shr    $0x20,%rax
add    %r9d,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x5,%eax
add    %edx,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%r9d
lea    0x2dc4(%rip),%rdi
lea    0xd96(%rip),%rdx
mov    $0x50,%esi
mov    %r9d,%r8d
jmp    1156 <timestr+0x46>
imul   $0xffffffff88888889,%rax,%rax
shr    $0x20,%rax
add    %r9d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%r9d
test   %r9d,%r9d
jle    12d2 <timestr+0x1c2>
lea    0x2d86(%rip),%rdi
lea    0xd5a(%rip),%rdx
mov    $0x50,%esi
mov    %r9d,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    12d9 <timestr+0x1c9>
movb   $0x0,0x2d67(%rip)
lea    0x2d60(%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*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i32 80, 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*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i32 80, 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*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i32 80, 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*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i32 80, 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*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i32 80, i8* 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*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i32 80, i8* 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*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i32 80, i8* 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*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @timestr.s, i64 0, i64 0), i32 80, i8* 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)
}