// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/udhcpc.c
// Function: update_ipv4_address
void update_ipv4_address(const char *ifname, const char *ip, const char *gw, unsigned prefix)
{
    char shell_cmd[128];

    if (!ifname)
        return;

    if (!access("/sbin/ip", X_OK)) {
        snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d address flush dev %s", 4, ifname);
        ql_system(shell_cmd);

        snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d address add %s/%u dev %s", 4, ip, prefix, ifname);
        ql_system(shell_cmd);

        //ping6 www.qq.com
        snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d route add default via %s dev %s", 4, gw, ifname);
        ql_system(shell_cmd);
    } else {
        unsigned n =  (0xFFFFFFFF >> (32 - prefix)) << (32 - prefix);
        n = (n>>24) | (n>>8&0xff00) | (n<<8&0xff0000) | (n<<24);

        snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s %s netmask %s", ifname, ip, ipv4Str(n));
        ql_system(shell_cmd);

        //Resetting default routes
        snprintf(shell_cmd, sizeof(shell_cmd), "route del default dev %s", ifname);
        while(!system(shell_cmd));

        snprintf(shell_cmd, sizeof(shell_cmd), "route add default gw %s dev %s", gw, ifname);
        ql_system(shell_cmd);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0x28fe6
jmp 0x291cb
leaq 0x7aac(%rip), %rdi      # 0x30a99
movl $0x1, %esi
callq 0x5460
cmpl $0x0, %eax
jne 0x290a2
leaq -0xa0(%rbp), %rdi
movq -0x8(%rbp), %r8
movl $0x80, %esi
leaq 0x7a8b(%rip), %rdx      # 0x30aa2
movl $0x4, %ecx
movb $0x0, %al
callq 0x51c0
leaq -0xa0(%rbp), %rdi
callq 0x28f30
leaq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %r8
movl -0x1c(%rbp), %r9d
movq -0x8(%rbp), %rax
movl $0x80, %esi
leaq 0x7a70(%rip), %rdx      # 0x30abe
movl $0x4, %ecx
movq %rax, (%rsp)
movb $0x0, %al
callq 0x51c0
leaq -0xa0(%rbp), %rdi
callq 0x28f30
leaq -0xa0(%rbp), %rdi
movq -0x18(%rbp), %r8
movq -0x8(%rbp), %r9
movl $0x80, %esi
leaq 0x7a59(%rip), %rdx      # 0x30ade
movl $0x4, %ecx
movb $0x0, %al
callq 0x51c0
leaq -0xa0(%rbp), %rdi
callq 0x28f30
jmp 0x291cb
movl $0x20, %ecx
subl -0x1c(%rbp), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shrl %cl, %eax
movl $0x20, %ecx
subl -0x1c(%rbp), %ecx
shll %cl, %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
shrl $0x18, %eax
movl -0xa4(%rbp), %ecx
shrl $0x8, %ecx
andl $0xff00, %ecx           # imm = 0xFF00
orl %ecx, %eax
movl -0xa4(%rbp), %ecx
shll $0x8, %ecx
andl $0xff0000, %ecx         # imm = 0xFF0000
orl %ecx, %eax
movl -0xa4(%rbp), %ecx
shll $0x18, %ecx
orl %ecx, %eax
movl %eax, -0xa4(%rbp)
leaq -0xa0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl -0xa4(%rbp), %edi
callq 0x291e0
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rcx
movq -0xb0(%rbp), %r8
movq %rax, %r9
movl $0x80, %esi
leaq 0x79b5(%rip), %rdx      # 0x30b05
movb $0x0, %al
callq 0x51c0
leaq -0xa0(%rbp), %rdi
callq 0x28f30
leaq -0xa0(%rbp), %rdi
movq -0x8(%rbp), %rcx
movl $0x80, %esi
leaq 0x79a5(%rip), %rdx      # 0x30b1f
movb $0x0, %al
callq 0x51c0
leaq -0xa0(%rbp), %rdi
callq 0x5170
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2919b
jmp 0x2919d
jmp 0x29181
leaq -0xa0(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %r8
movl $0x80, %esi
leaq 0x7980(%rip), %rdx      # 0x30b38
movb $0x0, %al
callq 0x51c0
leaq -0xa0(%rbp), %rdi
callq 0x28f30
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)