#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*/, unsigned int,
                           unsigned int *);
int isst_write_pm_config(int cpu, int cp_state) {
  unsigned int req, resp;
  int ret;
  if (cp_state)
    req = (1 << (16));
  else
    req = 0;
  ret = isst_send_mbox_command(cpu, 0x95, 0x03, 0, req, &resp);
  if (ret)
    return ret;
  debug_printf("cpu:%d WRITE_PM_CONFIG resp:%x\n", cpu, resp);
  return 0;
}


x86 assembly (clang, -O0):
<isst_write_pm_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1144 <isst_write_pm_config+0x24>
movl   $0x10000,-0x10(%rbp)
jmp    114b <isst_write_pm_config+0x2b>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%r8d
mov    $0x95,%esi
mov    $0x3,%edx
xor    %ecx,%ecx
lea    -0x14(%rbp),%r9
call   1040 <isst_send_mbox_command@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     117f <isst_write_pm_config+0x5f>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1198 <isst_write_pm_config+0x78>
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe74(%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_write_pm_config>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %r8d,%r8d
test   %esi,%esi
setne  %r8b
shl    $0x10,%r8d
lea    0x4(%rsp),%r9
mov    $0x95,%esi
mov    $0x3,%edx
xor    %ecx,%ecx
call   1040 <isst_send_mbox_command@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1160 <isst_write_pm_config+0x40>
mov    0x4(%rsp),%edx
lea    0xea7(%rip),%rdi
mov    %ebx,%esi
call   1030 <debug_printf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [32 x i8] c"cpu:%d WRITE_PM_CONFIG resp:%x\0A\00"
define i32 @isst_write_pm_config(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %1, 0
%6 = select i1 %5, i32 0, i32 65536
%7 = call i32 @isst_send_mbox_command(i32 %0, i32 149, i32 3, i32 0, i32 %6, i32* %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* %3
%11 = call i32 @debug_printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %10)
br label %12
12: ; preds = %2, %9
ret i32 %7
}