// File: /workspace/github_c_makefile_star2_O2/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 0x1bcdf(%rip), %r15     # 0x28fb8
movq (%r15), %r14
callq 0xe343
leaq 0x119d0(%rip), %rsi     # 0x1ecb8
leaq 0x119d6(%rip), %rcx     # 0x1ecc5
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1c9a2(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xd331
callq 0xe343
leaq 0x1199e(%rip), %rsi     # 0x1ecb8
leaq 0x119a4(%rip), %rcx     # 0x1ecc5
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0xe59(%rip), %rdx       # 0xe191
pushq $0x2
popq %rdi
pushq $0x2e
popq %rsi
leaq 0xf(%rsp), %rcx
callq 0xd53c
leaq 0x11976(%rip), %rcx     # 0x1ecc5
leaq 0x10(%rsp), %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x9e8b
movl %eax, %ebx
testl %eax, %eax
sets %al
movq (%r14), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xd3dc
movq (%r15), %r14
callq 0xe343
leaq 0x113f7(%rip), %rsi     # 0x1e781
leaq 0x11934(%rip), %rcx     # 0x1ecc5
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1c900(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xd496
callq 0xe343
leaq 0x113c1(%rip), %rsi     # 0x1e781
leaq 0x118fe(%rip), %rcx     # 0x1ecc5
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xd496
movzwl 0x10(%r12), %edi
callq 0xe73e
testw %ax, %ax
jne 0xd400
movzwl 0x12(%r12), %edi
callq 0xe73e
testw %ax, %ax
je 0xd4a7
movzwl 0x12(%r12), %edi
callq 0xe73e
movl %eax, %ebx
movq (%r15), %r14
callq 0xe343
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xe73e
movzwl %ax, %r8d
movzwl %bx, %ebx
leaq 0x11362(%rip), %rsi     # 0x1e793
leaq 0x1188d(%rip), %rcx     # 0x1ecc5
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1c859(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xd48c
callq 0xe343
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xe73e
movzwl %ax, %r8d
leaq 0x1131e(%rip), %rsi     # 0x1e793
leaq 0x11849(%rip), %rcx     # 0x1ecc5
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 0xcfa(%rip), %rdx       # 0xe1be
pushq $0xb
popq %rdi
leaq 0xe(%rsp), %rcx
callq 0xd53c
leaq 0x117ed(%rip), %rcx     # 0x1ecc5
movq %rax, %rdi
movq %r14, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x9e8b
movl %eax, %ebx
testl %eax, %eax
sets %al
movq (%r14), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
je 0xd37b
movzwl 0x10(%r12), %edi
callq 0xe73e
testw %ax, %ax
jne 0xd400
movzwl 0x12(%r12), %edi
callq 0xe73e
testw %ax, %ax
jne 0xd400
movq 0x10(%rsp), %rdi
callq 0x5040
xorl %ebx, %ebx
jmp 0xd496