#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 */
int BUFSIZ;
scalar_t__ sensors_read_line(char *, int, char *);
int sscanf(char *, char *, unsigned long *);
int system_get_uptime(int *days, int *hours, int *mins) {
  char buf[BUFSIZ];
  unsigned long ut;
  if (sensors_read_line("/proc/uptime", BUFSIZ, buf) <= 0) {
    return 0;
  }
  if (sscanf(buf, "%lu", &ut) != 1) {
    return 0;
  }
  ut /= 60;
  *mins = ut % 60;
  ut /= 60;
  *hours = ut % 24;
  ut /= 24;
  *days = ut;
  return 1;
}


x86 assembly (clang, -O0):
<system_get_uptime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x48(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x30(%rbp)
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
lea    0xe90(%rip),%rdi
call   1040 <sensors_read_line@plt>
cmp    $0x0,%rax
jg     1192 <system_get_uptime+0x72>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    123e <system_get_uptime+0x11e>
mov    -0x48(%rbp),%rdi
lea    0xe70(%rip),%rsi
lea    -0x38(%rbp),%rdx
call   1030 <sscanf@plt>
cmp    $0x1,%eax
je     11c2 <system_get_uptime+0xa2>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    123e <system_get_uptime+0x11e>
mov    -0x38(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    $0x18,%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    $0x18,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<system_get_uptime>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r14
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xea5(%rip),%rdi
mov    %rbx,%rdx
call   1040 <sensors_read_line@plt>
xor    %r13d,%r13d
test   %rax,%rax
jle    1210 <system_get_uptime+0xf0>
lea    0xe97(%rip),%rsi
lea    -0x30(%rbp),%rdx
mov    %rbx,%rdi
call   1030 <sscanf@plt>
cmp    $0x1,%eax
jne    1210 <system_get_uptime+0xf0>
mov    -0x30(%rbp),%rcx
movabs $0x8888888888888889,%rdi
88 88 88
mov    %rcx,%rax
mul    %rdi
mov    %rdx,%rsi
shr    $0x5,%rsi
mov    %rsi,%rax
mul    %rdi
shr    $0x5,%rdx
imul   $0x3c,%edx,%eax
sub    %eax,%esi
mov    %rcx,%rax
shr    $0x4,%rax
movabs $0x91a2b3c4d5e6f81,%rdx
2b 1a 09
mul    %rdx
mov    %rdx,%rdi
shr    $0x3,%rdi
movabs $0xaaaaaaaaaaaaaaab,%rdx
aa aa aa
mov    %rdi,%rax
mul    %rdx
mov    %esi,(%r12)
shr    $0x4,%rdx
shl    $0x3,%edx
lea    (%rdx,%rdx,2),%eax
sub    %eax,%edi
movabs $0xc22e450672894ab7,%rdx
45 2e c2
mov    %rcx,%rax
mul    %rdx
mov    %edi,(%r15)
shr    $0x10,%rdx
mov    %edx,(%r14)
mov    $0x1,%r13d
mov    %r13d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [13 x i8] c"/proc/uptime\00"
@.str.1 = [4 x i8] c"%lu\00"
define i32 @system_get_uptime(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%12 = load i32, i32* @BUFSIZ
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %8
%15 = alloca i8, i64 %13
store i64 %13, i64* %9
%16 = load i32, i32* @BUFSIZ
%17 = call i64 @sensors_read_line(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %16, i8* %15)
%18 = icmp sle i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %3
store i32 0, i32* %4
store i32 1, i32* %11
br label %42
20: ; preds = %3
%21 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %10)
%22 = icmp ne i32 %21, 1
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 0, i32* %4
store i32 1, i32* %11
br label %42
24: ; preds = %20
%25 = load i64, i64* %10
%26 = udiv i64 %25, 60
store i64 %26, i64* %10
%27 = load i64, i64* %10
%28 = urem i64 %27, 60
%29 = trunc i64 %28 to i32
%30 = load i32*, i32** %7
store i32 %29, i32* %30
%31 = load i64, i64* %10
%32 = udiv i64 %31, 60
store i64 %32, i64* %10
%33 = load i64, i64* %10
%34 = urem i64 %33, 24
%35 = trunc i64 %34 to i32
%36 = load i32*, i32** %6
store i32 %35, i32* %36
%37 = load i64, i64* %10
%38 = udiv i64 %37, 24
store i64 %38, i64* %10
%39 = load i64, i64* %10
%40 = trunc i64 %39 to i32
%41 = load i32*, i32** %5
store i32 %40, i32* %41
store i32 1, i32* %4
store i32 1, i32* %11
br label %42
42: ; preds = %24, %23, %19
%43 = load i8*, i8** %8
%44 = load i32, i32* %4
ret i32 %44
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [13 x i8] c"/proc/uptime\00"
@.str.1 = [4 x i8] c"%lu\00"
define i32 @system_get_uptime(i32* nocapture writeonly %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca i64
%5 = load i32, i32* @BUFSIZ
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = bitcast i64* %4 to i8*
%9 = call i64 @sensors_read_line(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %5, i8* %7)
%10 = icmp slt i64 %9, 1
br i1 %10, label %24, label %11
11: ; preds = %3
%12 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %4)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i64, i64* %4
%16 = udiv i64 %15, 60
%17 = urem i64 %16, 60
%18 = trunc i64 %17 to i32
store i32 %18, i32* %2
%19 = udiv i64 %15, 3600
%20 = urem i64 %19, 24
%21 = trunc i64 %20 to i32
store i32 %21, i32* %1
%22 = udiv i64 %15, 86400
%23 = trunc i64 %22 to i32
store i32 %23, i32* %0
br label %24
24: ; preds = %11, %3, %14
%25 = phi i32 [ 1, %14 ], [ 0, %3 ], [ 0, %11 ]
ret i32 %25
}