// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_device_services_query
static int mbim_device_services_query(void) {
    MBIM_MESSAGE_HEADER *pRequest = NULL;
    MBIM_COMMAND_DONE_T *pCmdDone = NULL;
    int err;
    int mbim_v2_support = 0;

    mbim_debug("%s()", __func__);
    pRequest = compose_basic_connect_command(MBIM_CID_DEVICE_SERVICES, MBIM_CID_CMD_TYPE_QUERY, NULL, 0);
    err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout);
    mbim_check_err(err, pRequest, pCmdDone);

    if (pCmdDone->InformationBufferLength) {
         MBIM_DEVICE_SERVICES_INFO_T *pInfo = (MBIM_DEVICE_SERVICES_INFO_T *)pCmdDone->InformationBuffer;
         UINT32 i;

        for (i = 0; i < le32toh(pInfo->DeviceServicesCount) ; i++) {
            //UINT32 size = pInfo->DeviceServicesRefList[i].size;
            UINT32 offset = le32toh(pInfo->DeviceServicesRefList[i].offset);
            MBIM_DEVICE_SERVICE_ELEMENT_T *pSrvEle = (MBIM_DEVICE_SERVICE_ELEMENT_T *)((void *)pInfo + offset);

            //mbim_debug("\t[%2d] %s (%s)", i, DeviceServiceId2str(&pSrvEle->DeviceServiceId), uuid2str(&pSrvEle->DeviceServiceId));
            if (!strcasecmp(UUID_BASIC_CONNECT_EXT, uuid2str(&pSrvEle->DeviceServiceId))) {
                UINT32 cid = 0;

                for (cid = 0; cid < le32toh(pSrvEle->CidCount); cid++) {
                  if (MBIM_CID_MS_VERSION == le32toh(pSrvEle->CidList[cid])) {
                        mbim_v2_support = 1;
                    }
                }
            }
            else if (!strcasecmp(uuid_ext_qmux, uuid2str(&pSrvEle->DeviceServiceId))) {
                qmi_over_mbim_support = 1;
            }
        }
    }
    mbim_free(pRequest); mbim_free(pCmdDone);

    if (mbim_v2_support) {
        mbim_ms_version_query();
    }

    return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
