// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/atc.c
// Function: at_netdevstatus
static int at_netdevstatus(int pdp, unsigned int *pV4Addr) {
    int err;
    ATResponse *p_response = NULL;
    char *cmd = NULL;
    char *ipv4_address = NULL;
    char *ipv4_gate = NULL;
    char *ipv4_DHCP = NULL;
    char *ipv4_pDNS = NULL;
    char *ipv4_sDNS = NULL;
    char *ipv6_address = NULL;
    char *ipv6_gate = NULL;
    char *ipv6_DHCP = NULL;
    char *ipv6_pDNS = NULL;
    char *ipv6_sDNS = NULL;

    *pV4Addr = 0;

    asprintf(&cmd, "AT+QNETDEVSTATUS=%d", pdp);
    err = at_send_command_singleline(cmd, "+QNETDEVSTATUS", &p_response);
    safe_free(cmd);
    if (at_response_error(err, p_response)) goto _error;
    if (!p_response->p_intermediates || !p_response->p_intermediates->line) goto _error;

    err = at_tok_scanf(p_response->p_intermediates->line, "%s%s%s%s%s%s%s%s%s%s",
        &ipv4_address, &ipv4_gate, &ipv4_DHCP, &ipv4_pDNS, &ipv4_sDNS,
        &ipv6_address, &ipv6_gate, &ipv6_DHCP, &ipv6_pDNS, &ipv6_sDNS);
    if (err > 0) {
#if 0
        dbg_time("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s",
            ipv4_address, ipv4_gate, ipv4_DHCP, ipv4_pDNS, ipv4_sDNS,
            ipv6_address, ipv6_gate, ipv6_DHCP, ipv6_pDNS, ipv6_sDNS);
#endif

        if (ipv4_address && ipv4_address[0]) {
            int addr[4] = {0, 0, 0, 0};

            if (strstr(ipv4_address, ".")) {
                sscanf(ipv4_address, "%d.%d.%d.%d", &addr[0], &addr[1], &addr[2], &addr[3]);
            }
            else {
                sscanf(ipv4_address, "%02X%02X%02X%02X", &addr[3], &addr[2], &addr[1], &addr[0]);
            }
            *pV4Addr = (addr[0]) | (addr[1]<<8) | (addr[2]<<16) | (addr[3]<<24);
       }
    }

_error:
    safe_at_response_free(p_response);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xb8, %rsp
movl %edi, -0x1c(%rbp)
movq %rsi, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movl -0x1c(%rbp), %edx
leaq -0x40(%rbp), %rdi
leaq 0x9cc2(%rip), %rsi      # 0x304e7
movb $0x0, %al
callq 0x53c0
movq -0x40(%rbp), %rdi
leaq 0x9cc4(%rip), %rsi      # 0x304fb
leaq -0x38(%rbp), %rdx
callq 0x26e80
movl %eax, -0x2c(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x2685b
movq -0x40(%rbp), %rdi
callq 0x5040
movq $0x0, -0x40(%rbp)
jmp 0x2685d
cmpl $0x0, -0x2c(%rbp)
jne 0x2687e
cmpq $0x0, -0x38(%rbp)
je 0x2687e
movq -0x38(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x2687e
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x26883
jmp 0x269ff
movq -0x38(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x2689d
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
cmpq $0x0, 0x8(%rax)
jne 0x268a2
jmp 0x269ff
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x9c64(%rip), %rsi      # 0x30519
leaq -0x48(%rbp), %rdx
leaq -0x50(%rbp), %rcx
leaq -0x58(%rbp), %r8
leaq -0x60(%rbp), %r9
leaq -0x68(%rbp), %r15
leaq -0x70(%rbp), %r14
leaq -0x78(%rbp), %rbx
leaq -0x80(%rbp), %r11
leaq -0x88(%rbp), %r10
leaq -0x90(%rbp), %rax
movq %r15, (%rsp)
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movb $0x0, %al
callq 0x28860
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jle 0x269fd
cmpq $0x0, -0x48(%rbp)
je 0x269fb
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x269fb
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x5200
movq -0x48(%rbp), %rdi
leaq 0x9be1(%rip), %rsi      # 0x3052e
callq 0x5560
cmpq $0x0, %rax
je 0x26994
movq -0x48(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
addq $0x4, %rcx
leaq -0xa0(%rbp), %r8
addq $0x8, %r8
leaq -0xa0(%rbp), %r9
addq $0xc, %r9
leaq 0x9ba5(%rip), %rsi      # 0x30530
movb $0x0, %al
callq 0x53a0
jmp 0x269ce
movq -0x48(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
addq $0xc, %rdx
leaq -0xa0(%rbp), %rcx
addq $0x8, %rcx
leaq -0xa0(%rbp), %r8
addq $0x4, %r8
leaq -0xa0(%rbp), %r9
leaq 0x9b75(%rip), %rsi      # 0x3053c
movb $0x0, %al
callq 0x53a0
movl -0xa0(%rbp), %ecx
movl -0x9c(%rbp), %eax
shll $0x8, %eax
orl %eax, %ecx
movl -0x98(%rbp), %eax
shll $0x10, %eax
orl %eax, %ecx
movl -0x94(%rbp), %eax
shll $0x18, %eax
orl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x269fd
jmp 0x269ff
cmpq $0x0, -0x38(%rbp)
je 0x26a17
movq -0x38(%rbp), %rdi
callq 0x26d20
movq $0x0, -0x38(%rbp)
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopw (%rax,%rax)