// File: /workspace/github_c_makefile_star2_O3/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 0x106a0(%rip), %rax     # 0x21474
leaq 0x10697(%rip), %rbx     # 0x21472
cmovnsq %rax, %rbx
testl %esi, %esi
je 0x11478
movq %rdi, %r14
movq 0x1afc7(%rip), %rax     # 0x2bdb8
testq %rax, %rax
jne 0x10e10
movl $0x1000, %edi           # imm = 0x1000
callq 0x5360
movq %rax, 0x1afb1(%rip)     # 0x2bdb8
testq %rax, %rax
je 0x10ecb
testl %ebp, %ebp
setns %cl
addb %cl, %cl
orb $0x3c, %cl
movb %cl, (%rax)
movb $0x0, 0x1(%rax)
cmpl $0x0, 0x4(%r14)
je 0x10e72
leaq 0x10648(%rip), %r15     # 0x21476
xorl %r13d, %r13d
movq 0x1af80(%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 0x10e72
incq %r13
movl 0x4(%r14), %eax
cmpq %rax, %r13
jb 0x10e31
movq 0x19147(%rip), %rax     # 0x29fc0
movq (%rax), %r15
callq 0xea3b
movq 0x1af30(%rip), %rcx     # 0x2bdb8
leaq 0xe0b7(%rip), %rsi      # 0x1ef46
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x19e05(%rip), %rax     # 0x2aca8
movq (%rax), %r15
testq %r15, %r15
je 0x10ecb
callq 0xea3b
movq 0x1af01(%rip), %rcx     # 0x2bdb8
leaq 0xe088(%rip), %rsi      # 0x1ef46
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movq 0x190ee(%rip), %rbp     # 0x29fc0
movq (%rbp), %r15
callq 0xea3b
leaq 0x1062b(%rip), %rsi     # 0x2150d
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0x19daf(%rip), %r13     # 0x2aca8
movq (%r13), %r15
testq %r15, %r15
je 0x10f1e
callq 0xea3b
leaq 0x105ff(%rip), %rsi     # 0x2150d
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r15
callq 0xea3b
movl 0x4(%r14), %r8d
leaq 0x105ec(%rip), %rsi     # 0x2151e
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x10f6b
callq 0xea3b
movl 0x4(%r14), %r8d
leaq 0x105c3(%rip), %rsi     # 0x2151e
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r15
callq 0xea3b
movl (%r14), %r9d
movl $0x4, %ecx
leaq 0x1854d(%rip), %r12     # 0x294d0
leaq 0x106a7(%rip), %r8      # 0x21631
cmpl %r9d, -0x4(%rcx,%r12)
je 0x10f9d
addq $0xc, %rcx
cmpq $0x70, %rcx
jne 0x10f8a
jmp 0x10fa1
movq (%rcx,%r12), %r8
leaq 0x10592(%rip), %rsi     # 0x2153a
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x11003
callq 0xea3b
movl (%r14), %r9d
movl $0x4, %ecx
leaq 0x1065c(%rip), %r8      # 0x21631
cmpl %r9d, -0x4(%rcx,%r12)
je 0x10fe8
addq $0xc, %rcx
cmpq $0x70, %rcx
jne 0x10fd5
jmp 0x10fec
movq (%rcx,%r12), %r8
leaq 0x10547(%rip), %rsi     # 0x2153a
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r15
callq 0xea3b
movl 0x8(%r14), %r8d
leaq 0x10547(%rip), %rsi     # 0x2155e
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x11050
callq 0xea3b
movl 0x8(%r14), %r8d
leaq 0x1051e(%rip), %rsi     # 0x2155e
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r15
callq 0xea3b
leaq 0x1051a(%rip), %rsi     # 0x2157a
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x11095
callq 0xea3b
leaq 0x104f5(%rip), %rsi     # 0x2157a
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 0x110f9
leaq 0x10236(%rip), %rax     # 0x212e0
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq (%rbp), %r15
callq 0xea3b
movl 0xc(%r14), %r8d
leaq 0x103d6(%rip), %rsi     # 0x2149d
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x11478
callq 0xea3b
movl 0xc(%r14), %r8d
leaq 0x103a9(%rip), %rsi     # 0x2149d
jmp 0x1129e
cmpl $0x3, %eax
je 0x1136d
cmpl $0x1, %eax
jne 0x11478
movq (%rbp), %r15
callq 0xea3b
movl 0xc(%r14), %r8d
leaq 0x1035d(%rip), %rsi     # 0x2147c
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x11478
callq 0xea3b
movl 0xc(%r14), %r8d
leaq 0x10330(%rip), %rsi     # 0x2147c
jmp 0x1129e
leaq 0x14(%r14), %r15
movl 0x24(%r14), %esi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x1583a
movq (%rbp), %r12
callq 0xea3b
movl 0x28(%r14), %r8d
leaq 0x10325(%rip), %rsi     # 0x2149d
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r12
testq %r12, %r12
je 0x111b1
callq 0xea3b
movl 0x28(%r14), %r8d
leaq 0x102fc(%rip), %rsi     # 0x2149d
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r12
callq 0xea3b
movl 0x2c(%r14), %r8d
leaq 0x1049d(%rip), %rsi     # 0x21662
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r12
testq %r12, %r12
je 0x111fe
callq 0xea3b
movl 0x2c(%r14), %r8d
leaq 0x10474(%rip), %rsi     # 0x21662
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
cmpl $0x0, 0x2c(%r14)
je 0x11478
leaq 0x101c2(%rip), %rdi     # 0x213d2
callq 0x10b31
movdqu (%r15), %xmm0
movdqu 0x1ab12(%rip), %xmm1    # 0x2bd34
pcmpeqb %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x11478
movl 0x24(%r14), %eax
cmpl $0x9, %eax
jg 0x114f9
cmpl $0x2, %eax
je 0x1150d
cmpl $0x9, %eax
jne 0x11478
addq $0x30, %r14
jmp 0x11551
movq (%rbp), %r15
callq 0xea3b
movl 0xc(%r14), %r8d
leaq 0x1027e(%rip), %rsi     # 0x214ef
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x11478
callq 0xea3b
movl 0xc(%r14), %r8d
leaq 0x10251(%rip), %rsi     # 0x214ef
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 0x1583a
movq (%rbp), %r12
callq 0xea3b
movl 0x28(%r14), %r8d
leaq 0x1037f(%rip), %rsi     # 0x21662
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r12
testq %r12, %r12
je 0x1131c
callq 0xea3b
movl 0x28(%r14), %r8d
leaq 0x10356(%rip), %rsi     # 0x21662
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
cmpl $0x0, 0x28(%r14)
je 0x11478
leaq 0x100a4(%rip), %rdi     # 0x213d2
callq 0x10b31
movdqu (%r15), %xmm0
movdqu 0x1a9f4(%rip), %xmm1    # 0x2bd34
pcmpeqb %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x114d7
leaq 0x10170(%rip), %rdi     # 0x214ca
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10b31
leaq 0x14(%r14), %rdi
movl 0x24(%r14), %esi
movq %rdi, (%rsp)
movq %rbx, %rdx
callq 0x1583a
movq %r13, %r15
movq (%rbp), %r13
callq 0xea3b
movl 0x28(%r14), %r9d
testl %r9d, %r9d
leaq 0x110d2(%rip), %rcx     # 0x2246d
leaq 0x11101(%rip), %r12     # 0x224a3
movq %r12, %r8
cmoveq %rcx, %r8
leaq 0x10293(%rip), %rsi     # 0x21643
movq %r13, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r15), %r13
testq %r13, %r13
je 0x113f9
callq 0xea3b
movl 0x28(%r14), %r9d
testl %r9d, %r9d
leaq 0x11092(%rip), %rcx     # 0x2246d
cmoveq %rcx, %r12
leaq 0x1025d(%rip), %rsi     # 0x21643
movq %r13, %rdi
movq %rax, %rdx
movq %rbx, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x52c0
movq (%rbp), %r12
callq 0xea3b
movl 0x2c(%r14), %r8d
leaq 0x10255(%rip), %rsi     # 0x21662
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0x19884(%rip), %r13     # 0x2aca8
movq (%r13), %r12
testq %r12, %r12
je 0x1144d
callq 0xea3b
movl 0x2c(%r14), %r8d
leaq 0x10225(%rip), %rsi     # 0x21662
movq %r12, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0xff7e(%rip), %rdi      # 0x213d2
callq 0x10b31
movq (%rsp), %rax
movdqu (%rax), %xmm0
movdqu 0x1a8cb(%rip), %xmm1    # 0x2bd34
pcmpeqb %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x11487
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x24(%r14), %eax
cmpl $0xf, %eax
je 0x11495
cmpl $0xc, %eax
jne 0x11478
movq (%rbp), %r15
callq 0xea3b
movl 0x30(%r14), %r8d
leaq 0x10009(%rip), %rsi     # 0x214b2
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r15
testq %r15, %r15
je 0x11478
callq 0xea3b
movl 0x30(%r14), %r8d
leaq 0xffe0(%rip), %rsi      # 0x214b2
jmp 0x1129e
movl 0x24(%r14), %eax
addl $-0x2, %eax
cmpl $0xa, %eax
ja 0x11478
leaq 0xfe12(%rip), %rcx      # 0x212fc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
addq $0x2c, %r14
jmp 0x11511
cmpl $0xa, %eax
je 0x1152a
cmpl $0xc, %eax
jne 0x11478
addq $0x30, %r14
jmp 0x1158b
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 0x1519e
addq $0x30, %r14
jmp 0x11534
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 0x14f47
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 0x154d2
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 0x1568b
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 0x14c29