// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/QMIThread.c
// Function: requestGetIPAddress
static int requestGetIPAddress(PROFILE_T *profile, int curIpFamily) {
    PQCQMIMSG pRequest;
    PQCQMIMSG pResponse;
    PQMUX_MSG pMUXMsg;
    int err;
    PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR pIpv4Addr;
    PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR pIpv6Addr = NULL;
    PQMIWDS_GET_RUNTIME_SETTINGS_TLV_MTU pMtu;
    IPV4_T *pIpv4 = &profile->ipv4;
    IPV6_T *pIpv6 = &profile->ipv6;
    UCHAR QMIType = (curIpFamily == 0x04) ? QMUX_TYPE_WDS : QMUX_TYPE_WDS_IPV6;
    PQMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV6_ADDR pPCSCFIpv6Addr;
	PQMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV4_ADDR pPCSCFIpv4Addr;

    if (curIpFamily == IpFamilyV4) {
        memset(pIpv4, 0x00, sizeof(IPV4_T));
        if (WdsConnectionIPv4Handle == 0)
            return 0;
    } else if (curIpFamily == IpFamilyV6) {
        memset(pIpv6, 0x00, sizeof(IPV6_T));
        if (WdsConnectionIPv6Handle == 0)
            return 0;
    }

    pRequest = ComposeQMUXMsg(QMIType, QMIWDS_GET_RUNTIME_SETTINGS_REQ, WdsGetRuntimeSettingReq, NULL);
    err = QmiThreadSendQMI(pRequest, &pResponse);
    qmi_rsp_check_and_return();

	pPCSCFIpv6Addr = (PQMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV6_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x2e);    // 0x2e - pcscf ipv6 address 
	if (pPCSCFIpv6Addr) {
    	if (pPCSCFIpv6Addr->PCSCFNumber == 1) {
        	UCHAR *PCSCFIpv6Addr1 = (UCHAR *)(pPCSCFIpv6Addr + 1);
        	memcpy(profile->PCSCFIpv6Addr1, PCSCFIpv6Addr1, 16);
        }else if (pPCSCFIpv6Addr->PCSCFNumber == 2) {
        	UCHAR *PCSCFIpv6Addr1 = (UCHAR *)(pPCSCFIpv6Addr + 1);
        	UCHAR *PCSCFIpv6Addr2 = PCSCFIpv6Addr1 + 16;
        	memcpy(profile->PCSCFIpv6Addr1, PCSCFIpv6Addr1, 16);
        	memcpy(profile->PCSCFIpv6Addr2, PCSCFIpv6Addr2, 16);
        }
    }
    
	pPCSCFIpv4Addr = (PQMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV4_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x23);    // 0x23 - pcscf ipv4 address 
	if (pPCSCFIpv4Addr) {
    	if (pPCSCFIpv4Addr->PCSCFNumber == 1) {
        	UCHAR *PCSCFIpv4Addr1 = (UCHAR *)(pPCSCFIpv4Addr + 1);
        	memcpy(&profile->PCSCFIpv4Addr1, PCSCFIpv4Addr1, 4);
        }else if (pPCSCFIpv4Addr->PCSCFNumber == 2) {
        	UCHAR *PCSCFIpv4Addr1 = (UCHAR *)(pPCSCFIpv4Addr + 1);
        	UCHAR *PCSCFIpv4Addr2 = PCSCFIpv4Addr1 + 4;
        	memcpy(&profile->PCSCFIpv4Addr1, PCSCFIpv4Addr1, 4);
        	memcpy(&profile->PCSCFIpv4Addr2, PCSCFIpv4Addr2, 4);
        }
    }

    pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4PRIMARYDNS);
    if (pIpv4Addr) {
        pIpv4->DnsPrimary = pIpv4Addr->IPV4Address;
    }

    pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4SECONDARYDNS);
    if (pIpv4Addr) {
        pIpv4->DnsSecondary = pIpv4Addr->IPV4Address;
    }

    pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4GATEWAY);
    if (pIpv4Addr) {
        pIpv4->Gateway = pIpv4Addr->IPV4Address;
    }

    pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4SUBNET);
    if (pIpv4Addr) {
        pIpv4->SubnetMask = pIpv4Addr->IPV4Address;
    }

    pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4);
    if (pIpv4Addr) {
        pIpv4->Address = pIpv4Addr->IPV4Address;
    }

    pIpv6Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6PRIMARYDNS);
    if (pIpv6Addr) {
        memcpy(pIpv6->DnsPrimary, pIpv6Addr->IPV6Address, 16);
    }

    pIpv6Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6SECONDARYDNS);
    if (pIpv6Addr) {
        memcpy(pIpv6->DnsSecondary, pIpv6Addr->IPV6Address, 16);
    }

    pIpv6Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6GATEWAY);
    if (pIpv6Addr) {
        memcpy(pIpv6->Gateway, pIpv6Addr->IPV6Address, 16);
        pIpv6->PrefixLengthGateway = pIpv6Addr->PrefixLength;
    }

    pIpv6Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6);
    if (pIpv6Addr) {
        memcpy(pIpv6->Address, pIpv6Addr->IPV6Address, 16);
        pIpv6->PrefixLengthIPAddr = pIpv6Addr->PrefixLength;
    }

    pMtu = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_MTU)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_MTU);
    if (pMtu) {
        if (curIpFamily == IpFamilyV4)
            pIpv4->Mtu =  le32_to_cpu(pMtu->Mtu);
        else
            pIpv6->Mtu =  le32_to_cpu(pMtu->Mtu);
    }

    free(pResponse);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x126(%rdi), %r13
leaq 0x13e(%rdi), %r12
cmpl $0x4, %esi
setne %al
jne 0xceef
andq $0x0, 0x10(%r13)
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
cmpl $0x0, 0x1cd54(%rip)     # 0x29c3c
jne 0xcf27
jmp 0xd29b
cmpl $0x6, %esi
jne 0xcf27
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%r12)
movups %xmm0, 0x30(%r12)
movups %xmm0, 0x20(%r12)
andq $0x0, 0x4e(%r12)
movups %xmm0, 0x10(%r12)
movups %xmm0, (%r12)
cmpl $0x0, 0x1cd1f(%rip)     # 0x29c40
je 0xd29b
movl %esi, 0x14(%rsp)
shlb $0x4, %al
incb %al
movzbl %al, %edi
leaq 0x122b(%rip), %rdx      # 0xe165
pushq $0x2d
popq %rsi
xorl %ecx, %ecx
callq 0xd53c
leaq 0x11d59(%rip), %rcx     # 0x1eca4
leaq 0x8(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x9e8b
movl %eax, %r14d
testl %eax, %eax
sets %al
movq (%r15), %rbp
testq %rbp, %rbp
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xcfe0
movq 0x1c039(%rip), %rax     # 0x28fb8
movq (%rax), %rbx
callq 0xe343
leaq 0x117f3(%rip), %rsi     # 0x1e781
leaq 0x11d0f(%rip), %rcx     # 0x1eca4
movq %rbx, %rdi
movq %rax, %rdx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1ccfc(%rip), %rax     # 0x29ca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xd29e
callq 0xe343
leaq 0x117bd(%rip), %rsi     # 0x1e781
leaq 0x11cd9(%rip), %rcx     # 0x1eca4
movq %rbx, %rdi
movq %rax, %rdx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xd29e
movzwl 0x10(%rbp), %edi
callq 0xe73e
testw %ax, %ax
jne 0xd000
movzwl 0x12(%rbp), %edi
callq 0xe73e
testw %ax, %ax
je 0xd09d
movzwl 0x12(%rbp), %edi
callq 0xe73e
movl %eax, %ebx
movq 0x1bfa6(%rip), %rax     # 0x28fb8
movq (%rax), %r15
callq 0xe343
movq %rax, %r12
movzwl 0x10(%rbp), %edi
callq 0xe73e
movzwl %ax, %r8d
movzwl %bx, %r14d
leaq 0x1175e(%rip), %rsi     # 0x1e793
leaq 0x11c68(%rip), %rcx     # 0x1eca4
movq %r15, %rdi
movq %r12, %rdx
movl %r14d, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1cc55(%rip), %rax     # 0x29ca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xd08e
callq 0xe343
movq %rax, %r15
movzwl 0x10(%rbp), %edi
callq 0xe73e
movzwl %ax, %r8d
leaq 0x1171c(%rip), %rsi     # 0x1e793
leaq 0x11c26(%rip), %rcx     # 0x1eca4
movq %rbx, %rdi
movq %r15, %rdx
movl %r14d, %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x8(%rsp), %rdi
callq 0x5040
jmp 0xd29e
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
pushq $0x2e
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xd0e7
movzbl 0x3(%rax), %ecx
cmpl $0x2, %ecx
je 0xd0cc
cmpl $0x1, %ecx
jne 0xd0e7
addq $0x4, %rax
movl $0x19c, %ecx            # imm = 0x19C
jmp 0xd0e0
movups 0x4(%rax), %xmm0
addq $0x14, %rax
movups %xmm0, 0x19c(%rbx)
movl $0x1ac, %ecx            # imm = 0x1AC
movups (%rax), %xmm0
movups %xmm0, (%rbx,%rcx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
pushq $0x23
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xd12d
movzbl 0x3(%rax), %ecx
cmpl $0x2, %ecx
je 0xd116
cmpl $0x1, %ecx
jne 0xd12d
addq $0x4, %rax
movl $0x194, %ecx            # imm = 0x194
jmp 0xd128
movl 0x4(%rax), %ecx
addq $0x8, %rax
movl %ecx, 0x194(%rbx)
movl $0x198, %ecx            # imm = 0x198
movl (%rax), %eax
movl %eax, (%rbx,%rcx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
pushq $0x15
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xd14c
movl 0x3(%rax), %eax
movl %eax, 0x132(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
pushq $0x16
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xd16b
movl 0x3(%rax), %eax
movl %eax, 0x136(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
pushq $0x20
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xd18a
movl 0x3(%rax), %eax
movl %eax, 0x12a(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
pushq $0x21
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xd1a9
movl 0x3(%rax), %eax
movl %eax, 0x12e(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
pushq $0x1e
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xd1c6
movl 0x3(%rax), %eax
movl %eax, (%r13)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
pushq $0x27
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xd1e7
movups 0x3(%rax), %xmm0
movups %xmm0, 0x16e(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
pushq $0x28
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xd208
movups 0x3(%rax), %xmm0
movups %xmm0, 0x17e(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
pushq $0x26
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xd232
movups 0x3(%rax), %xmm0
movups %xmm0, 0x14e(%rbx)
movb 0x13(%rax), %al
movb %al, 0x18f(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
pushq $0x25
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xd25a
movups 0x3(%rax), %xmm0
movups %xmm0, (%r12)
movb 0x13(%rax), %al
movb %al, 0x18e(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
pushq $0x29
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xd291
movl 0x3(%rax), %edi
callq 0xe741
leaq 0x190(%rbx), %rcx
addq $0x13a, %rbx            # imm = 0x13A
cmpl $0x4, 0x14(%rsp)
cmovneq %rcx, %rbx
movl %eax, (%rbx)
movq 0x8(%rsp), %rdi
callq 0x5040
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq