// File: /workspace/github_c_makefile_star2_O1/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
movq %rsi, %rbx
movl %edi, %edx
xorl %eax, %eax
leaq 0x18(%rsp), %r15
movq %rax, (%r15)
leaq 0x70(%rsp), %r14
movq %rax, (%r14)
movq %rax, 0x68(%rsp)
movq %rax, 0x60(%rsp)
movq %rax, 0x58(%rsp)
movq %rax, 0x50(%rsp)
movq %rax, 0x48(%rsp)
movq %rax, 0x40(%rsp)
movq %rax, 0x38(%rsp)
movq %rax, 0x30(%rsp)
movq %rax, 0x28(%rsp)
movq %rax, 0x20(%rsp)
movl $0x0, (%rsi)
leaq 0x87db(%rip), %rsi      # 0x23247
movq %r14, %rdi
xorl %eax, %eax
callq 0x53b0
movq (%r14), %rdi
leaq 0x87db(%rip), %rsi      # 0x2325b
movq %r15, %rdx
callq 0x1b3c6
movl %eax, %ebp
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1aaa0
callq 0x5040
movq $0x0, 0x70(%rsp)
testl %ebp, %ebp
setne %cl
movq 0x18(%rsp), %rax
testq %rax, %rax
sete %dl
orb %cl, %dl
jne 0x1abd4
cmpq $0x0, 0x8(%rax)
je 0x1abd4
cmpl $0x0, (%rax)
je 0x1abd4
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x1abd4
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x1abd4
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 0x876e(%rip), %rsi      # 0x23279
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 0x1be91
addq $0x30, %rsp
testl %eax, %eax
setg %al
movq (%r14), %r14
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1abd4
cmpb $0x0, (%r14)
je 0x1abd4
xorps %xmm0, %xmm0
leaq 0x8(%rsp), %r15
movaps %xmm0, -0x8(%r15)
movq %r14, %rdi
movl $0x2e, %esi
callq 0x5190
testq %rax, %rax
je 0x1ab95
leaq 0x4(%rsp), %rcx
leaq 0xc(%rsp), %r9
leaq 0x8704(%rip), %rsi      # 0x2328e
movq %rsp, %rdx
movq %r14, %rdi
movq %r15, %r8
jmp 0x1abaf
leaq 0xc(%rsp), %rdx
leaq 0x4(%rsp), %r8
leaq 0x86f4(%rip), %rsi      # 0x2329a
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 0x1abec
callq 0x1b2da
movq $0x0, 0x18(%rsp)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop