// File: /workspace/github_c_makefile_star2_O3/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 0x1b4f(%rip), %rdx      # 0xe570
movl $0x20, %esi
callq 0xd9a2
leaq 0x140fa(%rip), %rcx     # 0x20b2c
movq %rsp, %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x1d4c0, %edx          # imm = 0x1D4C0
callq 0xa273
movl %eax, %ebp
testl %eax, %eax
sets %al
movq (%r14), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xcac4
movq 0x1d55d(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
leaq 0x13d0f(%rip), %rsi     # 0x20781
leaq 0x140b3(%rip), %rcx     # 0x20b2c
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1e218(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xccf6
callq 0xea3b
leaq 0x13cd9(%rip), %rsi     # 0x20781
leaq 0x1407d(%rip), %rcx     # 0x20b2c
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xccf6
movzwl 0x10(%r12), %edi
callq 0xee73
testw %ax, %ax
jne 0xcae8
movzwl 0x12(%r12), %edi
callq 0xee73
testw %ax, %ax
je 0xcb7b
movzwl 0x12(%r12), %edi
callq 0xee73
movl %eax, %ebp
movq 0x1d4c4(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xee73
movzwl %ax, %r8d
movzwl %bp, %ebp
leaq 0x13c73(%rip), %rsi     # 0x20793
leaq 0x14005(%rip), %rcx     # 0x20b2c
movq %r14, %rdi
movq %r15, %rdx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1e16a(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xcb7b
callq 0xea3b
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xee73
movzwl %ax, %r8d
leaq 0x13c2f(%rip), %rsi     # 0x20793
leaq 0x13fc1(%rip), %rcx     # 0x20b2c
movq %r14, %rdi
movq %r15, %rdx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
movzwl 0x10(%r12), %edi
callq 0xee73
testw %ax, %ax
jne 0xcb9f
movzwl 0x12(%r12), %edi
callq 0xee73
testw %ax, %ax
je 0xcd07
movq (%rsp), %rdi
addq $0x9, %rdi
movl $0x10, %esi
callq 0xa1f8
testq %rax, %rax
je 0xcc13
movzwl 0x3(%rax), %edi
callq 0xee73
movl %eax, %ebx
movq 0x1d3f8(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
movzwl %bx, %ebx
leaq 0x13f67(%rip), %rsi     # 0x20b41
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x1e0b8(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xcc13
callq 0xea3b
leaq 0x13f3d(%rip), %rsi     # 0x20b41
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x52c0
movq (%rsp), %rdi
addq $0x9, %rdi
movl $0x11, %esi
callq 0xa1f8
testq %rax, %rax
je 0xccdf
movq %rax, %rbx
movzwl 0x3(%rax), %edi
callq 0xee73
movl %eax, %ebp
movzwl 0x5(%rbx), %edi
callq 0xee73
movl %eax, %ebx
movq 0x1d372(%rip), %r15     # 0x29fc0
movq (%r15), %r14
callq 0xea3b
movzwl %bp, %ebp
leaq 0x13efd(%rip), %rsi     # 0x20b5d
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x1e032(%rip), %r13     # 0x2aca8
movq (%r13), %r14
testq %r14, %r14
je 0xcc9a
callq 0xea3b
leaq 0x13ed2(%rip), %rsi     # 0x20b5d
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
movq (%r15), %r14
callq 0xea3b
movzwl %bx, %ebx
leaq 0x13ed2(%rip), %rsi     # 0x20b7e
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r14
testq %r14, %r14
je 0xccdf
callq 0xea3b
leaq 0x13eae(%rip), %rsi     # 0x20b7e
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x52c0
movq (%rsp), %rdi
callq 0x5040
movzwl 0x12(%r12), %edi
callq 0xee73
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 0xee76
cmpl $0x4, %ebx
jne 0xcd77
movl %eax, 0x1df1e(%rip)     # 0x2ac3c
movq 0x1d29b(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
movl 0x1df08(%rip), %r8d     # 0x2ac3c
leaq 0x13e67(%rip), %rsi     # 0x20ba2
leaq 0x13dea(%rip), %rcx     # 0x20b2c
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1df52(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xcde4
callq 0xea3b
movl 0x1dece(%rip), %r8d     # 0x2ac3c
leaq 0x13e2d(%rip), %rsi     # 0x20ba2
jmp 0xcdd0
movl %eax, 0x1dec3(%rip)     # 0x2ac40
movq 0x1d23c(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
movl 0x1dead(%rip), %r8d     # 0x2ac40
leaq 0x13e31(%rip), %rsi     # 0x20bcb
leaq 0x13d8b(%rip), %rcx     # 0x20b2c
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1def3(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xcde4
callq 0xea3b
movl 0x1de77(%rip), %r8d     # 0x2ac40
leaq 0x13dfb(%rip), %rsi     # 0x20bcb
leaq 0x13d55(%rip), %rcx     # 0x20b2c
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movq (%rsp), %rdi
callq 0x5040
xorl %ebp, %ebp
jmp 0xccf6