// File: /workspace/github_c_makefile_star2_O1/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 0x1f4db(%rip), %rcx     # 0x29300
movq (%rcx,%rax,8), %r15
leaq 0x20990(%rip), %r14     # 0x2a7c0
movq %r14, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9e6c
addq %rax, %r14
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl 0x1(%rbx), %edi
callq 0xef61
movzwl %ax, %ecx
leaq 0x150a1(%rip), %rdx     # 0x1ef00
movq %r14, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x51c0
leaq 0x3(%rbx), %r14
leal -0x1(%r12), %eax
cmpl $0xa, %eax
ja 0x9eda
leaq 0x14fdf(%rip), %rcx     # 0x1ee60
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x2092f(%rip), %r12     # 0x2a7c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa0db
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %edx
leaq 0x1e820(%rip), %rdi     # 0x286f0
movl $0x33, %esi
jmp 0xa0ba
cmpl $0x11, %r12d
je 0x9f3a
cmpl $0x1a, %r12d
jne 0x9f8a
leaq 0x208cf(%rip), %r12     # 0x2a7c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa0db
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %edx
leaq 0x1f100(%rip), %rdi     # 0x29030
movl $0xb, %esi
jmp 0xa0ba
leaq 0x2087f(%rip), %r12     # 0x2a7c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa0db
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %edx
leaq 0x1ed10(%rip), %rdi     # 0x28c90
movl $0x23, %esi
jmp 0xa0ba
leaq 0x2082f(%rip), %r15     # 0x2a7c0
movq %r15, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa0db
addq %rax, %r15
movl $0x400, %r12d           # imm = 0x400
subq %rax, %r12
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %ecx
leaq 0x14f54(%rip), %rdx     # 0x1ef18
leaq 0x14f6a(%rip), %r8      # 0x1ef35
movq %r15, %rdi
movq %r12, %rsi
jmp 0xa0d4
leaq 0x207e3(%rip), %r12     # 0x2a7c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa0db
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %edx
leaq 0x1ea04(%rip), %rdi     # 0x28a20
movl $0x27, %esi
jmp 0xa0ba
leaq 0x20793(%rip), %r12     # 0x2a7c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa0db
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %edx
leaq 0x1ee54(%rip), %rdi     # 0x28ec0
movl $0x17, %esi
jmp 0xa0ba
leaq 0x20746(%rip), %r12     # 0x2a7c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa0db
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xef61
movzwl %ax, %edx
leaq 0x1f02b(%rip), %rdi     # 0x290e0
movl $0x1f, %esi
movq %r15, %rcx
callq 0x9d55
leaq 0x14e4f(%rip), %rdx     # 0x1ef18
movq %r12, %rdi
movq %r13, %rsi
movl %ebp, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x51c0
leaq 0x206de(%rip), %r15     # 0x2a7c0
movq %r15, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0xa11e
addq %rax, %r15
movl $0x400, %r12d           # imm = 0x400
subq %rax, %r12
movzwl 0x5(%rbx), %edi
callq 0xef61
movzwl %ax, %ecx
leaq 0x14dd5(%rip), %rdx     # 0x1eee6
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x51c0
movq %r14, %rdi
callq 0x9b14
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq