// File: /workspace/github_c_makefile_star2_O2/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 0x1e8b9(%rip), %rcx     # 0x28260
movq (%rcx,%rax,8), %r15
leaq 0x1fe0e(%rip), %r14     # 0x297c0
movq %r14, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x99ee
addq %rax, %r14
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl 0x1(%rbx), %edi
callq 0xe73e
movzwl %ax, %ecx
leaq 0x1351b(%rip), %rdx     # 0x1cefc
movq %r14, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x51c0
leaq 0x3(%rbx), %r14
leal -0x1(%r12), %eax
cmpl $0xa, %eax
ja 0x9a59
leaq 0x13459(%rip), %rcx     # 0x1ce5c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1fdad(%rip), %r12     # 0x297c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9c4c
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %edx
leaq 0x1dbfe(%rip), %rdi     # 0x27650
pushq $0x33
jmp 0x9c2a
cmpl $0x11, %r12d
je 0x9ab6
cmpl $0x1a, %r12d
jne 0x9b03
leaq 0x1fd50(%rip), %r12     # 0x297c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9c4c
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %edx
leaq 0x1e4e1(%rip), %rdi     # 0x27f90
pushq $0xb
jmp 0x9c2a
leaq 0x1fd03(%rip), %r12     # 0x297c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9c4c
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %edx
leaq 0x1e0f4(%rip), %rdi     # 0x27bf0
pushq $0x23
jmp 0x9c2a
leaq 0x1fcb6(%rip), %r15     # 0x297c0
movq %r15, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9c4c
addq %rax, %r15
movl $0x400, %r12d           # imm = 0x400
subq %rax, %r12
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %ecx
leaq 0x133d7(%rip), %rdx     # 0x1cf14
leaq 0x133ed(%rip), %r8      # 0x1cf31
movq %r15, %rdi
movq %r12, %rsi
jmp 0x9c45
leaq 0x1fc6a(%rip), %r12     # 0x297c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9c4c
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %edx
leaq 0x1ddeb(%rip), %rdi     # 0x27980
pushq $0x27
jmp 0x9c2a
leaq 0x1fc1d(%rip), %r12     # 0x297c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9c4c
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %edx
leaq 0x1e23e(%rip), %rdi     # 0x27e20
pushq $0x17
jmp 0x9c2a
leaq 0x1fbd3(%rip), %r12     # 0x297c0
movq %r12, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9c4c
addq %rax, %r12
movl $0x400, %r13d           # imm = 0x400
subq %rax, %r13
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %ebp
movzwl (%r14), %edi
callq 0xe73e
movzwl %ax, %edx
leaq 0x1e418(%rip), %rdi     # 0x28040
pushq $0x1f
popq %rsi
movq %r15, %rcx
callq 0x98da
leaq 0x132da(%rip), %rdx     # 0x1cf14
movq %r12, %rdi
movq %r13, %rsi
movl %ebp, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x51c0
leaq 0x1fb6d(%rip), %r15     # 0x297c0
movq %r15, %rdi
callq 0x5160
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x9c8f
addq %rax, %r15
movl $0x400, %r12d           # imm = 0x400
subq %rax, %r12
movzwl 0x5(%rbx), %edi
callq 0xe73e
movzwl %ax, %ecx
leaq 0x13260(%rip), %rdx     # 0x1cee2
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x51c0
movq %r14, %rdi
callq 0x96ac
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq