// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, 0x10(%rsp)
andl $0x0, 0xc(%rsp)
andl $0x0, 0x8(%rsp)
movq %rdi, %r15
andl $0x0, 0x1c(%rsp)
movl 0x126d1(%rip), %ebp     # 0x2af38
movb $0x1, (%rdi)
cmpb $0x0, 0x126cb(%rip)     # 0x2af3c
je 0x188ae
leaq 0x8a30(%rip), %rdi      # 0x212aa
leaq 0x8769(%rip), %rsi      # 0x20fea
leaq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x19ed7
testl %eax, %eax
setne %al
movq (%rbx), %r14
testq %r14, %r14
sete %cl
orb %al, %cl
je 0x188cf
testq %r14, %r14
jne 0x189db
jmp 0x189e3
leaq 0x1c(%rsp), %rbx
movl %ebp, %edi
movq %rbx, %rsi
callq 0x19553
cmpl $0x0, (%rbx)
je 0x189e3
movb $0x2, (%r15)
jmp 0x189e3
cmpq $0x0, 0x8(%r14)
je 0x189db
cmpl $0x0, (%r14)
je 0x189db
movq %r15, 0x20(%rsp)
addq $0x10, %r14
leaq 0x8b0a(%rip), %r15      # 0x213fe
leaq 0x8(%rsp), %r12
leaq 0x18(%rsp), %r13
leaq 0xc(%rsp), %rbx
movq (%r14), %r14
testq %r14, %r14
je 0x1893e
movq 0x8(%r14), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
movq %rbx, %r9
xorl %eax, %eax
callq 0x1a825
cmpl $0x4, %eax
jne 0x18903
cmpl %ebp, 0x18(%rsp)
jne 0x18903
cmpl $0x1, 0x8(%rsp)
je 0x18903
andl $0x0, 0x8(%rsp)
jmp 0x18903
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18953
callq 0x19d1e
andq $0x0, 0x10(%rsp)
cmpl $0x0, 0x8(%rsp)
movq 0x20(%rsp), %r13
je 0x189e3
cmpl $0x0, 0xc(%rsp)
je 0x189e3
leaq 0x88ca(%rip), %rdi      # 0x2123b
leaq 0x88cd(%rip), %rsi      # 0x21245
leaq 0x10(%rsp), %rbx
movq %rbx, %rdx
callq 0x19ed7
testl %eax, %eax
setne %al
movq (%rbx), %r14
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x188a0
cmpq $0x0, 0x8(%r14)
je 0x189db
cmpl $0x0, (%r14)
je 0x189db
addq $0x10, %r14
leaq 0x8a4f(%rip), %rbx      # 0x21402
leaq 0x18(%rsp), %r15
leaq 0xc(%rsp), %r12
movq (%r14), %r14
testq %r14, %r14
je 0x189f4
movq 0x8(%r14), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1a825
jmp 0x189bd
movq %r14, %rdi
callq 0x19d1e
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18a03
callq 0x19d1e
cmpl $0x0, 0x8(%rsp)
je 0x189e3
cmpl $0x0, 0xc(%rsp)
je 0x189e3
movb $0x2, (%r13)
jmp 0x189e3