#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int fscanf(int /*<<< orphan*/ *, char *, float *);
int /*<<< orphan*/ stderr;
float get_uptime(void) {
  FILE *f = fopen("/proc/uptime", "r");
  if (f) {
    float uptime;
    int match = fscanf(f, "%f", &uptime);
    fclose(f);
    if (match == 1)
      return uptime;
  }
  fputs("autoupdater: error: unable to determine uptime\n", stderr);
  exit(1);
}


x86 assembly (clang, -O0):
<get_uptime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11b4 <get_uptime+0x64>
mov    -0x8(%rbp),%rdi
lea    0xe8a(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <fscanf@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
cmpl   $0x1,-0x10(%rbp)
jne    11af <get_uptime+0x5f>
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret
jmp    11b4 <get_uptime+0x64>
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
lea    0xe4e(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<get_uptime>:
push   %rbp
push   %rbx
push   %rax
lea    0xea6(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     119e <get_uptime+0x4e>
mov    %rax,%rbx
lea    0xe9a(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fclose@plt>
cmp    $0x1,%ebp
jne    119e <get_uptime+0x4e>
movss  0x4(%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
lea    0xe64(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"/proc/uptime\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [48 x i8] c"autoupdater: error: unable to determine uptime\0A\00"
@stderr = global i32 0
define float @get_uptime() {
%1 = alloca i32*
%2 = alloca float
%3 = alloca i32
%4 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %1
%5 = load i32*, i32** %1
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %17
7: ; preds = %0
%8 = load i32*, i32** %1
%9 = call i32 @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
store i32 %9, i32* %3
%10 = load i32*, i32** %1
%11 = call i32 @fclose(i32* %10)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = load float, float* %2
ret float %15
16: ; preds = %7
br label %17
17: ; preds = %16, %0
%18 = load i32, i32* @stderr
%19 = call i32 @fputs(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [13 x i8] c"/proc/uptime\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [48 x i8] c"autoupdater: error: unable to determine uptime\0A\00"
@stderr = global i32 0
define float @get_uptime() {
%1 = alloca float
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %10, label %4
4: ; preds = %0
%5 = bitcast float* %1 to i8*
%6 = call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%7 = call i32 @fclose(i32* %2)
%8 = icmp eq i32 %6, 1
%9 = load float, float* %1
br i1 %8, label %14, label %10
10: ; preds = %4, %0
%11 = load i32, i32* @stderr
%12 = call i32 @fputs(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %4
ret float %9
}