// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/QMIThread.c
// Function: requestGetProfile
static int requestGetProfile(PROFILE_T *profile) {
    PQCQMIMSG pRequest;
    PQCQMIMSG pResponse;
    PQMUX_MSG pMUXMsg;
    int err;
    PQMIWDS_APNNAME pApnName;
    PQMIWDS_USERNAME pUserName;
    PQMIWDS_PASSWD pPassWd;
    PQMIWDS_AUTH_PREFERENCE pAuthPref;
    PQMIWDS_IPTYPE pIpType;
    const char *ipStr[] = {"IPV4", "NULL", "IPV6", "IPV4V6"};

    profile->old_apn[0] = profile->old_user[0] = profile->old_password[0] = '\0';
    profile->old_auth = 0;
    profile->old_iptype = 0;
    if (profile->enable_ipv4 && profile->enable_ipv6)
        profile->iptype = 3;
    else if (profile->enable_ipv6)
        profile->iptype = 2;
    else
        profile->iptype = 0;

    if (!profile->pdp)
        return 0;

_re_check:
    pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_GET_PROFILE_SETTINGS_REQ, WdsGetProfileSettingsReqSend, profile);
    err = QmiThreadSendQMI(pRequest, &pResponse);
    if (err == 0 && pResponse && le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.QMUXResult)
        && le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.QMUXError) == QMI_ERR_EXTENDED_INTERNAL)
    {
        free(pResponse);
        pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_CREATE_PROFILE_REQ, WdsCreateProfileSettingsReqSend, profile);
        err = QmiThreadSendQMI(pRequest, &pResponse);
        qmi_rsp_check_and_return();
        free(pResponse);
        goto _re_check;
    }
    qmi_rsp_check_and_return();

    pApnName = (PQMIWDS_APNNAME)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x14);
    pUserName = (PQMIWDS_USERNAME)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1B);
    pPassWd = (PQMIWDS_PASSWD)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1C);
    pAuthPref = (PQMIWDS_AUTH_PREFERENCE)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1D);
    pIpType = (PQMIWDS_IPTYPE)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11);

    if (pApnName/* && le16_to_cpu(pApnName->TLVLength)*/)
        uchar2char(profile->old_apn, sizeof(profile->old_apn), &pApnName->ApnName, le16_to_cpu(pApnName->TLVLength));
    if (pUserName/*  && pUserName->UserName*/)
        uchar2char(profile->old_user, sizeof(profile->old_user), &pUserName->UserName, le16_to_cpu(pUserName->TLVLength));
    if (pPassWd/*  && le16_to_cpu(pPassWd->TLVLength)*/)
        uchar2char(profile->old_password, sizeof(profile->old_password), &pPassWd->Passwd, le16_to_cpu(pPassWd->TLVLength));
    if (pAuthPref/*  && le16_to_cpu(pAuthPref->TLVLength)*/) {
        profile->old_auth = pAuthPref->AuthPreference;
    }
    if (pIpType) {
        profile->old_iptype = pIpType->IPType;
    }

    dbg_time("%s[%d] %s/%s/%s/%d/%s", __func__, profile->pdp, profile->old_apn, profile->old_user, profile->old_password, profile->old_auth, ipStr[profile->old_iptype]);

    free(pResponse);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorl %ebp, %ebp
