// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/udhcpc.c
// Function: update_ip_address_by_qmi
static void update_ip_address_by_qmi(const char *ifname, const IPV4_T *ipv4, const IPV6_T *ipv6) {
    char *d1, *d2;

    if (ipv4 && ipv4->Address) {
        d1 = strdup(ipv4Str(ipv4->Address));
        d2 = strdup(ipv4Str(ipv4->Gateway));
        unsigned prefix = 0;
        unsigned n = 0;

        for (n = 0; n < 32; n++) {
            if (ipv4->SubnetMask&(1<<n)) {
                prefix++;
            }
        }

        update_ipv4_address(ifname, d1, d2, prefix);
        free(d1); free(d2);

        //Adding DNS
        if (ipv4->DnsPrimary) {
            d1 = strdup(ipv4Str(ipv4->DnsPrimary));
            d2 = strdup(ipv4Str(ipv4->DnsSecondary ? ipv4->DnsSecondary : ipv4->DnsPrimary));
            update_resolv_conf(4, ifname, d1, d2);
            free(d1); free(d2);
        }
    }

    if (ipv6 && ipv6->Address[0] && ipv6->PrefixLengthIPAddr) {
        d1 = strdup(ipv6Str(ipv6->Address));
        d2 = strdup(ipv6Str(ipv6->Gateway));

        update_ipv6_address(ifname, d1, d2, ipv6->PrefixLengthIPAddr);
        free(d1); free(d2);

        //Adding DNS
        if (ipv6->DnsPrimary[0]) {
            d1 = strdup(ipv6Str(ipv6->DnsPrimary));
            d2 = strdup(ipv6Str(ipv6->DnsSecondary[0] ? ipv6->DnsSecondary : ipv6->DnsPrimary));
            update_resolv_conf(6, ifname, d1, d2);
            free(d1); free(d2);
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rdi, %rbx
testq %rsi, %rsi
je 0x1b9b9
movq %rsi, %r15
movl (%rsi), %edi
testl %edi, %edi
je 0x1b9b9
callq 0x1adaa
leaq 0xda18(%rip), %r13      # 0x29320
movq %r13, %rdi
callq 0x5530
movq %rax, %r12
movl 0x4(%r15), %edi
callq 0x1adaa
movq %r13, %rdi
callq 0x5530
movq %rax, %r13
movl 0x8(%r15), %eax
xorl %ecx, %ecx
xorl %edx, %edx
cmpl $0x20, %edx
je 0x1b93e
btl %edx, %eax
adcl $0x0, %ecx
incl %edx
jmp 0x1b92f
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1ac30
movq %r12, %rdi
callq 0x5040
movq %r13, %rdi
callq 0x5040
movl 0xc(%r15), %edi
testl %edi, %edi
je 0x1b9b9
callq 0x1adaa
leaq 0xd9b0(%rip), %rdi      # 0x29320
callq 0x5530
movq %rax, %r12
movl 0x10(%r15), %edi
testl %edi, %edi
jne 0x1b984
movl 0xc(%r15), %edi
callq 0x1adaa
leaq 0xd990(%rip), %rdi      # 0x29320
callq 0x5530
movq %rax, %r15
pushq $0x4
popq %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %rax, %rcx
callq 0xe74f
movq %r12, %rdi
callq 0x5040
movq %r15, %rdi
callq 0x5040
testq %r14, %r14
je 0x1ba7b
cmpb $0x0, (%r14)
je 0x1ba7b
cmpb $0x0, 0x50(%r14)
je 0x1ba7b
movq %r14, %rdi
callq 0x1b859
leaq 0xfa0a(%rip), %rdi      # 0x2b3f0
callq 0x5530
movq %rax, %r15
leaq 0x10(%r14), %rdi
callq 0x1b859
movzbl 0x50(%r14), %ecx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1ade8
movq %r15, %rdi
callq 0x5040
cmpb $0x0, 0x30(%r14)
je 0x1ba7b
leaq 0x30(%r14), %r15
movq %r15, %rdi
callq 0x1b859
leaq 0xf9c7(%rip), %r12      # 0x2b3f0
movq %r12, %rdi
callq 0x5530
movq %rax, %r13
leaq 0x40(%r14), %rdi
cmpb $0x0, 0x40(%r14)
cmoveq %r15, %rdi
callq 0x1b859
movq %r12, %rdi
callq 0x5530
movq %rax, %r14
pushq $0x6
popq %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0xe74f
movq %r13, %rdi
callq 0x5040
movq %r14, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x5040
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq