// File: /workspace/github_c_makefile_star2_O1/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 0xd416
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
movq $0x0, 0x10(%r13)
cmpl $0x0, 0x1d82d(%rip)     # 0x2ac3c
jne 0xd451
jmp 0xd7df
cmpl $0x6, %esi
jne 0xd451
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, 0x1d7f5(%rip)     # 0x2ac40
je 0xd7df
movl %esi, 0x14(%rsp)
shlb $0x4, %al
incb %al
movzbl %al, %edi
leaq 0x14da(%rip), %rdx      # 0xe93e
movl $0x2d, %esi
xorl %ecx, %ecx
callq 0xda86
leaq 0x1381b(%rip), %rcx     # 0x20c92
leaq 0x8(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0xa317
movl %eax, %r14d
testl %eax, %eax
sets %al
movq (%r15), %rbp
testq %rbp, %rbp
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xd50c
movq 0x1cb15(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
leaq 0x132cb(%rip), %rsi     # 0x20785
leaq 0x137d1(%rip), %rcx     # 0x20c92
movq %rbx, %rdi
movq %rax, %rdx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1d7d0(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xd7e2
callq 0xeb2f
leaq 0x13295(%rip), %rsi     # 0x20785
leaq 0x1379b(%rip), %rcx     # 0x20c92
movq %rbx, %rdi
movq %rax, %rdx
movl %r14d, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xd7e2
movzwl 0x10(%rbp), %edi
callq 0xef61
testw %ax, %ax
jne 0xd52c
movzwl 0x12(%rbp), %edi
callq 0xef61
testw %ax, %ax
je 0xd5c9
movzwl 0x12(%rbp), %edi
callq 0xef61
movl %eax, %ebx
movq 0x1ca82(%rip), %rax     # 0x29fc0
movq (%rax), %r15
callq 0xeb2f
movq %rax, %r12
movzwl 0x10(%rbp), %edi
callq 0xef61
movzwl %ax, %r8d
movzwl %bx, %r14d
leaq 0x13236(%rip), %rsi     # 0x20797
leaq 0x1372a(%rip), %rcx     # 0x20c92
movq %r15, %rdi
movq %r12, %rdx
movl %r14d, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1d729(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xd5ba
callq 0xeb2f
movq %rax, %r15
movzwl 0x10(%rbp), %edi
callq 0xef61
movzwl %ax, %r8d
leaq 0x131f4(%rip), %rsi     # 0x20797
leaq 0x136e8(%rip), %rcx     # 0x20c92
movq %rbx, %rdi
movq %r15, %rdx
movl %r14d, %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x8(%rsp), %rdi
callq 0x5040
jmp 0xd7e2
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x2e, %esi
callq 0xa29c
testq %rax, %rax
je 0xd615
movzbl 0x3(%rax), %ecx
cmpl $0x2, %ecx
je 0xd5fa
cmpl $0x1, %ecx
jne 0xd615
addq $0x4, %rax
movl $0x19c, %ecx            # imm = 0x19C
jmp 0xd60e
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 0xa29c
testq %rax, %rax
je 0xd65d
movzbl 0x3(%rax), %ecx
cmpl $0x2, %ecx
je 0xd646
cmpl $0x1, %ecx
jne 0xd65d
addq $0x4, %rax
movl $0x194, %ecx            # imm = 0x194
jmp 0xd658
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 0xa29c
testq %rax, %rax
je 0xd67e
movl 0x3(%rax), %eax
movl %eax, 0x132(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x16, %esi
callq 0xa29c
testq %rax, %rax
je 0xd69f
movl 0x3(%rax), %eax
movl %eax, 0x136(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x20, %esi
callq 0xa29c
testq %rax, %rax
je 0xd6c0
movl 0x3(%rax), %eax
movl %eax, 0x12a(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x21, %esi
callq 0xa29c
testq %rax, %rax
je 0xd6e1
movl 0x3(%rax), %eax
movl %eax, 0x12e(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x1e, %esi
callq 0xa29c
testq %rax, %rax
je 0xd700
movl 0x3(%rax), %eax
movl %eax, (%r13)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x27, %esi
callq 0xa29c
testq %rax, %rax
je 0xd723
movups 0x3(%rax), %xmm0
movups %xmm0, 0x16e(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x28, %esi
callq 0xa29c
testq %rax, %rax
je 0xd746
movups 0x3(%rax), %xmm0
movups %xmm0, 0x17e(%rbx)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x26, %esi
callq 0xa29c
testq %rax, %rax
je 0xd772
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 0xa29c
testq %rax, %rax
je 0xd79c
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 0xa29c
testq %rax, %rax
je 0xd7d5
movl 0x3(%rax), %edi
callq 0xef64
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