#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 */
struct sysinfo {
  long uptime;
};

/* Variables and functions */
char *calloc(int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ sprintf(char *, char *, long);
int /*<<< orphan*/ strcat(char *, char *);
char *strdup(char *);
int sysinfo(struct sysinfo *);
char *myuptime_get_uptime(int pretty_flag) {
  int str_len = 512;
  char *str;
  char *str_tmp;
  char *str_res;
  long uptime;
  struct sysinfo si;
  const long minute = 60;
  const long hour = minute * 60;
  const long day = hour * 24;
  const long week = 7 * day;
  const long year = 365 * day;
  long minutes, hours, days, weeks, years;
  str_tmp = calloc(str_len, sizeof(char));
  if (str_tmp == NULL)
    return NULL;
  str = calloc(str_len, sizeof(char));
  if (str == NULL)
    return NULL;
  if (sysinfo(&si) == -1)
    return NULL;
  uptime = si.uptime;
  years = uptime / year;
  weeks = (uptime % year) / week;
  hours = (uptime % day) / hour;
  minutes = (uptime % hour) / minute;
  if (pretty_flag) {
    days = (uptime % week) / day;
    if (years) {
      sprintf(str_tmp, "%ld years, ", years);
      strcat(str, str_tmp);
    }
    if (weeks) {
      sprintf(str_tmp, "%ld weeks, ", weeks);
      strcat(str, str_tmp);
    }
    if (days) {
      sprintf(str_tmp, "%ld days, ", days);
      strcat(str, str_tmp);
    }
    if (hours) {
      sprintf(str_tmp, "%ld hours, ", hours);
      strcat(str, str_tmp);
    }
    if (minutes) {
      sprintf(str_tmp, "%02ld minutes", minutes);
      strcat(str, str_tmp);
    }
  } else {
    days = (uptime % year) / day;
    if (years) {
      sprintf(str_tmp, "%ld years, ", years);
      strcat(str, str_tmp);
    }
    if (days) {
      sprintf(str_tmp, "%ld days, ", days);
      strcat(str, str_tmp);
    }
    if (hours) {
      sprintf(str_tmp, "%ld:", hours);
      strcat(str, str_tmp);
    }
    if (minutes) {
      if (hours)
        sprintf(str_tmp, "%02ld", minutes);
      else
        sprintf(str_tmp, "%02ld minutes", minutes);
      strcat(str, str_tmp);
    }
  }
  free(str_tmp);
  str_res = strdup(str);
  free(str);
  return str_res;
}


x86 assembly (clang, -O0):
<myuptime_get_uptime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0xc(%rbp)
movl   $0x200,-0x10(%rbp)
movq   $0x3c,-0x40(%rbp)
movq   $0xe10,-0x48(%rbp)
movq   $0x15180,-0x50(%rbp)
movq   $0x93a80,-0x58(%rbp)
movq   $0x1e13380,-0x60(%rbp)
01
mov    -0x10(%rbp),%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c6 <myuptime_get_uptime+0x66>
movq   $0x0,-0x8(%rbp)
jmp    14bd <myuptime_get_uptime+0x35d>
mov    -0x10(%rbp),%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ef <myuptime_get_uptime+0x8f>
movq   $0x0,-0x8(%rbp)
jmp    14bd <myuptime_get_uptime+0x35d>
lea    -0x38(%rbp),%rdi
call   1050 <sysinfo@plt>
cmp    $0xffffffff,%eax
jne    120e <myuptime_get_uptime+0xae>
movq   $0x0,-0x8(%rbp)
jmp    14bd <myuptime_get_uptime+0x35d>
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    $0x1e13380,%ecx
cqto
idiv   %rcx
mov    %rax,-0x88(%rbp)
mov    -0x30(%rbp),%rax
mov    $0x1e13380,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0x93a80,%ecx
cqto
idiv   %rcx
mov    %rax,-0x80(%rbp)
mov    -0x30(%rbp),%rax
mov    $0x15180,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rax,-0x70(%rbp)
mov    -0x30(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,-0x68(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1398 <myuptime_get_uptime+0x238>
mov    -0x30(%rbp),%rax
mov    $0x93a80,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0x15180,%ecx
cqto
idiv   %rcx
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     12e3 <myuptime_get_uptime+0x183>
mov    -0x20(%rbp),%rdi
mov    -0x88(%rbp),%rdx
lea    0xd2f(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
cmpq   $0x0,-0x80(%rbp)
je     130f <myuptime_get_uptime+0x1af>
mov    -0x20(%rbp),%rdi
mov    -0x80(%rbp),%rdx
lea    0xd0f(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
cmpq   $0x0,-0x78(%rbp)
je     133b <myuptime_get_uptime+0x1db>
mov    -0x20(%rbp),%rdi
mov    -0x78(%rbp),%rdx
lea    0xcef(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
cmpq   $0x0,-0x70(%rbp)
je     1367 <myuptime_get_uptime+0x207>
mov    -0x20(%rbp),%rdi
mov    -0x70(%rbp),%rdx
lea    0xcce(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
cmpq   $0x0,-0x68(%rbp)
je     1393 <myuptime_get_uptime+0x233>
mov    -0x20(%rbp),%rdi
mov    -0x68(%rbp),%rdx
lea    0xcae(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
jmp    1496 <myuptime_get_uptime+0x336>
mov    -0x30(%rbp),%rax
mov    $0x1e13380,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0x15180,%ecx
cqto
idiv   %rcx
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     13e9 <myuptime_get_uptime+0x289>
mov    -0x20(%rbp),%rdi
mov    -0x88(%rbp),%rdx
lea    0xc29(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
cmpq   $0x0,-0x78(%rbp)
je     1415 <myuptime_get_uptime+0x2b5>
mov    -0x20(%rbp),%rdi
mov    -0x78(%rbp),%rdx
lea    0xc15(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
cmpq   $0x0,-0x70(%rbp)
je     1441 <myuptime_get_uptime+0x2e1>
mov    -0x20(%rbp),%rdi
mov    -0x70(%rbp),%rdx
lea    0xc0e(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
cmpq   $0x0,-0x68(%rbp)
je     1491 <myuptime_get_uptime+0x331>
cmpq   $0x0,-0x70(%rbp)
je     1470 <myuptime_get_uptime+0x310>
mov    -0x20(%rbp),%rdi
mov    -0x68(%rbp),%rdx
lea    0xbdc(%rip),%rsi
call   1070 <sprintf@plt>
jmp    1484 <myuptime_get_uptime+0x324>
mov    -0x20(%rbp),%rdi
mov    -0x68(%rbp),%rdx
lea    0xbb0(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <strcat@plt>
jmp    1496 <myuptime_get_uptime+0x336>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myuptime_get_uptime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebp
mov    $0x200,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     1396 <myuptime_get_uptime+0x236>
mov    %rax,%r12
mov    $0x200,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     1396 <myuptime_get_uptime+0x236>
mov    %rax,%r14
lea    0x20(%rsp),%rdi
call   1050 <sysinfo@plt>
cmp    $0xffffffff,%eax
je     1396 <myuptime_get_uptime+0x236>
mov    0x20(%rsp),%rbx
movabs $0x883148f5cb1270b9,%rcx
48 31 88
mov    %rbx,%rax
imul   %rcx
mov    %rdx,%rcx
add    %rbx,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x18,%rcx
add    %rax,%rcx
imul   $0x1e13380,%rcx,%rax
mov    %rbx,%r13
sub    %rax,%r13
movslq %r13d,%rsi
movabs $0x1845c8a0ce512957,%rdx
c8 45 18
mov    %rbx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xd,%rdx
add    %rax,%rdx
imul   $0x15180,%rdx,%rax
mov    %rbx,%r15
sub    %rax,%r15
movslq %r15d,%rax
imul   $0xffffffff91a2b3c5,%rax,%rdx
shr    $0x20,%rdx
add    %edx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0xb,%eax
add    %edx,%eax
cltq
mov    %rax,0x10(%rsp)
movabs $0x48d159e26af37c05,%rdx
59 d1 48
mov    %rbx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xa,%rdx
add    %rax,%rdx
imul   $0xe10,%rdx,%rax
mov    %rbx,%rdx
sub    %rax,%rdx
mov    %rdx,0x8(%rsp)
test   %ebp,%ebp
je     139d <myuptime_get_uptime+0x23d>
movabs $0x377aef2669de1559,%rdx
ef 7a 37
mov    %rbx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x11,%rdx
add    %rax,%rdx
imul   $0x93a80,%rdx,%rbp
lea    0x1e1337f(%rbx),%rax
cmp    $0x3c266ff,%rax
jb     12d1 <myuptime_get_uptime+0x171>
mov    %rsi,0x18(%rsp)
lea    0xd4a(%rip),%rsi
mov    %r12,%rdi
mov    %rcx,%rdx
call   1070 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
mov    0x18(%rsp),%rsi
sub    %rbp,%rbx
add    $0x93a7f,%r13
cmp    $0x1274ff,%r13
jb     1318 <myuptime_get_uptime+0x1b8>
imul   $0x6ef5de4d,%rsi,%rax
mov    %rax,%rcx
shr    $0x20,%rcx
shr    $0x3f,%rax
sar    $0x12,%ecx
add    %eax,%ecx
movslq %ecx,%rdx
lea    0xd07(%rip),%rsi
mov    %r12,%rdi
call   1070 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
lea    0x1517f(%rbx),%rax
cmp    $0x2a2ff,%rax
jb     135e <myuptime_get_uptime+0x1fe>
movslq %ebx,%rax
imul   $0xffffffffc22e4507,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x10,%eax
add    %ecx,%eax
movslq %eax,%rdx
lea    0xccd(%rip),%rsi
mov    %r12,%rdi
call   1070 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
add    $0xe0f,%r15
cmp    $0x1c1f,%r15
jb     1424 <myuptime_get_uptime+0x2c4>
lea    0xcaa(%rip),%rsi
mov    %r12,%rdi
mov    0x10(%rsp),%rdx
call   1070 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
jmp    1424 <myuptime_get_uptime+0x2c4>
xor    %ebx,%ebx
jmp    14bf <myuptime_get_uptime+0x35f>
add    $0x1e1337f,%rbx
cmp    $0x3c266ff,%rbx
jb     13d0 <myuptime_get_uptime+0x270>
mov    %rsi,%rbx
lea    0xc49(%rip),%rsi
mov    %r12,%rdi
mov    %rcx,%rdx
call   1070 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rsi
add    $0x1517f,%r13
cmp    $0x2a2ff,%r13
jb     1414 <myuptime_get_uptime+0x2b4>
imul   $0xffffffffc22e4507,%rsi,%rax
shr    $0x20,%rax
add    %eax,%esi
mov    %esi,%eax
shr    $0x1f,%eax
sar    $0x10,%esi
add    %eax,%esi
movslq %esi,%rdx
lea    0xc17(%rip),%rsi
mov    %r12,%rdi
call   1070 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
add    $0xe0f,%r15
cmp    $0x1c1e,%r15
ja     143c <myuptime_get_uptime+0x2dc>
mov    0x8(%rsp),%rcx
lea    0x3b(%rcx),%rax
cmp    $0x77,%rax
jb     14a4 <myuptime_get_uptime+0x344>
lea    0xbf5(%rip),%rsi
jmp    1471 <myuptime_get_uptime+0x311>
lea    0xbfa(%rip),%rsi
mov    %r12,%rdi
mov    0x10(%rsp),%rdx
call   1070 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
mov    0x8(%rsp),%rcx
lea    0x3b(%rcx),%rax
cmp    $0x77,%rax
jb     14a4 <myuptime_get_uptime+0x344>
lea    0xbd1(%rip),%rsi
movswl %cx,%eax
imul   $0xffff8889,%eax,%eax
shr    $0x10,%eax
add    %ecx,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
sar    $0x5,%ecx
add    %eax,%ecx
movswq %cx,%rdx
mov    %r12,%rdi
call   1070 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.sysinfo = type { i64 }
@.str = [12 x i8] c"%ld years, \00"
@.str.1 = [12 x i8] c"%ld weeks, \00"
@.str.2 = [11 x i8] c"%ld days, \00"
@.str.3 = [12 x i8] c"%ld hours, \00"
@.str.4 = [14 x i8] c"%02ld minutes\00"
@.str.5 = [5 x i8] c"%ld:\00"
@.str.6 = [6 x i8] c"%02ld\00"
define noalias i8* @myuptime_get_uptime(i32 %0) {
%2 = alloca %struct.sysinfo
%3 = bitcast %struct.sysinfo* %2 to i8*
%4 = tail call dereferenceable_or_null(512) i8* @calloc(i32 512, i32 1)
%5 = icmp eq i8* %4, null
br i1 %5, label %93, label %6
6: ; preds = %1
%7 = tail call dereferenceable_or_null(512) i8* @calloc(i32 512, i32 1)
%8 = icmp eq i8* %7, null
br i1 %8, label %93, label %9
9: ; preds = %6
%10 = call i32 @sysinfo(%struct.sysinfo* %2)
%11 = icmp eq i32 %10, -1
br i1 %11, label %93, label %12
12: ; preds = %9
%13 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i64 0, i32 0
%14 = load i64, i64* %13
%15 = sdiv i64 %14, 31536000
%16 = srem i64 %14, 31536000
%17 = trunc i64 %16 to i32
%18 = sdiv i32 %17, 604800
%19 = sext i32 %18 to i64
%20 = srem i64 %14, 86400
%21 = trunc i64 %20 to i32
%22 = sdiv i32 %21, 3600
%23 = sext i32 %22 to i64
%24 = srem i64 %14, 3600
%25 = trunc i64 %24 to i16
%26 = sdiv i16 %25, 60
%27 = sext i16 %26 to i64
%28 = icmp eq i32 %0, 0
br i1 %28, label %60, label %29
29: ; preds = %12
%30 = srem i64 %14, 604800
%31 = trunc i64 %30 to i32
%32 = sdiv i32 %31, 86400
%33 = sext i32 %32 to i64
%34 = add i64 %14, 31535999
%35 = icmp ult i64 %34, 63071999
br i1 %35, label %39, label %36
36: ; preds = %29
%37 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 %15)
%38 = call i32 @strcat(i8* %7, i8* %4)
br label %39
39: ; preds = %36, %29
%40 = add nsw i64 %16, 604799
%41 = icmp ult i64 %40, 1209599
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 %19)
%44 = call i32 @strcat(i8* %7, i8* %4)
br label %45
45: ; preds = %42, %39
%46 = add nsw i64 %30, 86399
%47 = icmp ult i64 %46, 172799
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %33)
%50 = call i32 @strcat(i8* %7, i8* %4)
br label %51
51: ; preds = %48, %45
%52 = add nsw i64 %20, 3599
%53 = icmp ult i64 %52, 7199
br i1 %53, label %57, label %54
54: ; preds = %51
%55 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i64 %23)
%56 = call i32 @strcat(i8* %7, i8* %4)
br label %57
57: ; preds = %54, %51
%58 = add nsw i64 %24, 59
%59 = icmp ult i64 %58, 119
br i1 %59, label %89, label %85
60: ; preds = %12
%61 = sdiv i32 %17, 86400
%62 = sext i32 %61 to i64
%63 = add i64 %14, 31535999
%64 = icmp ult i64 %63, 63071999
br i1 %64, label %68, label %65
65: ; preds = %60
%66 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 %15)
%67 = call i32 @strcat(i8* %7, i8* %4)
br label %68
68: ; preds = %65, %60
%69 = add nsw i64 %16, 86399
%70 = icmp ult i64 %69, 172799
br i1 %70, label %74, label %71
71: ; preds = %68
%72 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %62)
%73 = call i32 @strcat(i8* %7, i8* %4)
br label %74
74: ; preds = %71, %68
%75 = add nsw i64 %20, 3599
%76 = icmp ult i64 %75, 7199
br i1 %76, label %77, label %80
77: ; preds = %74
%78 = add nsw i64 %24, 59
%79 = icmp ult i64 %78, 119
br i1 %79, label %89, label %85
80: ; preds = %74
%81 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 %23)
%82 = call i32 @strcat(i8* %7, i8* %4)
%83 = add nsw i64 %24, 59
%84 = icmp ult i64 %83, 119
br i1 %84, label %89, label %85
85: ; preds = %80, %77, %57
%86 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), %57 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), %80 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), %77 ]
%87 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) %86, i64 %27)
%88 = call i32 @strcat(i8* %7, i8* %4)
br label %89
89: ; preds = %85, %80, %77, %57
%90 = call i32 @free(i8* %4)
%91 = call i8* @strdup(i8* %7)
%92 = call i32 @free(i8* %7)
br label %93
93: ; preds = %9, %6, %1, %89
%94 = phi i8* [ %91, %89 ], [ null, %1 ], [ null, %6 ], [ null, %9 ]
ret i8* %94
}