// File: /workspace/github_c_makefile_star2_O1/Carton32[P]quectel-CM/QmiWwanCM.c
// Function: QmiWwanGetClientID
static UCHAR QmiWwanGetClientID(UCHAR QMIType) {
    PQCQMIMSG pResponse;

    QmiThreadSendQMI(ComposeQCTLMsg(QMICTL_GET_CLIENT_ID_REQ, CtlGetClientIdReq, &QMIType), &pResponse);

    if (pResponse) {
        USHORT QMUXResult = cpu_to_le16(pResponse->CTLMsg.QMICTLMsgHdrRsp.QMUXResult);       // QMI_RESULT_SUCCESS
        USHORT QMUXError = cpu_to_le16(pResponse->CTLMsg.QMICTLMsgHdrRsp.QMUXError);        // QMI_ERR_INVALID_ARG
        //UCHAR QMIType = pResponse->CTLMsg.GetClientIdRsp.QMIType;
        UCHAR ClientId = pResponse->CTLMsg.GetClientIdRsp.ClientId;

        if (!QMUXResult && !QMUXError && (QMIType == pResponse->CTLMsg.GetClientIdRsp.QMIType)) {
            switch (QMIType) {
                case QMUX_TYPE_WDS: dbg_time("Get clientWDS = %d", ClientId); break;
                case QMUX_TYPE_DMS: dbg_time("Get clientDMS = %d", ClientId); break;
                case QMUX_TYPE_NAS: dbg_time("Get clientNAS = %d", ClientId); break;
                case QMUX_TYPE_QOS: dbg_time("Get clientQOS = %d", ClientId); break;
                case QMUX_TYPE_WMS: dbg_time("Get clientWMS = %d", ClientId); break;
                case QMUX_TYPE_PDS: dbg_time("Get clientPDS = %d", ClientId); break;
                case QMUX_TYPE_UIM: dbg_time("Get clientUIM = %d", ClientId); break;
                case QMUX_TYPE_WDS_ADMIN: dbg_time("Get clientWDA = %d", ClientId);
                break;
                default: break;
            }
            return ClientId;
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
leaq 0x7(%rsp), %rdx
movb %dil, (%rdx)
leaq 0x49a(%rip), %rsi       # 0x680a
movl $0x22, %edi
callq 0x6683
leaq 0x17eb5(%rip), %rcx     # 0x1e236
leaq 0x8(%rsp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0xa317
movq (%rbx), %rax
testq %rax, %rax
je 0x6432
movzwl 0xf(%rax), %edi
callq 0xef6c
movl %eax, %ebx
movq 0x8(%rsp), %rax
movzwl 0x11(%rax), %edi
callq 0xef6c
orw %bx, %ax
jne 0x6432
movq 0x8(%rsp), %rcx
movzbl 0x7(%rsp), %eax
cmpb 0x16(%rcx), %al
jne 0x6432
movb 0x17(%rcx), %bl
movzbl %bl, %ebp
leal -0x1(%rax), %ecx
cmpl $0xa, %ecx
ja 0x643f
leaq 0x17c20(%rip), %rax     # 0x1e004
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x23bcc(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
leaq 0x17e46(%rip), %rsi     # 0x1e249
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x2488f(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x6434
callq 0xeb2f
leaq 0x17e1c(%rip), %rsi     # 0x1e249
jmp 0x6637
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
cmpl $0x1a, %eax
jne 0x6434
movq 0x23b75(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
leaq 0x17e9e(%rip), %rsi     # 0x1e2f8
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x24838(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x6434
callq 0xeb2f
leaq 0x17e74(%rip), %rsi     # 0x1e2f8
jmp 0x6637
movq 0x23b30(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
leaq 0x17e40(%rip), %rsi     # 0x1e2df
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x247f3(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x6434
callq 0xeb2f
leaq 0x17e12(%rip), %rsi     # 0x1e2df
jmp 0x6637
movq 0x23ae7(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
leaq 0x17d93(%rip), %rsi     # 0x1e27b
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x247aa(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x6434
callq 0xeb2f
leaq 0x17d65(%rip), %rsi     # 0x1e27b
jmp 0x6637
movq 0x23a9e(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
leaq 0x17d63(%rip), %rsi     # 0x1e294
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x24761(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x6434
callq 0xeb2f
leaq 0x17d35(%rip), %rsi     # 0x1e294
jmp 0x6637
movq 0x23a55(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
leaq 0x17ce8(%rip), %rsi     # 0x1e262
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x24718(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x6434
callq 0xeb2f
leaq 0x17cba(%rip), %rsi     # 0x1e262
jmp 0x6637
movq 0x23a0c(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
leaq 0x17cea(%rip), %rsi     # 0x1e2ad
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x246cf(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x6434
callq 0xeb2f
leaq 0x17cbc(%rip), %rsi     # 0x1e2ad
jmp 0x6637
movq 0x239c6(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
leaq 0x17cbd(%rip), %rsi     # 0x1e2c6
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x24689(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x6434
callq 0xeb2f
leaq 0x17c8f(%rip), %rsi     # 0x1e2c6
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
jmp 0x6434