#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(int /*<<< orphan*/, 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*/ gettext(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(gettext("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    0xe7e(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11a2 <suggest_hpet+0x32>
jmp    1237 <suggest_hpet+0xc7>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x3ff,%esi
call   1060 <fgets@plt>
cmp    $0x0,%eax
jne    11e1 <suggest_hpet+0x71>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1237 <suggest_hpet+0xc7>
lea    -0x410(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     120c <suggest_hpet+0x9c>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1237 <suggest_hpet+0xc7>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe2e(%rip),%rdi
call   1040 <gettext@plt>
mov    %eax,%edi
mov    $0x7,%esi
xor    %edx,%edx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   1070 <add_suggestion@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<suggest_hpet>:
push   %r14
push   %rbx
sub    $0x408,%rsp
lea    0xe7f(%rip),%rdi
lea    0xebb(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1203 <suggest_hpet+0x93>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    $0x3ff,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %eax,%eax
je     11fb <suggest_hpet+0x8b>
lea    0xe83(%rip),%rsi
mov    %rsp,%rdi
call   1090 <strstr@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <fclose@plt>
test   %r14,%r14
jne    1203 <suggest_hpet+0x93>
lea    0xe69(%rip),%rdi
call   1040 <gettext@plt>
mov    %eax,%edi
mov    $0x7,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1070 <add_suggestion@plt>
jmp    1203 <suggest_hpet+0x93>
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 %29
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 %29
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 %29
24: ; preds = %17
%25 = load i32*, i32** %1
%26 = call i32 @fclose(i32* %25)
%27 = call i32 @gettext(i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @add_suggestion(i32 %27, i32 7, i32 0, i32* null, i32* null)
br label %29
29: ; 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 %18, 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 %18
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 %18
15: ; preds = %11
%16 = call i32 @gettext(i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @add_suggestion(i32 %16, i32 7, i32 0, i32* null, i32* null)
br label %18
18: ; preds = %11, %0, %15, %9
ret void
}