// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/mbim-cm.c
// Function: mbim_ip_config
static int mbim_ip_config(PROFILE_T *profile, int sessionID) {
    MBIM_MESSAGE_HEADER *pRequest = NULL;
    MBIM_COMMAND_DONE_T *pCmdDone = NULL;
    MBIM_IP_CONFIGURATION_INFO_T ip_info;
    int err;

    if (profile->ipv4.Address == 0 || mbim_verbose)
        mbim_debug("%s(sessionID=%d)", __func__, sessionID);
    ip_info.SessionId = htole32(sessionID);
    pRequest = compose_basic_connect_command(MBIM_CID_IP_CONFIGURATION, MBIM_CID_CMD_TYPE_QUERY, &ip_info, sizeof(ip_info));
    err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout);
    mbim_check_err(err, pRequest, pCmdDone);

    if (le32toh(pCmdDone->InformationBufferLength)) {
        UINT8 prefix, *ipv4=NULL, *ipv6=NULL, *gw=NULL, *dns1=NULL, *dns2=NULL;
        UINT32 mtu = 1500;
        MBIM_IP_CONFIGURATION_INFO_T *pInfo = (MBIM_IP_CONFIGURATION_INFO_T *)pCmdDone->InformationBuffer;

        /* IPv4 network configration */
        if (le32toh(pInfo->IPv4ConfigurationAvailable)&0x1) {
            MBIM_IPV4_ELEMENT_T *pAddress = (MBIM_IPV4_ELEMENT_T *)(&pInfo->DataBuffer[le32toh(pInfo->IPv4AddressOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]);
            prefix = le32toh(pAddress->OnLinkPrefixLength);
            ipv4 = pAddress->IPv4Address;

            if (le32toh(pInfo->IPv4ConfigurationAvailable)&0x2)
                gw = (UINT8 *)(&pInfo->DataBuffer[le32toh(pInfo->IPv4GatewayOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]);

            if (le32toh(pInfo->IPv4ConfigurationAvailable)&0x4) {
                dns1 = (UINT8 *)(&pInfo->DataBuffer[le32toh(pInfo->IPv4DnsServerOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]);
                if (le32toh(pInfo->IPv4DnsServerCount) == 2)
                    dns2 = dns1 + 4;
            }

            if (le32toh(pInfo->IPv4ConfigurationAvailable)&0x8)
                mtu =  le32toh(pInfo->IPv4Mtu);

            if (profile->ipv4.Address != mbim2qmi_ipv4addr(*(uint32_t *)ipv4) || mbim_verbose) {
                mbim_dump_ipconfig(pInfo, "<");
                profile->ipv4.Address = mbim2qmi_ipv4addr(*(uint32_t *)ipv4);
            }

			if(gw != NULL)
            	profile->ipv4.Gateway = mbim2qmi_ipv4addr(*(uint32_t *)gw);
            profile->ipv4.SubnetMask = mbim2qmi_ipv4addr(0xFFFFFFFF>>(32-prefix)<<(32-prefix));
			if(dns1 != NULL)
            	profile->ipv4.DnsPrimary = mbim2qmi_ipv4addr(*(uint32_t *)dns1);
			if(dns2 != NULL)
            	profile->ipv4.DnsSecondary = mbim2qmi_ipv4addr(*(uint32_t *)dns2);
            profile->ipv4.Mtu = mbim2qmi_ipv4addr(mtu);
        }

        /* IPv6 network configration */
        if (le32toh(pInfo->IPv6ConfigurationAvailable)&0x1) {
			gw = NULL; dns1 = NULL; dns2 = NULL;
            MBIM_IPV6_ELEMENT_T *pAddress = (MBIM_IPV6_ELEMENT_T *)(&pInfo->DataBuffer[le32toh(pInfo->IPv6AddressOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]);
            prefix = le32toh(pAddress->OnLinkPrefixLength);
            ipv6 = pAddress->IPv6Address;

            if (le32toh(pInfo->IPv6ConfigurationAvailable)&0x2)
                gw = (UINT8 *)(&pInfo->DataBuffer[le32toh(pInfo->IPv6GatewayOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]);

            if (le32toh(pInfo->IPv6ConfigurationAvailable)&0x4) {
                dns1 = (UINT8 *)(&pInfo->DataBuffer[le32toh(pInfo->IPv6DnsServerOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]);
                if (le32toh(pInfo->IPv6DnsServerCount) == 2)
                    dns2 = dns1 + 16;
            }

            if (le32toh(pInfo->IPv6ConfigurationAvailable)&0x8)
                mtu =  le32toh(pInfo->IPv6Mtu);

            if(ipv6 != NULL)
            	mbim2qmi_ipv6addr(ipv6, profile->ipv6.Address);
			if(gw != NULL)
            	mbim2qmi_ipv6addr(gw, profile->ipv6.Gateway);
			if(dns1 != NULL)
            	mbim2qmi_ipv6addr(dns1, profile->ipv6.DnsPrimary);
			if(dns2 != NULL)
            	mbim2qmi_ipv6addr(dns2, profile->ipv6.DnsSecondary);
            profile->ipv6.PrefixLengthIPAddr = prefix;
            profile->ipv6.PrefixLengthGateway = prefix;
            profile->ipv6.Mtu = mbim2qmi_ipv4addr(mtu);
        }
    }
    return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x126(%rax)
je 0x1e8ac
cmpl $0x0, 0x1a64a(%rip)     # 0x38ef0
je 0x1e931
jmp 0x1e8ae
movq 0x1872b(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
callq 0x13930
movq -0xc0(%rbp), %rdi
movq %rax, %rdx
movl -0x14(%rbp), %r8d
leaq 0x10e9f(%rip), %rsi     # 0x2f778
leaq 0x10ec2(%rip), %rcx     # 0x2f7a2
movb $0x0, %al
callq 0x52c0
leaq 0x1957a(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x1e92d
leaq 0x1956d(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
callq 0x13930
movq -0xc8(%rbp), %rdi
movq %rax, %rdx
movl -0x14(%rbp), %r8d
leaq 0x10e59(%rip), %rsi     # 0x2f778
leaq 0x10e7c(%rip), %rcx     # 0x2f7a2
movb $0x0, %al
callq 0x52c0
jmp 0x1e92f
jmp 0x1e931
movl -0x14(%rbp), %edi
callq 0x191c0
movl %eax, -0x64(%rbp)
movl $0xf, %edi
xorl %esi, %esi
leaq -0x64(%rbp), %rdx
movl $0x3c, %ecx
callq 0x16eb0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl 0x18ac1(%rip), %edx     # 0x37420
leaq -0x28(%rbp), %rsi
callq 0x17270
movl %eax, -0x68(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1e97f
movq -0x28(%rbp), %rax
movq %rax, -0xd0(%rbp)
jmp 0x1e98a
xorl %eax, %eax
movq %rax, -0xd0(%rbp)
jmp 0x1e98a
movq -0xd0(%rbp), %rdi
callq 0x17480
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x68(%rbp)
jne 0x1e9b0
cmpl $0x0, -0x6c(%rbp)
jne 0x1e9b0
cmpq $0x0, -0x28(%rbp)
jne 0x1ead0
cmpq $0x0, -0x28(%rbp)
je 0x1e9cf
movq -0x28(%rbp), %rdi
cmpl $0x0, 0x1a52e(%rip)     # 0x38ef0
sete %al
andb $0x1, %al
movzbl %al, %esi
callq 0x17560
jmp 0x1e9d1
cmpq $0x0, -0x20(%rbp)
je 0x1e9e9
movq -0x20(%rbp), %rdi
callq 0x5040
movq $0x0, -0x20(%rbp)
jmp 0x1e9eb
jmp 0x1e9ed
cmpq $0x0, -0x28(%rbp)
je 0x1ea05
movq -0x28(%rbp), %rdi
callq 0x5040
movq $0x0, -0x28(%rbp)
jmp 0x1ea07
jmp 0x1ea09
movq 0x185d0(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xd8(%rbp)
callq 0x13930
movq -0xd8(%rbp), %rdi
movq %rax, %rdx
movl -0x68(%rbp), %r9d
movl -0x6c(%rbp), %eax
leaq 0xfbb6(%rip), %rsi      # 0x2e5ed
leaq 0x10d64(%rip), %rcx     # 0x2f7a2
movl $0x815, %r8d            # imm = 0x815
movl %eax, (%rsp)
movb $0x0, %al
callq 0x52c0
leaq 0x19413(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x1eaa0
leaq 0x19406(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
callq 0x13930
movq -0xe0(%rbp), %rdi
movq %rax, %rdx
movl -0x68(%rbp), %r9d
movl -0x6c(%rbp), %eax
leaq 0xfb64(%rip), %rsi      # 0x2e5ed
leaq 0x10d12(%rip), %rcx     # 0x2f7a2
movl $0x815, %r8d            # imm = 0x815
movl %eax, (%rsp)
movb $0x0, %al
callq 0x52c0
jmp 0x1eaa2
cmpl $0x0, -0x68(%rbp)
je 0x1eab3
movl -0x68(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1eff8
cmpl $0x0, -0x6c(%rbp)
je 0x1eac4
movl -0x6c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1eff8
movl $0x22b8, -0x4(%rbp)     # imm = 0x22B8
jmp 0x1eff8
jmp 0x1ead2
movq -0x28(%rbp), %rax
movl 0x2c(%rax), %edi
callq 0x191c0
cmpl $0x0, %eax
je 0x1eff2
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
movq $0x0, -0x98(%rbp)
movl $0x5dc, -0x9c(%rbp)     # imm = 0x5DC
movq -0x28(%rbp), %rax
addq $0x30, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x191c0
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1eda9
movq -0xa8(%rbp), %rax
addq $0x3c, %rax
movq %rax, -0xe8(%rbp)
movq -0xa8(%rbp), %rax
movl 0x10(%rax), %edi
callq 0x191c0
movl %eax, %ecx
movq -0xe8(%rbp), %rax
movl %ecx, %ecx
subq $0x3c, %rcx
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movl (%rax), %edi
callq 0x191c0
movb %al, -0x6d(%rbp)
movq -0xb0(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x78(%rbp)
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x191c0
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1ebf7
movq -0xa8(%rbp), %rax
addq $0x3c, %rax
movq %rax, -0xf0(%rbp)
movq -0xa8(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0x191c0
movl %eax, %ecx
movq -0xf0(%rbp), %rax
movl %ecx, %ecx
subq $0x3c, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x191c0
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1ec70
movq -0xa8(%rbp), %rax
addq $0x3c, %rax
movq %rax, -0xf8(%rbp)
movq -0xa8(%rbp), %rax
movl 0x28(%rax), %edi
callq 0x191c0
movl %eax, %ecx
movq -0xf8(%rbp), %rax
movl %ecx, %ecx
subq $0x3c, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0xa8(%rbp), %rax
movl 0x24(%rax), %edi
callq 0x191c0
cmpl $0x2, %eax
jne 0x1ec6e
movq -0x90(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x98(%rbp)
jmp 0x1ec70
movq -0xa8(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x191c0
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1ec9c
movq -0xa8(%rbp), %rax
movl 0x34(%rax), %edi
callq 0x191c0
movl %eax, -0x9c(%rbp)
movq -0x10(%rbp), %rax
movl 0x126(%rax), %eax
movl %eax, -0xfc(%rbp)
movq -0x78(%rbp), %rax
movl (%rax), %edi
callq 0x1f010
movl %eax, %ecx
movl -0xfc(%rbp), %eax
cmpl %ecx, %eax
jne 0x1eccc
cmpl $0x0, 0x1a226(%rip)     # 0x38ef0
je 0x1ecf6
movq -0xa8(%rbp), %rdi
leaq 0xfa00(%rip), %rsi      # 0x2e6da
callq 0x1f050
movq -0x78(%rbp), %rax
movl (%rax), %edi
callq 0x1f010
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x126(%rax)
cmpq $0x0, -0x88(%rbp)
je 0x1ed1a
movq -0x88(%rbp), %rax
movl (%rax), %edi
callq 0x1f010
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x12a(%rax)
movzbl -0x6d(%rbp), %eax
movl $0x20, %ecx
subl %eax, %ecx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
shrl %cl, %edi
movzbl -0x6d(%rbp), %eax
movl $0x20, %ecx
subl %eax, %ecx
shll %cl, %edi
callq 0x1f010
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x12e(%rax)
cmpq $0x0, -0x90(%rbp)
je 0x1ed6e
movq -0x90(%rbp), %rax
movl (%rax), %edi
callq 0x1f010
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x132(%rax)
cmpq $0x0, -0x98(%rbp)
je 0x1ed92
movq -0x98(%rbp), %rax
movl (%rax), %edi
callq 0x1f010
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x136(%rax)
movl -0x9c(%rbp), %edi
callq 0x1f010
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x13a(%rax)
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x191c0
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1eff0
movq $0x0, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
movq $0x0, -0x98(%rbp)
movq -0xa8(%rbp), %rax
addq $0x3c, %rax
movq %rax, -0x108(%rbp)
movq -0xa8(%rbp), %rax
movl 0x18(%rax), %edi
callq 0x191c0
movl %eax, %ecx
movq -0x108(%rbp), %rax
movl %ecx, %ecx
subq $0x3c, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movl (%rax), %edi
callq 0x191c0
movb %al, -0x6d(%rbp)
movq -0xb8(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x80(%rbp)
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x191c0
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1ee90
movq -0xa8(%rbp), %rax
addq $0x3c, %rax
movq %rax, -0x110(%rbp)
movq -0xa8(%rbp), %rax
movl 0x20(%rax), %edi
callq 0x191c0
movl %eax, %ecx
movq -0x110(%rbp), %rax
movl %ecx, %ecx
subq $0x3c, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x191c0
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1ef09
movq -0xa8(%rbp), %rax
addq $0x3c, %rax
movq %rax, -0x118(%rbp)
movq -0xa8(%rbp), %rax
movl 0x30(%rax), %edi
callq 0x191c0
movl %eax, %ecx
movq -0x118(%rbp), %rax
movl %ecx, %ecx
subq $0x3c, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0xa8(%rbp), %rax
movl 0x2c(%rax), %edi
callq 0x191c0
cmpl $0x2, %eax
jne 0x1ef07
movq -0x90(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x98(%rbp)
jmp 0x1ef09
movq -0xa8(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x191c0
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1ef35
movq -0xa8(%rbp), %rax
movl 0x38(%rax), %edi
callq 0x191c0
movl %eax, -0x9c(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x1ef50
movq -0x80(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x13e, %rsi            # imm = 0x13E
callq 0x20790
cmpq $0x0, -0x88(%rbp)
je 0x1ef75
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x13e, %rsi            # imm = 0x13E
addq $0x10, %rsi
callq 0x20790
cmpq $0x0, -0x90(%rbp)
je 0x1ef9a
movq -0x90(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x13e, %rsi            # imm = 0x13E
addq $0x30, %rsi
callq 0x20790
cmpq $0x0, -0x98(%rbp)
je 0x1efbf
movq -0x98(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x13e, %rsi            # imm = 0x13E
addq $0x40, %rsi
callq 0x20790
movb -0x6d(%rbp), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x18e(%rax)
movb -0x6d(%rbp), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x18f(%rax)
movl -0x9c(%rbp), %edi
callq 0x1f010
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x190(%rax)
jmp 0x1eff2
movl -0x68(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)