#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 *, int, ...);
const char *eta_to_human_short(int secs, unsigned char condensed) {
  static char buf[10];
  static int last = -1;
  const char *space = condensed ? "" : " ";
  if (secs == last)
    return buf;
  last = secs;
  if (secs < 100)
    sprintf(buf, "%ds", secs);
  else if (secs < 100 * 60)
    sprintf(buf, "%dm%s%ds", secs / 60, space, secs % 60);
  else if (secs < 48 * 3600)
    sprintf(buf, "%dh%s%dm", secs / 3600, space, (secs / 60) % 60);
  else if (secs < 100 * 86400)
    sprintf(buf, "%dd%s%dh", secs / 86400, space, (secs / 3600) % 60);
  else
    sprintf(buf, "%dd", secs / 86400);
  return buf;
}


x86 assembly (clang, -O0):
<eta_to_human_short>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %edi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
movzbl -0xd(%rbp),%edx
lea    0xed4(%rip),%rax
lea    0xece(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cmp    0x2ee1(%rip),%eax
jne    115d <eta_to_human_short+0x4d>
lea    0x2ed9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12b7 <eta_to_human_short+0x1a7>
mov    -0xc(%rbp),%eax
mov    %eax,0x2ec2(%rip)
cmpl   $0x64,-0xc(%rbp)
jge    118d <eta_to_human_short+0x7d>
mov    -0xc(%rbp),%edx
lea    0x2eb3(%rip),%rdi
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12ac <eta_to_human_short+0x19c>
cmpl   $0x1770,-0xc(%rbp)
jge    11d7 <eta_to_human_short+0xc7>
mov    -0xc(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0xc(%rbp),%eax
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %edx,%r8d
mov    -0x1c(%rbp),%edx
lea    0x2e69(%rip),%rdi
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12a7 <eta_to_human_short+0x197>
cmpl   $0x2a300,-0xc(%rbp)
jge    1229 <eta_to_human_short+0x119>
mov    -0xc(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0xc(%rbp),%eax
mov    $0x3c,%esi
cltd
idiv   %esi
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %edx,%r8d
mov    -0x20(%rbp),%edx
lea    0x2e17(%rip),%rdi
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12a2 <eta_to_human_short+0x192>
cmpl   $0x83d600,-0xc(%rbp)
jge    127b <eta_to_human_short+0x16b>
mov    -0xc(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0xc(%rbp),%eax
mov    $0xe10,%esi
cltd
idiv   %esi
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %edx,%r8d
mov    -0x24(%rbp),%edx
lea    0x2dc5(%rip),%rdi
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    129d <eta_to_human_short+0x18d>
mov    -0xc(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0x2d9e(%rip),%rdi
lea    0xd87(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    12a2 <eta_to_human_short+0x192>
jmp    12a7 <eta_to_human_short+0x197>
jmp    12ac <eta_to_human_short+0x19c>
lea    0x2d7a(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eta_to_human_short>:
push   %rax
test   %esi,%esi
lea    0xee6(%rip),%rdx
lea    0xee0(%rip),%rcx
cmove  %rdx,%rcx
cmp    %edi,0x2efd(%rip)
je     121e <eta_to_human_short+0x10e>
mov    %edi,%eax
mov    %edi,0x2eef(%rip)
cmp    $0x63,%edi
jg     115a <eta_to_human_short+0x4a>
lea    0x2ee8(%rip),%rdi
lea    0xebb(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    121e <eta_to_human_short+0x10e>
cmp    $0x176f,%eax
ja     1189 <eta_to_human_short+0x79>
movzwl %ax,%edx
imul   $0x8889,%edx,%edx
shr    $0x15,%edx
imul   $0x3c,%edx,%esi
sub    %esi,%eax
movzwl %ax,%r8d
lea    0x2eb0(%rip),%rdi
lea    0xe7e(%rip),%rsi
jmp    1217 <eta_to_human_short+0x107>
cmp    $0x2a2ff,%eax
ja     11d1 <eta_to_human_short+0xc1>
mov    %eax,%eax
mov    $0x91a2b3c5,%edx
imul   %rax,%rdx
shr    $0x2b,%rdx
mov    $0x88888889,%esi
imul   %rax,%rsi
shr    $0x25,%rsi
movzwl %si,%eax
imul   $0x8889,%eax,%eax
shr    $0x15,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%esi
movzwl %si,%r8d
lea    0x2e65(%rip),%rdi
lea    0xe3c(%rip),%rsi
jmp    1217 <eta_to_human_short+0x107>
mov    %eax,%esi
mov    $0xc22e4507,%edx
imul   %rsi,%rdx
shr    $0x30,%rdx
cmp    $0x83d5ff,%eax
ja     1227 <eta_to_human_short+0x117>
mov    $0x91a2b3c5,%eax
imul   %rsi,%rax
shr    $0x2b,%rax
movzwl %ax,%esi
imul   $0x8889,%esi,%esi
shr    $0x15,%esi
imul   $0x3c,%esi,%esi
sub    %esi,%eax
movzwl %ax,%r8d
lea    0x2e1d(%rip),%rdi
lea    0xdfd(%rip),%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
lea    0x2e08(%rip),%rax
pop    %rcx
ret
lea    0x2dff(%rip),%rdi
lea    0xde8(%rip),%rsi
jmp    114e <eta_to_human_short+0x3e>

LLVM IR (-O0):
@eta_to_human_short.buf = internal global [10 x i8] zeroinitializer
@eta_to_human_short.last = internal global i32 -1
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c" \00"
@.str.2 = [4 x i8] c"%ds\00"
@.str.3 = [9 x i8] c"%dm%s%ds\00"
@.str.4 = [9 x i8] c"%dh%s%dm\00"
@.str.5 = [9 x i8] c"%dd%s%dh\00"
@.str.6 = [4 x i8] c"%dd\00"
define i8* @eta_to_human_short(i32 %0, i8 zeroext %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8*
store i32 %0, i32* %4
store i8 %1, i8* %5
%7 = load i8, i8* %5
%8 = zext i8 %7 to i32
%9 = icmp ne i32 %8, 0
%10 = zext i1 %9 to i64
%11 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
store i8* %11, i8** %6
%12 = load i32, i32* %4
%13 = load i32, i32* @eta_to_human_short.last
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0), i8** %3
br label %63
16: ; preds = %2
%17 = load i32, i32* %4
store i32 %17, i32* @eta_to_human_short.last
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 100
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* %4
%22 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %62
23: ; preds = %16
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 6000
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load i32, i32* %4
%28 = sdiv i32 %27, 60
%29 = load i8*, i8** %6
%30 = load i32, i32* %4
%31 = srem i32 %30, 60
%32 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %28, i8* %29, i32 %31)
br label %61
33: ; preds = %23
%34 = load i32, i32* %4
%35 = icmp slt i32 %34, 172800
br i1 %35, label %36, label %44
36: ; preds = %33
%37 = load i32, i32* %4
%38 = sdiv i32 %37, 3600
%39 = load i8*, i8** %6
%40 = load i32, i32* %4
%41 = sdiv i32 %40, 60
%42 = srem i32 %41, 60
%43 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %38, i8* %39, i32 %42)
br label %60
44: ; preds = %33
%45 = load i32, i32* %4
%46 = icmp slt i32 %45, 8640000
br i1 %46, label %47, label %55
47: ; preds = %44
%48 = load i32, i32* %4
%49 = sdiv i32 %48, 86400
%50 = load i8*, i8** %6
%51 = load i32, i32* %4
%52 = sdiv i32 %51, 3600
%53 = srem i32 %52, 60
%54 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %49, i8* %50, i32 %53)
br label %59
55: ; preds = %44
%56 = load i32, i32* %4
%57 = sdiv i32 %56, 86400
%58 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %55, %47
br label %60
60: ; preds = %59, %36
br label %61
61: ; preds = %60, %26
br label %62
62: ; preds = %61, %20
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0), i8** %3
br label %63
63: ; preds = %62, %15
%64 = load i8*, i8** %3
ret i8* %64
}

LLVM IR (-O2):
@eta_to_human_short.buf = internal global [10 x i8] zeroinitializer
@eta_to_human_short.last = internal unnamed_addr global i32 -1
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c" \00"
@.str.2 = [4 x i8] c"%ds\00"
@.str.3 = [9 x i8] c"%dm%s%ds\00"
@.str.4 = [9 x i8] c"%dh%s%dm\00"
@.str.5 = [9 x i8] c"%dd%s%dh\00"
@.str.6 = [4 x i8] c"%dd\00"
define i8* @eta_to_human_short(i32 %0, i8 zeroext %1) {
%3 = icmp eq i8 %1, 0
%4 = select i1 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
%5 = load i32, i32* @eta_to_human_short.last
%6 = icmp eq i32 %5, %0
br i1 %6, label %40, label %7
7: ; preds = %2
store i32 %0, i32* @eta_to_human_short.last
%8 = icmp slt i32 %0, 100
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %40
11: ; preds = %7
%12 = icmp ult i32 %0, 6000
br i1 %12, label %13, label %20
13: ; preds = %11
%14 = trunc i32 %0 to i16
%15 = udiv i16 %14, 60
%16 = zext i16 %15 to i32
%17 = urem i16 %14, 60
%18 = zext i16 %17 to i32
%19 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %16, i8* %4, i32 %18)
br label %40
20: ; preds = %11
%21 = icmp ult i32 %0, 172800
br i1 %21, label %22, label %29
22: ; preds = %20
%23 = udiv i32 %0, 3600
%24 = udiv i32 %0, 60
%25 = trunc i32 %24 to i16
%26 = urem i16 %25, 60
%27 = zext i16 %26 to i32
%28 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %23, i8* %4, i32 %27)
br label %40
29: ; preds = %20
%30 = icmp ult i32 %0, 8640000
%31 = udiv i32 %0, 86400
br i1 %30, label %32, label %38
32: ; preds = %29
%33 = udiv i32 %0, 3600
%34 = trunc i32 %33 to i16
%35 = urem i16 %34, 60
%36 = zext i16 %35 to i32
%37 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %31, i8* %4, i32 %36)
br label %40
38: ; preds = %29
%39 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %31)
br label %40
40: ; preds = %9, %22, %38, %32, %13, %2
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @eta_to_human_short.buf, i64 0, i64 0)
}