#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*/ mudstrlcat(char *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int, char);
char *sec_to_hms(time_t loctime, char *tstr) {
  time_t t_rem;
  int sc, mn, hr, dy, wk;
  int sflg = 0;
  char buff[4096];
  if (loctime < 1) {
    mudstrlcat(tstr, "no time at all", 4096);
    return (tstr);
  }
  sc = loctime % (60);
  t_rem = loctime - sc;
  if (t_rem > 0) {
    t_rem /= (60);
    mn = t_rem % (60);
    t_rem -= mn;
    if (t_rem > 0) {
      t_rem /= (60);
      hr = t_rem % (24);
      t_rem -= hr;
      if (t_rem > 0) {
        t_rem /= (24);
        dy = t_rem % (7);
        t_rem -= dy;
        if (t_rem > 0) {
          wk = t_rem / (7);
          if (wk) {
            sflg = 1;
            snprintf(buff, 4096, "%d week%c", wk, ((wk) == 1 ? '\0' : 's'));
            mudstrlcat(tstr, buff, 4096);
          }
        }
        if (dy) {
          if (sflg == 1)
            mudstrlcat(tstr, " ", 4096);
          sflg = 1;
          snprintf(buff, 4096, "%d day%c", dy, ((dy) == 1 ? '\0' : 's'));
          mudstrlcat(tstr, buff, 4096);
        }
      }
      if (hr) {
        if (sflg == 1)
          mudstrlcat(tstr, " ", 4096);
        sflg = 1;
        snprintf(buff, 4096, "%d hour%c", hr, ((hr) == 1 ? '\0' : 's'));
        mudstrlcat(tstr, buff, 4096);
      }
    }
    if (mn) {
      if (sflg == 1)
        mudstrlcat(tstr, " ", 4096);
      sflg = 1;
      snprintf(buff, 4096, "%d minute%c", mn, ((mn) == 1 ? '\0' : 's'));
      mudstrlcat(tstr, buff, 4096);
    }
  }
  if (sc) {
    if (sflg == 1)
      mudstrlcat(tstr, " ", 4096);
    snprintf(buff, 4096, "%d second%c", sc, ((sc) == 1 ? '\0' : 's'));
    mudstrlcat(tstr, buff, 4096);
  }
  return (tstr);
}


