// File: /workspace/github_c_makefile_star2_O2/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 0x18d8(%rip), %rdx      # 0xdecb
pushq $0x20
popq %rsi
callq 0xd53c
leaq 0x12540(%rip), %rcx     # 0x1eb42
movq %rsp, %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x1d4c0, %edx          # imm = 0x1D4C0
callq 0x9e8b
movl %eax, %ebp
testl %eax, %eax
sets %al
movq (%r14), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xc694
movq 0x1c985(%rip), %rax     # 0x28fb8
movq (%rax), %rbx
callq 0xe343
leaq 0x1213f(%rip), %rsi     # 0x1e781
leaq 0x124f9(%rip), %rcx     # 0x1eb42
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1d648(%rip), %rax     # 0x29ca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xc8c2
callq 0xe343
leaq 0x12109(%rip), %rsi     # 0x1e781
leaq 0x124c3(%rip), %rcx     # 0x1eb42
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xc8c2
movzwl 0x10(%r12), %edi
callq 0xe73e
testw %ax, %ax
jne 0xc6b8
movzwl 0x12(%r12), %edi
callq 0xe73e
testw %ax, %ax
je 0xc74b
movzwl 0x12(%r12), %edi
callq 0xe73e
movl %eax, %ebp
movq 0x1c8ec(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xe73e
movzwl %ax, %r8d
movzwl %bp, %ebp
leaq 0x120a3(%rip), %rsi     # 0x1e793
leaq 0x1244b(%rip), %rcx     # 0x1eb42
movq %r14, %rdi
movq %r15, %rdx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1d59a(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xc74b
callq 0xe343
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xe73e
movzwl %ax, %r8d
leaq 0x1205f(%rip), %rsi     # 0x1e793
leaq 0x12407(%rip), %rcx     # 0x1eb42
movq %r14, %rdi
movq %r15, %rdx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
movzwl 0x10(%r12), %edi
callq 0xe73e
testw %ax, %ax
jne 0xc76f
movzwl 0x12(%r12), %edi
callq 0xe73e
testw %ax, %ax
je 0xc8d3
movq (%rsp), %rdi
addq $0x9, %rdi
pushq $0x10
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xc7e1
movzwl 0x3(%rax), %edi
callq 0xe73e
movl %eax, %ebx
movq 0x1c822(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
movzwl %bx, %ebx
leaq 0x123af(%rip), %rsi     # 0x1eb57
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x1d4ea(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xc7e1
callq 0xe343
leaq 0x12385(%rip), %rsi     # 0x1eb57
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x52c0
movq (%rsp), %rdi
addq $0x9, %rdi
pushq $0x11
popq %rsi
callq 0x9e14
testq %rax, %rax
je 0xc8ab
movq %rax, %rbx
movzwl 0x3(%rax), %edi
callq 0xe73e
movl %eax, %ebp
movzwl 0x5(%rbx), %edi
callq 0xe73e
movl %eax, %ebx
movq 0x1c79e(%rip), %r15     # 0x28fb8
movq (%r15), %r14
callq 0xe343
movzwl %bp, %ebp
leaq 0x12347(%rip), %rsi     # 0x1eb73
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
leaq 0x1d466(%rip), %r13     # 0x29ca8
movq (%r13), %r14
testq %r14, %r14
je 0xc866
callq 0xe343
leaq 0x1231c(%rip), %rsi     # 0x1eb73
movq %r14, %rdi
movq %rax, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x52c0
movq (%r15), %r14
callq 0xe343
movzwl %bx, %ebx
leaq 0x1231c(%rip), %rsi     # 0x1eb94
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x52c0
movq (%r13), %r14
testq %r14, %r14
je 0xc8ab
callq 0xe343
leaq 0x122f8(%rip), %rsi     # 0x1eb94
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x52c0
movq (%rsp), %rdi
callq 0x5040
movzwl 0x12(%r12), %edi
callq 0xe73e
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 0xe741
cmpl $0x4, %ebx
jne 0xc943
movl %eax, 0x1d352(%rip)     # 0x29c3c
movq 0x1c6c7(%rip), %rax     # 0x28fb8
movq (%rax), %rbx
callq 0xe343
movl 0x1d33c(%rip), %r8d     # 0x29c3c
leaq 0x122b1(%rip), %rsi     # 0x1ebb8
leaq 0x12234(%rip), %rcx     # 0x1eb42
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1d386(%rip), %rax     # 0x29ca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xc9b0
callq 0xe343
movl 0x1d302(%rip), %r8d     # 0x29c3c
leaq 0x12277(%rip), %rsi     # 0x1ebb8
jmp 0xc99c
movl %eax, 0x1d2f7(%rip)     # 0x29c40
movq 0x1c668(%rip), %rax     # 0x28fb8
movq (%rax), %rbx
callq 0xe343
movl 0x1d2e1(%rip), %r8d     # 0x29c40
leaq 0x1227b(%rip), %rsi     # 0x1ebe1
leaq 0x121d5(%rip), %rcx     # 0x1eb42
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1d327(%rip), %rax     # 0x29ca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xc9b0
callq 0xe343
movl 0x1d2ab(%rip), %r8d     # 0x29c40
leaq 0x12245(%rip), %rsi     # 0x1ebe1
leaq 0x1219f(%rip), %rcx     # 0x1eb42
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
movq (%rsp), %rdi
callq 0x5040
xorl %ebp, %ebp
jmp 0xc8c2