// File: /workspace/github_c_makefile_star2_O1/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_dump
static void mbim_dump(MBIM_MESSAGE_HEADER *pMsg, int mbim_verbose) {
    unsigned char *data = (unsigned char *)pMsg;
    const char *direction = (le32toh(pMsg->MessageType) & 0x80000000) ? "<" : ">";

    if (!mbim_verbose)
        return;

    if (mbim_verbose) {
        unsigned i;
        static char *_tmp = NULL;

        if (!_tmp)
            _tmp = (char *)malloc(4096);

        if (_tmp) {
            _tmp[0] = (le32toh(pMsg->MessageType) & 0x80000000) ? '<' : '>';
            _tmp[1] = '\0';
            for (i = 0; i < le32toh(pMsg->MessageLength) && i < 4096; i++)
                snprintf(_tmp + strlen(_tmp), 4096 - strlen(_tmp), "%02X:", data[i]);
            mbim_debug("%s", _tmp);
        }
    }

    mbim_dump_header(pMsg, direction);

    switch (le32toh(pMsg->MessageType)) {
    case MBIM_OPEN_MSG: {
        MBIM_OPEN_MSG_T *pOpenMsg = (MBIM_OPEN_MSG_T *)pMsg;
        mbim_debug("%s MaxControlTransfer = %u", direction, le32toh(pOpenMsg->MaxControlTransfer));
    }
    break;
    case MBIM_OPEN_DONE: {
        MBIM_OPEN_DONE_T *pOpenDone = (MBIM_OPEN_DONE_T *)pMsg;
        mbim_debug("%s Status = %u", direction, le32toh(pOpenDone->Status));
    }
    break;
    case MBIM_CLOSE_MSG: {

    }
    break;
    case MBIM_CLOSE_DONE: {
        MBIM_CLOSE_DONE_T *pCloseDone = (MBIM_CLOSE_DONE_T *)pMsg;
        mbim_debug("%s Status = %u", direction, le32toh(pCloseDone->Status));
    }
    break;
    case MBIM_COMMAND_MSG: {
        MBIM_COMMAND_MSG_T *pCmdMsg = (MBIM_COMMAND_MSG_T *)pMsg;

        mbim_dump_command_msg(pCmdMsg, direction);
        if (!memcmp(pCmdMsg->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT), 16)) {
            switch (le32toh(pCmdMsg->CID)) {
               case  MBIM_CID_CONNECT: {
                    MBIM_SET_CONNECT_T *pInfo = (MBIM_SET_CONNECT_T *)pCmdMsg->InformationBuffer;
                    mbim_debug("%s SessionId = %u", direction, le32toh(pInfo->SessionId));
                }
                break;
                case MBIM_CID_IP_CONFIGURATION: {
                    MBIM_IP_CONFIGURATION_INFO_T *pInfo = (MBIM_IP_CONFIGURATION_INFO_T *)pCmdMsg->InformationBuffer;
                    mbim_debug("%s SessionId = %u", direction, le32toh(pInfo->SessionId));
                }
                break;
                default:
                break;
            }
        }
    }
    break;
    case MBIM_COMMAND_DONE: {
        MBIM_COMMAND_DONE_T *pCmdDone = (MBIM_COMMAND_DONE_T *)pMsg;

        mbim_dump_command_done(pCmdDone, direction);
        if (le32toh(pCmdDone->InformationBufferLength) == 0)
            return;

        if (!memcmp(pCmdDone->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT), 16)) {
            switch (le32toh(pCmdDone->CID)) {
                case MBIM_CID_CONNECT: {
                MBIM_CONNECT_T *pInfo = (MBIM_CONNECT_T *)pCmdDone->InformationBuffer;
                mbim_dump_connect(pInfo, direction);
                }
                break;
                case MBIM_CID_IP_CONFIGURATION: {
                    //MBIM_IP_CONFIGURATION_INFO_T *pInfo = (MBIM_IP_CONFIGURATION_INFO_T *)pCmdDone->InformationBuffer;
                    //mbim_dump_ipconfig(pInfo, direction);
                }
                break;
                case MBIM_CID_PACKET_SERVICE: {
                    MBIM_PACKET_SERVICE_INFO_T *pInfo = (MBIM_PACKET_SERVICE_INFO_T *)pCmdDone->InformationBuffer;
                    mbim_dump_packet_service(pInfo, direction);
                }
                break;
                case MBIM_CID_SUBSCRIBER_READY_STATUS: {
                    MBIM_SUBSCRIBER_READY_STATUS_T *pInfo = (MBIM_SUBSCRIBER_READY_STATUS_T *)pCmdDone->InformationBuffer;
                    mbim_dump_subscriber_status(pInfo, direction);
                }
                break;
                case MBIM_CID_REGISTER_STATE: {
                    MBIM_REGISTRATION_STATE_INFO_T *pInfo = (MBIM_REGISTRATION_STATE_INFO_T *)pCmdDone->InformationBuffer;
                    mbim_dump_regiester_status(pInfo, direction);
                }
                break;
                default:
                break;
            }
        }
    }
    break;
    case MBIM_INDICATE_STATUS_MSG: {
        MBIM_INDICATE_STATUS_MSG_T *pIndMsg = (MBIM_INDICATE_STATUS_MSG_T *)pMsg;

        mbim_dump_indicate_msg(pIndMsg, direction);
        if (le32toh(pIndMsg->InformationBufferLength) == 0)
            return;

        if (!memcmp(pIndMsg->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT), 16)) {
            switch (le32toh(pIndMsg->CID)) {
                case MBIM_CID_CONNECT: {
                    MBIM_CONNECT_T *pInfo = (MBIM_CONNECT_T *)pIndMsg->InformationBuffer;
                    mbim_dump_connect(pInfo, direction);
                }
                break;
                case MBIM_CID_SIGNAL_STATE: {
                    MBIM_SIGNAL_STATE_INFO_T *pInfo = (MBIM_SIGNAL_STATE_INFO_T *)pIndMsg->InformationBuffer;
                    mbim_dump_signal_state(pInfo, direction);
                }
                break;
                case MBIM_CID_SUBSCRIBER_READY_STATUS: {
                    MBIM_SUBSCRIBER_READY_STATUS_T *pInfo = (MBIM_SUBSCRIBER_READY_STATUS_T *)pIndMsg->InformationBuffer;
                    mbim_dump_subscriber_status(pInfo, direction);
                }
                break;
                case MBIM_CID_REGISTER_STATE: {
                    MBIM_REGISTRATION_STATE_INFO_T *pInfo = (MBIM_REGISTRATION_STATE_INFO_T *)pIndMsg->InformationBuffer;
                    mbim_dump_regiester_status(pInfo, direction);
                }
                break;
                case MBIM_CID_PACKET_SERVICE: {
                    MBIM_PACKET_SERVICE_INFO_T *pInfo = (MBIM_PACKET_SERVICE_INFO_T *)pIndMsg->InformationBuffer;
                    mbim_dump_packet_service(pInfo, direction);
                }
                break;
                default:
                break;
            }
        }
        else if (!memcmp(pIndMsg->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT_EXT), 16)) {
        }
    }
    break;
    case MBIM_FUNCTION_ERROR_MSG: {
        MBIM_FUNCTION_ERROR_MSG_T *pErrMsg = (MBIM_FUNCTION_ERROR_MSG_T*)pMsg;
        mbim_debug("%s ErrorStatusCode = %u", direction, le32toh(pErrMsg->ErrorStatusCode));
    }
    break;
    default:
    break;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl (%rdi), %ebp
