#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
void check_dev_msr() {
  struct stat sb;
  if (stat("/dev/cpu/0/msr", &sb)) {
    fprintf(stderr, "no /dev/cpu/0/msr\n");
    fprintf(stderr, "Try \"# modprobe msr\"\n");
    exit(-5);
  }
}


x86 assembly (clang, -O0):
<check_dev_msr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%rax
je     1186 <check_dev_msr+0x56>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
lea    0xead(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xeab(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xfffffffb,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_dev_msr>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <stat@plt>
test   %rax,%rax
jne    1151 <check_dev_msr+0x21>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e88(%rip),%rbx
mov    (%rbx),%edi
lea    0xeae(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xeb3(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xfffffffb,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [15 x i8] c"/dev/cpu/0/msr\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"no /dev/cpu/0/msr\0A\00"
@.str.2 = [22 x i8] c"Try \22# modprobe msr\22\0A\00"
define void @check_dev_msr() {
%1 = alloca %struct.stat
%2 = call i64 @stat(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %10
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @exit(i32 -5)
unreachable
10: ; preds = %0
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [15 x i8] c"/dev/cpu/0/msr\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"no /dev/cpu/0/msr\0A\00"
@.str.2 = [22 x i8] c"Try \22# modprobe msr\22\0A\00"
define void @check_dev_msr() {
%1 = alloca %struct.stat
%2 = bitcast %struct.stat* %1 to i8*
%3 = call i64 @stat(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %11, label %5
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @exit(i32 -5)
unreachable
11: ; preds = %0
ret void
}