x86 assembly (clang, -O0):
<sec_to_hms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    1165 <sec_to_hms+0x45>
mov    -0x18(%rbp),%rdi
lea    0xeb2(%rip),%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1461 <sec_to_hms+0x341>
mov    -0xc(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    13ec <sec_to_hms+0x2cc>
mov    -0x1c(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1373 <sec_to_hms+0x253>
mov    -0x1c(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x18,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
mov    -0x28(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    12fa <sec_to_hms+0x1da>
mov    -0x1c(%rbp),%eax
mov    $0x18,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0x2c(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1281 <sec_to_hms+0x161>
mov    -0x1c(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     127c <sec_to_hms+0x15c>
movl   $0x1,-0x34(%rbp)
lea    -0x1040(%rbp),%rdi
mov    -0x30(%rbp),%ecx
mov    -0x30(%rbp),%esi
mov    $0x73,%eax
xor    %edx,%edx
cmp    $0x1,%esi
cmove  %edx,%eax
mov    $0x1000,%esi
lea    0xdb1(%rip),%rdx
movsbl %al,%r8d
call   1030 <snprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x1040(%rbp),%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
jmp    1281 <sec_to_hms+0x161>
cmpl   $0x0,-0x2c(%rbp)
je     12f5 <sec_to_hms+0x1d5>
cmpl   $0x1,-0x34(%rbp)
jne    12aa <sec_to_hms+0x18a>
mov    -0x18(%rbp),%rdi
lea    0xd79(%rip),%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
movl   $0x1,-0x34(%rbp)
lea    -0x1040(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
mov    -0x2c(%rbp),%esi
mov    $0x73,%eax
xor    %edx,%edx
cmp    $0x1,%esi
cmove  %edx,%eax
mov    $0x1000,%esi
lea    0xd44(%rip),%rdx
movsbl %al,%r8d
call   1030 <snprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x1040(%rbp),%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
jmp    12fa <sec_to_hms+0x1da>
cmpl   $0x0,-0x28(%rbp)
je     136e <sec_to_hms+0x24e>
cmpl   $0x1,-0x34(%rbp)
jne    1323 <sec_to_hms+0x203>
mov    -0x18(%rbp),%rdi
lea    0xd00(%rip),%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
movl   $0x1,-0x34(%rbp)
lea    -0x1040(%rbp),%rdi
mov    -0x28(%rbp),%ecx
mov    -0x28(%rbp),%esi
mov    $0x73,%eax
xor    %edx,%edx
cmp    $0x1,%esi
cmove  %edx,%eax
mov    $0x1000,%esi
lea    0xcd4(%rip),%rdx
movsbl %al,%r8d
call   1030 <snprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x1040(%rbp),%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
jmp    1373 <sec_to_hms+0x253>
cmpl   $0x0,-0x24(%rbp)
je     13e7 <sec_to_hms+0x2c7>
cmpl   $0x1,-0x34(%rbp)
jne    139c <sec_to_hms+0x27c>
mov    -0x18(%rbp),%rdi
lea    0xc87(%rip),%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
movl   $0x1,-0x34(%rbp)
lea    -0x1040(%rbp),%rdi
mov    -0x24(%rbp),%ecx
mov    -0x24(%rbp),%esi
mov    $0x73,%eax
xor    %edx,%edx
cmp    $0x1,%esi
cmove  %edx,%eax
mov    $0x1000,%esi
lea    0xc65(%rip),%rdx
movsbl %al,%r8d
call   1030 <snprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x1040(%rbp),%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
jmp    13ec <sec_to_hms+0x2cc>
cmpl   $0x0,-0x20(%rbp)
je     1459 <sec_to_hms+0x339>
cmpl   $0x1,-0x34(%rbp)
jne    1415 <sec_to_hms+0x2f5>
mov    -0x18(%rbp),%rdi
lea    0xc0e(%rip),%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
lea    -0x1040(%rbp),%rdi
mov    -0x20(%rbp),%ecx
mov    -0x20(%rbp),%esi
mov    $0x73,%eax
xor    %edx,%edx
cmp    $0x1,%esi
cmove  %edx,%eax
mov    $0x1000,%esi
lea    0xbff(%rip),%rdx
movsbl %al,%r8d
call   1030 <snprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x1040(%rbp),%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sec_to_hms>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %rsi,%r13
test   %edi,%edi
jle    125e <sec_to_hms+0x13e>
mov    %edi,%eax
mov    $0x88888889,%esi
mov    %rax,%rdx
imul   %rsi,%rdx
shr    $0x25,%rdx
imul   $0x3c,%edx,%ecx
mov    %edi,%ebp
sub    %ecx,%ebp
xor    %ecx,%ecx
cmp    %edi,%ebp
jae    138a <sec_to_hms+0x26a>
mov    %edx,%ebx
imul   %rsi,%rbx
shr    $0x25,%rbx
imul   $0x3c,%ebx,%esi
mov    %edx,%r14d
sub    %esi,%r14d
cmp    %r14d,%edx
jbe    126d <sec_to_hms+0x14d>
mov    $0x91a2b3c5,%esi
imul   %rax,%rsi
shr    $0x2b,%rsi
mov    $0xaaaaaaab,%ecx
imul   %rsi,%rcx
shr    $0x24,%rcx
shl    $0x3,%ecx
lea    (%rcx,%rcx,2),%ecx
mov    %esi,%r15d
sub    %ecx,%r15d
xor    %edx,%edx
mov    $0x0,%ecx
cmp    %r15d,%esi
jbe    12c6 <sec_to_hms+0x1a6>
mov    $0xc22e4507,%ecx
imul   %rax,%rcx
shr    $0x30,%rcx
imul   $0x2493,%ecx,%edx
shr    $0x10,%edx
mov    %ecx,%esi
sub    %edx,%esi
movzwl %si,%esi
shr    %esi
add    %edx,%esi
shr    $0x2,%esi
lea    0x0(,%rsi,8),%edx
sub    %edx,%esi
add    %ecx,%esi
movzwl %si,%r12d
cmp    $0x93a80,%edi
jb     127b <sec_to_hms+0x15b>
cmp    %r12d,%ecx
jbe    127b <sec_to_hms+0x15b>
imul   $0x6ef5de4d,%rax,%rcx
shr    $0x32,%rcx
add    $0xfff6c580,%edi
xor    %eax,%eax
cmp    $0x93a80,%edi
mov    $0x73,%r8d
cmovb  %eax,%r8d
lea    0xdec(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1030 <snprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
test   %r12d,%r12d
je     12bf <sec_to_hms+0x19f>
lea    0xdca(%rip),%rsi
mov    %r13,%rdi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
jmp    1284 <sec_to_hms+0x164>
lea    0xd9b(%rip),%rsi
mov    %r13,%rdi
jmp    13d4 <sec_to_hms+0x2b4>
test   %r14d,%r14d
jne    134a <sec_to_hms+0x22a>
jmp    138a <sec_to_hms+0x26a>
test   %r12d,%r12d
je     1324 <sec_to_hms+0x204>
xor    %eax,%eax
cmp    $0x1,%r12w
mov    $0x73,%r8d
cmove  %eax,%r8d
lea    0xd7f(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    %r12d,%ecx
call   1030 <snprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
mov    $0x1,%ecx
mov    $0x1,%dl
test   %r15d,%r15d
je     132d <sec_to_hms+0x20d>
test   %dl,%dl
je     12e3 <sec_to_hms+0x1c3>
lea    0xd43(%rip),%rsi
mov    %r13,%rdi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
xor    %eax,%eax
cmp    $0x1,%r15d
mov    $0x73,%r8d
cmove  %eax,%r8d
lea    0xd2a(%rip),%rdx
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x1000,%esi
mov    %r15d,%ecx
call   1030 <snprintf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
test   %r14d,%r14d
jne    1336 <sec_to_hms+0x216>
jmp    1384 <sec_to_hms+0x264>
xor    %edx,%edx
xor    %ecx,%ecx
test   %r15d,%r15d
jne    12cb <sec_to_hms+0x1ab>
test   %r14d,%r14d
je     138a <sec_to_hms+0x26a>
test   %dl,%dl
je     134a <sec_to_hms+0x22a>
lea    0xcdc(%rip),%rsi
mov    %r13,%rdi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
xor    %eax,%eax
cmp    $0x1,%r14d
mov    $0x73,%r8d
cmove  %eax,%r8d
lea    0xccd(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x1000,%esi
mov    %r14d,%ecx
call   1030 <snprintf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
test   %ebp,%ebp
jne    1392 <sec_to_hms+0x272>
jmp    13de <sec_to_hms+0x2be>
test   %ebp,%ebp
je     13de <sec_to_hms+0x2be>
test   %ecx,%ecx
je     13a6 <sec_to_hms+0x286>
lea    0xc80(%rip),%rsi
mov    %r13,%rdi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
xor    %eax,%eax
cmp    $0x1,%ebp
mov    $0x73,%r8d
cmove  %eax,%r8d
lea    0xc7e(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
mov    %ebp,%ecx
call   1030 <snprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1040 <mudstrlcat@plt>
mov    %r13,%rax
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"no time at all\00"
@.str.1 = [10 x i8] c"%d week%c\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [9 x i8] c"%d day%c\00"
@.str.4 = [10 x i8] c"%d hour%c\00"
@.str.5 = [12 x i8] c"%d minute%c\00"
@.str.6 = [12 x i8] c"%d second%c\00"
define i8* @sec_to_hms(i32 %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [4096 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 0, i32* %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = call i32 @mudstrlcat(i8* %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 4096)
%19 = load i8*, i8** %5
store i8* %19, i8** %3
br label %165
20: ; preds = %2
%21 = load i32, i32* %4
%22 = srem i32 %21, 60
store i32 %22, i32* %7
%23 = load i32, i32* %4
%24 = load i32, i32* %7
%25 = sub nsw i32 %23, %24
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %142
28: ; preds = %20
%29 = load i32, i32* %6
%30 = sdiv i32 %29, 60
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = srem i32 %31, 60
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = load i32, i32* %6
%35 = sub nsw i32 %34, %33
store i32 %35, i32* %6
%36 = load i32, i32* %6
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %120
38: ; preds = %28
%39 = load i32, i32* %6
%40 = sdiv i32 %39, 60
store i32 %40, i32* %6
%41 = load i32, i32* %6
%42 = srem i32 %41, 24
store i32 %42, i32* %9
%43 = load i32, i32* %9
%44 = load i32, i32* %6
%45 = sub nsw i32 %44, %43
store i32 %45, i32* %6
%46 = load i32, i32* %6
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %98
48: ; preds = %38
%49 = load i32, i32* %6
%50 = sdiv i32 %49, 24
store i32 %50, i32* %6
%51 = load i32, i32* %6
%52 = srem i32 %51, 7
store i32 %52, i32* %10
%53 = load i32, i32* %10
%54 = load i32, i32* %6
%55 = sub nsw i32 %54, %53
store i32 %55, i32* %6
%56 = load i32, i32* %6
%57 = icmp sgt i32 %56, 0
br i1 %57, label %58, label %76
58: ; preds = %48
%59 = load i32, i32* %6
%60 = sdiv i32 %59, 7
store i32 %60, i32* %11
%61 = load i32, i32* %11
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %75
63: ; preds = %58
store i32 1, i32* %12
%64 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%65 = load i32, i32* %11
%66 = load i32, i32* %11
%67 = icmp eq i32 %66, 1
%68 = zext i1 %67 to i64
%69 = select i1 %67, i32 0, i32 115
%70 = trunc i32 %69 to i8
%71 = call i32 @snprintf(i8* %64, i32 4096, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %65, i8 signext %70)
%72 = load i8*, i8** %5
%73 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%74 = call i32 @mudstrlcat(i8* %72, i8* %73, i32 4096)
br label %75
75: ; preds = %63, %58
br label %76
76: ; preds = %75, %48
%77 = load i32, i32* %10
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %97
79: ; preds = %76
%80 = load i32, i32* %12
%81 = icmp eq i32 %80, 1
br i1 %81, label %82, label %85
82: ; preds = %79
%83 = load i8*, i8** %5
%84 = call i32 @mudstrlcat(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 4096)
br label %85
85: ; preds = %82, %79
store i32 1, i32* %12
%86 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%87 = load i32, i32* %10
%88 = load i32, i32* %10
%89 = icmp eq i32 %88, 1
%90 = zext i1 %89 to i64
%91 = select i1 %89, i32 0, i32 115
%92 = trunc i32 %91 to i8
%93 = call i32 @snprintf(i8* %86, i32 4096, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %87, i8 signext %92)
%94 = load i8*, i8** %5
%95 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%96 = call i32 @mudstrlcat(i8* %94, i8* %95, i32 4096)
br label %97
97: ; preds = %85, %76
br label %98
98: ; preds = %97, %38
%99 = load i32, i32* %9
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %119
101: ; preds = %98
%102 = load i32, i32* %12
%103 = icmp eq i32 %102, 1
br i1 %103, label %104, label %107
104: ; preds = %101
%105 = load i8*, i8** %5
%106 = call i32 @mudstrlcat(i8* %105, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 4096)
br label %107
107: ; preds = %104, %101
store i32 1, i32* %12
%108 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%109 = load i32, i32* %9
%110 = load i32, i32* %9
%111 = icmp eq i32 %110, 1
%112 = zext i1 %111 to i64
%113 = select i1 %111, i32 0, i32 115
%114 = trunc i32 %113 to i8
%115 = call i32 @snprintf(i8* %108, i32 4096, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %109, i8 signext %114)
%116 = load i8*, i8** %5
%117 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%118 = call i32 @mudstrlcat(i8* %116, i8* %117, i32 4096)
br label %119
119: ; preds = %107, %98
br label %120
120: ; preds = %119, %28
%121 = load i32, i32* %8
%122 = icmp ne i32 %121, 0
br i1 %122, label %123, label %141
123: ; preds = %120
%124 = load i32, i32* %12
%125 = icmp eq i32 %124, 1
br i1 %125, label %126, label %129
126: ; preds = %123
%127 = load i8*, i8** %5
%128 = call i32 @mudstrlcat(i8* %127, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 4096)
br label %129
129: ; preds = %126, %123
store i32 1, i32* %12
%130 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%131 = load i32, i32* %8
%132 = load i32, i32* %8
%133 = icmp eq i32 %132, 1
%134 = zext i1 %133 to i64
%135 = select i1 %133, i32 0, i32 115
%136 = trunc i32 %135 to i8
%137 = call i32 @snprintf(i8* %130, i32 4096, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %131, i8 signext %136)
%138 = load i8*, i8** %5
%139 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%140 = call i32 @mudstrlcat(i8* %138, i8* %139, i32 4096)
br label %141
141: ; preds = %129, %120
br label %142
142: ; preds = %141, %20
%143 = load i32, i32* %7
%144 = icmp ne i32 %143, 0
br i1 %144, label %145, label %163
145: ; preds = %142
%146 = load i32, i32* %12
%147 = icmp eq i32 %146, 1
br i1 %147, label %148, label %151
148: ; preds = %145
%149 = load i8*, i8** %5
%150 = call i32 @mudstrlcat(i8* %149, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 4096)
br label %151
151: ; preds = %148, %145
%152 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%153 = load i32, i32* %7
%154 = load i32, i32* %7
%155 = icmp eq i32 %154, 1
%156 = zext i1 %155 to i64
%157 = select i1 %155, i32 0, i32 115
%158 = trunc i32 %157 to i8
%159 = call i32 @snprintf(i8* %152, i32 4096, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %153, i8 signext %158)
%160 = load i8*, i8** %5
%161 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%162 = call i32 @mudstrlcat(i8* %160, i8* %161, i32 4096)
br label %163
163: ; preds = %151, %142
%164 = load i8*, i8** %5
store i8* %164, i8** %3
br label %165
165: ; preds = %163, %16
%166 = load i8*, i8** %3
ret i8* %166
}

LLVM IR (-O2):
@.str = [15 x i8] c"no time at all\00"
@.str.1 = [10 x i8] c"%d week%c\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [9 x i8] c"%d day%c\00"
@.str.4 = [10 x i8] c"%d hour%c\00"
@.str.5 = [12 x i8] c"%d minute%c\00"
@.str.6 = [12 x i8] c"%d second%c\00"
define i8* @sec_to_hms(i32 %0, i8* returned %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @mudstrlcat(i8* %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 4096)
br label %84
8: ; preds = %2
%9 = urem i32 %0, 60
%10 = udiv i32 %0, 60
%11 = icmp ult i32 %9, %0
br i1 %11, label %12, label %64
12: ; preds = %8
%13 = urem i32 %10, 60
%14 = icmp ugt i32 %10, %13
br i1 %14, label %15, label %59
15: ; preds = %12
%16 = udiv i32 %0, 3600
%17 = urem i32 %16, 24
%18 = icmp ugt i32 %16, %17
br i1 %18, label %19, label %44
19: ; preds = %15
%20 = udiv i32 %0, 86400
%21 = trunc i32 %20 to i16
%22 = urem i16 %21, 7
%23 = zext i16 %22 to i32
%24 = icmp ule i32 %20, %23
%25 = icmp ult i32 %0, 604800
%26 = or i1 %25, %24
br i1 %26, label %35, label %27
27: ; preds = %19
%28 = udiv i32 %0, 604800
%29 = add nsw i32 %0, -604800
%30 = icmp ult i32 %29, 604800
%31 = select i1 %30, i8 0, i8 115
%32 = call i32 @snprintf(i8* %4, i32 4096, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %28, i8 signext %31)
%33 = call i32 @mudstrlcat(i8* %1, i8* %4, i32 4096)
%34 = icmp eq i16 %22, 0
br i1 %34, label %44, label %37
35: ; preds = %19
%36 = icmp eq i16 %22, 0
br i1 %36, label %44, label %39
37: ; preds = %27
%38 = call i32 @mudstrlcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 4096)
br label %39
39: ; preds = %35, %37
%40 = icmp eq i16 %22, 1
%41 = select i1 %40, i8 0, i8 115
%42 = call i32 @snprintf(i8* %4, i32 4096, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %23, i8 signext %41)
%43 = call i32 @mudstrlcat(i8* %1, i8* %4, i32 4096)
br label %44
44: ; preds = %35, %27, %39, %15
%45 = phi i1 [ false, %35 ], [ true, %27 ], [ true, %39 ], [ false, %15 ]
%46 = phi i32 [ 0, %35 ], [ 1, %27 ], [ 1, %39 ], [ 0, %15 ]
%47 = icmp eq i32 %17, 0
br i1 %47, label %51, label %48
48: ; preds = %44
br i1 %45, label %49, label %53
49: ; preds = %48
%50 = call i32 @mudstrlcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 4096)
br label %53
51: ; preds = %44
%52 = icmp eq i32 %13, 0
br i1 %52, label %64, label %61
53: ; preds = %48, %49
%54 = icmp eq i32 %17, 1
%55 = select i1 %54, i8 0, i8 115
%56 = call i32 @snprintf(i8* %4, i32 4096, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %17, i8 signext %55)
%57 = call i32 @mudstrlcat(i8* %1, i8* %4, i32 4096)
%58 = icmp eq i32 %13, 0
br i1 %58, label %67, label %62
59: ; preds = %12
%60 = icmp eq i32 %13, 0
br i1 %60, label %64, label %69
61: ; preds = %51
br i1 %45, label %62, label %69
62: ; preds = %53, %61
%63 = call i32 @mudstrlcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 4096)
br label %69
64: ; preds = %59, %51, %8
%65 = phi i32 [ %46, %51 ], [ 0, %8 ], [ 0, %59 ]
%66 = icmp eq i32 %9, 0
br i1 %66, label %84, label %75
67: ; preds = %53
%68 = icmp eq i32 %9, 0
br i1 %68, label %84, label %77
69: ; preds = %61, %62, %59
%70 = icmp eq i32 %13, 1
%71 = select i1 %70, i8 0, i8 115
%72 = call i32 @snprintf(i8* %4, i32 4096, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %13, i8 signext %71)
%73 = call i32 @mudstrlcat(i8* %1, i8* %4, i32 4096)
%74 = icmp eq i32 %9, 0
br i1 %74, label %84, label %77
75: ; preds = %64
%76 = icmp eq i32 %65, 1
br i1 %76, label %77, label %79
77: ; preds = %67, %69, %75
%78 = call i32 @mudstrlcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 4096)
br label %79
79: ; preds = %77, %75
%80 = icmp eq i32 %9, 1
%81 = select i1 %80, i8 0, i8 115
%82 = call i32 @snprintf(i8* %4, i32 4096, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %9, i8 signext %81)
%83 = call i32 @mudstrlcat(i8* %1, i8* %4, i32 4096)
br label %84
84: ; preds = %67, %69, %64, %79, %6
ret i8* %1
}