#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 u_long;
typedef int /*<<< orphan*/ tmp;
typedef int time_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int, char);
int /*<<< orphan*/ strlcat(char *, char *, int);
const char *interval_time(time_t t) {
  static char buf[128];
  char tmp[128];
  u_long r;
  int unit_div[] = {(((((60) * 60) * 24) * 7) * 52),
                    ((((60) * 60) * 24) * 7),
                    (((60) * 60) * 24),
                    ((60) * 60),
                    (60),
                    1,
                    -1};
  char unit_sym[] = {'y', 'w', 'd', 'h', 'm', 's'};
  int i;
  *buf = '\0';
  for (i = 0; unit_div[i] != -1; i++) {
    if ((r = t / unit_div[i]) != 0 || unit_div[i] == 1) {
      snprintf(tmp, sizeof(tmp), "%lu%c", r, unit_sym[i]);
      strlcat(buf, tmp, sizeof(buf));
      t %= unit_div[i];
    }
  }
  return (buf);
}


x86 assembly (clang, -O0):
<interval_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x4(%rbp)
mov    0xecb(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xec5(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    0xebf(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xeba(%rip),%eax
mov    %eax,-0x98(%rbp)
mov    0xeb2(%rip),%eax
mov    %eax,-0xb6(%rbp)
mov    0xea9(%rip),%ax
mov    %ax,-0xb2(%rbp)
movb   $0x0,0x2ebb(%rip)
movl   $0x0,-0xbc(%rbp)
movslq -0xbc(%rbp),%rax
cmpl   $0xffffffff,-0xb0(%rbp,%rax,4)
ff
je     1250 <interval_time+0x130>
mov    -0x4(%rbp),%eax
movslq -0xbc(%rbp),%rcx
cltd
idivl  -0xb0(%rbp,%rcx,4)
mov    %eax,-0x94(%rbp)
cmp    $0x0,%eax
jne    11da <interval_time+0xba>
movslq -0xbc(%rbp),%rax
cmpl   $0x1,-0xb0(%rbp,%rax,4)
01
jne    1237 <interval_time+0x117>
lea    -0x90(%rbp),%rdi
mov    -0x94(%rbp),%ecx
movslq -0xbc(%rbp),%rax
mov    $0x80,%esi
lea    0xe28(%rip),%rdx
movsbl -0xb6(%rbp,%rax,1),%r8d
ff ff
call   1040 <snprintf@plt>
lea    -0x90(%rbp),%rsi
lea    0x2e2a(%rip),%rdi
mov    $0x80,%edx
call   1030 <strlcat@plt>
movslq -0xbc(%rbp),%rax
mov    -0xb0(%rbp,%rax,4),%ecx
mov    -0x4(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
jmp    123c <interval_time+0x11c>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
jmp    118f <interval_time+0x6f>
lea    0x2de9(%rip),%rax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interval_time>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
movb   $0x0,0x2f08(%rip)
lea    0xec1(%rip),%rbx
xor    %ebp,%ebp
lea    0xeda(%rip),%r14
mov    %rsp,%r12
lea    0x2eee(%rip),%r15
jmp    11a0 <interval_time+0x80>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xeb5(%rip),%rcx
movsbl 0x0(%rbp,%rcx,1),%r8d
mov    %r12,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
mov    %eax,%ecx
call   1040 <snprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    $0x80,%edx
call   1030 <strlcat@plt>
mov    %r13d,%edi
add    $0x1,%rbp
add    $0x4,%rbx
cmp    $0x6,%rbp
je     11b4 <interval_time+0x94>
mov    %edi,%eax
cltd
idivl  (%rbx)
mov    %edx,%r13d
test   %eax,%eax
jne    1160 <interval_time+0x40>
cmp    $0x5,%rbp
jne    1192 <interval_time+0x72>
jmp    1160 <interval_time+0x40>
lea    0x2e85(%rip),%rax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@interval_time.buf = internal global [128 x i8] zeroinitializer
@__const.interval_time.unit_div = [7 x i32] [i32 31449600, i32 604800, i32 86400, i32 3600, i32 60, i32 1, i32 -1]
@__const.interval_time.unit_sym = [6 x i8] c"ywdhms"
@.str = [6 x i8] c"%lu%c\00"
define i8* @interval_time(i32 %0) {
%2 = alloca i32
%3 = alloca [128 x i8]
%4 = alloca i32
%5 = alloca [7 x i32]
%6 = alloca [6 x i8]
%7 = alloca i32
store i32 %0, i32* %2
%8 = bitcast [7 x i32]* %5 to i8*
%9 = bitcast [6 x i8]* %6 to i8*
store i8 0, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @interval_time.buf, i64 0, i64 0)
store i32 0, i32* %7
br label %10
10: ; preds = %47, %1
%11 = load i32, i32* %7
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %50
16: ; preds = %10
%17 = load i32, i32* %2
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = sdiv i32 %17, %21
store i32 %22, i32* %4
%23 = icmp ne i32 %22, 0
br i1 %23, label %30, label %24
24: ; preds = %16
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %46
30: ; preds = %24, %16
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%32 = load i32, i32* %4
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = call i32 @snprintf(i8* %31, i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %32, i8 signext %36)
%38 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%39 = call i32 @strlcat(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @interval_time.buf, i64 0, i64 0), i8* %38, i32 128)
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [7 x i32], [7 x i32]* %5, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* %2
%45 = srem i32 %44, %43
store i32 %45, i32* %2
br label %46
46: ; preds = %30, %24
br label %47
47: ; preds = %46
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %10
50: ; preds = %10
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @interval_time.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@interval_time.buf = internal global [128 x i8] zeroinitializer
@__const.interval_time.unit_div = [7 x i32] [i32 31449600, i32 604800, i32 86400, i32 3600, i32 60, i32 1, i32 -1]
@__const.interval_time.unit_sym = [6 x i8] c"ywdhms"
@.str = [6 x i8] c"%lu%c\00"
define i8* @interval_time(i32 %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
store i8 0, i8* getelementptr inbounds ([128 x i8], [128 x i8]* @interval_time.buf, i64 0, i64 0)
br label %4
4: ; preds = %1, %19
%5 = phi i64 [ 0, %1 ], [ %21, %19 ]
%6 = phi i32 [ %0, %1 ], [ %20, %19 ]
%7 = getelementptr inbounds [7 x i32], [7 x i32]* @__const.interval_time.unit_div, i64 0, i64 %5
%8 = load i32, i32* %7
%9 = sdiv i32 %6, %8
%10 = srem i32 %6, %8
%11 = icmp ne i32 %9, 0
%12 = icmp eq i64 %5, 5
%13 = select i1 %11, i1 true, i1 %12
br i1 %13, label %14, label %19
14: ; preds = %4
%15 = getelementptr inbounds [6 x i8], [6 x i8]* @__const.interval_time.unit_sym, i64 0, i64 %5
%16 = load i8, i8* %15
%17 = call i32 @snprintf(i8* %3, i32 128, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %9, i8 signext %16)
%18 = call i32 @strlcat(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @interval_time.buf, i64 0, i64 0), i8* %3, i32 128)
br label %19
19: ; preds = %4, %14
%20 = phi i32 [ %10, %14 ], [ %6, %4 ]
%21 = add nuw nsw i64 %5, 1
%22 = icmp eq i64 %21, 6
br i1 %22, label %23, label %4
23: ; preds = %19
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @interval_time.buf, i64 0, i64 0)
}