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

/* Variables and functions */
int /*<<< orphan*/ LONG_MAX;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *);
time_t read_wakeup_file() {
  time_t wakeupTime = LONG_MAX;
  FILE *wakeupFile;
  wakeupFile = fopen("/var/wakeup", "r");
  if (wakeupFile) {
    fscanf(wakeupFile, "%ld", &wakeupTime);
    fclose(wakeupFile);
  }
  return wakeupTime;
}


x86 assembly (clang, -O0):
<read_wakeup_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
lea    0xeb5(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1183 <read_wakeup_file+0x53>
mov    -0x10(%rbp),%rdi
lea    0xe9d(%rip),%rsi
lea    -0x4(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_wakeup_file>:
push   %r14
push   %rbx
push   %rax
mov    0x2ea5(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,0x4(%rsp)
lea    0xeb8(%rip),%rdi
lea    0xebd(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     117c <read_wakeup_file+0x4c>
mov    %rax,%r14
lea    0xeab(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x4(%rsp),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@LONG_MAX = global i32 0
@.str = [12 x i8] c"/var/wakeup\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%ld\00"
define i32 @read_wakeup_file() {
%1 = alloca i32
%2 = alloca i32*
%3 = load i32, i32* @LONG_MAX
store i32 %3, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 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** %2
%5 = load i32*, i32** %2
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = load i32*, i32** %2
%9 = call i32 @fscanf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%10 = load i32*, i32** %2
%11 = call i32 @fclose(i32* %10)
br label %12
12: ; preds = %7, %0
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@LONG_MAX = global i32 0
@.str = [12 x i8] c"/var/wakeup\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%ld\00"
define i32 @read_wakeup_file() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @LONG_MAX
store i32 %3, i32* %1
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %10, label %6
6: ; preds = %0
%7 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = call i32 @fclose(i32* %4)
%9 = load i32, i32* %1
br label %10
10: ; preds = %6, %0
%11 = phi i32 [ %9, %6 ], [ %3, %0 ]
ret i32 %11
}