#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*/ printf(char *, long, ...);
void print_level(long diffsec) {
  if (diffsec < 60) {
    printf("%ld sec\n", diffsec);
    return;
  }
  long min = diffsec / 60;
  long sec = diffsec % 60;
  if (min < 60) {
    printf("%ld min, %ld sec\n", min, sec);
    return;
  }
  long hour = min / 60;
  min %= 60;
  if (hour < 24) {
    printf("%ld hour, %ld min\n", hour, min);
    return;
  }
  long day = hour / 24;
  hour %= 24;
  if (day < 365) {
    printf("%ld day, %ld hour\n", day, hour);
    return;
  }
  long year = day / 365;
  day %= 365;
  printf("%ld year, %ld day\n", year, day);
}


x86 assembly (clang, -O0):
<print_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x3c,-0x8(%rbp)
jge    113e <print_level+0x2e>
mov    -0x8(%rbp),%rsi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1259 <print_level+0x149>
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x18(%rbp)
cmpq   $0x3c,-0x10(%rbp)
jge    1188 <print_level+0x78>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1259 <print_level+0x149>
mov    -0x10(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x10(%rbp)
cmpq   $0x18,-0x20(%rbp)
jge    11d2 <print_level+0xc2>
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1259 <print_level+0x149>
mov    -0x20(%rbp),%rax
mov    $0x18,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    $0x18,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x20(%rbp)
cmpq   $0x16d,-0x28(%rbp)
jge    121f <print_level+0x10f>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1259 <print_level+0x149>
mov    -0x28(%rbp),%rax
mov    $0x16d,%ecx
cqto
idiv   %rcx
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    $0x16d,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x28(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_level>:
mov    %rdi,%rsi
cmp    $0x3b,%rdi
jg     1127 <print_level+0x17>
lea    0xee9(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
movabs $0x8888888888888889,%rdi
88 88 88
mov    %rsi,%rax
mul    %rdi
mov    %rdx,%rcx
shr    $0x5,%rcx
cmp    $0xe0f,%rsi
ja     116c <print_level+0x5c>
movzwl %si,%eax
imul   $0x8889,%eax,%eax
shr    $0x15,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%esi
movzwl %si,%edx
lea    0xe9e(%rip),%rdi
mov    %rcx,%rsi
xor    %eax,%eax
jmp    1030 <printf@plt>
mov    %rsi,%rax
shr    $0x4,%rax
movabs $0x91a2b3c4d5e6f81,%rdx
2b 1a 09
mul    %rdx
mov    %rdx,%r8
shr    $0x3,%r8
cmp    $0x1517f,%rsi
ja     11b0 <print_level+0xa0>
mov    %rcx,%rax
mul    %rdi
shr    $0x5,%rdx
imul   $0x3c,%rdx,%rax
sub    %rax,%rcx
lea    0xe6a(%rip),%rdi
mov    %r8,%rsi
jmp    124e <print_level+0x13e>
movabs $0xc22e450672894ab7,%rcx
45 2e c2
mov    %rsi,%rax
mul    %rcx
mov    %rdx,%rcx
shr    $0x10,%rcx
cmp    $0x1e1337f,%rsi
ja     1202 <print_level+0xf2>
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    0xe30(%rip),%rdi
mov    %rcx,%rsi
mov    %r8,%rdx
xor    %eax,%eax
jmp    1030 <printf@plt>
shr    $0x7,%rsi
movabs $0x220c523d72c49c3,%rdx
c5 20 02
mov    %rsi,%rax
mul    %rdx
mov    %rdx,%rsi
shr    $0xb,%rsi
movabs $0x6719f36016719f37,%rdx
f3 19 67
mov    %rcx,%rax
mul    %rdx
mov    %rcx,%rax
sub    %rdx,%rax
shr    %rax
add    %rdx,%rax
shr    $0x8,%rax
imul   $0x16d,%rax,%rax
sub    %rax,%rcx
lea    0xdea(%rip),%rdi
mov    %rcx,%rdx
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%ld sec\0A\00"
@.str.1 = [18 x i8] c"%ld min, %ld sec\0A\00"
@.str.2 = [19 x i8] c"%ld hour, %ld min\0A\00"
@.str.3 = [19 x i8] c"%ld day, %ld hour\0A\00"
@.str.4 = [19 x i8] c"%ld year, %ld day\0A\00"
define void @print_level(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
%9 = icmp slt i64 %8, 60
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i64, i64* %2
%12 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 %11)
br label %54
13: ; preds = %1
%14 = load i64, i64* %2
%15 = sdiv i64 %14, 60
store i64 %15, i64* %3
%16 = load i64, i64* %2
%17 = srem i64 %16, 60
store i64 %17, i64* %4
%18 = load i64, i64* %3
%19 = icmp slt i64 %18, 60
br i1 %19, label %20, label %24
20: ; preds = %13
%21 = load i64, i64* %3
%22 = load i64, i64* %4
%23 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 %21, i64 %22)
br label %54
24: ; preds = %13
%25 = load i64, i64* %3
%26 = sdiv i64 %25, 60
store i64 %26, i64* %5
%27 = load i64, i64* %3
%28 = srem i64 %27, 60
store i64 %28, i64* %3
%29 = load i64, i64* %5
%30 = icmp slt i64 %29, 24
br i1 %30, label %31, label %35
31: ; preds = %24
%32 = load i64, i64* %5
%33 = load i64, i64* %3
%34 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 %32, i64 %33)
br label %54
35: ; preds = %24
%36 = load i64, i64* %5
%37 = sdiv i64 %36, 24
store i64 %37, i64* %6
%38 = load i64, i64* %5
%39 = srem i64 %38, 24
store i64 %39, i64* %5
%40 = load i64, i64* %6
%41 = icmp slt i64 %40, 365
br i1 %41, label %42, label %46
42: ; preds = %35
%43 = load i64, i64* %6
%44 = load i64, i64* %5
%45 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 %43, i64 %44)
br label %54
46: ; preds = %35
%47 = load i64, i64* %6
%48 = sdiv i64 %47, 365
store i64 %48, i64* %7
%49 = load i64, i64* %6
%50 = srem i64 %49, 365
store i64 %50, i64* %6
%51 = load i64, i64* %7
%52 = load i64, i64* %6
%53 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i64 %51, i64 %52)
br label %54
54: ; preds = %46, %42, %31, %20, %10
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%ld sec\0A\00"
@.str.1 = [18 x i8] c"%ld min, %ld sec\0A\00"
@.str.2 = [19 x i8] c"%ld hour, %ld min\0A\00"
@.str.3 = [19 x i8] c"%ld day, %ld hour\0A\00"
@.str.4 = [19 x i8] c"%ld year, %ld day\0A\00"
define void @print_level(i64 %0) {
%2 = icmp slt i64 %0, 60
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 %0)
br label %29
5: ; preds = %1
%6 = udiv i64 %0, 60
%7 = icmp ult i64 %0, 3600
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = trunc i64 %0 to i16
%10 = urem i16 %9, 60
%11 = zext i16 %10 to i64
%12 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 %6, i64 %11)
br label %29
13: ; preds = %5
%14 = udiv i64 %0, 3600
%15 = icmp ult i64 %0, 86400
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = urem i64 %6, 60
%18 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 %14, i64 %17)
br label %29
19: ; preds = %13
%20 = udiv i64 %0, 86400
%21 = icmp ult i64 %0, 31536000
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = urem i64 %14, 24
%24 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 %20, i64 %23)
br label %29
25: ; preds = %19
%26 = udiv i64 %0, 31536000
%27 = urem i64 %20, 365
%28 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i64 %26, i64 %27)
br label %29
29: ; preds = %8, %22, %25, %16, %3
ret void
}