#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 /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, double *, double *);
int /*<<< orphan*/ print_time(char *, long);
int main() {
  FILE *fp;
  double uptime, idletime;
  fp = fopen("/proc/uptime", "r");
  fscanf(fp, "%lf %lf\n", &uptime, &idletime);
  fclose(fp);
  print_time("uptime", (long)uptime);
  print_time("idle time", (long)idletime);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9e(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1040 <fscanf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
cvttsd2si -0x18(%rbp),%rsi
lea    0xe72(%rip),%rdi
call   1050 <print_time@plt>
cvttsd2si -0x20(%rbp),%rsi
lea    0xe72(%rip),%rdi
call   1050 <print_time@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xead(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
mov    %rax,%rdi
call   1040 <fscanf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
cvttsd2si 0x8(%rsp),%rsi
lea    0xe7e(%rip),%rdi
call   1050 <print_time@plt>
cvttsd2si (%rsp),%rsi
lea    0xe7e(%rip),%rdi
call   1050 <print_time@plt>
xor    %eax,%eax
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 = [9 x i8] c"%lf %lf\0A\00"
@.str.3 = [7 x i8] c"uptime\00"
@.str.4 = [10 x i8] c"idle time\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
%5 = 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* %5, i32** %2
%6 = load i32*, i32** %2
%7 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double* %3, double* %4)
%8 = load i32*, i32** %2
%9 = call i32 @fclose(i32* %8)
%10 = load double, double* %3
%11 = fptosi double %10 to i64
%12 = call i32 @print_time(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 %11)
%13 = load double, double* %4
%14 = fptosi double %13 to i64
%15 = call i32 @print_time(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i64 %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"/proc/uptime\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [9 x i8] c"%lf %lf\0A\00"
@.str.3 = [7 x i8] c"uptime\00"
@.str.4 = [10 x i8] c"idle time\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = 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))
%6 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double* %1, double* %2)
%7 = call i32 @fclose(i32* %5)
%8 = load double, double* %1
%9 = fptosi double %8 to i64
%10 = call i32 @print_time(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 %9)
%11 = load double, double* %2
%12 = fptosi double %11 to i64
%13 = call i32 @print_time(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i64 %12)
ret i32 0
}