#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*/ debug_printf(char *, int, ...);
int isst_send_msr_command(int, int, int /*<<< orphan*/, unsigned long long *);
int isst_get_trl_bucket_info(int cpu, unsigned long long *buckets_info) {
  int ret;
  debug_printf("cpu:%d bucket info via MSR\n", cpu);
  *buckets_info = 0;
  ret = isst_send_msr_command(cpu, 0x1ae, 0, buckets_info);
  if (ret)
    return ret;
  debug_printf("cpu:%d bucket info via MSR successful 0x%llx\n", cpu,
               *buckets_info);
  return 0;
}


x86 assembly (clang, -O0):
<isst_get_trl_bucket_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%esi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <debug_printf@plt>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rcx
mov    $0x1ae,%esi
xor    %edx,%edx
call   1040 <isst_send_msr_command@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1176 <isst_get_trl_bucket_info+0x56>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1195 <isst_get_trl_bucket_info+0x75>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <debug_printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isst_get_trl_bucket_info>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%r14d
lea    0xecf(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <debug_printf@plt>
movq   $0x0,(%rbx)
mov    %r14d,%edi
mov    $0x1ae,%esi
xor    %edx,%edx
mov    %rbx,%rcx
call   1040 <isst_send_msr_command@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    116e <isst_get_trl_bucket_info+0x4e>
mov    (%rbx),%rdx
lea    0xeb8(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <debug_printf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"cpu:%d bucket info via MSR\0A\00"
@.str.1 = [46 x i8] c"cpu:%d bucket info via MSR successful 0x%llx\0A\00"
define i32 @isst_get_trl_bucket_info(i32 %0, i64* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64*
%6 = alloca i32
store i32 %0, i32* %4
store i64* %1, i64** %5
%7 = load i32, i32* %4
%8 = call i32 (i8*, i32, ...) @debug_printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i64*, i64** %5
store i64 0, i64* %9
%10 = load i32, i32* %4
%11 = load i64*, i64** %5
%12 = call i32 @isst_send_msr_command(i32 %10, i32 430, i32 0, i64* %11)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i32, i32* %6
store i32 %16, i32* %3
br label %22
17: ; preds = %2
%18 = load i32, i32* %4
%19 = load i64*, i64** %5
%20 = load i64, i64* %19
%21 = call i32 (i8*, i32, ...) @debug_printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %18, i64 %20)
store i32 0, i32* %3
br label %22
22: ; preds = %17, %15
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@.str = [28 x i8] c"cpu:%d bucket info via MSR\0A\00"
@.str.1 = [46 x i8] c"cpu:%d bucket info via MSR successful 0x%llx\0A\00"
define i32 @isst_get_trl_bucket_info(i32 %0, i64* %1) {
%3 = tail call i32 (i8*, i32, ...) @debug_printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %0)
store i64 0, i64* %1
%4 = tail call i32 @isst_send_msr_command(i32 %0, i32 430, i32 0, i64* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i64, i64* %1
%8 = tail call i32 (i8*, i32, ...) @debug_printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %0, i64 %7)
br label %9
9: ; preds = %2, %6
ret i32 %4
}