// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x3, %edi
movl $0x25, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x11170
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movl $0x7530, %edx           # imm = 0x7530
leaq 0x1b043(%rip), %rcx     # 0x2dd0c
callq 0xc670
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jl 0x12ce2
cmpq $0x0, -0x38(%rbp)
jne 0x12d64
jmp 0x12ce4
movq 0x242f5(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x68(%rbp)
callq 0x13930
movq -0x68(%rbp), %rdi
movq %rax, %rdx
movl -0x44(%rbp), %r8d
leaq 0x1ac58(%rip), %rsi     # 0x2d961
leaq 0x1affc(%rip), %rcx     # 0x2dd0c
movb $0x0, %al
callq 0x52c0
leaq 0x2514a(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x12d57
leaq 0x2513d(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x70(%rbp)
callq 0x13930
movq -0x70(%rbp), %rdi
movq %rax, %rdx
movl -0x44(%rbp), %r8d
leaq 0x1ac18(%rip), %rsi     # 0x2d961
leaq 0x1afbc(%rip), %rcx     # 0x2dd0c
movb $0x0, %al
callq 0x52c0
jmp 0x12d59
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x12f3f
movq -0x38(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movzwl 0xa(%rax), %edi
callq 0x13ed0
movzwl %ax, %eax
cmpl $0x0, %eax
jne 0x12d9e
movq -0x40(%rbp), %rax
movzwl 0xc(%rax), %edi
callq 0x13ed0
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x12e73
movq -0x40(%rbp), %rax
movzwl 0xc(%rax), %edi
callq 0x13ed0
movw %ax, -0x5a(%rbp)
movq 0x2422a(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x80(%rbp)
callq 0x13930
movq %rax, -0x78(%rbp)
movq -0x40(%rbp), %rax
movzwl 0xa(%rax), %edi
callq 0x13ed0
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rdx
movzwl %ax, %r8d
movzwl -0x5a(%rbp), %r9d
leaq 0x1ab88(%rip), %rsi     # 0x2d973
leaq 0x1af1a(%rip), %rcx     # 0x2dd0c
movb $0x0, %al
callq 0x52c0
leaq 0x25068(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x12e5c
leaq 0x2505b(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x90(%rbp)
callq 0x13930
movq %rax, -0x88(%rbp)
movq -0x40(%rbp), %rax
movzwl 0xa(%rax), %edi
callq 0x13ed0
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rdx
movzwl %ax, %r8d
movzwl -0x5a(%rbp), %r9d
leaq 0x1ab25(%rip), %rsi     # 0x2d973
leaq 0x1aeb7(%rip), %rcx     # 0x2dd0c
movb $0x0, %al
callq 0x52c0
jmp 0x12e5e
movq -0x38(%rbp), %rdi
callq 0x5040
movzwl -0x5a(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x12f3f
jmp 0x12e75
movq -0x38(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x1, %esi
callq 0xc580
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x12ed2
cmpq $0x0, -0x10(%rbp)
je 0x12ed2
cmpq $0x0, -0x18(%rbp)
je 0x12ed2
movq -0x50(%rbp), %rax
movzwl 0x3(%rax), %edi
callq 0x13ed0
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, (%rax)
movq -0x50(%rbp), %rax
movzwl 0x5(%rax), %edi
callq 0x13ed0
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, (%rax)
movq -0x38(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x10, %esi
callq 0xc580
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x12f2f
cmpq $0x0, -0x20(%rbp)
je 0x12f2f
cmpq $0x0, -0x28(%rbp)
je 0x12f2f
movq -0x58(%rbp), %rax
movzwl 0x3(%rax), %edi
callq 0x13ed0
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, (%rax)
movq -0x58(%rbp), %rax
movzwl 0x5(%rax), %edi
callq 0x13ed0
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, (%rax)
movq -0x38(%rbp), %rdi
callq 0x5040
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)