// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/atc.c
// Function: requestQueryDataCall
static int requestQueryDataCall(UCHAR  *pConnectionStatus, int curIpFamily) {
    int err;
    ATResponse *p_response = NULL;
    ATLine *p_cur = NULL;
    int state = 0;
    int bind = 0;
    int cid;
    int pdp = s_pdp;
    unsigned int v4Addr = 0;

    (void)curIpFamily;

    *pConnectionStatus = QWDS_PKT_DATA_DISCONNECTED;

    if (!asr_style_atc) {
        err = at_netdevstatus(pdp, &v4Addr);
        if (!err && v4Addr) {
            *pConnectionStatus = QWDS_PKT_DATA_CONNECTED;
            //if (profile->ipv4.Address == v4Addr) {} //TODO
        }
        return err;
    }

    err = at_send_command_multiline("AT+QNETDEVCTL?", "+QNETDEVCTL:", &p_response);
    if (at_response_error(err, p_response))
        goto _error;

    for (p_cur = p_response->p_intermediates; p_cur != NULL; p_cur = p_cur->p_next)
    {
        //+QNETDECTL:<op>,<cid>,<urc_en>,<state>
        err = at_tok_scanf(p_cur->line, "%d%d%d%d", &bind, &cid, NULL, &state);
        if (err != 4 || cid != pdp)
            continue;
        if (bind != 1)
            bind = 0;
    }
    safe_at_response_free(p_response);

    if (bind == 0 || state == 0)
        goto _error;

    err = at_send_command_multiline("AT+CGACT?", "+CGACT:", &p_response);
    if (at_response_error(err, p_response))
        goto _error;

    for (p_cur = p_response->p_intermediates; p_cur != NULL; p_cur = p_cur->p_next)
    {
        err = at_tok_scanf(p_cur->line, "%d%d", &cid, &state);
        if (err != 2 || cid != pdp)
            continue;
    }
    safe_at_response_free(p_response);

    if (bind && state)
        *pConnectionStatus = QWDS_PKT_DATA_CONNECTED;

_error:
    safe_at_response_free(p_response);
    //dbg_time("%s err=%d, call_state=%d", __func__, err, *pConnectionStatus);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r13
movq $0x0, 0x10(%rsp)
xorl %eax, %eax
movl %eax, 0xc(%rsp)
movl %eax, 0x8(%rsp)
movl 0x124ed(%rip), %ebp     # 0x2bf38
movl %eax, 0x1c(%rsp)
movb $0x1, (%rdi)
cmpb $0x0, 0x124e3(%rip)     # 0x2bf3c
je 0x19a96
leaq 0x9828(%rip), %rdi      # 0x2328a
leaq 0x9561(%rip), %rsi      # 0x22fca
leaq 0x10(%rsp), %r14
movq %r14, %rdx
callq 0x1b08f
testl %eax, %eax
setne %al
movq (%r14), %rdi
testq %rdi, %rdi
sete %cl
orb %al, %cl
je 0x19ab9
testq %rdi, %rdi
jne 0x19bf6
jmp 0x19bfb
leaq 0x1c(%rsp), %r14
movl %ebp, %edi
movq %r14, %rsi
callq 0x1a78b
cmpl $0x0, (%r14)
je 0x19bfb
movb $0x2, (%r13)
jmp 0x19bfb
cmpq $0x0, 0x8(%rdi)
je 0x19bf6
cmpl $0x0, (%rdi)
je 0x19bf6
movq 0x10(%rdi), %rbx
testq %rbx, %rbx
je 0x19b3c
movq %r13, 0x20(%rsp)
leaq 0x98fc(%rip), %r14      # 0x233de
leaq 0x8(%rsp), %r15
leaq 0x18(%rsp), %r12
leaq 0xc(%rsp), %r13
movq 0x8(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
movq %r13, %r9
xorl %eax, %eax
callq 0x1bb39
cmpl $0x4, %eax
jne 0x19b25
cmpl %ebp, 0x18(%rsp)
jne 0x19b25
cmpl $0x1, 0x8(%rsp)
je 0x19b25
movl $0x0, 0x8(%rsp)
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x19af1
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
movq 0x20(%rsp), %r13
je 0x19b4a
callq 0x1aeb5
movq $0x0, 0x10(%rsp)
cmpl $0x0, 0x8(%rsp)
je 0x19bfb
cmpl $0x0, 0xc(%rsp)
je 0x19bfb
leaq 0x96b4(%rip), %rdi      # 0x2321b
leaq 0x96b7(%rip), %rsi      # 0x23225
leaq 0x10(%rsp), %r14
movq %r14, %rdx
callq 0x1b08f
testl %eax, %eax
setne %al
movq (%r14), %rdi
testq %rdi, %rdi
sete %cl
orb %al, %cl
jne 0x19a88
cmpq $0x0, 0x8(%rdi)
je 0x19bf6
cmpl $0x0, (%rdi)
je 0x19bf6
movq 0x10(%rdi), %rbx
testq %rbx, %rbx
je 0x19bdd
leaq 0x9835(%rip), %r14      # 0x233e2
leaq 0x18(%rsp), %r15
leaq 0xc(%rsp), %r12
movq 0x8(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1bb39
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x19bb7
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x19be2
callq 0x1aeb5
cmpl $0x0, 0x8(%rsp)
je 0x19bfb
cmpl $0x0, 0xc(%rsp)
jne 0x19aaf
jmp 0x19bfb
callq 0x1aeb5
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq