#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 isst_send_msr_command(int, int, int /*<<< orphan*/, unsigned long long *);
int isst_get_get_trl_from_msr(int cpu, int *trl) {
  unsigned long long msr_trl;
  int ret;
  ret = isst_send_msr_command(cpu, 0x1AD, 0, &msr_trl);
  if (ret)
    return ret;
  trl[0] = msr_trl & (((~0UL) << (0)) & (~0UL >> (sizeof(long) * 8 - 1 - (7))));
  trl[1] =
      (msr_trl & (((~0UL) << (8)) & (~0UL >> (sizeof(long) * 8 - 1 - (15))))) >>
      8;
  trl[2] = (msr_trl &
            (((~0UL) << (16)) & (~0UL >> (sizeof(long) * 8 - 1 - (23))))) >>
           16;
  trl[3] = (msr_trl &
            (((~0UL) << (24)) & (~0UL >> (sizeof(long) * 8 - 1 - (31))))) >>
           24;
  trl[4] = (msr_trl &
            (((~0UL) << (32)) & (~0UL >> (sizeof(long) * 8 - 1 - (39))))) >>
           32;
  trl[5] = (msr_trl &
            (((~0UL) << (40)) & (~0UL >> (sizeof(long) * 8 - 1 - (47))))) >>
           40;
  trl[6] = (msr_trl &
            (((~0UL) << (48)) & (~0UL >> (sizeof(long) * 8 - 1 - (55))))) >>
           48;
  trl[7] = (msr_trl &
            (((~0UL) << (56)) & (~0UL >> (sizeof(long) * 8 - 1 - (63))))) >>
           56;
  return 0;
}


x86 assembly (clang, -O0):
<isst_get_get_trl_from_msr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1ad,%esi
xor    %edx,%edx
lea    -0x18(%rbp),%rcx
call   1030 <isst_send_msr_command@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     114a <isst_get_get_trl_from_msr+0x3a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1218 <isst_get_get_trl_from_msr+0x108>
mov    -0x18(%rbp),%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
and    $0xff00,%rax
shr    $0x8,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%rax
and    $0xff0000,%rax
shr    $0x10,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
movabs $0xff000000,%rax
and    -0x18(%rbp),%rax
shr    $0x18,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
movabs $0xff00000000,%rax
and    -0x18(%rbp),%rax
shr    $0x20,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x10(%rax)
movabs $0xff0000000000,%rax
and    -0x18(%rbp),%rax
shr    $0x28,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x14(%rax)
movabs $0xff000000000000,%rax
and    -0x18(%rbp),%rax
shr    $0x30,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x18(%rax)
movabs $0xff00000000000000,%rax
and    -0x18(%rbp),%rax
shr    $0x38,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x1c(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isst_get_get_trl_from_msr>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0x8(%rsp),%rcx
mov    $0x1ad,%esi
xor    %edx,%edx
call   1030 <isst_send_msr_command@plt>
test   %eax,%eax
jne    117e <isst_get_get_trl_from_msr+0x6e>
mov    0x8(%rsp),%rcx
movzbl %cl,%edx
mov    %edx,(%rbx)
movzbl %ch,%edx
mov    %edx,0x4(%rbx)
mov    %ecx,%edx
shr    $0x10,%edx
movzbl %dl,%edx
mov    %edx,0x8(%rbx)
mov    %ecx,%edx
shr    $0x18,%edx
mov    %edx,0xc(%rbx)
mov    %rcx,%rdx
shr    $0x20,%rdx
movzbl %dl,%edx
mov    %edx,0x10(%rbx)
mov    %rcx,%rdx
shr    $0x28,%rdx
movzbl %dl,%edx
mov    %edx,0x14(%rbx)
mov    %rcx,%rdx
shr    $0x30,%rdx
movzbl %dl,%edx
mov    %edx,0x18(%rbx)
shr    $0x38,%rcx
mov    %ecx,0x1c(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @isst_get_get_trl_from_msr(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
%8 = load i32, i32* %4
%9 = call i32 @isst_send_msr_command(i32 %8, i32 429, i32 0, i64* %6)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i32, i32* %7
store i32 %13, i32* %3
br label %62
14: ; preds = %2
%15 = load i64, i64* %6
%16 = and i64 %15, 255
%17 = trunc i64 %16 to i32
%18 = load i32*, i32** %5
%19 = getelementptr inbounds i32, i32* %18, i64 0
store i32 %17, i32* %19
%20 = load i64, i64* %6
%21 = and i64 %20, 65280
%22 = lshr i64 %21, 8
%23 = trunc i64 %22 to i32
%24 = load i32*, i32** %5
%25 = getelementptr inbounds i32, i32* %24, i64 1
store i32 %23, i32* %25
%26 = load i64, i64* %6
%27 = and i64 %26, 16711680
%28 = lshr i64 %27, 16
%29 = trunc i64 %28 to i32
%30 = load i32*, i32** %5
%31 = getelementptr inbounds i32, i32* %30, i64 2
store i32 %29, i32* %31
%32 = load i64, i64* %6
%33 = and i64 %32, 4278190080
%34 = lshr i64 %33, 24
%35 = trunc i64 %34 to i32
%36 = load i32*, i32** %5
%37 = getelementptr inbounds i32, i32* %36, i64 3
store i32 %35, i32* %37
%38 = load i64, i64* %6
%39 = and i64 %38, 1095216660480
%40 = lshr i64 %39, 32
%41 = trunc i64 %40 to i32
%42 = load i32*, i32** %5
%43 = getelementptr inbounds i32, i32* %42, i64 4
store i32 %41, i32* %43
%44 = load i64, i64* %6
%45 = and i64 %44, 280375465082880
%46 = lshr i64 %45, 40
%47 = trunc i64 %46 to i32
%48 = load i32*, i32** %5
%49 = getelementptr inbounds i32, i32* %48, i64 5
store i32 %47, i32* %49
%50 = load i64, i64* %6
%51 = and i64 %50, 71776119061217280
%52 = lshr i64 %51, 48
%53 = trunc i64 %52 to i32
%54 = load i32*, i32** %5
%55 = getelementptr inbounds i32, i32* %54, i64 6
store i32 %53, i32* %55
%56 = load i64, i64* %6
%57 = and i64 %56, -72057594037927936
%58 = lshr i64 %57, 56
%59 = trunc i64 %58 to i32
%60 = load i32*, i32** %5
%61 = getelementptr inbounds i32, i32* %60, i64 7
store i32 %59, i32* %61
store i32 0, i32* %3
br label %62
62: ; preds = %14, %12
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
define i32 @isst_get_get_trl_from_msr(i32 %0, i32* nocapture writeonly %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = call i32 @isst_send_msr_command(i32 %0, i32 429, i32 0, i64* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %34
7: ; preds = %2
%8 = load i64, i64* %3
%9 = trunc i64 %8 to i32
%10 = and i32 %9, 255
store i32 %10, i32* %1
%11 = lshr i32 %9, 8
%12 = and i32 %11, 255
%13 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %12, i32* %13
%14 = lshr i32 %9, 16
%15 = and i32 %14, 255
%16 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %15, i32* %16
%17 = lshr i32 %9, 24
%18 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %17, i32* %18
%19 = lshr i64 %8, 32
%20 = trunc i64 %19 to i32
%21 = and i32 %20, 255
%22 = getelementptr inbounds i32, i32* %1, i64 4
store i32 %21, i32* %22
%23 = lshr i64 %8, 40
%24 = trunc i64 %23 to i32
%25 = and i32 %24, 255
%26 = getelementptr inbounds i32, i32* %1, i64 5
store i32 %25, i32* %26
%27 = lshr i64 %8, 48
%28 = trunc i64 %27 to i32
%29 = and i32 %28, 255
%30 = getelementptr inbounds i32, i32* %1, i64 6
store i32 %29, i32* %30
%31 = lshr i64 %8, 56
%32 = trunc i64 %31 to i32
%33 = getelementptr inbounds i32, i32* %1, i64 7
store i32 %32, i32* %33
br label %34
34: ; preds = %2, %7
ret i32 %5
}