// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x3
popq %rdi
pushq $0x25
popq %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xd53c
leaq 0x10f29(%rip), %rcx     # 0x1eb2c
movq %rsp, %r12
movq %rax, %rdi
movq %r12, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x9e8b
movl %eax, %ebx
testl %eax, %eax
sets %al
movq (%r12), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xdc96
movq 0x1b383(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x10b3d(%rip), %rsi     # 0x1e781
leaq 0x10ee1(%rip), %rcx     # 0x1eb2c
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1c046(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xdd56
callq 0xe343
leaq 0x10b07(%rip), %rsi     # 0x1e781
leaq 0x10eab(%rip), %rcx     # 0x1eb2c
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xdd56
movzwl 0x10(%r12), %edi
callq 0xe73e
testw %ax, %ax
jne 0xdcba
movzwl 0x12(%r12), %edi
callq 0xe73e
testw %ax, %ax
je 0xdd64
movzwl 0x12(%r12), %edi
callq 0xe73e
movl %eax, %ebx
movq 0x1b2ea(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xe73e
movzwl %ax, %r8d
movzwl %bx, %ebx
leaq 0x10aa1(%rip), %rsi     # 0x1e793
leaq 0x10e33(%rip), %rcx     # 0x1eb2c
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1bf98(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xdd4d
callq 0xe343
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xe73e
movzwl %ax, %r8d
leaq 0x10a5d(%rip), %rsi     # 0x1e793
leaq 0x10def(%rip), %rcx     # 0x1eb2c
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
pushq $0x1
popq %rsi
callq 0x9e14
testq %r14, %r14
je 0xdda0
testq %r15, %r15
je 0xdda0
movq %rax, %rbx
testq %rax, %rax
je 0xdda0
movzwl 0x3(%rbx), %edi
callq 0xe73e
movw %ax, (%r15)
movzwl 0x5(%rbx), %edi
callq 0xe73e
movw %ax, (%r14)
movq (%rsp), %rdi
addq $0x9, %rdi
pushq $0x10
popq %rsi
callq 0x9e14
movq (%rsp), %rdi
callq 0x5040
xorl %ebx, %ebx
jmp 0xdd56