#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, unsigned int, unsigned int);
int find_phy_core_num(int);
int isst_send_mbox_command(int, int, int, unsigned int, int /*<<< orphan*/,
                           unsigned int *);
int isst_clos_get_assoc_status(int cpu, int *clos_id) {
  unsigned int resp;
  unsigned int param;
  int core_id, ret;
  core_id = find_phy_core_num(cpu);
  param = core_id;
  ret = isst_send_mbox_command(cpu, 0xd0, 0x00, param, 0, &resp);
  if (ret)
    return ret;
  debug_printf("cpu:%d CLOS_PQR_ASSOC param:%x resp:%x\n", cpu, param, resp);
  *clos_id = (resp >> 16) & 0x03;
  return 0;
}


x86 assembly (clang, -O0):
<isst_clos_get_assoc_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <find_phy_core_num@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%ecx
mov    $0xd0,%esi
xor    %r8d,%r8d
lea    -0x14(%rbp),%r9
mov    %r8d,%edx
call   1050 <isst_send_mbox_command@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1182 <isst_clos_get_assoc_status+0x52>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ad <isst_clos_get_assoc_status+0x7d>
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe6e(%rip),%rdi
call   1030 <debug_printf@plt>
mov    -0x14(%rbp),%ecx
shr    $0x10,%ecx
and    $0x3,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isst_clos_get_assoc_status>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
call   1040 <find_phy_core_num@plt>
mov    %eax,%r15d
lea    0x4(%rsp),%r9
mov    %ebp,%edi
mov    $0xd0,%esi
xor    %edx,%edx
mov    %eax,%ecx
xor    %r8d,%r8d
call   1050 <isst_send_mbox_command@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    1182 <isst_clos_get_assoc_status+0x52>
mov    0x4(%rsp),%ecx
lea    0xe93(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <debug_printf@plt>
movzwl 0x6(%rsp),%eax
and    $0x3,%eax
mov    %eax,(%r14)
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"cpu:%d CLOS_PQR_ASSOC param:%x resp:%x\0A\00"
define i32 @isst_clos_get_assoc_status(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
%10 = load i32, i32* %4
%11 = call i32 @find_phy_core_num(i32 %10)
store i32 %11, i32* %8
%12 = load i32, i32* %8
store i32 %12, i32* %7
%13 = load i32, i32* %4
%14 = load i32, i32* %7
%15 = call i32 @isst_send_mbox_command(i32 %13, i32 208, i32 0, i32 %14, i32 0, i32* %6)
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = load i32, i32* %9
store i32 %19, i32* %3
br label %29
20: ; preds = %2
%21 = load i32, i32* %4
%22 = load i32, i32* %7
%23 = load i32, i32* %6
%24 = call i32 @debug_printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
%25 = load i32, i32* %6
%26 = lshr i32 %25, 16
%27 = and i32 %26, 3
%28 = load i32*, i32** %5
store i32 %27, i32* %28
store i32 0, i32* %3
br label %29
29: ; preds = %20, %18
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [40 x i8] c"cpu:%d CLOS_PQR_ASSOC param:%x resp:%x\0A\00"
define i32 @isst_clos_get_assoc_status(i32 %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @find_phy_core_num(i32 %0)
%6 = call i32 @isst_send_mbox_command(i32 %0, i32 208, i32 0, i32 %5, i32 0, i32* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32, i32* %3
%10 = call i32 @debug_printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %5, i32 %9)
%11 = load i32, i32* %3
%12 = lshr i32 %11, 16
%13 = and i32 %12, 3
store i32 %13, i32* %1
br label %14
14: ; preds = %2, %8
ret i32 %6
}