// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/MPQMUX.c
// Function: dump_qmux
int dump_qmux(QMI_SERVICE_TYPE serviceType, PQCQMUX_HDR QMUXHdr) {
    PQCQMUX_MSG_HDR QMUXMsgHdr = (PQCQMUX_MSG_HDR) (QMUXHdr + 1);
    const char *tag;

    //dbg("QCQMUX--------------------------------------------\n");
    switch (QMUXHdr->CtlFlags&QMUX_CTL_FLAG_MASK_TYPE) {
        case QMUX_CTL_FLAG_TYPE_CMD: tag = "_REQ"; break;
        case QMUX_CTL_FLAG_TYPE_RSP: tag = "_RESP"; break;
        case QMUX_CTL_FLAG_TYPE_IND: tag = "_IND"; break;
        default: tag = 0; break;
    }
    //dbg("CtlFlags:           %02x\t\t%s\n", QMUXHdr->CtlFlags, QMUX_NAME(qmux_CtlFlags, QMUXHdr->CtlFlags, tag));
    dbg("TransactionId:    %04x\n", le16_to_cpu(QMUXHdr->TransactionId));

    //dbg("QCQMUX_MSG_HDR-----------------------------------\n");
    switch (serviceType) {
        case QMUX_TYPE_DMS:
            dbg("Type:               %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type),
            QMUX_NAME(qmux_dms_Type, le16_to_cpu(QMUXMsgHdr->Type), tag));
        break;
        case QMUX_TYPE_NAS:
            dbg("Type:               %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type),
            QMUX_NAME(qmux_nas_Type, le16_to_cpu(QMUXMsgHdr->Type), tag));
        break;
        case QMUX_TYPE_WDS:
        case QMUX_TYPE_WDS_IPV6:
            dbg("Type:               %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type),
            QMUX_NAME(qmux_wds_Type, le16_to_cpu(QMUXMsgHdr->Type), tag));
        break;
        case QMUX_TYPE_WMS:
            dbg("Type:               %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type),
            QMUX_NAME(qmux_wms_Type, le16_to_cpu(QMUXMsgHdr->Type), tag));
        break;
        case QMUX_TYPE_WDS_ADMIN:
            dbg("Type:               %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type),
            QMUX_NAME(qmux_wds_admin_Type, le16_to_cpu(QMUXMsgHdr->Type), tag));
        break;
        case QMUX_TYPE_UIM:
            dbg("Type:               %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type),
            QMUX_NAME(qmux_uim_Type, le16_to_cpu(QMUXMsgHdr->Type), tag));
        break;
        case QMUX_TYPE_PDS:
        case QMUX_TYPE_QOS:
        case QMUX_TYPE_CTL:                
        default:
            dbg("Type:               %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), "PDS/QOS/CTL/unknown!");
        break;    
    }
    dbg("Length:             %04x\n", le16_to_cpu(QMUXMsgHdr->Length));

    dump_tlv(QMUXMsgHdr);
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %r12d
movzbl (%rsi), %eax
andl $0x6, %eax
leaq 0x1f57e(%rip), %rcx     # 0x29300
movq (%rcx,%rax,8), %r15
leaq 0x20a33(%rip), %r14     # 0x2a7c0
movq %r14, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9dc9
addq %rax, %r14
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl 0x1(%rbx), %edi
callq 0xee73
movzwl %ax, %ecx
leaq 0x15140(%rip), %rdx     # 0x1eefc
movq %r14, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x51c0
leaq 0x3(%rbx), %r14
leal -0x1(%r12), %eax
cmpl $0xa, %eax
ja 0x9e37
leaq 0x1507e(%rip), %rcx     # 0x1ee5c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x209d2(%rip), %r12     # 0x2a7c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa038
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %edx
leaq 0x1e8c3(%rip), %rdi     # 0x286f0
movl $0x33, %esi
jmp 0xa017
cmpl $0x11, %r12d
je 0x9e97
cmpl $0x1a, %r12d
jne 0x9ee7
leaq 0x20972(%rip), %r12     # 0x2a7c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa038
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %edx
leaq 0x1f1a3(%rip), %rdi     # 0x29030
movl $0xb, %esi
jmp 0xa017
leaq 0x20922(%rip), %r12     # 0x2a7c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa038
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %edx
leaq 0x1edb3(%rip), %rdi     # 0x28c90
movl $0x23, %esi
jmp 0xa017
leaq 0x208d2(%rip), %r15     # 0x2a7c0
movq %r15, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa038
addq %rax, %r15
movl $0x400, %r12d           # imm = 0x400
subq %rax, %r12
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %ecx
leaq 0x14ff3(%rip), %rdx     # 0x1ef14
leaq 0x15009(%rip), %r8      # 0x1ef31
movq %r15, %rdi
movq %r12, %rsi
jmp 0xa031
leaq 0x20886(%rip), %r12     # 0x2a7c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa038
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %edx
leaq 0x1eaa7(%rip), %rdi     # 0x28a20
movl $0x27, %esi
jmp 0xa017
leaq 0x20836(%rip), %r12     # 0x2a7c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa038
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %edx
leaq 0x1eef7(%rip), %rdi     # 0x28ec0
movl $0x17, %esi
jmp 0xa017
leaq 0x207e9(%rip), %r12     # 0x2a7c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa038
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xee73
movzwl %ax, %edx
leaq 0x1f0ce(%rip), %rdi     # 0x290e0
movl $0x1f, %esi
movq %r15, %rcx
callq 0x9cb3
leaq 0x14eee(%rip), %rdx     # 0x1ef14
movq %r12, %rdi
movq %r13, %rsi
movl %ebp, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x51c0
leaq 0x20781(%rip), %r15     # 0x2a7c0
movq %r15, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa07b
addq %rax, %r15
movl $0x400, %r12d           # imm = 0x400
subq %rax, %r12
movzwl 0x5(%rbx), %edi
callq 0xee73
movzwl %ax, %ecx
leaq 0x14e74(%rip), %rdx     # 0x1eee2
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x51c0
movq %r14, %rdi
callq 0x9a5c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq