// File: /workspace/github_c_makefile_star2_O2/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 0x497(%rip), %rsi       # 0x66d3
pushq $0x22
popq %rdi
callq 0x6553
leaq 0x15feb(%rip), %rcx     # 0x1c236
leaq 0x8(%rsp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x9e8b
movq (%rbx), %rax
testq %rax, %rax
je 0x62fc
movzwl 0xf(%rax), %edi
callq 0xe749
movl %eax, %ebx
movq 0x8(%rsp), %rax
movzwl 0x11(%rax), %edi
callq 0xe749
orw %bx, %ax
jne 0x62fc
movq 0x8(%rsp), %rcx
movzbl 0x7(%rsp), %eax
cmpb 0x16(%rcx), %al
jne 0x62fc
movb 0x17(%rcx), %bl
movzbl %bl, %ebp
leal -0x1(%rax), %ecx
cmpl $0xa, %ecx
ja 0x6309
leaq 0x15d56(%rip), %rax     # 0x1c004
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0x22cfa(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x15f7c(%rip), %rsi     # 0x1c249
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x239c5(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x62fe
callq 0xe343
leaq 0x15f52(%rip), %rsi     # 0x1c249
jmp 0x6501
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
cmpl $0x1a, %eax
jne 0x62fe
movq 0x22ca3(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x15fd4(%rip), %rsi     # 0x1c2f8
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x2396e(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x62fe
callq 0xe343
leaq 0x15faa(%rip), %rsi     # 0x1c2f8
jmp 0x6501
movq 0x22c5e(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x15f76(%rip), %rsi     # 0x1c2df
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x23929(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x62fe
callq 0xe343
leaq 0x15f48(%rip), %rsi     # 0x1c2df
jmp 0x6501
movq 0x22c15(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x15ec9(%rip), %rsi     # 0x1c27b
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x238e0(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x62fe
callq 0xe343
leaq 0x15e9b(%rip), %rsi     # 0x1c27b
jmp 0x6501
movq 0x22bcc(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x15e99(%rip), %rsi     # 0x1c294
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x23897(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x62fe
callq 0xe343
leaq 0x15e6b(%rip), %rsi     # 0x1c294
jmp 0x6501
movq 0x22b83(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x15e1e(%rip), %rsi     # 0x1c262
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x2384e(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x62fe
callq 0xe343
leaq 0x15df0(%rip), %rsi     # 0x1c262
jmp 0x6501
movq 0x22b3a(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x15e20(%rip), %rsi     # 0x1c2ad
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x23805(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x62fe
callq 0xe343
leaq 0x15df2(%rip), %rsi     # 0x1c2ad
jmp 0x6501
movq 0x22af4(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x15df3(%rip), %rsi     # 0x1c2c6
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x237bf(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0x62fe
callq 0xe343
leaq 0x15dc5(%rip), %rsi     # 0x1c2c6
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
jmp 0x62fe