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


x86 assembly (clang, -O0):
<isst_clos_associate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x3,%eax
shl    $0x10,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <find_phy_core_num@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
or     $0x100,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    $0xd0,%esi
xor    %edx,%edx
lea    -0x14(%rbp),%r9
call   1050 <isst_send_mbox_command@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1192 <isst_clos_associate+0x62>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ae <isst_clos_associate+0x7e>
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe5e(%rip),%rdi
call   1030 <debug_printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

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

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

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