// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: requestRadioPower
static int requestRadioPower(int state) {
    PQCQMIMSG pRequest;
    PQCQMIMSG pResponse;
    PQMUX_MSG pMUXMsg;
    int err;
    UCHAR OperatingMode = (!!state) ? DMS_OP_MODE_ONLINE : DMS_OP_MODE_LOW_POWER;
    USHORT SimOp = (!!state) ? QMIUIM_POWER_UP : QMIUIM_POWER_DOWN;
    UCHAR cardSlot = 0x01;

    dbg_time("%s(%d)", __func__, state);

    pRequest = ComposeQMUXMsg(QMUX_TYPE_DMS, QMIDMS_SET_OPERATING_MODE_REQ, DmsSetOperatingModeReq, &OperatingMode);
    err = QmiThreadSendQMI(pRequest, &pResponse);
    qmi_rsp_check_and_return();
    free(pResponse);

    pRequest = ComposeQMUXMsg(QMUX_TYPE_UIM, SimOp, UimSetCardSlotReq, &cardSlot);
    err = QmiThreadSendQMI(pRequest, &pResponse);
    qmi_rsp_check_and_return();
    free(pResponse);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
xorl %ebp, %ebp
testl %edi, %edi
sete 0xf(%rsp)
sete %r13b
movb $0x1, 0xe(%rsp)
movq 0x1c887(%rip), %r15     # 0x29fc0
movq (%r15), %r14
callq 0xea3b
leaq 0x1355a(%rip), %rsi     # 0x20ca2
leaq 0x13560(%rip), %rcx     # 0x20caf
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1d542(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xd791
callq 0xea3b
leaq 0x13528(%rip), %rsi     # 0x20ca2
leaq 0x1352e(%rip), %rcx     # 0x20caf
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x10df(%rip), %rdx      # 0xe877
leaq 0xf(%rsp), %rcx
movl $0x2, %edi
movl $0x2e, %esi
callq 0xd9a2
leaq 0x134fc(%rip), %rcx     # 0x20caf
leaq 0x10(%rsp), %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0xa273
movl %eax, %ebx
testl %eax, %eax
sets %al
movq (%r14), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xd840
movq (%r15), %r14
callq 0xea3b
leaq 0x12f93(%rip), %rsi     # 0x20781
leaq 0x134ba(%rip), %rcx     # 0x20caf
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1d49c(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xd8fa
callq 0xea3b
leaq 0x12f5d(%rip), %rsi     # 0x20781
leaq 0x13484(%rip), %rcx     # 0x20caf
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xd8fa
movzwl 0x10(%r12), %edi
callq 0xee73
testw %ax, %ax
jne 0xd864
movzwl 0x12(%r12), %edi
callq 0xee73
testw %ax, %ax
je 0xd90b
movzwl 0x12(%r12), %edi
callq 0xee73
movl %eax, %ebx
movq (%r15), %r14
callq 0xea3b
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xee73
movzwl %ax, %r8d
movzwl %bx, %ebx
leaq 0x12efe(%rip), %rsi     # 0x20793
leaq 0x13413(%rip), %rcx     # 0x20caf
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1d3f5(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xd8f0
callq 0xea3b
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xee73
movzwl %ax, %r8d
leaq 0x12eba(%rip), %rsi     # 0x20793
leaq 0x133cf(%rip), %rcx     # 0x20caf
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x10(%rsp), %rdi
callq 0x5040
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb %r13b, %bpl
xorl $0x31, %ebp
leaq 0x10(%rsp), %r14
movq (%r14), %rdi
callq 0x5040
movzwl %bp, %esi
leaq 0xf7e(%rip), %rdx       # 0xe8a6
leaq 0xe(%rsp), %rcx
movl $0xb, %edi
callq 0xd9a2
leaq 0x13371(%rip), %rcx     # 0x20caf
movq %rax, %rdi
movq %r14, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0xa273
movl %eax, %ebx
testl %eax, %eax
sets %al
movq (%r14), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
je 0xd7df
movzwl 0x10(%r12), %edi
callq 0xee73
testw %ax, %ax
jne 0xd864
movzwl 0x12(%r12), %edi
callq 0xee73
testw %ax, %ax
jne 0xd864
movq 0x10(%rsp), %rdi
callq 0x5040
xorl %ebx, %ebx
jmp 0xd8fa