// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl 0x142a5(%rip), %eax     # 0x39108
movl %eax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
cmpl $0x0, 0x14291(%rip)     # 0x3910c
jne 0x24eaa
movl -0x38(%rbp), %edi
leaq -0x3c(%rbp), %rsi
callq 0x26790
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x24e9f
cmpl $0x0, -0x3c(%rbp)
je 0x24e9f
movq -0x10(%rbp), %rax
movb $0x2, (%rax)
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2505b
leaq 0xb659(%rip), %rdi      # 0x3050a
leaq 0xb392(%rip), %rsi      # 0x3024a
leaq -0x20(%rbp), %rdx
callq 0x27030
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x24ee5
cmpq $0x0, -0x20(%rbp)
je 0x24ee5
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x24ee5
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x24eea
jmp 0x2503c
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x24f53
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xb7c3(%rip), %rsi      # 0x306cf
leaq -0x30(%rbp), %rdx
leaq -0x34(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
leaq -0x2c(%rbp), %r9
movb $0x0, %al
callq 0x28860
movl %eax, -0x18(%rbp)
cmpl $0x4, -0x18(%rbp)
jne 0x24f35
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
je 0x24f37
jmp 0x24f46
cmpl $0x1, -0x30(%rbp)
je 0x24f44
movl $0x0, -0x30(%rbp)
jmp 0x24f46
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x24ef6
cmpq $0x0, -0x20(%rbp)
je 0x24f6b
movq -0x20(%rbp), %rdi
callq 0x26d20
movq $0x0, -0x20(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x24f77
cmpl $0x0, -0x2c(%rbp)
jne 0x24f7c
jmp 0x2503c
leaq 0xb518(%rip), %rdi      # 0x3049b
leaq 0xb51b(%rip), %rsi      # 0x304a5
leaq -0x20(%rbp), %rdx
callq 0x27030
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jne 0x24fb7
cmpq $0x0, -0x20(%rbp)
je 0x24fb7
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x24fb7
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x24fbc
jmp 0x2503c
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x2500f
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xb6f5(%rip), %rsi      # 0x306d3
leaq -0x34(%rbp), %rdx
leaq -0x2c(%rbp), %rcx
movb $0x0, %al
callq 0x28860
movl %eax, -0x18(%rbp)
cmpl $0x2, -0x18(%rbp)
jne 0x24ffe
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
je 0x25000
jmp 0x25002
jmp 0x25002
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x24fc8
cmpq $0x0, -0x20(%rbp)
je 0x25027
movq -0x20(%rbp), %rdi
callq 0x26d20
movq $0x0, -0x20(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x2503a
cmpl $0x0, -0x2c(%rbp)
je 0x2503a
movq -0x10(%rbp), %rax
movb $0x2, (%rax)
jmp 0x2503c
cmpq $0x0, -0x20(%rbp)
je 0x25054
movq -0x20(%rbp), %rdi
callq 0x26d20
movq $0x0, -0x20(%rbp)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)