#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 /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int);
char *DHMS(unsigned long t) {
  static char buf[32];
  int days, hours, mins, secs;
  days = t / 86400;
  t %= 86400;
  hours = t / 3600;
  t %= 3600;
  mins = t / 60;
  t %= 60;
  secs = t;
  snprintf(buf, sizeof(buf) - 1, "%d days, %d:%02d:%02d", days, hours, mins,
           secs);
  return buf;
}


x86 assembly (clang, -O0):
<DHMS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x15180,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x15180,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
mov    -0x18(%rbp),%eax
lea    0x2e9f(%rip),%rdi
mov    $0x1f,%esi
lea    0xe53(%rip),%rdx
mov    %eax,(%rsp)
call   1030 <snprintf@plt>
lea    0x2e84(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DHMS>:
push   %rbx
sub    $0x10,%rsp
movabs $0xc22e450672894ab7,%rcx
45 2e c2
mov    %rdi,%rax
mul    %rcx
mov    %rdx,%rcx
shr    $0x10,%rcx
imul   $0x15180,%rcx,%rax
sub    %rax,%rdi
mov    $0x91a2b3c5,%r8d
imul   %rdi,%r8
shr    $0x2b,%r8
imul   $0xe10,%r8d,%eax
sub    %eax,%edi
imul   $0x8889,%edi,%r9d
shr    $0x15,%r9d
imul   $0x3c,%r9d,%eax
sub    %eax,%edi
movzwl %di,%eax
mov    %eax,(%rsp)
lea    0x2ed5(%rip),%rbx
lea    0xe8e(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1f,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@DHMS.buf = internal global [32 x i8] zeroinitializer
@.str = [22 x i8] c"%d days, %d:%02d:%02d\00"
define i8* @DHMS(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i64 %0, i64* %2
%7 = load i64, i64* %2
%8 = udiv i64 %7, 86400
%9 = trunc i64 %8 to i32
store i32 %9, i32* %3
%10 = load i64, i64* %2
%11 = urem i64 %10, 86400
store i64 %11, i64* %2
%12 = load i64, i64* %2
%13 = udiv i64 %12, 3600
%14 = trunc i64 %13 to i32
store i32 %14, i32* %4
%15 = load i64, i64* %2
%16 = urem i64 %15, 3600
store i64 %16, i64* %2
%17 = load i64, i64* %2
%18 = udiv i64 %17, 60
%19 = trunc i64 %18 to i32
store i32 %19, i32* %5
%20 = load i64, i64* %2
%21 = urem i64 %20, 60
store i64 %21, i64* %2
%22 = load i64, i64* %2
%23 = trunc i64 %22 to i32
store i32 %23, i32* %6
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @DHMS.buf, i64 0, i64 0), i32 31, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25, i32 %26, i32 %27)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @DHMS.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@DHMS.buf = internal global [32 x i8] zeroinitializer
@.str = [22 x i8] c"%d days, %d:%02d:%02d\00"
define i8* @DHMS(i64 %0) {
%2 = udiv i64 %0, 86400
%3 = trunc i64 %2 to i32
%4 = urem i64 %0, 86400
%5 = trunc i64 %4 to i32
%6 = udiv i32 %5, 3600
%7 = urem i32 %5, 3600
%8 = trunc i32 %7 to i16
%9 = udiv i16 %8, 60
%10 = zext i16 %9 to i32
%11 = urem i16 %8, 60
%12 = zext i16 %11 to i32
%13 = tail call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @DHMS.buf, i64 0, i64 0), i32 31, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %6, i32 %10, i32 %12)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @DHMS.buf, i64 0, i64 0)
}