#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, 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;
  if (days == 1)
    printf("1 day, %02u:%02u:%02u\n", hours, minutes, seconds);
  else
    printf("%u days, %02u:%02u:%02u\n", 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    121f <main+0xef>
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)
cmpl   $0x1,-0x1c(%rbp)
jne    11fd <main+0xcd>
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1218 <main+0xe8>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
call   1050 <sysinfo@plt>
cmp    $0xffffffff,%eax
je     11c3 <main+0x93>
mov    0x8(%rsp),%eax
mov    $0xc22e4507,%esi
imul   %rax,%rsi
shr    $0x30,%rsi
imul   $0x15180,%esi,%ecx
lea    -0x15180(%rax),%edi
sub    %ecx,%eax
mov    $0x91a2b3c5,%edx
imul   %rax,%rdx
shr    $0x2b,%rdx
imul   $0xe10,%edx,%ecx
sub    %ecx,%eax
imul   $0x8889,%eax,%ecx
shr    $0x15,%ecx
imul   $0x3c,%ecx,%ebx
sub    %ebx,%eax
movzwl %ax,%r8d
cmp    $0x1517f,%edi
ja     11ab <main+0x7b>
lea    0xe76(%rip),%rdi
xor    %ebx,%ebx
mov    %edx,%esi
mov    %ecx,%edx
mov    %r8d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11bb <main+0x8b>
lea    0xe74(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe36(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%ebx
jmp    11bb <main+0x8b>

LLVM IR (-O0):
%struct.sysinfo = type { i32 }
@.str = [15 x i8] c"error: sysinfo\00"
@.str.1 = [23 x i8] c"1 day, %02u:%02u:%02u\0A\00"
@.str.2 = [25 x i8] c"%u days, %02u:%02u:%02u\0A\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 %45
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 = icmp eq i32 %31, 1
br i1 %32, label %33, label %38
33: ; preds = %12
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %35, i32 %36)
br label %44
38: ; preds = %12
%39 = load i32, i32* %4
%40 = load i32, i32* %5
%41 = load i32, i32* %6
%42 = load i32, i32* %7
%43 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %40, i32 %41, i32 %42)
br label %44
44: ; preds = %38, %33
store i32 0, i32* %1
br label %45
45: ; preds = %44, %10
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
%struct.sysinfo = type { i32 }
@.str = [15 x i8] c"error: sysinfo\00"
@.str.1 = [23 x i8] c"1 day, %02u:%02u:%02u\0A\00"
@.str.2 = [25 x i8] c"%u days, %02u:%02u:%02u\0A\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 %25
7: ; preds = %0
%8 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 0
%9 = load i32, i32* %8
%10 = urem i32 %9, 86400
%11 = udiv i32 %9, 86400
%12 = udiv i32 %10, 3600
%13 = urem i32 %10, 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
br i1 %20, label %21, label %23
21: ; preds = %7
%22 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %16, i32 %18)
br label %25
23: ; preds = %7
%24 = call i32 (i8*, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %12, i32 %16, i32 %18)
br label %25
25: ; preds = %21, %23, %5
%26 = phi i32 [ 1, %5 ], [ 0, %23 ], [ 0, %21 ]
ret i32 %26
}