#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*/ snprintf(char *, unsigned int, char *, long, ...);
void format_seconds_short(char *buf, unsigned int n, long t) {
  if (t >= 24 * 60 * 60)
    snprintf(buf, n, "%ldd %ldh", t / 60 / 60 / 24, (t / 60 / 60) % 24);
  else if (t >= 60 * 60)
    snprintf(buf, n, "%ldh %ldm", (t / 60 / 60) % 24, (t / 60) % 60);
  else
    snprintf(buf, n, "%ldm", t / 60);
}


x86 assembly (clang, -O0):
<format_seconds_short>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x15180,-0x18(%rbp)
jl     1198 <format_seconds_short+0x88>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    $0x18,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    $0x3c,%r8d
cqto
idiv   %r8
mov    $0x3c,%r8d
cqto
idiv   %r8
mov    $0x18,%r8d
cqto
idiv   %r8
mov    %rdx,%r8
lea    0xe74(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    122d <format_seconds_short+0x11d>
cmpq   $0xe10,-0x18(%rbp)
jl     1202 <format_seconds_short+0xf2>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    $0x18,%ecx
cqto
idiv   %rcx
mov    %rdx,%rcx
mov    -0x18(%rbp),%rax
mov    $0x3c,%r8d
cqto
idiv   %r8
mov    $0x3c,%r8d
cqto
idiv   %r8
mov    %rdx,%r8
lea    0xe14(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    1228 <format_seconds_short+0x118>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
lea    0xdee(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    122d <format_seconds_short+0x11d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_seconds_short>:
mov    %rdx,%rcx
cmp    $0x15180,%rdx
jl     117a <format_seconds_short+0x6a>
mov    %rcx,%rax
shr    $0x4,%rax
movabs $0x91a2b3c4d5e6f81,%rdx
2b 1a 09
mul    %rdx
mov    %rdx,%r8
shr    $0x3,%r8
movabs $0xc22e450672894ab7,%rdx
45 2e c2
mov    %rcx,%rax
mul    %rdx
mov    %rdx,%rcx
shr    $0x10,%rcx
movabs $0xaaaaaaaaaaaaaaab,%rdx
aa aa aa
mov    %r8,%rax
mul    %rdx
shr    %rdx
and    $0xfffffffffffffff8,%rdx
lea    (%rdx,%rdx,2),%rax
sub    %rax,%r8
lea    0xe8d(%rip),%rdx
xor    %eax,%eax
jmp    1030 <snprintf@plt>
cmp    $0xe10,%rcx
jl     11d9 <format_seconds_short+0xc9>
mov    %ecx,%ecx
mov    $0x88888889,%eax
imul   %rcx,%rax
shr    $0x25,%rax
mov    $0x91a2b3c5,%edx
imul   %rcx,%rdx
shr    $0x2b,%rdx
movzbl %dl,%ecx
imul   $0xab,%ecx,%ecx
shr    $0x9,%ecx
and    $0xfffffff8,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %cl,%dl
movzbl %dl,%ecx
movzwl %ax,%edx
imul   $0x8889,%edx,%edx
shr    $0x15,%edx
imul   $0x3c,%edx,%edx
sub    %edx,%eax
movzwl %ax,%r8d
lea    0xe38(%rip),%rdx
xor    %eax,%eax
jmp    1030 <snprintf@plt>
movabs $0x8888888888888889,%rdx
88 88 88
mov    %rcx,%rax
imul   %rdx
add    %rdx,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x5,%rcx
add    %rax,%rcx
lea    0xe0e(%rip),%rdx
xor    %eax,%eax
jmp    1030 <snprintf@plt>

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

LLVM IR (-O2):
@.str = [10 x i8] c"%ldd %ldh\00"
@.str.1 = [10 x i8] c"%ldh %ldm\00"
@.str.2 = [5 x i8] c"%ldm\00"
define void @format_seconds_short(i8* %0, i32 %1, i64 %2) {
%4 = icmp sgt i64 %2, 86399
br i1 %4, label %5, label %10
5: ; preds = %3
%6 = udiv i64 %2, 3600
%7 = udiv i64 %2, 86400
%8 = urem i64 %6, 24
%9 = tail call i32 (i8*, i32, i8*, i64, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %7, i64 %8)
br label %26
10: ; preds = %3
%11 = icmp sgt i64 %2, 3599
br i1 %11, label %12, label %23
12: ; preds = %10
%13 = trunc i64 %2 to i32
%14 = udiv i32 %13, 60
%15 = udiv i32 %13, 3600
%16 = trunc i32 %15 to i8
%17 = urem i8 %16, 24
%18 = zext i8 %17 to i64
%19 = trunc i32 %14 to i16
%20 = urem i16 %19, 60
%21 = zext i16 %20 to i64
%22 = tail call i32 (i8*, i32, i8*, i64, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64 %18, i64 %21)
br label %26
23: ; preds = %10
%24 = sdiv i64 %2, 60
%25 = tail call i32 (i8*, i32, i8*, i64, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %24)
br label %26
26: ; preds = %12, %23, %5
ret void
}