// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x29fdc
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x29fdc
movq -0x10(%rbp), %rax
movl (%rax), %edi
callq 0x291e0
movq %rax, %rdi
callq 0x5530
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edi
callq 0x291e0
movq %rax, %rdi
callq 0x5530
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x20, -0x30(%rbp)
jae 0x29f36
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl -0x30(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x29f29
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x29f2b
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x29f00
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl -0x2c(%rbp), %ecx
callq 0x28fc0
movq -0x20(%rbp), %rdi
callq 0x5040
movq -0x28(%rbp), %rdi
callq 0x5040
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x29fda
movq -0x10(%rbp), %rax
movl 0xc(%rax), %edi
callq 0x291e0
movq %rax, %rdi
callq 0x5530
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x10(%rax)
je 0x29f94
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x34(%rbp)
jmp 0x29f9e
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %edi
callq 0x291e0
movq %rax, %rdi
callq 0x5530
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x4, %edi
callq 0x140b0
movq -0x20(%rbp), %rdi
callq 0x5040
movq -0x28(%rbp), %rdi
callq 0x5040
jmp 0x29fdc
cmpq $0x0, -0x18(%rbp)
je 0x2a0ea
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x2a0ea
movq -0x18(%rbp), %rax
movzbl 0x50(%rax), %eax
cmpl $0x0, %eax
je 0x2a0ea
movq -0x18(%rbp), %rdi
callq 0x29dd0
movq %rax, %rdi
callq 0x5530
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
callq 0x29dd0
movq %rax, %rdi
callq 0x5530
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x18(%rbp), %rax
movzbl 0x50(%rax), %ecx
callq 0x29240
movq -0x20(%rbp), %rdi
callq 0x5040
movq -0x28(%rbp), %rdi
callq 0x5040
movq -0x18(%rbp), %rax
cmpb $0x0, 0x30(%rax)
je 0x2a0e8
movq -0x18(%rbp), %rdi
addq $0x30, %rdi
callq 0x29dd0
movq %rax, %rdi
callq 0x5530
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x40(%rax), %eax
cmpl $0x0, %eax
je 0x2a09f
movq -0x18(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x40(%rbp)
jmp 0x2a0ab
movq -0x18(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x29dd0
movq %rax, %rdi
callq 0x5530
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x6, %edi
callq 0x140b0
movq -0x20(%rbp), %rdi
callq 0x5040
movq -0x28(%rbp), %rdi
callq 0x5040
jmp 0x2a0ea
addq $0x40, %rsp
popq %rbp
retq