// File: /workspace/github_c_makefile_star2_O1/Carton32[P]quectel-CM/QMIThread.c
// Function: requestGetHomeNetwork
static int requestGetHomeNetwork(USHORT *p_mcc, USHORT *p_mnc, USHORT *p_sid, USHORT *p_nid) {
    PQCQMIMSG pRequest;
    PQCQMIMSG pResponse;
    PQMUX_MSG pMUXMsg;
    int err;
    PHOME_NETWORK pHomeNetwork;
    PHOME_NETWORK_SYSTEMID pHomeNetworkSystemID;

    pRequest = ComposeQMUXMsg(QMUX_TYPE_NAS, QMINAS_GET_HOME_NETWORK_REQ, NULL, NULL);
    err = QmiThreadSendQMI(pRequest, &pResponse);
    qmi_rsp_check_and_return();

    pHomeNetwork = (PHOME_NETWORK)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01);
    if (pHomeNetwork && p_mcc && p_mnc ) {
        *p_mcc = le16_to_cpu(pHomeNetwork->MobileCountryCode);
        *p_mnc = le16_to_cpu(pHomeNetwork->MobileNetworkCode);
        //dbg_time("%s MobileCountryCode: %d, MobileNetworkCode: %d", __func__, *pMobileCountryCode, *pMobileNetworkCode);
    }

    pHomeNetworkSystemID = (PHOME_NETWORK_SYSTEMID)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x10);
    if (pHomeNetworkSystemID && p_sid && p_nid) {
        *p_sid = le16_to_cpu(pHomeNetworkSystemID->SystemID); //china-hefei: sid 14451
        *p_nid = le16_to_cpu(pHomeNetworkSystemID->NetworkID);
        //dbg_time("%s SystemID: %d, NetworkID: %d", __func__, *pSystemID, *pNetworkID);
    }

    free(pResponse);

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
movl $0x3, %edi
movl $0x25, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xda86
leaq 0x1273e(%rip), %rcx     # 0x20b1a
movq %rsp, %r12
movq %rax, %rdi
movq %r12, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0xa317
movl %eax, %ebx
testl %eax, %eax
sets %al
movq (%r12), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xe46f
movq 0x1bbb2(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
leaq 0x12368(%rip), %rsi     # 0x20785
leaq 0x126f6(%rip), %rcx     # 0x20b1a
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1c86d(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xe52f
callq 0xeb2f
leaq 0x12332(%rip), %rsi     # 0x20785
leaq 0x126c0(%rip), %rcx     # 0x20b1a
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xe52f
movzwl 0x10(%r12), %edi
callq 0xef61
testw %ax, %ax
jne 0xe493
movzwl 0x12(%r12), %edi
callq 0xef61
testw %ax, %ax
je 0xe53d
movzwl 0x12(%r12), %edi
callq 0xef61
movl %eax, %ebx
movq 0x1bb19(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xef61
movzwl %ax, %r8d
movzwl %bx, %ebx
leaq 0x122cc(%rip), %rsi     # 0x20797
leaq 0x12648(%rip), %rcx     # 0x20b1a
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1c7bf(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xe526
callq 0xeb2f
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xef61
movzwl %ax, %r8d
leaq 0x12288(%rip), %rsi     # 0x20797
leaq 0x12604(%rip), %rcx     # 0x20b1a
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
movq (%rsp), %rdi
callq 0x5040
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq (%rsp), %rdi
addq $0x9, %rdi
movl $0x1, %esi
callq 0xa29c
testq %r14, %r14
je 0xe57b
testq %r15, %r15
je 0xe57b
movq %rax, %rbx
testq %rax, %rax
je 0xe57b
movzwl 0x3(%rbx), %edi
callq 0xef61
movw %ax, (%r15)
movzwl 0x5(%rbx), %edi
callq 0xef61
movw %ax, (%r14)
movq (%rsp), %rdi
addq $0x9, %rdi
movl $0x10, %esi
callq 0xa29c
movq (%rsp), %rdi
callq 0x5040
xorl %ebx, %ebx
jmp 0xe52f