movq 0x1aed7(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x50(%rbp)
callq 0x13930
movq -0x50(%rbp), %rdi
movq %rax, %rdx
leaq 0x1336b(%rip), %rsi     # 0x2f48e
leaq 0x13462(%rip), %rcx     # 0x2f58c
movb $0x0, %al
callq 0x52c0
leaq 0x1bd30(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x1c16d
leaq 0x1bd23(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x58(%rbp)
callq 0x13930
movq -0x58(%rbp), %rdi
movq %rax, %rdx
leaq 0x1332f(%rip), %rsi     # 0x2f48e
leaq 0x13426(%rip), %rcx     # 0x2f58c
movb $0x0, %al
callq 0x52c0
jmp 0x1c16f
movl $0x10, %edi
xorl %ecx, %ecx
xorl %eax, %eax
movl %eax, %edx
movl %ecx, %esi
callq 0x16eb0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl 0x1b291(%rip), %edx     # 0x37420
leaq -0x18(%rbp), %rsi
callq 0x17270
movl %eax, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1c1ac
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x1c1b4
xorl %eax, %eax
movq %rax, -0x60(%rbp)
jmp 0x1c1b4
movq -0x60(%rbp), %rdi
callq 0x17480
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1c1d7
cmpl $0x0, -0x24(%rbp)
jne 0x1c1d7
cmpq $0x0, -0x18(%rbp)
jne 0x1c2eb
cmpq $0x0, -0x18(%rbp)
je 0x1c1f6
movq -0x18(%rbp), %rdi
cmpl $0x0, 0x1cd07(%rip)     # 0x38ef0
sete %al
andb $0x1, %al
movzbl %al, %esi
callq 0x17560
jmp 0x1c1f8
cmpq $0x0, -0x10(%rbp)
je 0x1c210
movq -0x10(%rbp), %rdi
callq 0x5040
movq $0x0, -0x10(%rbp)
jmp 0x1c212
jmp 0x1c214
cmpq $0x0, -0x18(%rbp)
je 0x1c22c
movq -0x18(%rbp), %rdi
callq 0x5040
movq $0x0, -0x18(%rbp)
jmp 0x1c22e
jmp 0x1c230
movq 0x1ada9(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x68(%rbp)
callq 0x13930
movq -0x68(%rbp), %rdi
movq %rax, %rdx
movl -0x1c(%rbp), %r9d
movl -0x24(%rbp), %eax
leaq 0x12395(%rip), %rsi     # 0x2e5ed
leaq 0x1332d(%rip), %rcx     # 0x2f58c
movl $0x6f6, %r8d            # imm = 0x6F6
movl %eax, (%rsp)
movb $0x0, %al
callq 0x52c0
leaq 0x1bbf2(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x1c2bb
leaq 0x1bbe5(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x70(%rbp)
callq 0x13930
movq -0x70(%rbp), %rdi
movq %rax, %rdx
movl -0x1c(%rbp), %r9d
movl -0x24(%rbp), %eax
leaq 0x12349(%rip), %rsi     # 0x2e5ed
leaq 0x132e1(%rip), %rcx     # 0x2f58c
movl $0x6f6, %r8d            # imm = 0x6F6
movl %eax, (%rsp)
movb $0x0, %al
callq 0x52c0
jmp 0x1c2bd
cmpl $0x0, -0x1c(%rbp)
je 0x1c2ce
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1c448
cmpl $0x0, -0x24(%rbp)
je 0x1c2df
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1c448
movl $0x22b8, -0x4(%rbp)     # imm = 0x22B8
jmp 0x1c448
jmp 0x1c2ed
movq -0x18(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
je 0x1c3ff
movq -0x18(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %edi
callq 0x191c0
movl %eax, %ecx
movl -0x74(%rbp), %eax
cmpl %ecx, %eax
jae 0x1c3fd
movq -0x30(%rbp), %rax
movl -0x34(%rbp), %ecx
movl 0x8(%rax,%rcx,8), %edi
callq 0x191c0
movl %eax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movl -0x38(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1aee0
movq %rax, %rsi
leaq 0x123d2(%rip), %rdi     # 0x2e732
callq 0x5050
cmpl $0x0, %eax
jne 0x1c3c4
movl $0x0, -0x44(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x78(%rbp)
movq -0x40(%rbp), %rax
movl 0x18(%rax), %edi
callq 0x191c0
movl %eax, %ecx
movl -0x78(%rbp), %eax
cmpl %ecx, %eax
jae 0x1c3c2
movq -0x40(%rbp), %rax
movl -0x44(%rbp), %ecx
movl 0x1c(%rax,%rcx,4), %edi
callq 0x191c0
movl %eax, %ecx
movl $0xf, %eax
cmpl %ecx, %eax
jne 0x1c3b5
movl $0x1, -0x20(%rbp)
jmp 0x1c3b7
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1c378
jmp 0x1c3ed
movq -0x40(%rbp), %rdi
callq 0x1aee0
movq %rax, %rsi
leaq 0x12b39(%rip), %rdi     # 0x2ef10
callq 0x5050
cmpl $0x0, %eax
jne 0x1c3eb
movl $0x1, 0x1ccd5(%rip)     # 0x390c0
jmp 0x1c3ed
jmp 0x1c3ef
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1c30e
jmp 0x1c3ff
jmp 0x1c401
cmpq $0x0, -0x10(%rbp)
je 0x1c419
movq -0x10(%rbp), %rdi
callq 0x5040
movq $0x0, -0x10(%rbp)
jmp 0x1c41b
jmp 0x1c41d
cmpq $0x0, -0x18(%rbp)
je 0x1c435
movq -0x18(%rbp), %rdi
callq 0x5040
movq $0x0, -0x18(%rbp)
jmp 0x1c437
cmpl $0x0, -0x20(%rbp)
je 0x1c442
callq 0x1c8d0
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)