#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);
int isst_send_mbox_command(int, int, int, int /*<<< orphan*/,
                           int /*<<< orphan*/, unsigned int *);
int isst_clos_get_clos_information(int cpu, int *enable, int *type) {
  unsigned int resp;
  int ret;
  ret = isst_send_mbox_command(cpu, 0xd0, 0x02, 0, 0, &resp);
  if (ret)
    return ret;
  debug_printf("cpu:%d CLOS_PM_QOS_CONFIG resp:%x\n", cpu, resp);
  if (resp & (1 << (1)))
    *enable = 1;
  else
    *enable = 0;
  if (resp & (1 << (2)))
    *type = 1;
  else
    *type = 0;
  return 0;
}


x86 assembly (clang, -O0):
<isst_clos_get_clos_information>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    $0xd0,%esi
mov    $0x2,%edx
xor    %r8d,%r8d
lea    -0x1c(%rbp),%r9
mov    %r8d,%ecx
call   1040 <isst_send_mbox_command@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1167 <isst_clos_get_clos_information+0x47>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d0 <isst_clos_get_clos_information+0xb0>
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe8c(%rip),%rdi
call   1030 <debug_printf@plt>
mov    -0x1c(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1197 <isst_clos_get_clos_information+0x77>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    11a1 <isst_clos_get_clos_information+0x81>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x1c(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11bf <isst_clos_get_clos_information+0x9f>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    11c9 <isst_clos_get_clos_information+0xa9>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isst_clos_get_clos_information>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebx
lea    0x4(%rsp),%r9
mov    $0xd0,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <isst_send_mbox_command@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1177 <isst_clos_get_clos_information+0x57>
mov    0x4(%rsp),%edx
lea    0xea7(%rip),%rdi
mov    %ebx,%esi
call   1030 <debug_printf@plt>
mov    0x4(%rsp),%eax
mov    %eax,%ecx
shr    %ecx
and    $0x1,%ecx
mov    %ecx,(%r15)
shr    $0x2,%eax
and    $0x1,%eax
mov    %eax,(%r14)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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