#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 */

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dump_msr(int, char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
void dump_x86_msr(void) {
  int fd = open("/dev/cpu/0/msr", O_RDONLY);
  puts("");
  puts("MSR dump:");
  dump_msr(fd, "IA32_FEATURE_CONTROL", 0x3a);
  dump_msr(fd, "IA32_MISC_ENABLE", 0x1a0);
  dump_msr(fd, "IA32_APIC_BASE", 0x1b);
  dump_msr(fd, "IA32_EFER", 0xc0000080);
  dump_msr(fd, "IA32_VMX_BASIC", 0x480);
  dump_msr(fd, "IA32_VMX_PINBASED_CTLS", 0x481);
  dump_msr(fd, "IA32_VMX_PROCBASED_CTLS", 0x482);
  dump_msr(fd, "IA32_VMX_PROCBASED_CTLS2", 0x48b);
  dump_msr(fd, "IA32_VMX_EXIT_CTLS", 0x483);
  dump_msr(fd, "IA32_VMX_ENTRY_CTLS", 0x484);
  dump_msr(fd, "IA32_VMX_MISC", 0x485);
  dump_msr(fd, "IA32_VMX_VMCS_ENUM", 0x48a);
  dump_msr(fd, "IA32_VMX_EPT_VPID_CAP", 0x48c);
  dump_msr(fd, "IA32_VMX_TRUE_PINBASED_CTLS", 0x48d);
  dump_msr(fd, "IA32_VMX_TRUE_PROCBASED_CTLS", 0x48e);
  dump_msr(fd, "IA32_VMX_TRUE_EXIT_CTLS", 0x48f);
  dump_msr(fd, "IA32_VMX_TRUE_ENTRY_CTLS", 0x490);
  dump_msr(fd, "IA32_VM_CR", 0xc0010114);
  if (fd != -1)
    close(fd);
}


x86 assembly (clang, -O0):
<dump_x86_msr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
lea    0xea8(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x4(%rbp)
lea    0xf47(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%edi
lea    0xe97(%rip),%rsi
mov    $0x3a,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe98(%rip),%rsi
mov    $0x1a0,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe95(%rip),%rsi
mov    $0x1b,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe90(%rip),%rsi
mov    $0xc0000080,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe86(%rip),%rsi
mov    $0x480,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe81(%rip),%rsi
mov    $0x481,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe84(%rip),%rsi
mov    $0x482,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe88(%rip),%rsi
mov    $0x48b,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe8d(%rip),%rsi
mov    $0x483,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe8c(%rip),%rsi
mov    $0x484,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe8c(%rip),%rsi
mov    $0x485,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe86(%rip),%rsi
mov    $0x48a,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe85(%rip),%rsi
mov    $0x48c,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe87(%rip),%rsi
mov    $0x48d,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe8f(%rip),%rsi
mov    $0x48e,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe98(%rip),%rsi
mov    $0x48f,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xe9c(%rip),%rsi
mov    $0x490,%edx
call   1060 <dump_msr@plt>
mov    -0x4(%rbp),%edi
lea    0xea1(%rip),%rsi
mov    $0xc0010114,%edx
call   1060 <dump_msr@plt>
cmpl   $0xffffffff,-0x4(%rbp)
je     12f2 <dump_x86_msr+0x1b2>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_x86_msr>:
push   %rbx
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
lea    0xe9f(%rip),%rdi
call   1060 <open@plt>
mov    %eax,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe96(%rip),%rdi
call   1040 <puts@plt>
lea    0xe94(%rip),%rsi
mov    %ebx,%edi
mov    $0x3a,%edx
call   1070 <dump_msr@plt>
lea    0xe96(%rip),%rsi
mov    %ebx,%edi
mov    $0x1a0,%edx
call   1070 <dump_msr@plt>
lea    0xe94(%rip),%rsi
mov    %ebx,%edi
mov    $0x1b,%edx
call   1070 <dump_msr@plt>
lea    0xe90(%rip),%rsi
mov    %ebx,%edi
mov    $0xc0000080,%edx
call   1070 <dump_msr@plt>
lea    0xe87(%rip),%rsi
mov    %ebx,%edi
mov    $0x480,%edx
call   1070 <dump_msr@plt>
lea    0xe83(%rip),%rsi
mov    %ebx,%edi
mov    $0x481,%edx
call   1070 <dump_msr@plt>
lea    0xe87(%rip),%rsi
mov    %ebx,%edi
mov    $0x482,%edx
call   1070 <dump_msr@plt>
lea    0xe8c(%rip),%rsi
mov    %ebx,%edi
mov    $0x48b,%edx
call   1070 <dump_msr@plt>
lea    0xe92(%rip),%rsi
mov    %ebx,%edi
mov    $0x483,%edx
call   1070 <dump_msr@plt>
lea    0xe92(%rip),%rsi
mov    %ebx,%edi
mov    $0x484,%edx
call   1070 <dump_msr@plt>
lea    0xe93(%rip),%rsi
mov    %ebx,%edi
mov    $0x485,%edx
call   1070 <dump_msr@plt>
lea    0xe8e(%rip),%rsi
mov    %ebx,%edi
mov    $0x48a,%edx
call   1070 <dump_msr@plt>
lea    0xe8e(%rip),%rsi
mov    %ebx,%edi
mov    $0x48c,%edx
call   1070 <dump_msr@plt>
lea    0xe91(%rip),%rsi
mov    %ebx,%edi
mov    $0x48d,%edx
call   1070 <dump_msr@plt>
lea    0xe9a(%rip),%rsi
mov    %ebx,%edi
mov    $0x48e,%edx
call   1070 <dump_msr@plt>
lea    0xea4(%rip),%rsi
mov    %ebx,%edi
mov    $0x48f,%edx
call   1070 <dump_msr@plt>
lea    0xea9(%rip),%rsi
mov    %ebx,%edi
mov    $0x490,%edx
call   1070 <dump_msr@plt>
lea    0xeaf(%rip),%rsi
mov    %ebx,%edi
mov    $0xc0010114,%edx
call   1070 <dump_msr@plt>
cmp    $0xffffffff,%ebx
je     12e1 <dump_x86_msr+0x191>
mov    %ebx,%edi
pop    %rbx
jmp    1050 <close@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"/dev/cpu/0/msr\00"
@O_RDONLY = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [10 x i8] c"MSR dump:\00"
@.str.3 = [21 x i8] c"IA32_FEATURE_CONTROL\00"
@.str.4 = [17 x i8] c"IA32_MISC_ENABLE\00"
@.str.5 = [15 x i8] c"IA32_APIC_BASE\00"
@.str.6 = [10 x i8] c"IA32_EFER\00"
@.str.7 = [15 x i8] c"IA32_VMX_BASIC\00"
@.str.8 = [23 x i8] c"IA32_VMX_PINBASED_CTLS\00"
@.str.9 = [24 x i8] c"IA32_VMX_PROCBASED_CTLS\00"
@.str.10 = [25 x i8] c"IA32_VMX_PROCBASED_CTLS2\00"
@.str.11 = [19 x i8] c"IA32_VMX_EXIT_CTLS\00"
@.str.12 = [20 x i8] c"IA32_VMX_ENTRY_CTLS\00"
@.str.13 = [14 x i8] c"IA32_VMX_MISC\00"
@.str.14 = [19 x i8] c"IA32_VMX_VMCS_ENUM\00"
@.str.15 = [22 x i8] c"IA32_VMX_EPT_VPID_CAP\00"
@.str.16 = [28 x i8] c"IA32_VMX_TRUE_PINBASED_CTLS\00"
@.str.17 = [29 x i8] c"IA32_VMX_TRUE_PROCBASED_CTLS\00"
@.str.18 = [24 x i8] c"IA32_VMX_TRUE_EXIT_CTLS\00"
@.str.19 = [25 x i8] c"IA32_VMX_TRUE_ENTRY_CTLS\00"
@.str.20 = [11 x i8] c"IA32_VM_CR\00"
define void @dump_x86_msr() {
%1 = alloca i32
%2 = load i32, i32* @O_RDONLY
%3 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %2)
store i32 %3, i32* %1
%4 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%6 = load i32, i32* %1
%7 = call i32 @dump_msr(i32 %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 58)
%8 = load i32, i32* %1
%9 = call i32 @dump_msr(i32 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 416)
%10 = load i32, i32* %1
%11 = call i32 @dump_msr(i32 %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 27)
%12 = load i32, i32* %1
%13 = call i32 @dump_msr(i32 %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 -1073741696)
%14 = load i32, i32* %1
%15 = call i32 @dump_msr(i32 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 1152)
%16 = load i32, i32* %1
%17 = call i32 @dump_msr(i32 %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 1153)
%18 = load i32, i32* %1
%19 = call i32 @dump_msr(i32 %18, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i32 1154)
%20 = load i32, i32* %1
%21 = call i32 @dump_msr(i32 %20, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i32 1163)
%22 = load i32, i32* %1
%23 = call i32 @dump_msr(i32 %22, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i32 1155)
%24 = load i32, i32* %1
%25 = call i32 @dump_msr(i32 %24, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i32 1156)
%26 = load i32, i32* %1
%27 = call i32 @dump_msr(i32 %26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i32 1157)
%28 = load i32, i32* %1
%29 = call i32 @dump_msr(i32 %28, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i32 1162)
%30 = load i32, i32* %1
%31 = call i32 @dump_msr(i32 %30, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.15, i64 0, i64 0), i32 1164)
%32 = load i32, i32* %1
%33 = call i32 @dump_msr(i32 %32, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0), i32 1165)
%34 = load i32, i32* %1
%35 = call i32 @dump_msr(i32 %34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.17, i64 0, i64 0), i32 1166)
%36 = load i32, i32* %1
%37 = call i32 @dump_msr(i32 %36, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0), i32 1167)
%38 = load i32, i32* %1
%39 = call i32 @dump_msr(i32 %38, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.19, i64 0, i64 0), i32 1168)
%40 = load i32, i32* %1
%41 = call i32 @dump_msr(i32 %40, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.20, i64 0, i64 0), i32 -1073676012)
%42 = load i32, i32* %1
%43 = icmp ne i32 %42, -1
br i1 %43, label %44, label %47
44: ; preds = %0
%45 = load i32, i32* %1
%46 = call i32 @close(i32 %45)
br label %47
47: ; preds = %44, %0
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"/dev/cpu/0/msr\00"
@O_RDONLY = global i32 0
@.str.2 = [10 x i8] c"MSR dump:\00"
@.str.3 = [21 x i8] c"IA32_FEATURE_CONTROL\00"
@.str.4 = [17 x i8] c"IA32_MISC_ENABLE\00"
@.str.5 = [15 x i8] c"IA32_APIC_BASE\00"
@.str.6 = [10 x i8] c"IA32_EFER\00"
@.str.7 = [15 x i8] c"IA32_VMX_BASIC\00"
@.str.8 = [23 x i8] c"IA32_VMX_PINBASED_CTLS\00"
@.str.9 = [24 x i8] c"IA32_VMX_PROCBASED_CTLS\00"
@.str.10 = [25 x i8] c"IA32_VMX_PROCBASED_CTLS2\00"
@.str.11 = [19 x i8] c"IA32_VMX_EXIT_CTLS\00"
@.str.12 = [20 x i8] c"IA32_VMX_ENTRY_CTLS\00"
@.str.13 = [14 x i8] c"IA32_VMX_MISC\00"
@.str.14 = [19 x i8] c"IA32_VMX_VMCS_ENUM\00"
@.str.15 = [22 x i8] c"IA32_VMX_EPT_VPID_CAP\00"
@.str.16 = [28 x i8] c"IA32_VMX_TRUE_PINBASED_CTLS\00"
@.str.17 = [29 x i8] c"IA32_VMX_TRUE_PROCBASED_CTLS\00"
@.str.18 = [24 x i8] c"IA32_VMX_TRUE_EXIT_CTLS\00"
@.str.19 = [25 x i8] c"IA32_VMX_TRUE_ENTRY_CTLS\00"
@.str.20 = [11 x i8] c"IA32_VM_CR\00"
define void @dump_x86_msr() {
%1 = load i32, i32* @O_RDONLY
%2 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @putchar(i32 10)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 58)
%6 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 416)
%7 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 27)
%8 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 -1073741696)
%9 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 1152)
%10 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i32 1153)
%11 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i32 1154)
%12 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i32 1163)
%13 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), i32 1155)
%14 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i32 1156)
%15 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i32 1157)
%16 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i32 1162)
%17 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.15, i64 0, i64 0), i32 1164)
%18 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0), i32 1165)
%19 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.17, i64 0, i64 0), i32 1166)
%20 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.18, i64 0, i64 0), i32 1167)
%21 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.19, i64 0, i64 0), i32 1168)
%22 = tail call i32 @dump_msr(i32 %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.20, i64 0, i64 0), i32 -1073676012)
%23 = icmp eq i32 %2, -1
br i1 %23, label %26, label %24
24: ; preds = %0
%25 = tail call i32 @close(i32 %2)
br label %26
26: ; preds = %24, %0
ret void
}