#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, float *);
int get_uptime(void) {
  FILE *fff;
  float uptime_seconds;
  int result;
  fff = fopen("/proc/uptime", "r");
  if (fff != NULL) {
    result = fscanf(fff, "%f", &uptime_seconds);
    fclose(fff);
  }
  (void)result;
  return uptime_seconds;
}


x86 assembly (clang, -O0):
<get_uptime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     117a <get_uptime+0x4a>
mov    -0x8(%rbp),%rdi
lea    0xeaa(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
cvttss2si -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_uptime>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1174 <get_uptime+0x44>
mov    %rax,%rbx
lea    0xeb8(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
cvttss2si 0xc(%rsp),%eax
jmp    1174 <get_uptime+0x44>
add    $0x10,%rsp
pop    %rbx
ret

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"
define i32 @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 %12
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)
br label %12
12: ; preds = %7, %0
%13 = load i32, i32* %3
%14 = load float, float* %2
%15 = fptosi float %14 to i32
ret i32 %15
}

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"
define i32 @get_uptime() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = 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))
%4 = icmp eq i32* %3, null
br i1 %4, label %10, label %5
5: ; preds = %0
%6 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%7 = call i32 @fclose(i32* %3)
%8 = load float, float* %1
%9 = fptosi float %8 to i32
br label %10
10: ; preds = %5, %0
%11 = phi i32 [ %9, %5 ], [ undef, %0 ]
ret i32 %11
}