#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 sprintf(char *, char *, int, int, int);
char *statstr_dup(char *, int);
char *secs2hms_long(int t) {
  char tstr[60];
  int len, h, m, s;
  h = t / 3600;
  t = t % 3600;
  m = t / 60;
  s = t % 60;
  len = sprintf(tstr, "%d hours, %d minutes, %d seconds", h ? h : 0, m ? m : 0,
                s ? s : 0);
  if (len < 0)
    len = 0;
  return statstr_dup(tstr, len);
}


x86 assembly (clang, -O0):
<secs2hms_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x48(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4c(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x50(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpl   $0x0,-0x48(%rbp)
je     1180 <secs2hms_long+0x60>
mov    -0x48(%rbp),%eax
mov    %eax,-0x5c(%rbp)
jmp    118a <secs2hms_long+0x6a>
xor    %eax,%eax
mov    %eax,-0x5c(%rbp)
jmp    118a <secs2hms_long+0x6a>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x60(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     11a5 <secs2hms_long+0x85>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x64(%rbp)
jmp    11af <secs2hms_long+0x8f>
xor    %eax,%eax
mov    %eax,-0x64(%rbp)
jmp    11af <secs2hms_long+0x8f>
mov    -0x64(%rbp),%eax
mov    %eax,-0x68(%rbp)
cmpl   $0x0,-0x50(%rbp)
je     11ca <secs2hms_long+0xaa>
mov    -0x50(%rbp),%eax
mov    %eax,-0x6c(%rbp)
jmp    11d4 <secs2hms_long+0xb4>
xor    %eax,%eax
mov    %eax,-0x6c(%rbp)
jmp    11d4 <secs2hms_long+0xb4>
mov    -0x68(%rbp),%ecx
mov    -0x60(%rbp),%edx
mov    -0x58(%rbp),%rdi
mov    -0x6c(%rbp),%r8d
lea    0xe17(%rip),%rsi
call   1040 <sprintf@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jge    1202 <secs2hms_long+0xe2>
movl   $0x0,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1030 <statstr_dup@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<secs2hms_long>:
push   %rbx
sub    $0x40,%rsp
movslq %edi,%rax
imul   $0xffffffff91a2b3c5,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%ecx
shr    $0x1f,%ecx
sar    $0xb,%edx
add    %ecx,%edx
imul   $0xe10,%edx,%ecx
sub    %ecx,%eax
movswl %ax,%ecx
imul   $0xffff8889,%ecx,%ecx
shr    $0x10,%ecx
add    %eax,%ecx
movzwl %cx,%ecx
movswl %cx,%esi
shr    $0xf,%ecx
sar    $0x5,%esi
add    %ecx,%esi
movswl %si,%ecx
imul   $0x3c,%esi,%esi
sub    %esi,%eax
movswl %ax,%r8d
lea    0xe8a(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
xor    %esi,%esi
test   %eax,%eax
cmovns %eax,%esi
mov    %rbx,%rdi
call   1030 <statstr_dup@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"%d hours, %d minutes, %d seconds\00"
define i8* @secs2hms_long(i32 %0) {
%2 = alloca i32
%3 = alloca [60 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %2
%8 = load i32, i32* %2
%9 = sdiv i32 %8, 3600
store i32 %9, i32* %5
%10 = load i32, i32* %2
%11 = srem i32 %10, 3600
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 60
store i32 %13, i32* %6
%14 = load i32, i32* %2
%15 = srem i32 %14, 60
store i32 %15, i32* %7
%16 = getelementptr inbounds [60 x i8], [60 x i8]* %3, i64 0, i64 0
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %1
%20 = load i32, i32* %5
br label %22
21: ; preds = %1
br label %22
22: ; preds = %21, %19
%23 = phi i32 [ %20, %19 ], [ 0, %21 ]
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load i32, i32* %6
br label %29
28: ; preds = %22
br label %29
29: ; preds = %28, %26
%30 = phi i32 [ %27, %26 ], [ 0, %28 ]
%31 = load i32, i32* %7
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load i32, i32* %7
br label %36
35: ; preds = %29
br label %36
36: ; preds = %35, %33
%37 = phi i32 [ %34, %33 ], [ 0, %35 ]
%38 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %30, i32 %37)
store i32 %38, i32* %4
%39 = load i32, i32* %4
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %36
store i32 0, i32* %4
br label %42
42: ; preds = %41, %36
%43 = getelementptr inbounds [60 x i8], [60 x i8]* %3, i64 0, i64 0
%44 = load i32, i32* %4
%45 = call i8* @statstr_dup(i8* %43, i32 %44)
ret i8* %45
}

LLVM IR (-O2):
@.str = [33 x i8] c"%d hours, %d minutes, %d seconds\00"
define i8* @secs2hms_long(i32 %0) {
%2 = alloca [60 x i8]
%3 = getelementptr inbounds [60 x i8], [60 x i8]* %2, i64 0, i64 0
%4 = sdiv i32 %0, 3600
%5 = srem i32 %0, 3600
%6 = trunc i32 %5 to i16
%7 = sdiv i16 %6, 60
%8 = sext i16 %7 to i32
%9 = srem i16 %6, 60
%10 = sext i16 %9 to i32
%11 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %8, i32 %10)
%12 = icmp sgt i32 %11, 0
%13 = select i1 %12, i32 %11, i32 0
%14 = call i8* @statstr_dup(i8* %3, i32 %13)
ret i8* %14
}