#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*/ buf;

/* Variables and functions */
int snprintf(char *, int, char *, int, ...);
const char *do_time(unsigned long t) {
  int hh, mm, ss;
  static char buf[32];
  int cnt = 0;
  t /= 100;
  ss = t % 60;
  t /= 60;
  mm = t % 60;
  t /= 60;
  hh = t % 24;
  t /= 24;
  if (t)
    cnt = snprintf(buf, sizeof buf, "%d-", (int)t);
  snprintf(cnt + buf, sizeof(buf) - cnt, "%02d:%02d:%02d", hh, mm, ss);
  return buf;
}


x86 assembly (clang, -O0):
<do_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x18,%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x18,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11d2 <do_time+0xc2>
mov    -0x8(%rbp),%rax
mov    %eax,%ecx
lea    0x2e84(%rip),%rdi
mov    $0x20,%esi
lea    0xe38(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
lea    0x2e63(%rip),%rdi
add    %rax,%rdi
movslq -0x18(%rbp),%rcx
mov    $0x20,%eax
sub    %rcx,%rax
mov    %eax,%esi
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
lea    0xe04(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2e32(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_time>:
push   %rbx
mov    %rdi,%rbx
cmp    $0x83d600,%rdi
jae    1122 <do_time+0x12>
xor    %r10d,%r10d
jmp    1156 <do_time+0x46>
movabs $0xf88d2526f901a751,%rcx
25 8d f8
mov    %rbx,%rax
mul    %rcx
mov    %rdx,%rcx
shr    $0x17,%rcx
lea    0x2f00(%rip),%rdi
lea    0xeb9(%rip),%rdx
mov    $0x20,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
movslq %eax,%r10
movabs $0xba69dbdd3ac13d7d,%rcx
db 69 ba
mov    %rbx,%rax
mul    %rcx
mov    %rdx,%rcx
shr    $0x12,%rcx
movabs $0xaaaaaaaaaaaaaaab,%rdx
aa aa aa
mov    %rcx,%rax
mul    %rdx
shr    $0x4,%rdx
shl    $0x3,%edx
lea    (%rdx,%rdx,2),%eax
sub    %eax,%ecx
movabs $0xaec33e1f671529a5,%rdx
3e c3 ae
mov    %rbx,%rax
mul    %rdx
mov    %rdx,%r8
shr    $0xc,%r8
movabs $0x8888888888888889,%rdi
88 88 88
mov    %r8,%rax
mul    %rdi
mov    %rdx,%rsi
shr    $0x5,%rsi
shr    $0x2,%rbx
movabs $0x28f5c28f5c28f5c3,%rdx
c2 f5 28
mov    %rbx,%rax
mul    %rdx
mov    %rdx,%r9
imul   $0x3c,%esi,%esi
shr    $0x2,%r9
mov    %r9,%rax
mul    %rdi
sub    %esi,%r8d
shr    $0x5,%rdx
imul   $0x3c,%edx,%eax
sub    %eax,%r9d
lea    0x2e51(%rip),%rbx
lea    (%rbx,%r10,1),%rdi
mov    $0x20,%esi
sub    %r10d,%esi
lea    0xe02(%rip),%rdx
xor    %eax,%eax
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@do_time.buf = internal global [32 x i8] zeroinitializer
@.str = [4 x i8] c"%d-\00"
@.str.1 = [15 x i8] c"%02d:%02d:%02d\00"
define i8* @do_time(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i64 %0, i64* %2
store i32 0, i32* %6
%7 = load i64, i64* %2
%8 = udiv i64 %7, 100
store i64 %8, i64* %2
%9 = load i64, i64* %2
%10 = urem i64 %9, 60
%11 = trunc i64 %10 to i32
store i32 %11, i32* %5
%12 = load i64, i64* %2
%13 = udiv i64 %12, 60
store i64 %13, i64* %2
%14 = load i64, i64* %2
%15 = urem i64 %14, 60
%16 = trunc i64 %15 to i32
store i32 %16, i32* %4
%17 = load i64, i64* %2
%18 = udiv i64 %17, 60
store i64 %18, i64* %2
%19 = load i64, i64* %2
%20 = urem i64 %19, 24
%21 = trunc i64 %20 to i32
store i32 %21, i32* %3
%22 = load i64, i64* %2
%23 = udiv i64 %22, 24
store i64 %23, i64* %2
%24 = load i64, i64* %2
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %1
%27 = load i64, i64* %2
%28 = trunc i64 %27 to i32
%29 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @do_time.buf, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
store i32 %29, i32* %6
br label %30
30: ; preds = %26, %1
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @do_time.buf, i64 0, i64 0), i64 %32
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = sub i64 32, %35
%37 = trunc i64 %36 to i32
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = load i32, i32* %5
%41 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %33, i32 %37, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %38, i32 %39, i32 %40)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @do_time.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@do_time.buf = internal global [32 x i8] zeroinitializer
@.str = [4 x i8] c"%d-\00"
@.str.1 = [15 x i8] c"%02d:%02d:%02d\00"
define i8* @do_time(i64 %0) {
%2 = icmp ult i64 %0, 8640000
br i1 %2, label %8, label %3
3: ; preds = %1
%4 = udiv i64 %0, 8640000
%5 = trunc i64 %4 to i32
%6 = tail call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @do_time.buf, i64 0, i64 0), i32 32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = sext i32 %6 to i64
br label %8
8: ; preds = %3, %1
%9 = phi i64 [ %7, %3 ], [ 0, %1 ]
%10 = udiv i64 %0, 360000
%11 = urem i64 %10, 24
%12 = trunc i64 %11 to i32
%13 = udiv i64 %0, 6000
%14 = urem i64 %13, 60
%15 = trunc i64 %14 to i32
%16 = udiv i64 %0, 100
%17 = urem i64 %16, 60
%18 = trunc i64 %17 to i32
%19 = getelementptr inbounds [32 x i8], [32 x i8]* @do_time.buf, i64 0, i64 %9
%20 = trunc i64 %9 to i32
%21 = sub i32 32, %20
%22 = tail call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %19, i32 %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %15, i32 %18)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @do_time.buf, i64 0, i64 0)
}