#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 /*<<< orphan*/ sprintf(char *, char *, long, long, long);
char *hhmmss(long x) {
  static char buf[10];
  long s, h, m;
  h = x / 3600L;
  x = x % 3600L;
  m = x / 60L;
  s = x % 60L;
  if (x > -1L)
    sprintf(buf, "%02ld:%02ld:%02ld", h, m, s);
  else
    buf[0] = '\0';
  return ((char *)buf);
}


x86 assembly (clang, -O0):
<hhmmss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x8(%rbp)
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,-0x10(%rbp)
cmpq   $0xffffffffffffffff,-0x8(%rbp)
jle    1193 <hhmmss+0x83>
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0x2ea7(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1030 <sprintf@plt>
jmp    119a <hhmmss+0x8a>
movb   $0x0,0x2e8f(%rip)
lea    0x2e88(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hhmmss>:
push   %rax
movabs $0x48d159e26af37c05,%rcx
59 d1 48
mov    %rdi,%rax
imul   %rcx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xa,%rdx
add    %rax,%rdx
imul   $0xe10,%rdx,%rax
sub    %rax,%rdi
js     1165 <hhmmss+0x55>
movzwl %di,%eax
imul   $0x8889,%eax,%ecx
shr    $0x15,%ecx
imul   $0x3c,%ecx,%eax
sub    %eax,%edi
movzwl %di,%r8d
lea    0x2ed2(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1030 <sprintf@plt>
jmp    116c <hhmmss+0x5c>
movb   $0x0,0x2ebd(%rip)
lea    0x2eb6(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@hhmmss.buf = internal global [10 x i8] zeroinitializer
@.str = [18 x i8] c"%02ld:%02ld:%02ld\00"
define i8* @hhmmss(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = sdiv i64 %6, 3600
store i64 %7, i64* %4
%8 = load i64, i64* %2
%9 = srem i64 %8, 3600
store i64 %9, i64* %2
%10 = load i64, i64* %2
%11 = sdiv i64 %10, 60
store i64 %11, i64* %5
%12 = load i64, i64* %2
%13 = srem i64 %12, 60
store i64 %13, i64* %3
%14 = load i64, i64* %2
%15 = icmp sgt i64 %14, -1
br i1 %15, label %16, label %21
16: ; preds = %1
%17 = load i64, i64* %4
%18 = load i64, i64* %5
%19 = load i64, i64* %3
%20 = call i32 @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @hhmmss.buf, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %17, i64 %18, i64 %19)
br label %22
21: ; preds = %1
store i8 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @hhmmss.buf, i64 0, i64 0)
br label %22
22: ; preds = %21, %16
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @hhmmss.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@hhmmss.buf = internal global [10 x i8] zeroinitializer
@.str = [18 x i8] c"%02ld:%02ld:%02ld\00"
define i8* @hhmmss(i64 %0) {
%2 = srem i64 %0, 3600
%3 = sdiv i64 %0, 3600
%4 = icmp sgt i64 %2, -1
br i1 %4, label %5, label %12
5: ; preds = %1
%6 = trunc i64 %2 to i16
%7 = urem i16 %6, 60
%8 = zext i16 %7 to i64
%9 = udiv i16 %6, 60
%10 = zext i16 %9 to i64
%11 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @hhmmss.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %3, i64 %10, i64 %8)
br label %13
12: ; preds = %1
store i8 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @hhmmss.buf, i64 0, i64 0)
br label %13
13: ; preds = %12, %5
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @hhmmss.buf, i64 0, i64 0)
}