testl %ebp, %ebp
leaq 0x105a7(%rip), %rax     # 0x2144c
leaq 0x1059e(%rip), %rbx     # 0x2144a
cmovnsq %rax, %rbx
testl %esi, %esi
je 0x1154e
movq %rdi, %r14
cmpq $0x0, 0x1aef5(%rip)     # 0x2bdb8
jne 0x10ed6
movl $0x1000, %edi           # imm = 0x1000
callq 0x5360
movq %rax, 0x1aee2(%rip)     # 0x2bdb8
movq 0x1aedb(%rip), %rax     # 0x2bdb8
testq %rax, %rax
je 0x10fa1
testl %ebp, %ebp
setns %cl
addb %cl, %cl
orb $0x3c, %cl
movb %cl, (%rax)
movb $0x0, 0x1(%rax)
cmpl $0x0, 0x4(%r14)
je 0x10f48
leaq 0x1054a(%rip), %r15     # 0x2144e
xorl %r13d, %r13d
movq 0x1aeaa(%rip), %r12     # 0x2bdb8
movq %r12, %rdi
callq 0x5160
addq %rax, %r12
movl $0x1000, %esi           # imm = 0x1000
subq %rax, %rsi
movzbl (%r14,%r13), %ecx
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x51c0
cmpq $0xffe, %r13            # imm = 0xFFE
ja 0x10f48
incq %r13
movl 0x4(%r14), %eax
cmpq %rax, %r13
jb 0x10f07
movq 0x19071(%rip), %rax     # 0x29fc0
movq (%rax), %r15
callq 0xeb2f
movq 0x1ae5a(%rip), %rcx     # 0x2bdb8
leaq 0xdfe5(%rip), %rsi      # 0x1ef4a
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x19d2f(%rip), %rax     # 0x2aca8
movq (%rax), %r15
testq %r15, %r15
je 0x10fa1
callq 0xeb2f
movq 0x1ae2b(%rip), %rcx     # 0x2bdb8
leaq 0xdfb6(%rip), %rsi      # 0x1ef4a
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movq 0x19018(%rip), %rbp     # 0x29fc0
movq (%rbp), %r15
callq 0xeb2f
leaq 0x1052d(%rip), %rsi     # 0x214e5
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0x19cd9(%rip), %r13     # 0x2aca8
movq (%r13), %r15
testq %r15, %r15
je 0x10ff4
callq 0xeb2f
leaq 0x10501(%rip), %rsi     # 0x214e5
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r15
callq 0xeb2f
movl 0x4(%r14), %r8d
leaq 0x104ee(%rip), %rsi     # 0x214f6
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x11041
callq 0xeb2f
movl 0x4(%r14), %r8d
leaq 0x104c5(%rip), %rsi     # 0x214f6
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r15
callq 0xeb2f
movl (%r14), %r9d
movl $0x4, %ecx
leaq 0x18477(%rip), %r12     # 0x294d0
leaq 0x105a9(%rip), %r8      # 0x21609
cmpl %r9d, -0x4(%rcx,%r12)
je 0x11073
addq $0xc, %rcx
cmpq $0x70, %rcx
jne 0x11060
jmp 0x11077
movq (%rcx,%r12), %r8
leaq 0x10494(%rip), %rsi     # 0x21512
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x110d9
callq 0xeb2f
movl (%r14), %r9d
movl $0x4, %ecx
leaq 0x1055e(%rip), %r8      # 0x21609
cmpl %r9d, -0x4(%rcx,%r12)
je 0x110be
addq $0xc, %rcx
cmpq $0x70, %rcx
jne 0x110ab
jmp 0x110c2
movq (%rcx,%r12), %r8
leaq 0x10449(%rip), %rsi     # 0x21512
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r15
callq 0xeb2f
movl 0x8(%r14), %r8d
leaq 0x10449(%rip), %rsi     # 0x21536
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x11126
callq 0xeb2f
movl 0x8(%r14), %r8d
leaq 0x10420(%rip), %rsi     # 0x21536
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r15
callq 0xeb2f
leaq 0x1041c(%rip), %rsi     # 0x21552
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x1116b
callq 0xeb2f
leaq 0x103f7(%rip), %rsi     # 0x21552
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movl (%r14), %eax
leal 0x7fffffff(%rax), %ecx
cmpl $0x6, %ecx
ja 0x111cf
leaq 0x10154(%rip), %rax     # 0x212d4
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq (%rbp), %r15
callq 0xeb2f
movl 0xc(%r14), %r8d
leaq 0x102d8(%rip), %rsi     # 0x21475
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x1154e
callq 0xeb2f
movl 0xc(%r14), %r8d
leaq 0x102ab(%rip), %rsi     # 0x21475
jmp 0x11374
cmpl $0x3, %eax
je 0x11443
cmpl $0x1, %eax
jne 0x1154e
movq (%rbp), %r15
callq 0xeb2f
movl 0xc(%r14), %r8d
leaq 0x1025f(%rip), %rsi     # 0x21454
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x1154e
callq 0xeb2f
movl 0xc(%r14), %r8d
leaq 0x10232(%rip), %rsi     # 0x21454
jmp 0x11374
leaq 0x14(%r14), %r15
movl 0x24(%r14), %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x159fd
movq (%rbp), %r12
callq 0xeb2f
movl 0x28(%r14), %r8d
leaq 0x10227(%rip), %rsi     # 0x21475
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r12
testq %r12, %r12
je 0x11287
callq 0xeb2f
movl 0x28(%r14), %r8d
leaq 0x101fe(%rip), %rsi     # 0x21475
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r12
callq 0xeb2f
movl 0x2c(%r14), %r8d
leaq 0x1039f(%rip), %rsi     # 0x2163a
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r12
testq %r12, %r12
je 0x112d4
callq 0xeb2f
movl 0x2c(%r14), %r8d
leaq 0x10376(%rip), %rsi     # 0x2163a
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
cmpl $0x0, 0x2c(%r14)
je 0x1154e
leaq 0x100c4(%rip), %rdi     # 0x213aa
callq 0x10c1b
movdqu (%r15), %xmm0
movdqu 0x1aa3c(%rip), %xmm1    # 0x2bd34
pcmpeqb %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x1154e
movl 0x24(%r14), %eax
cmpl $0x9, %eax
jg 0x115cf
cmpl $0x2, %eax
je 0x115e3
cmpl $0x9, %eax
jne 0x1154e
addq $0x30, %r14
jmp 0x11627
movq (%rbp), %r15
callq 0xeb2f
movl 0xc(%r14), %r8d
leaq 0x10180(%rip), %rsi     # 0x214c7
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x1154e
callq 0xeb2f
movl 0xc(%r14), %r8d
leaq 0x10153(%rip), %rsi     # 0x214c7
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x52c0
leaq 0x14(%r14), %r15
movl 0x24(%r14), %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x159fd
movq (%rbp), %r12
callq 0xeb2f
movl 0x28(%r14), %r8d
leaq 0x10281(%rip), %rsi     # 0x2163a
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r12
testq %r12, %r12
je 0x113f2
callq 0xeb2f
movl 0x28(%r14), %r8d
leaq 0x10258(%rip), %rsi     # 0x2163a
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
cmpl $0x0, 0x28(%r14)
je 0x1154e
leaq 0xffa6(%rip), %rdi      # 0x213aa
callq 0x10c1b
movdqu (%r15), %xmm0
movdqu 0x1a91e(%rip), %xmm1    # 0x2bd34
pcmpeqb %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x115ad
leaq 0x10072(%rip), %rdi     # 0x214a2
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10c1b
leaq 0x14(%r14), %rdi
movl 0x24(%r14), %esi
movq %rdi, (%rsp)
movq %rbx, %rdx
callq 0x159fd
movq %r13, %r15
movq (%rbp), %r13
callq 0xeb2f
movl 0x28(%r14), %r9d
testl %r9d, %r9d
leaq 0x10fd4(%rip), %rcx     # 0x22445
leaq 0x11003(%rip), %r12     # 0x2247b
movq %r12, %r8
cmoveq %rcx, %r8
leaq 0x10195(%rip), %rsi     # 0x2161b
movq %r13, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r15), %r13
testq %r13, %r13
je 0x114cf
callq 0xeb2f
movl 0x28(%r14), %r9d
testl %r9d, %r9d
leaq 0x10f94(%rip), %rcx     # 0x22445
cmoveq %rcx, %r12
leaq 0x1015f(%rip), %rsi     # 0x2161b
movq %r13, %rdi
movq %rax, %rdx
movq %rbx, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r12
callq 0xeb2f
movl 0x2c(%r14), %r8d
leaq 0x10157(%rip), %rsi     # 0x2163a
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0x197ae(%rip), %r13     # 0x2aca8
movq (%r13), %r12
testq %r12, %r12
je 0x11523
callq 0xeb2f
movl 0x2c(%r14), %r8d
leaq 0x10127(%rip), %rsi     # 0x2163a
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0xfe80(%rip), %rdi      # 0x213aa
callq 0x10c1b
movq (%rsp), %rax
movdqu (%rax), %xmm0
movdqu 0x1a7f5(%rip), %xmm1    # 0x2bd34
pcmpeqb %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1155d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x24(%r14), %eax
cmpl $0xf, %eax
je 0x1156b
cmpl $0xc, %eax
jne 0x1154e
movq (%rbp), %r15
callq 0xeb2f
movl 0x30(%r14), %r8d
leaq 0xff0b(%rip), %rsi      # 0x2148a
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x1154e
callq 0xeb2f
movl 0x30(%r14), %r8d
leaq 0xfee2(%rip), %rsi      # 0x2148a
jmp 0x11374
movl 0x24(%r14), %eax
addl $-0x2, %eax
cmpl $0xa, %eax
ja 0x1154e
leaq 0xfd30(%rip), %rcx      # 0x212f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
addq $0x2c, %r14
jmp 0x115e7
cmpl $0xa, %eax
je 0x11600
cmpl $0xc, %eax
jne 0x1154e
addq $0x30, %r14
jmp 0x11661
addq $0x30, %r14
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1537f
addq $0x30, %r14
jmp 0x1160a
addq $0x2c, %r14
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x15128
addq $0x2c, %r14
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x15695
addq $0x2c, %r14
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1584e
addq $0x2c, %r14
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x14e0a