// File: /workspace/github_c_makefile_star2_O3/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 0xd332
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
movq $0x0, 0x10(%r13)
cmpl $0x0, 0x1d911(%rip)     # 0x2ac3c
jne 0xd36d
jmp 0xd6fb
cmpl $0x6, %esi
jne 0xd36d
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%r12)
movups %xmm0, 0x30(%r12)
movups %xmm0, 0x20(%r12)
movups %xmm0, 0x10(%r12)
movups %xmm0, (%r12)
movq $0x0, 0x4e(%r12)
cmpl $0x0, 0x1d8d9(%rip)     # 0x2ac40
je 0xd6fb
movl %esi, 0x14(%rsp)
shlb $0x4, %al
incb %al
movzbl %al, %edi
leaq 0x14c9(%rip), %rdx      # 0xe849
movl $0x2d, %esi
xorl %ecx, %ecx
callq 0xd9a2
leaq 0x138fb(%rip), %rcx     # 0x20c8e
leaq 0x8(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0xa273
movl %eax, %r14d
testl %eax, %eax
sets %al
movq (%r15), %rbp
testq %rbp, %rbp
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xd428
movq 0x1cbf9(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
leaq 0x133ab(%rip), %rsi     # 0x20781
leaq 0x138b1(%rip), %rcx     # 0x20c8e
movq %rbx, %rdi
movq %rax, %rdx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1d8b4(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xd6fe
callq 0xea3b
leaq 0x13375(%rip), %rsi     # 0x20781
leaq 0x1387b(%rip), %rcx     # 0x20c8e
movq %rbx, %rdi
movq %rax, %rdx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xd6fe
movzwl 0x10(%rbp), %edi
callq 0xee73
testw %ax, %ax
jne 0xd448
movzwl 0x12(%rbp), %edi
callq 0xee73
testw %ax, %ax
je 0xd4e5
movzwl 0x12(%rbp), %edi
callq 0xee73
movl %eax, %ebx
movq 0x1cb66(%rip), %rax     # 0x29fc0
movq (%rax), %r15
callq 0xea3b
movq %rax, %r12
movzwl 0x10(%rbp), %edi
callq 0xee73
movzwl %ax, %r8d
movzwl %bx, %r14d
leaq 0x13316(%rip), %rsi     # 0x20793
leaq 0x1380a(%rip), %rcx     # 0x20c8e
movq %r15, %rdi
movq %r12, %rdx
movl %r14d, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1d80d(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xd4d6
callq 0xea3b
movq %rax, %r15
movzwl 0x10(%rbp), %edi
callq 0xee73
movzwl %ax, %r8d
leaq 0x132d4(%rip), %rsi     # 0x20793
leaq 0x137c8(%rip), %rcx     # 0x20c8e
movq %rbx, %rdi
movq %r15, %rdx
movl %r14d, %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x8(%rsp), %rdi
callq 0x5040
jmp 0xd6fe
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x2e, %esi
callq 0xa1f8
testq %rax, %rax
je 0xd531
movzbl 0x3(%rax), %ecx
cmpl $0x2, %ecx
je 0xd516
cmpl $0x1, %ecx
jne 0xd531
addq $0x4, %rax
movl $0x19c, %ecx            # imm = 0x19C
jmp 0xd52a
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
movl $0x23, %esi
callq 0xa1f8
testq %rax, %rax
je 0xd579
movzbl 0x3(%rax), %ecx
cmpl $0x2, %ecx
je 0xd562
cmpl $0x1, %ecx
jne 0xd579
addq $0x4, %rax
movl $0x194, %ecx            # imm = 0x194
jmp 0xd574
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
movl $0x15, %esi
callq 0xa1f8
testq %rax, %rax
je 0xd59a
movl 0x3(%rax), %eax
movl %eax, 0x132(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x16, %esi
callq 0xa1f8
testq %rax, %rax
je 0xd5bb
movl 0x3(%rax), %eax
movl %eax, 0x136(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x20, %esi
callq 0xa1f8
testq %rax, %rax
je 0xd5dc
movl 0x3(%rax), %eax
movl %eax, 0x12a(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x21, %esi
callq 0xa1f8
testq %rax, %rax
je 0xd5fd
movl 0x3(%rax), %eax
movl %eax, 0x12e(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x1e, %esi
callq 0xa1f8
testq %rax, %rax
je 0xd61c
movl 0x3(%rax), %eax
movl %eax, (%r13)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x27, %esi
callq 0xa1f8
testq %rax, %rax
je 0xd63f
movups 0x3(%rax), %xmm0
movups %xmm0, 0x16e(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x28, %esi
callq 0xa1f8
testq %rax, %rax
je 0xd662
movups 0x3(%rax), %xmm0
movups %xmm0, 0x17e(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x26, %esi
callq 0xa1f8
testq %rax, %rax
je 0xd68e
movups 0x3(%rax), %xmm0
movups %xmm0, 0x14e(%rbx)
movb 0x13(%rax), %al
movb %al, 0x18f(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x25, %esi
callq 0xa1f8
testq %rax, %rax
je 0xd6b8
movups 0x3(%rax), %xmm0
movups %xmm0, (%r12)
movb 0x13(%rax), %al
movb %al, 0x18e(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x29, %esi
callq 0xa1f8
testq %rax, %rax
je 0xd6f1
movl 0x3(%rax), %edi
callq 0xee76
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