#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 time_t;

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, ...);
const char *apm_time_nosec(time_t t) {
  static char buffer[128];
  unsigned long s, m, h, d;
  d = t / (60 * 60 * 24);
  t -= d * (60 * 60 * 24);
  h = t / (60 * 60);
  t -= h * (60 * 60);
  m = t / (60);
  t -= m * (60);
  s = t;
  if (s > 30)
    ++m;
  if (d)
    sprintf(buffer, "%lu day%s, %lu:%02lu", d, d > 1 ? "s" : "", h, m);
  else
    sprintf(buffer, "%lu:%02lu", h, m);
  if (t == -1)
    sprintf(buffer, "unknown");
  return buffer;
}


x86 assembly (clang, -O0):
<apm_time_nosec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x28(%rbp)
imul   $0x15180,-0x28(%rbp),%rcx
movslq -0x4(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x20(%rbp)
imul   $0xe10,-0x20(%rbp),%rcx
movslq -0x4(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x18(%rbp)
imul   $0x3c,-0x18(%rbp),%rcx
movslq -0x4(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x1e,-0x10(%rbp)
jbe    11a0 <apm_time_nosec+0x90>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11eb <apm_time_nosec+0xdb>
mov    -0x28(%rbp),%rdx
mov    -0x28(%rbp),%rsi
lea    0xe64(%rip),%rcx
lea    0xe54(%rip),%rax
cmp    $0x1,%rsi
cmova  %rax,%rcx
mov    -0x20(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0x2e68(%rip),%rdi
lea    0xe21(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1208 <apm_time_nosec+0xf8>
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0x2e46(%rip),%rdi
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
cmpl   $0xffffffff,-0x4(%rbp)
jne    1227 <apm_time_nosec+0x117>
lea    0x2e27(%rip),%rdi
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
lea    0x2e12(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apm_time_nosec>:
push   %rbx
movslq %edi,%rcx
imul   $0xffffffffc22e4507,%rcx,%rax
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x10,%eax
add    %edx,%eax
imul   $0xfffeae80,%eax,%edx
add    %ecx,%edx
movslq %edx,%rdx
imul   $0xffffffff91a2b3c5,%rdx,%rsi
shr    $0x20,%rsi
add    %edx,%esi
mov    %esi,%edi
shr    $0x1f,%edi
sar    $0xb,%esi
add    %edi,%esi
movslq %esi,%r8
imul   $0xfffff1f0,%r8d,%esi
add    %edx,%esi
movslq %esi,%rdx
imul   $0xffffffff88888889,%rdx,%rsi
shr    $0x20,%rsi
add    %edx,%esi
mov    %esi,%edi
shr    $0x1f,%edi
sar    $0x5,%esi
add    %edi,%esi
movslq %esi,%r9
imul   $0xffffffc4,%r9d,%ebx
add    %edx,%ebx
cmp    $0x1f,%ebx
sbb    $0xffffffffffffffff,%r9
add    $0x1517f,%ecx
cmp    $0x2a2ff,%ecx
jae    11b3 <apm_time_nosec+0xa3>
lea    0x2ea8(%rip),%rdi
lea    0xe6c(%rip),%rsi
mov    %r8,%rdx
mov    %r9,%rcx
xor    %eax,%eax
call   1030 <sprintf@plt>
cmp    $0xffffffff,%ebx
jne    11f6 <apm_time_nosec+0xe6>
jmp    11e5 <apm_time_nosec+0xd5>
movslq %eax,%rdx
cmp    $0x2,%eax
lea    0xe55(%rip),%rax
lea    0xe4f(%rip),%rcx
cmovae %rax,%rcx
lea    0x2e6e(%rip),%rdi
lea    0xe27(%rip),%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
cmp    $0xffffffff,%ebx
jne    11f6 <apm_time_nosec+0xe6>
movabs $0x6e776f6e6b6e75,%rax
mov    %rax,0x2e4a(%rip)
lea    0x2e43(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@apm_time_nosec.buffer = internal global [128 x i8] zeroinitializer
@.str = [21 x i8] c"%lu day%s, %lu:%02lu\00"
@.str.1 = [2 x i8] c"s\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [10 x i8] c"%lu:%02lu\00"
@.str.4 = [8 x i8] c"unknown\00"
define i8* @apm_time_nosec(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = sdiv i32 %7, 86400
%9 = sext i32 %8 to i64
store i64 %9, i64* %6
%10 = load i64, i64* %6
%11 = mul i64 %10, 86400
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = sub i64 %13, %11
%15 = trunc i64 %14 to i32
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 3600
%18 = sext i32 %17 to i64
store i64 %18, i64* %5
%19 = load i64, i64* %5
%20 = mul i64 %19, 3600
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = sub i64 %22, %20
%24 = trunc i64 %23 to i32
store i32 %24, i32* %2
%25 = load i32, i32* %2
%26 = sdiv i32 %25, 60
%27 = sext i32 %26 to i64
store i64 %27, i64* %4
%28 = load i64, i64* %4
%29 = mul i64 %28, 60
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = sub i64 %31, %29
%33 = trunc i64 %32 to i32
store i32 %33, i32* %2
%34 = load i32, i32* %2
%35 = sext i32 %34 to i64
store i64 %35, i64* %3
%36 = load i64, i64* %3
%37 = icmp ugt i64 %36, 30
br i1 %37, label %38, label %41
38: ; preds = %1
%39 = load i64, i64* %4
%40 = add i64 %39, 1
store i64 %40, i64* %4
br label %41
41: ; preds = %38, %1
%42 = load i64, i64* %6
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %53
44: ; preds = %41
%45 = load i64, i64* %6
%46 = load i64, i64* %6
%47 = icmp ugt i64 %46, 1
%48 = zext i1 %47 to i64
%49 = select i1 %47, 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.2, i64 0, i64 0)
%50 = load i64, i64* %5
%51 = load i64, i64* %4
%52 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @apm_time_nosec.buffer, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %45, i8* %49, i64 %50, i64 %51)
br label %57
53: ; preds = %41
%54 = load i64, i64* %5
%55 = load i64, i64* %4
%56 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @apm_time_nosec.buffer, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 %54, i64 %55)
br label %57
57: ; preds = %53, %44
%58 = load i32, i32* %2
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @apm_time_nosec.buffer, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60, %57
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @apm_time_nosec.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@apm_time_nosec.buffer = internal global [128 x i8] zeroinitializer
@.str = [21 x i8] c"%lu day%s, %lu:%02lu\00"
@.str.1 = [2 x i8] c"s\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [10 x i8] c"%lu:%02lu\00"
define i8* @apm_time_nosec(i32 %0) {
%2 = sdiv i32 %0, 86400
%3 = mul nsw i32 %2, -86400
%4 = add i32 %3, %0
%5 = sdiv i32 %4, 3600
%6 = sext i32 %5 to i64
%7 = mul nsw i32 %5, -3600
%8 = add i32 %7, %4
%9 = sdiv i32 %8, 60
%10 = sext i32 %9 to i64
%11 = mul nsw i32 %9, -60
%12 = add i32 %11, %8
%13 = icmp ugt i32 %12, 30
%14 = zext i1 %13 to i64
%15 = add nsw i64 %14, %10
%16 = add i32 %0, 86399
%17 = icmp ult i32 %16, 172799
br i1 %17, label %23, label %18
18: ; preds = %1
%19 = sext i32 %2 to i64
%20 = icmp ugt i32 %2, 1
%21 = select i1 %20, 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.2, i64 0, i64 0)
%22 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @apm_time_nosec.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %19, i8* %21, i64 %6, i64 %15)
br label %25
23: ; preds = %1
%24 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @apm_time_nosec.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i64 %6, i64 %15)
br label %25
25: ; preds = %23, %18
%26 = icmp eq i32 %12, -1
br i1 %26, label %27, label %28
27: ; preds = %25
store i64 31093567915781749, i64* bitcast ([128 x i8]* @apm_time_nosec.buffer to i64*)
br label %28
28: ; preds = %27, %25
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @apm_time_nosec.buffer, i64 0, i64 0)
}