// File: /workspace/github_c_makefile_star2_O1/Carton32[P]quectel-CM/QMIThread.c
// Function: requestSetupDataCall
static int requestSetupDataCall(PROFILE_T *profile, int curIpFamily) {
    PQCQMIMSG pRequest;
    PQCQMIMSG pResponse;
    PQMUX_MSG pMUXMsg;
    int err = 0;
    UCHAR QMIType = (curIpFamily == IpFamilyV4) ? QMUX_TYPE_WDS : QMUX_TYPE_WDS_IPV6;

//DualIPSupported means can get ipv4 & ipv6 address at the same time, one wds for ipv4, the other wds for ipv6
    profile->curIpFamily = curIpFamily;
    pRequest = ComposeQMUXMsg(QMIType, QMIWDS_START_NETWORK_INTERFACE_REQ, WdsStartNwInterfaceReq, profile);
    err = QmiThreadSendQMITimeout(pRequest, &pResponse, 120 * 1000, __func__);
    qmi_rsp_check();

    if (le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult) || le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError)) {
        PQMI_TLV_HDR pTLVHdr;

        pTLVHdr = GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x10);
        if (pTLVHdr) {
            uint16_t *data16 = (uint16_t *)(pTLVHdr+1);
            uint16_t call_end_reason = le16_to_cpu(data16[0]);
            dbg_time("call_end_reason is %d", call_end_reason);
        }

        pTLVHdr = GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11);
        if (pTLVHdr) {
            uint16_t *data16 = (uint16_t *)(pTLVHdr+1);
            uint16_t call_end_reason_type = le16_to_cpu(data16[0]);
            uint16_t verbose_call_end_reason  = le16_to_cpu(data16[1]);

            dbg_time("call_end_reason_type is %d", call_end_reason_type);
            dbg_time("call_end_reason_verbose is %d", verbose_call_end_reason);
        }

        free(pResponse);
        return le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError);
    }

    if (curIpFamily == IpFamilyV4) {
        WdsConnectionIPv4Handle = le32_to_cpu(pResponse->MUXMsg.StartNwInterfaceResp.Handle);
        dbg_time("%s WdsConnectionIPv4Handle: 0x%08x", __func__, WdsConnectionIPv4Handle);
    } else {
        WdsConnectionIPv6Handle = le32_to_cpu(pResponse->MUXMsg.StartNwInterfaceResp.Handle);
        dbg_time("%s WdsConnectionIPv6Handle: 0x%08x", __func__, WdsConnectionIPv6Handle);
    }

    free(pResponse);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %rcx
xorl %edi, %edi
cmpl $0x4, %esi
setne %dil
movl %esi, 0x116(%rcx)
shll $0x4, %edi
incl %edi
leaq 0x1b67(%rip), %rdx      # 0xe667
movl $0x20, %esi
callq 0xda86
leaq 0x1401f(%rip), %rcx     # 0x20b30
movq %rsp, %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x1d4c0, %edx          # imm = 0x1D4C0
callq 0xa317
movl %eax, %ebp
testl %eax, %eax
sets %al
movq (%r14), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xcba3
movq 0x1d47e(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
leaq 0x13c34(%rip), %rsi     # 0x20785
leaq 0x13fd8(%rip), %rcx     # 0x20b30
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1e139(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xcdd5
callq 0xeb2f
leaq 0x13bfe(%rip), %rsi     # 0x20785
leaq 0x13fa2(%rip), %rcx     # 0x20b30
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xcdd5
movzwl 0x10(%r12), %edi
callq 0xef61
testw %ax, %ax
jne 0xcbc7
movzwl 0x12(%r12), %edi
callq 0xef61
testw %ax, %ax
je 0xcc5a
movzwl 0x12(%r12), %edi
callq 0xef61
movl %eax, %ebp
movq 0x1d3e5(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xef61
movzwl %ax, %r8d
movzwl %bp, %ebp
leaq 0x13b98(%rip), %rsi     # 0x20797
leaq 0x13f2a(%rip), %rcx     # 0x20b30
movq %r14, %rdi
movq %r15, %rdx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1e08b(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xcc5a
callq 0xeb2f
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xef61
movzwl %ax, %r8d
leaq 0x13b54(%rip), %rsi     # 0x20797
leaq 0x13ee6(%rip), %rcx     # 0x20b30
movq %r14, %rdi
movq %r15, %rdx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
movzwl 0x10(%r12), %edi
callq 0xef61
testw %ax, %ax
jne 0xcc7e
movzwl 0x12(%r12), %edi
callq 0xef61
testw %ax, %ax
je 0xcde6
movq (%rsp), %rdi
addq $0x9, %rdi
movl $0x10, %esi
callq 0xa29c
testq %rax, %rax
je 0xccf2
movzwl 0x3(%rax), %edi
callq 0xef61
movl %eax, %ebx
movq 0x1d319(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
movzwl %bx, %ebx
leaq 0x13e8c(%rip), %rsi     # 0x20b45
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x1dfd9(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xccf2
callq 0xeb2f
leaq 0x13e62(%rip), %rsi     # 0x20b45
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x52c0
movq (%rsp), %rdi
addq $0x9, %rdi
movl $0x11, %esi
callq 0xa29c
testq %rax, %rax
je 0xcdbe
movq %rax, %rbx
movzwl 0x3(%rax), %edi
callq 0xef61
movl %eax, %ebp
movzwl 0x5(%rbx), %edi
callq 0xef61
movl %eax, %ebx
movq 0x1d293(%rip), %r15     # 0x29fc0
movq (%r15), %r14
callq 0xeb2f
movzwl %bp, %ebp
leaq 0x13e22(%rip), %rsi     # 0x20b61
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x1df53(%rip), %r13     # 0x2aca8
movq (%r13), %r14
testq %r14, %r14
je 0xcd79
callq 0xeb2f
leaq 0x13df7(%rip), %rsi     # 0x20b61
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
movq (%r15), %r14
callq 0xeb2f
movzwl %bx, %ebx
leaq 0x13df7(%rip), %rsi     # 0x20b82
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r14
testq %r14, %r14
je 0xcdbe
callq 0xeb2f
leaq 0x13dd3(%rip), %rsi     # 0x20b82
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x52c0
movq (%rsp), %rdi
callq 0x5040
movzwl 0x12(%r12), %edi
callq 0xef61
movzwl %ax, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rsp), %rax
movl 0x17(%rax), %edi
callq 0xef64
cmpl $0x4, %ebx
jne 0xce56
movl %eax, 0x1de3f(%rip)     # 0x2ac3c
movq 0x1d1bc(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
movl 0x1de29(%rip), %r8d     # 0x2ac3c
leaq 0x13d8c(%rip), %rsi     # 0x20ba6
leaq 0x13d0f(%rip), %rcx     # 0x20b30
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1de73(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xcec3
callq 0xeb2f
movl 0x1ddef(%rip), %r8d     # 0x2ac3c
leaq 0x13d52(%rip), %rsi     # 0x20ba6
jmp 0xceaf
movl %eax, 0x1dde4(%rip)     # 0x2ac40
movq 0x1d15d(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
movl 0x1ddce(%rip), %r8d     # 0x2ac40
leaq 0x13d56(%rip), %rsi     # 0x20bcf
leaq 0x13cb0(%rip), %rcx     # 0x20b30
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1de14(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xcec3
callq 0xeb2f
movl 0x1dd98(%rip), %r8d     # 0x2ac40
leaq 0x13d20(%rip), %rsi     # 0x20bcf
leaq 0x13c7a(%rip), %rcx     # 0x20b30
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movq (%rsp), %rdi
callq 0x5040
xorl %ebp, %ebp
jmp 0xcdd5