#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 */
scalar_t__ snprintf(char *, int, char *, unsigned int, ...);
char *time_print(unsigned long s) {
  static char buffer[512];
  unsigned int weeks, days, hours, minutes, seconds, total;
  seconds = s % 60;
  minutes = s / 60;
  hours = minutes / 60;
  days = hours / 24;
  weeks = days / 7;
  minutes = minutes % 60;
  hours = hours % 24;
  days = days % 7;
  total = 0;
  if (weeks)
    total += snprintf(
        buffer, 512,
        ((weeks) == 1 ? (char *)("%u week, ") : (char *)("%u weeks, ")), weeks);
  if (days)
    total += snprintf(
        buffer + total, 512 - total,
        ((days) == 1 ? (char *)("%u day, ") : (char *)("%u days, ")), days);
  if ((hours || minutes || seconds) || (!(weeks || days)))
    total += snprintf(buffer + total, 512 - total, "%02u:%02u:%02u", hours,
                      minutes, seconds);
  return buffer;
}


x86 assembly (clang, -O0):
<time_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x18,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x7,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x18,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x7,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11e5 <time_print+0xd5>
mov    -0xc(%rbp),%ecx
lea    0xe55(%rip),%rdx
lea    0xe44(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdx
mov    -0xc(%rbp),%ecx
lea    0x2e73(%rip),%rdi
mov    $0x200,%esi
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1232 <time_print+0x122>
mov    -0x20(%rbp),%eax
lea    0x2e47(%rip),%rdi
add    %rax,%rdi
mov    $0x200,%esi
sub    -0x20(%rbp),%esi
mov    -0x10(%rbp),%ecx
lea    0xe10(%rip),%rdx
lea    0xe00(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdx
mov    -0x10(%rbp),%ecx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1264 <time_print+0x154>
cmpl   $0x0,-0x18(%rbp)
jne    1264 <time_print+0x154>
cmpl   $0x0,-0x1c(%rbp)
jne    1264 <time_print+0x154>
cmpl   $0x0,-0xc(%rbp)
jne    129e <time_print+0x18e>
cmpl   $0x0,-0x10(%rbp)
jne    129e <time_print+0x18e>
mov    -0x20(%rbp),%eax
lea    0x2dd2(%rip),%rdi
add    %rax,%rdi
mov    $0x200,%esi
sub    -0x20(%rbp),%esi
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xd9d(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%eax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
lea    0x2d9b(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rax
movabs $0x8888888888888889,%rcx
88 88 88
mov    %rdi,0x10(%rsp)
mul    %rcx
mov    %rdx,%r12
shr    $0x5,%r12
mov    %r12d,%eax
shr    $0x5,%eax
imul   $0x5b05b06,%rax,%rcx
shr    $0x20,%rcx
mov    %r12d,%edx
mov    $0x88888889,%r15d
imul   %rdx,%r15
shr    $0x25,%r15
mov    $0xaaaaaaab,%ebp
imul   %r15,%rbp
shr    $0x24,%rbp
shl    $0x3,%ebp
imul   $0x24924925,%rcx,%rdx
shr    $0x20,%rdx
mov    %ecx,%ebx
sub    %edx,%ebx
shr    %ebx
add    %edx,%ebx
shr    $0x2,%ebx
lea    0x0(,%rbx,8),%edx
sub    %edx,%ebx
add    %ecx,%ebx
xor    %r13d,%r13d
cmp    $0x2760,%r12d
jb     11d9 <time_print+0xc9>
imul   $0x6806807,%rax,%rcx
shr    $0x23,%rcx
lea    -0x2760(%r12),%eax
ff
cmp    $0x2760,%eax
lea    0xe48(%rip),%rax
lea    0xe4b(%rip),%rdx
cmovb  %rax,%rdx
lea    0x2e76(%rip),%rdi
mov    $0x200,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
mov    %rax,%r13
imul   $0x3c,%r12d,%r14d
imul   $0x3c,%r15d,%eax
lea    0x0(%rbp,%rbp,2),%ebp
test   %ebx,%ebx
je     122a <time_print+0x11a>
mov    %eax,0xc(%rsp)
mov    %r13d,%eax
lea    0x2e49(%rip),%rdi
add    %rax,%rdi
mov    $0x200,%esi
sub    %r13d,%esi
cmp    $0x1,%ebx
lea    0xe09(%rip),%rax
lea    0xe0b(%rip),%rdx
cmove  %rax,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
add    %r13d,%eax
mov    %eax,%r13d
mov    0xc(%rsp),%eax
mov    0x10(%rsp),%r9
sub    %r14d,%r9d
mov    %r12d,%r8d
sub    %eax,%r8d
sub    %ebp,%r15d
test   %ebx,%ebx
sete   %al
cmp    $0x2760,%r12d
setb   %cl
test   %al,%cl
jne    1259 <time_print+0x149>
mov    %r8d,%eax
or     %r9d,%eax
or     %r15d,%eax
je     127f <time_print+0x16f>
mov    %r13d,%eax
lea    0x2ddd(%rip),%rdi
add    %rax,%rdi
mov    $0x200,%esi
sub    %r13d,%esi
lea    0xdb3(%rip),%rdx
mov    %r15d,%ecx
xor    %eax,%eax
call   1030 <snprintf@plt>
lea    0x2dba(%rip),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@time_print.buffer = internal global [512 x i8] zeroinitializer
@.str = [10 x i8] c"%u week, \00"
@.str.1 = [11 x i8] c"%u weeks, \00"
@.str.2 = [9 x i8] c"%u day, \00"
@.str.3 = [10 x i8] c"%u days, \00"
@.str.4 = [15 x i8] c"%02u:%02u:%02u\00"
define i8* @time_print(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i64 %0, i64* %2
%9 = load i64, i64* %2
%10 = urem i64 %9, 60
%11 = trunc i64 %10 to i32
store i32 %11, i32* %7
%12 = load i64, i64* %2
%13 = udiv i64 %12, 60
%14 = trunc i64 %13 to i32
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = udiv i32 %15, 60
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = udiv i32 %17, 24
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = udiv i32 %19, 7
store i32 %20, i32* %3
%21 = load i32, i32* %6
%22 = urem i32 %21, 60
store i32 %22, i32* %6
%23 = load i32, i32* %5
%24 = urem i32 %23, 24
store i32 %24, i32* %5
%25 = load i32, i32* %4
%26 = urem i32 %25, 7
store i32 %26, i32* %4
store i32 0, i32* %8
%27 = load i32, i32* %3
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %40
29: ; preds = %1
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 1
%32 = zext i1 %31 to i64
%33 = select i1 %31, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0)
%34 = load i32, i32* %3
%35 = call i64 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @time_print.buffer, i64 0, i64 0), i32 512, i8* %33, i32 %34)
%36 = load i32, i32* %8
%37 = zext i32 %36 to i64
%38 = add nsw i64 %37, %35
%39 = trunc i64 %38 to i32
store i32 %39, i32* %8
br label %40
40: ; preds = %29, %1
%41 = load i32, i32* %4
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %59
43: ; preds = %40
%44 = load i32, i32* %8
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @time_print.buffer, i64 0, i64 0), i64 %45
%47 = load i32, i32* %8
%48 = sub i32 512, %47
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 1
%51 = zext i1 %50 to i64
%52 = select i1 %50, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0)
%53 = load i32, i32* %4
%54 = call i64 (i8*, i32, i8*, i32, ...) @snprintf(i8* %46, i32 %48, i8* %52, i32 %53)
%55 = load i32, i32* %8
%56 = zext i32 %55 to i64
%57 = add nsw i64 %56, %54
%58 = trunc i64 %57 to i32
store i32 %58, i32* %8
br label %59
59: ; preds = %43, %40
%60 = load i32, i32* %5
%61 = icmp ne i32 %60, 0
br i1 %61, label %74, label %62
62: ; preds = %59
%63 = load i32, i32* %6
%64 = icmp ne i32 %63, 0
br i1 %64, label %74, label %65
65: ; preds = %62
%66 = load i32, i32* %7
%67 = icmp ne i32 %66, 0
br i1 %67, label %74, label %68
68: ; preds = %65
%69 = load i32, i32* %3
%70 = icmp ne i32 %69, 0
br i1 %70, label %88, label %71
71: ; preds = %68
%72 = load i32, i32* %4
%73 = icmp ne i32 %72, 0
br i1 %73, label %88, label %74
74: ; preds = %71, %65, %62, %59
%75 = load i32, i32* %8
%76 = zext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @time_print.buffer, i64 0, i64 0), i64 %76
%78 = load i32, i32* %8
%79 = sub i32 512, %78
%80 = load i32, i32* %5
%81 = load i32, i32* %6
%82 = load i32, i32* %7
%83 = call i64 (i8*, i32, i8*, i32, ...) @snprintf(i8* %77, i32 %79, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %80, i32 %81, i32 %82)
%84 = load i32, i32* %8
%85 = zext i32 %84 to i64
%86 = add nsw i64 %85, %83
%87 = trunc i64 %86 to i32
store i32 %87, i32* %8
br label %88
88: ; preds = %74, %71, %68
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @time_print.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@time_print.buffer = internal global [512 x i8] zeroinitializer
@.str = [10 x i8] c"%u week, \00"
@.str.1 = [11 x i8] c"%u weeks, \00"
@.str.2 = [9 x i8] c"%u day, \00"
@.str.3 = [10 x i8] c"%u days, \00"
@.str.4 = [15 x i8] c"%02u:%02u:%02u\00"
define i8* @time_print(i64 %0) {
%2 = urem i64 %0, 60
%3 = trunc i64 %2 to i32
%4 = udiv i64 %0, 60
%5 = trunc i64 %4 to i32
%6 = udiv i32 %5, 60
%7 = udiv i32 %5, 1440
%8 = urem i32 %5, 60
%9 = urem i32 %6, 24
%10 = urem i32 %7, 7
%11 = icmp ugt i32 %5, 10079
br i1 %11, label %12, label %19
12: ; preds = %1
%13 = udiv i32 %5, 10080
%14 = add i32 %5, -10080
%15 = icmp ult i32 %14, 10080
%16 = select i1 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0)
%17 = tail call i64 (i8*, i32, i8*, i32, ...) @snprintf(i8* getelementptr inbounds ([512 x i8], [512 x i8]* @time_print.buffer, i64 0, i64 0), i32 512, i8* %16, i32 %13)
%18 = trunc i64 %17 to i32
br label %19
19: ; preds = %12, %1
%20 = phi i32 [ %18, %12 ], [ 0, %1 ]
%21 = icmp ne i32 %10, 0
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = zext i32 %20 to i64
%24 = getelementptr inbounds [512 x i8], [512 x i8]* @time_print.buffer, i64 0, i64 %23
%25 = sub i32 512, %20
%26 = icmp eq i32 %10, 1
%27 = select i1 %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0)
%28 = tail call i64 (i8*, i32, i8*, i32, ...) @snprintf(i8* %24, i32 %25, i8* %27, i32 %10)
%29 = trunc i64 %28 to i32
%30 = add i32 %20, %29
br label %31
31: ; preds = %22, %19
%32 = phi i32 [ %30, %22 ], [ %20, %19 ]
%33 = or i32 %8, %3
%34 = or i32 %33, %9
%35 = icmp eq i32 %34, 0
%36 = or i1 %11, %21
%37 = and i1 %36, %35
br i1 %37, label %43, label %38
38: ; preds = %31
%39 = zext i32 %32 to i64
%40 = getelementptr inbounds [512 x i8], [512 x i8]* @time_print.buffer, i64 0, i64 %39
%41 = sub i32 512, %32
%42 = tail call i64 (i8*, i32, i8*, i32, ...) @snprintf(i8* %40, i32 %41, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %9, i32 %8, i32 %3)
br label %43
43: ; preds = %31, %38
ret i8* getelementptr inbounds ([512 x i8], [512 x i8]* @time_print.buffer, i64 0, i64 0)
}