// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/atc.c
// Function: requestSetupDataCall
static int requestSetupDataCall(PROFILE_T *profile, int curIpFamily) {
    int err;
    ATResponse *p_response = NULL;
    char *cmd = NULL;
    ATLine *p_cur = NULL;
    int pdp = profile->pdp;
    int state = 0;

    (void)curIpFamily;

    if (strStartsWith(profile->BaseBandVersion, "RG801H") || strStartsWith(profile->BaseBandVersion, "EC200H")) {
        //RG801H will miss USB_CDC_NOTIFY_NETWORK_CONNECTION
        asprintf(&cmd, "ifconfig %s up", profile->usbnet_adapter);
        if (system(cmd)) {};
        safe_free(cmd);
    }

    if (asr_style_atc) {
        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) {
            int cid = 0;

            err = at_tok_scanf(p_cur->line, "%d%d", &cid, &state);
            if (err != 2 || cid != pdp)
                continue;
        }
        safe_at_response_free(p_response);

        if (state == 0) {
            asprintf(&cmd, "AT+CGACT=1,%d", pdp);
            err = at_send_command(cmd, &p_response);
            safe_free(cmd);
            if (at_response_error(err, p_response))
                goto _error;
        }
    }

    if(asr_style_atc)
        asprintf(&cmd, "AT+QNETDEVCTL=1,%d,%d", pdp, 1);
    else
        asprintf(&cmd, "AT+QNETDEVCTL=%d,1,%d", pdp, 1);
    err = at_send_command(cmd, &p_response);
    safe_free(cmd);

    if (at_response_error(err, p_response))
        goto _error;

    if (!asr_style_atc) { //TODO some modems do not sync return setup call resule
        int t = 0;

        while (t++ < 15) {
            asprintf(&cmd, "AT+QNETDEVSTATUS=%d", pdp);
            err = at_send_command_singleline(cmd, "+QNETDEVSTATUS", &p_response);
            safe_free(cmd);
            if (err) goto _error;

            if (!at_response_error(err, p_response)) {
                break;
            }
            safe_at_response_free(p_response);
            sleep(1);
        }
    }

    //some modem do not report URC
    qmidevice_send_event_to_main(RIL_UNSOL_DATA_CALL_LIST_CHANGED);

_error:
    safe_at_response_free(p_response);
    //dbg_time("%s err=%d", __func__, err);
    return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rdi
addq $0x216, %rdi            # imm = 0x216
leaq 0xb974(%rip), %rsi      # 0x3047e
callq 0x26a30
cmpl $0x0, %eax
jne 0x24b30
movq -0x8(%rbp), %rdi
addq $0x216, %rdi            # imm = 0x216
leaq 0xb95f(%rip), %rsi      # 0x30485
callq 0x26a30
cmpl $0x0, %eax
je 0x24b7b
movq -0x8(%rbp), %rdx
addq $0xaa, %rdx
leaq -0x20(%rbp), %rdi
leaq 0xb946(%rip), %rsi      # 0x3048c
movb $0x0, %al
callq 0x53c0
movq -0x20(%rbp), %rdi
callq 0x5170
cmpl $0x0, %eax
je 0x24b5d
jmp 0x24b5d
jmp 0x24b5f
cmpq $0x0, -0x20(%rbp)
je 0x24b77
movq -0x20(%rbp), %rdi
callq 0x5040
movq $0x0, -0x20(%rbp)
jmp 0x24b79
jmp 0x24b7b
cmpl $0x0, 0x1458a(%rip)     # 0x3910c
je 0x24ca9
leaq 0xb90c(%rip), %rdi      # 0x3049b
leaq 0xb90f(%rip), %rsi      # 0x304a5
leaq -0x18(%rbp), %rdx
callq 0x27030
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jne 0x24bc3
cmpq $0x0, -0x18(%rbp)
je 0x24bc3
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x24bc3
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x24bc8
jmp 0x24e04
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x24c22
movl $0x0, -0x34(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xbae2(%rip), %rsi      # 0x306d3
leaq -0x34(%rbp), %rdx
leaq -0x30(%rbp), %rcx
movb $0x0, %al
callq 0x28860
movl %eax, -0x10(%rbp)
cmpl $0x2, -0x10(%rbp)
jne 0x24c11
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
je 0x24c13
jmp 0x24c15
jmp 0x24c15
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x24bd4
cmpq $0x0, -0x18(%rbp)
je 0x24c3a
movq -0x18(%rbp), %rdi
callq 0x26d20
movq $0x0, -0x18(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x24ca7
movl -0x2c(%rbp), %edx
leaq -0x20(%rbp), %rdi
leaq 0xb85f(%rip), %rsi      # 0x304ad
movb $0x0, %al
callq 0x53c0
movq -0x20(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x26d90
movl %eax, -0x10(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x24c7d
movq -0x20(%rbp), %rdi
callq 0x5040
movq $0x0, -0x20(%rbp)
jmp 0x24c7f
cmpl $0x0, -0x10(%rbp)
jne 0x24ca0
cmpq $0x0, -0x18(%rbp)
je 0x24ca0
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x24ca0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x24ca5
jmp 0x24e04
jmp 0x24ca7
jmp 0x24ca9
cmpl $0x0, 0x1445c(%rip)     # 0x3910c
je 0x24cce
movl -0x2c(%rbp), %edx
leaq -0x20(%rbp), %rdi
leaq 0xb7fb(%rip), %rsi      # 0x304bb
movl $0x1, %ecx
movb $0x0, %al
callq 0x53c0
jmp 0x24ce8
movl -0x2c(%rbp), %edx
leaq -0x20(%rbp), %rdi
leaq 0xb7f5(%rip), %rsi      # 0x304d1
movl $0x1, %ecx
movb $0x0, %al
callq 0x53c0
movq -0x20(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x26d90
movl %eax, -0x10(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x24d10
movq -0x20(%rbp), %rdi
callq 0x5040
movq $0x0, -0x20(%rbp)
jmp 0x24d12
cmpl $0x0, -0x10(%rbp)
jne 0x24d33
cmpq $0x0, -0x18(%rbp)
je 0x24d33
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x24d33
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x24d38
jmp 0x24e04
cmpl $0x0, 0x143cd(%rip)     # 0x3910c
jne 0x24dfa
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x38(%rbp)
cmpl $0xf, %eax
jge 0x24df8
movl -0x2c(%rbp), %edx
leaq -0x20(%rbp), %rdi
leaq 0xb779(%rip), %rsi      # 0x304e7
movb $0x0, %al
callq 0x53c0
movq -0x20(%rbp), %rdi
leaq 0xb77b(%rip), %rsi      # 0x304fb
leaq -0x18(%rbp), %rdx
callq 0x26e80
movl %eax, -0x10(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x24da4
movq -0x20(%rbp), %rdi
callq 0x5040
movq $0x0, -0x20(%rbp)
jmp 0x24da6
cmpl $0x0, -0x10(%rbp)
je 0x24dae
jmp 0x24e04
cmpl $0x0, -0x10(%rbp)
jne 0x24dd1
cmpq $0x0, -0x18(%rbp)
je 0x24dd1
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x24dd1
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x24dd1
jmp 0x24df8
cmpq $0x0, -0x18(%rbp)
je 0x24de9
movq -0x18(%rbp), %rdi
callq 0x26d20
movq $0x0, -0x18(%rbp)
movl $0x1, %edi
callq 0x5550
jmp 0x24d4c
jmp 0x24dfa
movl $0x1005, %edi           # imm = 0x1005
callq 0x8240
cmpq $0x0, -0x18(%rbp)
je 0x24e1c
movq -0x18(%rbp), %rdi
callq 0x26d20
movq $0x0, -0x18(%rbp)
movl -0x10(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)