// File: /workspace/github_c_makefile_star2_O3/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 0xd9a2
leaq 0x12828(%rip), %rcx     # 0x20b16
movq %rsp, %r12
movq %rax, %rdi
movq %r12, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0xa273
movl %eax, %ebx
testl %eax, %eax
sets %al
movq (%r12), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xe381
movq 0x1bca0(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
leaq 0x12452(%rip), %rsi     # 0x20781
leaq 0x127e0(%rip), %rcx     # 0x20b16
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1c95b(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xe441
callq 0xea3b
leaq 0x1241c(%rip), %rsi     # 0x20781
leaq 0x127aa(%rip), %rcx     # 0x20b16
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xe441
movzwl 0x10(%r12), %edi
callq 0xee73
testw %ax, %ax
jne 0xe3a5
movzwl 0x12(%r12), %edi
callq 0xee73
testw %ax, %ax
je 0xe44f
movzwl 0x12(%r12), %edi
callq 0xee73
movl %eax, %ebx
movq 0x1bc07(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xee73
movzwl %ax, %r8d
movzwl %bx, %ebx
leaq 0x123b6(%rip), %rsi     # 0x20793
leaq 0x12732(%rip), %rcx     # 0x20b16
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1c8ad(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xe438
callq 0xea3b
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xee73
movzwl %ax, %r8d
leaq 0x12372(%rip), %rsi     # 0x20793
leaq 0x126ee(%rip), %rcx     # 0x20b16
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 0xa1f8
testq %r14, %r14
je 0xe48d
testq %r15, %r15
je 0xe48d
movq %rax, %rbx
testq %rax, %rax
je 0xe48d
movzwl 0x3(%rbx), %edi
callq 0xee73
movw %ax, (%r15)
movzwl 0x5(%rbx), %edi
callq 0xee73
movw %ax, (%r14)
movq (%rsp), %rdi
addq $0x9, %rdi
movl $0x10, %esi
callq 0xa1f8
movq (%rsp), %rdi
callq 0x5040
xorl %ebx, %ebx
jmp 0xe441