#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*/ add_suggestion(char *, int, int /*<<< orphan*/,
                                  int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
scalar_t__ strstr(char *, char *);
void suggest_hpet(void) {
  FILE *file;
  char buffer[1024];
  file = fopen(
      "/sys/devices/system/clocksource/clocksource0/available_clocksource",
      "r");
  if (!file)
    return;
  memset(buffer, 0, 1024);
  if (!fgets(buffer, 1023, file)) {
    fclose(file);
    return;
  }
  if (strstr(buffer, "hpet")) {
    fclose(file);
    return;
  }
  fclose(file);
  add_suggestion(
      "Suggestion: enable the HPET (Multimedia Timer) in your BIOS or add \n"
      "the kernel patch to force-enable HPET. HPET support allows Linux to \n"
      "have much longer sleep intervals.",
      7, 0, NULL, NULL);
}


x86 assembly (clang, -O0):
<suggest_hpet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
lea    0xe8e(%rip),%rdi
lea    0xeca(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1192 <suggest_hpet+0x32>
jmp    1220 <suggest_hpet+0xc0>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x3ff,%esi
call   1050 <fgets@plt>
cmp    $0x0,%eax
jne    11d1 <suggest_hpet+0x71>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1220 <suggest_hpet+0xc0>
lea    -0x410(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     11fc <suggest_hpet+0x9c>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1220 <suggest_hpet+0xc0>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe3e(%rip),%rdi
mov    $0x7,%esi
xor    %edx,%edx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   1060 <add_suggestion@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<suggest_hpet>:
push   %r14
push   %rbx
sub    $0x408,%rsp
lea    0xe8f(%rip),%rdi
lea    0xecb(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11ec <suggest_hpet+0x8c>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    %r14,%rdi
mov    $0x3ff,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %eax,%eax
je     11e4 <suggest_hpet+0x84>
lea    0xe93(%rip),%rsi
mov    %rsp,%rdi
call   1080 <strstr@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <fclose@plt>
test   %r14,%r14
jne    11ec <suggest_hpet+0x8c>
lea    0xe79(%rip),%rdi
mov    $0x7,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <add_suggestion@plt>
jmp    11ec <suggest_hpet+0x8c>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [67 x i8] c"/sys/devices/system/clocksource/clocksource0/available_clocksource\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"hpet\00"
@.str.3 = [171 x i8] c"Suggestion: enable the HPET (Multimedia Timer) in your BIOS or add \0Athe kernel patch to force-enable HPET. HPET support allows Linux to \0Ahave much longer sleep intervals.\00"
define void @suggest_hpet() {
%1 = alloca i32*
%2 = alloca [1024 x i8]
%3 = call i32* @fopen(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = icmp ne i32* %4, null
br i1 %5, label %7, label %6
6: ; preds = %0
br label %28
7: ; preds = %0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 1024)
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%11 = load i32*, i32** %1
%12 = call i32 @fgets(i8* %10, i32 1023, i32* %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %7
%15 = load i32*, i32** %1
%16 = call i32 @fclose(i32* %15)
br label %28
17: ; preds = %7
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%19 = call i64 @strstr(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32*, i32** %1
%23 = call i32 @fclose(i32* %22)
br label %28
24: ; preds = %17
%25 = load i32*, i32** %1
%26 = call i32 @fclose(i32* %25)
%27 = call i32 @add_suggestion(i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 7, i32 0, i32* null, i32* null)
br label %28
28: ; preds = %24, %21, %14, %6
ret void
}

LLVM IR (-O2):
@.str = [67 x i8] c"/sys/devices/system/clocksource/clocksource0/available_clocksource\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"hpet\00"
@.str.3 = [171 x i8] c"Suggestion: enable the HPET (Multimedia Timer) in your BIOS or add \0Athe kernel patch to force-enable HPET. HPET support allows Linux to \0Ahave much longer sleep intervals.\00"
define void @suggest_hpet() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([67 x i8], [67 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 %17, label %5
5: ; preds = %0
%6 = call i32 @memset(i8* %2, i32 0, i32 1024)
%7 = call i32 @fgets(i8* %2, i32 1023, i32* %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i32 @fclose(i32* %3)
br label %17
11: ; preds = %5
%12 = call i64 @strstr(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = call i32 @fclose(i32* %3)
br i1 %13, label %15, label %17
15: ; preds = %11
%16 = call i32 @add_suggestion(i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0), i32 7, i32 0, i32* null, i32* null)
br label %17
17: ; preds = %11, %0, %15, %9
ret void
}