#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 {
  unsigned int uptime;
};

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, unsigned int, char *, unsigned int,
                          unsigned int, unsigned int);
int sysinfo(struct sysinfo *);
int main(void) {
  long int remainder;
  struct sysinfo s_info;
  unsigned int days, hours, minutes, seconds;
  if (sysinfo(&s_info) == -1) {
    perror("error: sysinfo");
    return 1;
  }
  seconds = s_info.uptime;
  days = seconds / (60 * 60 * 24);
  remainder = seconds % (60 * 60 * 24);
  hours = remainder / (60 * 60);
  remainder = remainder % (60 * 60);
  minutes = remainder / 60;
  seconds = remainder % 60;
  printf("%u %s, %02u:%02u:%02u\n", days, (days == 1 ? "day" : "days"), hours,
         minutes, seconds);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x18(%rbp),%rdi
call   1050 <sysinfo@plt>
cmp    $0xffffffff,%eax
jne    1169 <main+0x39>
lea    0xea8(%rip),%rdi
call   1040 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1210 <main+0xe0>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x15180,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x15180,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%eax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%ecx
lea    0xe46(%rip),%rdx
lea    0xe3b(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    %rsp,%rdi
call   1050 <sysinfo@plt>
cmp    $0xffffffff,%eax
je     11ae <main+0x7e>
mov    (%rsp),%eax
mov    $0xc22e4507,%esi
imul   %rax,%rsi
shr    $0x30,%rsi
imul   $0x15180,%esi,%ecx
lea    -0x15180(%rax),%edx
sub    %ecx,%eax
mov    $0x91a2b3c5,%ecx
imul   %rax,%rcx
shr    $0x2b,%rcx
imul   $0xe10,%ecx,%edi
sub    %edi,%eax
imul   $0x8889,%eax,%r8d
shr    $0x15,%r8d
imul   $0x3c,%r8d,%edi
sub    %edi,%eax
movzwl %ax,%r9d
cmp    $0x15180,%edx
lea    0xe93(%rip),%rax
lea    0xe90(%rip),%rdx
cmovb  %rax,%rdx
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe4b(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.sysinfo = type { i32 }
@.str = [15 x i8] c"error: sysinfo\00"
@.str.1 = [23 x i8] c"%u %s, %02u:%02u:%02u\0A\00"
@.str.2 = [4 x i8] c"day\00"
@.str.3 = [5 x i8] c"days\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca %struct.sysinfo
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @sysinfo(%struct.sysinfo* %3)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %40
12: ; preds = %0
%13 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %3, i32 0, i32 0
%14 = load i32, i32* %13
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = udiv i32 %15, 86400
store i32 %16, i32* %4
%17 = load i32, i32* %7
%18 = urem i32 %17, 86400
%19 = zext i32 %18 to i64
store i64 %19, i64* %2
%20 = load i64, i64* %2
%21 = sdiv i64 %20, 3600
%22 = trunc i64 %21 to i32
store i32 %22, i32* %5
%23 = load i64, i64* %2
%24 = srem i64 %23, 3600
store i64 %24, i64* %2
%25 = load i64, i64* %2
%26 = sdiv i64 %25, 60
%27 = trunc i64 %26 to i32
store i32 %27, i32* %6
%28 = load i64, i64* %2
%29 = srem i64 %28, 60
%30 = trunc i64 %29 to i32
store i32 %30, i32* %7
%31 = load i32, i32* %4
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 1
%34 = zext i1 %33 to i64
%35 = select i1 %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%36 = load i32, i32* %5
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %31, i8* %35, i32 %36, i32 %37, i32 %38)
store i32 0, i32* %1
br label %40
40: ; preds = %12, %10
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
%struct.sysinfo = type { i32 }
@.str = [15 x i8] c"error: sysinfo\00"
@.str.1 = [23 x i8] c"%u %s, %02u:%02u:%02u\0A\00"
@.str.2 = [4 x i8] c"day\00"
@.str.3 = [5 x i8] c"days\00"
define i32 @main() {
%1 = alloca %struct.sysinfo
%2 = bitcast %struct.sysinfo* %1 to i8*
%3 = call i32 @sysinfo(%struct.sysinfo* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %23
7: ; preds = %0
%8 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 0
%9 = load i32, i32* %8
%10 = udiv i32 %9, 86400
%11 = urem i32 %9, 86400
%12 = udiv i32 %11, 3600
%13 = urem i32 %11, 3600
%14 = trunc i32 %13 to i16
%15 = udiv i16 %14, 60
%16 = zext i16 %15 to i32
%17 = urem i16 %14, 60
%18 = zext i16 %17 to i32
%19 = add i32 %9, -86400
%20 = icmp ult i32 %19, 86400
%21 = select i1 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%22 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %10, i8* %21, i32 %12, i32 %16, i32 %18)
br label %23
23: ; preds = %7, %5
%24 = phi i32 [ 1, %5 ], [ 0, %7 ]
ret i32 %24
}