#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 *, long, ...);
char *svz_uptime(long diff) {
  static char text[64];
  long sec, min, hour, day, old;
  old = diff;
  sec = diff % 60;
  diff /= 60;
  min = diff % 60;
  diff /= 60;
  hour = diff % 24;
  diff /= 24;
  day = diff;
  if (old < 60) {
    sprintf(text, "%ld sec", sec);
  } else if (old < 60 * 60) {
    sprintf(text, "%ld min", min);
  } else if (old < 60 * 60 * 24) {
    sprintf(text, "%ld hours, %ld min", hour, min);
  } else {
    sprintf(text, "%ld days, %ld:%02ld", day, hour, min);
  }
  return text;
}


x86 assembly (clang, -O0):
<svz_uptime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x18,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x18,%ecx
cqto
idiv   %rcx
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x3c,-0x30(%rbp)
jge    11c1 <svz_uptime+0xb1>
mov    -0x10(%rbp),%rdx
lea    0x2e92(%rip),%rdi
lea    0xe4b(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1248 <svz_uptime+0x138>
cmpq   $0xe10,-0x30(%rbp)
jge    11ed <svz_uptime+0xdd>
mov    -0x18(%rbp),%rdx
lea    0x2e66(%rip),%rdi
lea    0xe32(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1243 <svz_uptime+0x133>
cmpq   $0x15180,-0x30(%rbp)
jge    121d <svz_uptime+0x10d>
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0x2e36(%rip),%rdi
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    123e <svz_uptime+0x12e>
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    0x2e10(%rip),%rdi
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1243 <svz_uptime+0x133>
jmp    1248 <svz_uptime+0x138>
lea    0x2df1(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<svz_uptime>:
push   %rax
mov    %rdi,%rcx
movabs $0x8888888888888889,%rsi
88 88 88
mov    %rdi,%rax
imul   %rsi
mov    %rdx,%r8
add    %rdi,%r8
mov    %r8,%rax
shr    $0x3f,%rax
sar    $0x5,%r8
add    %rax,%r8
mov    %r8,%rax
imul   %rsi
mov    %rdx,%rdi
movabs $0x48d159e26af37c05,%rdx
59 d1 48
mov    %rcx,%rax
imul   %rdx
mov    %rdx,%r9
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xa,%r9
add    %rax,%r9
movabs $0x2aaaaaaaaaaaaaab,%rdx
aa aa 2a
mov    %r9,%rax
imul   %rdx
mov    %rdx,%rsi
movabs $0x1845c8a0ce512957,%rdx
c8 45 18
mov    %rcx,%rax
imul   %rdx
cmp    $0x3b,%rcx
jg     11a5 <svz_uptime+0x95>
imul   $0x3c,%r8,%rax
sub    %rax,%rcx
lea    0x2ea7(%rip),%rdi
lea    0xe60(%rip),%rsi
mov    %rcx,%rdx
jmp    11d7 <svz_uptime+0xc7>
add    %r8,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x5,%rdi
add    %rax,%rdi
imul   $0x3c,%rdi,%rax
sub    %rax,%r8
cmp    $0xe0f,%rcx
ja     11e7 <svz_uptime+0xd7>
lea    0x2e73(%rip),%rdi
lea    0xe3f(%rip),%rsi
mov    %r8,%rdx
xor    %eax,%eax
call   1030 <sprintf@plt>
lea    0x2e5b(%rip),%rax
pop    %rcx
ret
mov    %rsi,%rax
shr    $0x3f,%rax
shr    $0x2,%rsi
add    %rax,%rsi
shl    $0x3,%rsi
lea    (%rsi,%rsi,2),%rax
sub    %rax,%r9
cmp    $0x1517f,%rcx
ja     1226 <svz_uptime+0x116>
lea    0x2e30(%rip),%rdi
lea    0xdf1(%rip),%rsi
mov    %r9,%rdx
mov    %r8,%rcx
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    11de <svz_uptime+0xce>
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xd,%rdx
add    %rax,%rdx
lea    0x2e05(%rip),%rdi
lea    0xdd9(%rip),%rsi
mov    %r9,%rcx
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    11de <svz_uptime+0xce>

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

LLVM IR (-O2):
@svz_uptime.text = internal global [64 x i8] zeroinitializer
@.str = [8 x i8] c"%ld sec\00"
@.str.1 = [8 x i8] c"%ld min\00"
@.str.2 = [19 x i8] c"%ld hours, %ld min\00"
@.str.3 = [20 x i8] c"%ld days, %ld:%02ld\00"
define i8* @svz_uptime(i64 %0) {
%2 = sdiv i64 %0, 60
%3 = srem i64 %0, 60
%4 = srem i64 %2, 60
%5 = sdiv i64 %0, 3600
%6 = srem i64 %5, 24
%7 = sdiv i64 %0, 86400
%8 = icmp slt i64 %0, 60
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = tail call i32 (i8*, i8*, i64, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @svz_uptime.text, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %3)
br label %21
11: ; preds = %1
%12 = icmp ult i64 %0, 3600
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 (i8*, i8*, i64, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @svz_uptime.text, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 %4)
br label %21
15: ; preds = %11
%16 = icmp ult i64 %0, 86400
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = tail call i32 (i8*, i8*, i64, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @svz_uptime.text, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 %6, i64 %4)
br label %21
19: ; preds = %15
%20 = tail call i32 (i8*, i8*, i64, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @svz_uptime.text, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i64 %7, i64 %6, i64 %4)
br label %21
21: ; preds = %13, %19, %17, %9
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @svz_uptime.text, i64 0, i64 0)
}