// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
leaq 0x18(%rsp), %r15
andq $0x0, (%r15)
leaq 0x70(%rsp), %r14
andq $0x0, (%r14)
andq $0x0, 0x68(%rsp)
andq $0x0, 0x60(%rsp)
andq $0x0, 0x58(%rsp)
andq $0x0, 0x50(%rsp)
andq $0x0, 0x48(%rsp)
andq $0x0, 0x40(%rsp)
andq $0x0, 0x38(%rsp)
andq $0x0, 0x30(%rsp)
andq $0x0, 0x28(%rsp)
movq %rsi, %rbx
andq $0x0, 0x20(%rsp)
movl %edi, %edx
andl $0x0, (%rsi)
leaq 0x7cc9(%rip), %rsi      # 0x21287
movq %r14, %rdi
xorl %eax, %eax
callq 0x53c0
movq (%r14), %rdi
leaq 0x7cc9(%rip), %rsi      # 0x2129b
movq %r15, %rdx
callq 0x19e06
movl %eax, %ebp
movq (%r14), %rdi
testq %rdi, %rdi
je 0x195ef
callq 0x5040
andq $0x0, 0x70(%rsp)
testl %ebp, %ebp
setne %al
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x19722
cmpq $0x0, 0x8(%rdi)
je 0x1971d
cmpl $0x0, (%rdi)
je 0x1971d
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x1971d
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x1971d
leaq 0x20(%rsp), %r10
leaq 0x28(%rsp), %r11
leaq 0x30(%rsp), %r15
leaq 0x38(%rsp), %r12
leaq 0x40(%rsp), %r13
leaq 0x48(%rsp), %rbp
leaq 0x7c5f(%rip), %rsi      # 0x212b9
leaq 0x68(%rsp), %r14
leaq 0x60(%rsp), %rcx
leaq 0x58(%rsp), %r8
leaq 0x50(%rsp), %r9
movq %r14, %rdx
movl $0x0, %eax
pushq %r10
pushq %r11
pushq %r15
pushq %r12
pushq %r13
pushq %rbp
callq 0x1a825
addq $0x30, %rsp
testl %eax, %eax
setg %al
movq (%r14), %r14
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1971d
cmpb $0x0, (%r14)
je 0x1971d
xorps %xmm0, %xmm0
leaq 0x8(%rsp), %r15
movaps %xmm0, -0x8(%r15)
pushq $0x2e
popq %rsi
movq %r14, %rdi
callq 0x5190
testq %rax, %rax
je 0x196de
leaq 0x4(%rsp), %rcx
leaq 0xc(%rsp), %r9
leaq 0x7bfb(%rip), %rsi      # 0x212ce
movq %rsp, %rdx
movq %r14, %rdi
movq %r15, %r8
jmp 0x196f8
leaq 0xc(%rsp), %rdx
leaq 0x4(%rsp), %r8
leaq 0x7beb(%rip), %rsi      # 0x212da
movq %rsp, %r9
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x5390
movl 0x4(%rsp), %eax
movl 0x8(%rsp), %ecx
shll $0x8, %eax
orl (%rsp), %eax
shll $0x10, %ecx
movl 0xc(%rsp), %edx
shll $0x18, %edx
orl %ecx, %edx
orl %eax, %edx
movl %edx, (%rbx)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1972c
callq 0x19d1e
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop