// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rax
addq $0x126, %rax            # imm = 0x126
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
addq $0x13e, %rax            # imm = 0x13E
movq %rax, -0x60(%rbp)
movl -0x14(%rbp), %edx
movl $0x11, %eax
movl $0x1, %ecx
cmpl $0x4, %edx
cmovel %ecx, %eax
movb %al, -0x61(%rbp)
cmpl $0x4, -0x14(%rbp)
jne 0x106b9
movq -0x58(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x5200
cmpl $0x0, 0x27757(%rip)     # 0x37e00
jne 0x106b7
movl $0x0, -0x4(%rbp)
jmp 0x10cae
jmp 0x106e8
cmpl $0x6, -0x14(%rbp)
jne 0x106e6
movq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x56, %edx
callq 0x5200
cmpl $0x0, 0x2772e(%rip)     # 0x37e04
jne 0x106e4
movl $0x0, -0x4(%rbp)
jmp 0x10cae
jmp 0x106e6
jmp 0x106e8
movl $0x2d, %esi
leaq 0x2f7c(%rip), %rdx      # 0x13670
xorl %eax, %eax
movl %eax, %ecx
movzbl -0x61(%rbp), %edi
callq 0x11170
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x7530, %edx           # imm = 0x7530
leaq 0x1d76b(%rip), %rcx     # 0x2de84
callq 0xc670
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x10732
cmpq $0x0, -0x28(%rbp)
jne 0x107c0
jmp 0x10734
movq 0x268a5(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
callq 0x13930
movq -0xb8(%rbp), %rdi
movq %rax, %rdx
movl -0x34(%rbp), %r8d
leaq 0x1d202(%rip), %rsi     # 0x2d961
leaq 0x1d71e(%rip), %rcx     # 0x2de84
movb $0x0, %al
callq 0x52c0
leaq 0x276f4(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x107b3
leaq 0x276e7(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
callq 0x13930
movq -0xc0(%rbp), %rdi
movq %rax, %rdx
movl -0x34(%rbp), %r8d
leaq 0x1d1bc(%rip), %rsi     # 0x2d961
leaq 0x1d6d8(%rip), %rcx     # 0x2de84
movb $0x0, %al
callq 0x52c0
jmp 0x107b5
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x10cae
movq -0x28(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzwl 0xa(%rax), %edi
callq 0x13ed0
movzwl %ax, %eax
cmpl $0x0, %eax
jne 0x107fa
movq -0x30(%rbp), %rax
movzwl 0xc(%rax), %edi
callq 0x13ed0
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x108db
movq -0x30(%rbp), %rax
movzwl 0xc(%rax), %edi
callq 0x13ed0
movw %ax, -0x7a(%rbp)
movq 0x267ce(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
callq 0x13930
movq %rax, -0xc8(%rbp)
movq -0x30(%rbp), %rax
movzwl 0xa(%rax), %edi
callq 0x13ed0
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rdx
movzwl %ax, %r8d
movzwl -0x7a(%rbp), %r9d
leaq 0x1d120(%rip), %rsi     # 0x2d973
leaq 0x1d62a(%rip), %rcx     # 0x2de84
movb $0x0, %al
callq 0x52c0
leaq 0x27600(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x108c4
leaq 0x275f3(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
callq 0x13930
movq %rax, -0xd8(%rbp)
movq -0x30(%rbp), %rax
movzwl 0xa(%rax), %edi
callq 0x13ed0
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rdx
movzwl %ax, %r8d
movzwl -0x7a(%rbp), %r9d
leaq 0x1d0bd(%rip), %rsi     # 0x2d973
leaq 0x1d5c7(%rip), %rcx     # 0x2de84
movb $0x0, %al
callq 0x52c0
jmp 0x108c6
movq -0x28(%rbp), %rdi
callq 0x5040
movzwl -0x7a(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x10cae
jmp 0x108dd
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x2e, %esi
callq 0xc580
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x109b2
movq -0x70(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x1, %eax
jne 0x10940
movq -0x70(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq -0x88(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, 0x19c(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x1a4(%rax)
jmp 0x109b0
movq -0x70(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x2, %eax
jne 0x109ae
movq -0x70(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq -0x90(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, 0x19c(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x1a4(%rax)
movq -0x10(%rbp), %rax
movq -0x98(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, 0x1ac(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x1b4(%rax)
jmp 0x109b0
jmp 0x109b2
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x23, %esi
callq 0xc580
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x10a60
movq -0x78(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x1, %eax
jne 0x10a08
movq -0x78(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq -0xa0(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, 0x194(%rax)
jmp 0x10a5e
movq -0x78(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x2, %eax
jne 0x10a5c
movq -0x78(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rax
movq -0xa8(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, 0x194(%rax)
movq -0x10(%rbp), %rax
movq -0xb0(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, 0x198(%rax)
jmp 0x10a5e
jmp 0x10a60
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x15, %esi
callq 0xc580
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x10a8f
movq -0x40(%rbp), %rax
movl 0x3(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x16, %esi
callq 0xc580
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x10abe
movq -0x40(%rbp), %rax
movl 0x3(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x20, %esi
callq 0xc580
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x10aed
movq -0x40(%rbp), %rax
movl 0x3(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x21, %esi
callq 0xc580
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x10b1c
movq -0x40(%rbp), %rax
movl 0x3(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x1e, %esi
callq 0xc580
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x10b4a
movq -0x40(%rbp), %rax
movl 0x3(%rax), %ecx
movq -0x58(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x27, %esi
callq 0xc580
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x10b83
movq -0x60(%rbp), %rax
movq -0x48(%rbp), %rcx
movq 0x3(%rcx), %rdx
movq %rdx, 0x30(%rax)
movq 0xb(%rcx), %rcx
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x28, %esi
callq 0xc580
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x10bbc
movq -0x60(%rbp), %rax
movq -0x48(%rbp), %rcx
movq 0x3(%rcx), %rdx
movq %rdx, 0x40(%rax)
movq 0xb(%rcx), %rcx
movq %rcx, 0x48(%rax)
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x26, %esi
callq 0xc580
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x10c03
movq -0x60(%rbp), %rax
movq -0x48(%rbp), %rcx
movq 0x3(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0xb(%rcx), %rcx
movq %rcx, 0x18(%rax)
movq -0x48(%rbp), %rax
movb 0x13(%rax), %cl
movq -0x60(%rbp), %rax
movb %cl, 0x51(%rax)
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x25, %esi
callq 0xc580
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x10c49
movq -0x60(%rbp), %rax
movq -0x48(%rbp), %rcx
movq 0x3(%rcx), %rdx
movq %rdx, (%rax)
movq 0xb(%rcx), %rcx
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rax
movb 0x13(%rax), %cl
movq -0x60(%rbp), %rax
movb %cl, 0x50(%rax)
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
addq $0x3, %rdi
movl $0x29, %esi
callq 0xc580
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x10c9e
cmpl $0x4, -0x14(%rbp)
jne 0x10c87
movq -0x50(%rbp), %rax
movl 0x3(%rax), %edi
callq 0x13f20
movl %eax, %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x14(%rax)
jmp 0x10c9c
movq -0x50(%rbp), %rax
movl 0x3(%rax), %edi
callq 0x13f20
movl %eax, %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x52(%rax)
jmp 0x10c9e
movq -0x28(%rbp), %rdi
callq 0x5040
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopw (%rax,%rax)