movb %bpl, 0x2d6(%rdi)
movb %bpl, 0x296(%rdi)
movb %bpl, 0x256(%rdi)
movq $0x0, 0x316(%rdi)
cmpb $0x1, 0x50(%rdi)
movl $0x3, %eax
sbbl $0x0, %eax
cmpb %bpl, 0x51(%rdi)
cmovel %ebp, %eax
movl %eax, 0x1c(%rdi)
cmpl $0x0, 0x48(%rdi)
je 0xbc29
movq %rdi, %rbx
leaq 0x28c4(%rip), %rdx      # 0xe22b
movl $0x1, %edi
movl $0x2b, %esi
movq %rbx, %rcx
callq 0xd9a2
leaq 0x15099(%rip), %rcx     # 0x20a19
leaq 0x8(%rsp), %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0xa273
movl %eax, %ebp
testl %eax, %eax
sete %al
movq (%r14), %r14
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xbaae
leaq 0x28b9(%rip), %r15      # 0xe270
leaq 0x1505b(%rip), %r12     # 0x20a19
leaq 0x8(%rsp), %r13
movzwl 0x10(%r14), %edi
callq 0xee73
xorl %ebp, %ebp
movq 0x8(%rsp), %r14
testw %ax, %ax
je 0xbaae
movzwl 0x12(%r14), %edi
callq 0xee73
movq 0x8(%rsp), %r14
cmpw $0x51, %ax
jne 0xbaae
movq %r14, %rdi
callq 0x5040
movl $0x1, %edi
movl $0x27, %esi
movq %r15, %rdx
movq %rbx, %rcx
callq 0xd9a2
movq %rax, %rdi
movq %r13, %rsi
movl $0x7530, %edx           # imm = 0x7530
movq %r12, %rcx
callq 0xa273
movl %eax, %ebp
testl %eax, %eax
js 0xbac0
movq 0x8(%rsp), %r14
testq %r14, %r14
je 0xbac0
movzwl 0x10(%r14), %edi
callq 0xee73
testw %ax, %ax
jne 0xbb8f
movzwl 0x12(%r14), %edi
callq 0xee73
testw %ax, %ax
jne 0xbb8f
movq 0x8(%rsp), %rdi
callq 0x5040
movl $0x1, %edi
movl $0x2b, %esi
leaq 0x27ac(%rip), %rdx      # 0xe22b
movq %rbx, %rcx
callq 0xd9a2
movq %rax, %rdi
movq %r13, %rsi
movl $0x7530, %edx           # imm = 0x7530
movq %r12, %rcx
callq 0xa273
movl %eax, %ebp
movq 0x8(%rsp), %r14
testl %eax, %eax
jne 0xbaae
testq %r14, %r14
jne 0xb9c3
testl %ebp, %ebp
sets %al
testq %r14, %r14
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xbb28
movq 0x1e4f9(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
leaq 0x14cab(%rip), %rsi     # 0x20781
leaq 0x14f3c(%rip), %rcx     # 0x20a19
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1f1b4(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xbc29
callq 0xea3b
leaq 0x14c75(%rip), %rsi     # 0x20781
leaq 0x14f06(%rip), %rcx     # 0x20a19
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xbc29
movzwl 0x10(%r14), %edi
callq 0xee73
testw %ax, %ax
jne 0xbb4a
movzwl 0x12(%r14), %edi
callq 0xee73
testw %ax, %ax
je 0xbc3a
movzwl 0x12(%r14), %edi
callq 0xee73
movl %eax, %ebx
movq 0x1e463(%rip), %rax     # 0x29fc0
movq (%rax), %r15
callq 0xea3b
movq %rax, %r12
movzwl 0x10(%r14), %edi
callq 0xee73
movzwl %ax, %r8d
movzwl %bx, %ebp
leaq 0x14c13(%rip), %rsi     # 0x20793
leaq 0x14e92(%rip), %rcx     # 0x20a19
movq %r15, %rdi
movq %r12, %rdx
jmp 0xbbd2
movzwl 0x12(%r14), %edi
callq 0xee73
movl %eax, %ebx
movq 0x1e41e(%rip), %rax     # 0x29fc0
movq (%rax), %r12
callq 0xea3b
movq %rax, %r15
movzwl 0x10(%r14), %edi
callq 0xee73
movzwl %ax, %r8d
movzwl %bx, %ebp
leaq 0x14bce(%rip), %rsi     # 0x20793
leaq 0x14e4d(%rip), %rcx     # 0x20a19
movq %r12, %rdi
movq %r15, %rdx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1f0c5(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xbc1f
callq 0xea3b
movq %rax, %r15
movzwl 0x10(%r14), %edi
callq 0xee73
movzwl %ax, %r8d
leaq 0x14b8b(%rip), %rsi     # 0x20793
leaq 0x14e0a(%rip), %rcx     # 0x20a19
movq %rbx, %rdi
movq %r15, %rdx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x8(%rsp), %rdi
callq 0x5040
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x256(%rbx), %r13
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x14, %esi
callq 0xa1f8
movq %rax, %r15
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x1b, %esi
callq 0xa1f8
movq %rax, %r14
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x1c, %esi
callq 0xa1f8
movq %rax, %rbp
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x1d, %esi
callq 0xa1f8
movq %rax, 0x20(%rsp)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x11, %esi
callq 0xa1f8
movq %rax, 0x18(%rsp)
testq %r15, %r15
je 0xbcef
movzwl 0x1(%r15), %edi
callq 0xee73
cmpw $0x3f, %ax
movl $0x3f, %ecx
cmovbl %eax, %ecx
movzwl %cx, %r12d
testw %ax, %ax
je 0xbce9
addq $0x3, %r15
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x52f0
movb $0x0, (%r13,%r12)
leaq 0x296(%rbx), %r15
testq %r14, %r14
je 0xbd31
movzwl 0x1(%r14), %edi
callq 0xee73
cmpw $0x3f, %ax
movl $0x3f, %ecx
cmovbl %eax, %ecx
movzwl %cx, %r12d
testw %ax, %ax
je 0xbd2c
addq $0x3, %r14
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x52f0
movb $0x0, (%r15,%r12)
leaq 0x2d6(%rbx), %r14
testq %rbp, %rbp
je 0xbd72
movzwl 0x1(%rbp), %edi
callq 0xee73
cmpw $0x3f, %ax
movl $0x3f, %ecx
cmovbl %eax, %ecx
movzwl %cx, %r12d
testw %ax, %ax
je 0xbd6d
addq $0x3, %rbp
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x52f0
movb $0x0, (%r14,%r12)
movq %r14, 0x10(%rsp)
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0xbd8b
movzbl 0x3(%rax), %eax
movl %eax, 0x316(%rbx)
movq %r15, %r14
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0xbda2
movzbl 0x3(%rax), %eax
movl %eax, 0x31a(%rbx)
movq 0x1e217(%rip), %rax     # 0x29fc0
movq (%rax), %r12
callq 0xea3b
movl 0x48(%rbx), %r8d
movl 0x316(%rbx), %r10d
movslq 0x31a(%rbx), %r11
leaq 0x1d636(%rip), %r15     # 0x29400
leaq 0x14bf7(%rip), %rsi     # 0x209c8
leaq 0x14c41(%rip), %rcx     # 0x20a19
xorl %ebp, %ebp
movq %r12, %rdi
movq %rax, %rdx
movq %r13, %r9
xorl %eax, %eax
pushq (%r15,%r11,8)
pushq %r10
movq 0x20(%rsp), %r15
pushq %r15
pushq %r14
callq 0x52c0
addq $0x20, %rsp
leaq 0x1eea4(%rip), %rax     # 0x2aca8
movq (%rax), %r12
testq %r12, %r12
je 0xbc1f
callq 0xea3b
movl 0x48(%rbx), %r8d
movl 0x316(%rbx), %r10d
movslq 0x31a(%rbx), %r11
leaq 0x14b9a(%rip), %rsi     # 0x209c8
leaq 0x14be4(%rip), %rcx     # 0x20a19
movq %r12, %rdi
movq %rax, %rdx
movq %r13, %r9
xorl %eax, %eax
leaq 0x1d5b9(%rip), %rbx     # 0x29400
pushq (%rbx,%r11,8)
pushq %r10
pushq %r15
pushq %r14
callq 0x52c0
addq $0x20, %rsp
jmp 0xbc1f