#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*/ binary32(unsigned long long);
int /*<<< orphan*/ binary64(unsigned long long);
int /*<<< orphan*/ printf(char *, unsigned int);
int read_msr(int, unsigned int, unsigned long long *);
void dumpmsr_bin(int cpu, unsigned int msr, int size) {
  unsigned long long val = 0;
  if (read_msr(cpu, msr, &val) == 1) {
    if (size == 32)
      binary32(val);
    if (size == 64)
      binary64(val);
    return;
  }
  printf("Couldn't read MSR 0x%x\n", msr);
}


x86 assembly (clang, -O0):
<dumpmsr_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x18(%rbp),%rdx
call   1050 <read_msr@plt>
cmp    $0x1,%eax
jne    119c <dumpmsr_bin+0x5c>
cmpl   $0x20,-0xc(%rbp)
jne    1184 <dumpmsr_bin+0x44>
mov    -0x18(%rbp),%rdi
call   1040 <binary32@plt>
cmpl   $0x40,-0xc(%rbp)
jne    1197 <dumpmsr_bin+0x57>
mov    -0x18(%rbp),%rdi
call   1060 <binary64@plt>
jmp    11ab <dumpmsr_bin+0x6b>
mov    -0x8(%rbp),%esi
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpmsr_bin>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%ebp
movq   $0x0,(%rsp)
mov    %rsp,%rdx
call   1050 <read_msr@plt>
cmp    $0x1,%eax
jne    1171 <dumpmsr_bin+0x31>
cmp    $0x40,%ebx
je     1181 <dumpmsr_bin+0x41>
cmp    $0x20,%ebx
jne    118a <dumpmsr_bin+0x4a>
mov    (%rsp),%rdi
call   1040 <binary32@plt>
jmp    118a <dumpmsr_bin+0x4a>
lea    0xe88(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
jmp    118a <dumpmsr_bin+0x4a>
mov    (%rsp),%rdi
call   1060 <binary64@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Couldn't read MSR 0x%x\0A\00"
define void @dumpmsr_bin(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i64 0, i64* %7
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = call i32 @read_msr(i32 %8, i32 %9, i64* %7)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %25
12: ; preds = %3
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, 32
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i64, i64* %7
%17 = call i32 @binary32(i64 %16)
br label %18
18: ; preds = %15, %12
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 64
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i64, i64* %7
%23 = call i32 @binary64(i64 %22)
br label %24
24: ; preds = %21, %18
br label %28
25: ; preds = %3
%26 = load i32, i32* %5
%27 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25, %24
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"Couldn't read MSR 0x%x\0A\00"
define void @dumpmsr_bin(i32 %0, i32 %1, i32 %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%6 = call i32 @read_msr(i32 %0, i32 %1, i64* %4)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %15
8: ; preds = %3
switch i32 %2, label %17 [
i32 32, label %9
i32 64, label %12
]
9: ; preds = %8
%10 = load i64, i64* %4
%11 = call i32 @binary32(i64 %10)
br label %17
12: ; preds = %8
%13 = load i64, i64* %4
%14 = call i32 @binary64(i64 %13)
br label %17
15: ; preds = %3
%16 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %17
17: ; preds = %9, %12, %8, %15
ret void
}