// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rdi, %rbp
testq %rsi, %rsi
je 0x1d2ae
movq %rsi, %r15
movl (%rsi), %eax
testl %eax, %eax
je 0x1d2ae
movq %rbp, 0x10(%rsp)
movl %eax, %r9d
shrl $0x8, %r9d
movl %eax, %r8d
shrl $0x10, %r8d
movl %eax, %ecx
shrl $0x18, %ecx
movl $0xff, %ebp
andl %ebp, %r8d
andl %ebp, %r9d
andl %ebp, %eax
movl %eax, (%rsp)
leaq 0xd1da(%rip), %r13      # 0x2a320
leaq 0x6141(%rip), %rdx      # 0x2328e
xorl %ebx, %ebx
movl $0x10, %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x51c0
movq %r13, %rdi
callq 0x5520
movq %rax, %r12
movl 0x4(%r15), %eax
movl %eax, %r9d
shrl $0x8, %r9d
movl %eax, %r8d
shrl $0x10, %r8d
movl %eax, %ecx
shrl $0x18, %ecx
andl %ebp, %r8d
andl %ebp, %r9d
andl %ebp, %eax
movl %eax, (%rsp)
movl $0x10, %esi
movq %r13, %rdi
leaq 0x60f4(%rip), %rdx      # 0x2328e
xorl %eax, %eax
callq 0x51c0
movq %r13, %rdi
callq 0x5520
movq %rax, %r13
movl 0x8(%r15), %eax
xorl %ecx, %ecx
btl %ebx, %eax
adcl $0x0, %ecx
incl %ebx
cmpl $0x20, %ebx
jne 0x1d1b2
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1c30c
movq %r12, %rdi
callq 0x5040
movq %r13, %rdi
callq 0x5040
movl 0xc(%r15), %eax
testl %eax, %eax
je 0x1d2ae
movl %eax, %r9d
shrl $0x8, %r9d
movl %eax, %r8d
shrl $0x10, %r8d
movl %eax, %ecx
shrl $0x18, %ecx
movl $0xff, %ebx
andl %ebx, %r8d
andl %ebx, %r9d
andl %ebx, %eax
movl %eax, (%rsp)
leaq 0xd108(%rip), %r12      # 0x2a320
leaq 0x606f(%rip), %rdx      # 0x2328e
movl $0x10, %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0x51c0
movq %r12, %rdi
callq 0x5520
movq %rax, %r12
movl 0x10(%r15), %eax
testl %eax, %eax
jne 0x1d245
movl 0xc(%r15), %eax
movl %eax, %r9d
shrl $0x8, %r9d
movl %eax, %r8d
shrl $0x10, %r8d
movl %eax, %ecx
shrl $0x18, %ecx
andl %ebx, %r8d
andl %ebx, %r9d
andl %ebx, %eax
movl %eax, (%rsp)
leaq 0xd0b6(%rip), %r15      # 0x2a320
leaq 0x601d(%rip), %rdx      # 0x2328e
movl $0x10, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x51c0
movq %r15, %rdi
callq 0x5520
movq %rax, %r15
movl $0x4, %edi
movq %rbp, %rsi
movq %r12, %rdx
movq %rax, %rcx
callq 0xef72
movq %r12, %rdi
callq 0x5040
movq %r15, %rdi
callq 0x5040
testq %r14, %r14
je 0x1d377
cmpb $0x0, (%r14)
je 0x1d377
cmpb $0x0, 0x50(%r14)
je 0x1d377
movq %r14, %rdi
callq 0x1d06f
leaq 0xf115(%rip), %rdi      # 0x2c3f0
callq 0x5520
movq %rax, %r15
leaq 0x10(%r14), %rdi
callq 0x1d06f
movzbl 0x50(%r14), %ecx
movq %rbp, %rdi
movq %r15, %rsi
callq 0x1c4ac
movq %r15, %rdi
callq 0x5040
cmpb $0x0, 0x30(%r14)
je 0x1d377
leaq 0x30(%r14), %r15
movq %r15, %rdi
callq 0x1d06f
leaq 0xf0d2(%rip), %r12      # 0x2c3f0
movq %r12, %rdi
callq 0x5520
movq %rax, %r13
leaq 0x40(%r14), %rdi
cmpb $0x0, 0x40(%r14)
cmoveq %r15, %rdi
callq 0x1d06f
movq %r12, %rdi
callq 0x5520
movq %rax, %r14
movl $0x6, %edi
movq %rbp, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0xef72
movq %r13, %rdi
callq 0x5040
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5040
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq