// File: /workspace/github_c_makefile_star2_O1/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
movq %rdi, %rbx
xorl %eax, %eax
movb %al, 0x2d6(%rdi)
movb %al, 0x296(%rdi)
movb %al, 0x256(%rdi)
movq $0x0, 0x316(%rdi)
cmpb %al, 0x50(%rdi)
je 0xba18
cmpb $0x0, 0x51(%rbx)
je 0xba18
movl $0x3, 0x1c(%rbx)
jmp 0xba2e
cmpb $0x0, 0x51(%rbx)
je 0xba27
movl $0x2, 0x1c(%rbx)
jmp 0xba2e
movl $0x0, 0x1c(%rbx)
cmpl $0x0, 0x48(%rbx)
je 0xbc0c
leaq 0x28da(%rip), %rdx      # 0xe319
movl $0x1, %edi
movl $0x2b, %esi
movq %rbx, %rcx
callq 0xda86
leaq 0x14fc5(%rip), %rcx     # 0x20a1d
leaq 0x8(%rsp), %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0xa317
movl %eax, %ebp
testl %eax, %eax
sete %cl
movq (%r14), %rax
testq %rax, %rax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0xbb8d
movzwl 0x10(%rax), %edi
callq 0xef61
testw %ax, %ax
je 0xbb8d
leaq 0x28bd(%rip), %r14      # 0xe35e
leaq 0x14f75(%rip), %r15     # 0x20a1d
leaq 0x8(%rsp), %r12
movq 0x8(%rsp), %rax
movzwl 0x12(%rax), %edi
callq 0xef61
cmpw $0x51, %ax
jne 0xbb8d
movq 0x8(%rsp), %rdi
callq 0x5040
movl $0x1, %edi
movl $0x27, %esi
movq %r14, %rdx
movq %rbx, %rcx
callq 0xda86
movq %rax, %rdi
movq %r12, %rsi
movl $0x7530, %edx           # imm = 0x7530
movq %r15, %rcx
callq 0xa317
movl %eax, %ebp
testl %eax, %eax
js 0xbba4
movq 0x8(%rsp), %r13
testq %r13, %r13
je 0xbba4
movzwl 0x10(%r13), %edi
callq 0xef61
testw %ax, %ax
jne 0xbca9
movzwl 0x12(%r13), %edi
callq 0xef61
testw %ax, %ax
jne 0xbca9
movq 0x8(%rsp), %rdi
callq 0x5040
movl $0x1, %edi
movl $0x2b, %esi
leaq 0x27c9(%rip), %rdx      # 0xe319
movq %rbx, %rcx
callq 0xda86
movq %rax, %rdi
movq %r12, %rsi
movl $0x7530, %edx           # imm = 0x7530
movq %r15, %rcx
callq 0xa317
movl %eax, %ebp
testl %eax, %eax
jne 0xbb8d
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0xbb8d
movzwl 0x10(%rax), %edi
callq 0xef61
testw %ax, %ax
jne 0xbaad
testl %ebp, %ebp
sets %al
movq 0x8(%rsp), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xbc13
movq 0x1e415(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
leaq 0x14bcb(%rip), %rsi     # 0x20785
leaq 0x14e5c(%rip), %rcx     # 0x20a1d
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1f0d0(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xbd43
callq 0xeb2f
leaq 0x14b95(%rip), %rsi     # 0x20785
leaq 0x14e26(%rip), %rcx     # 0x20a1d
movq %rbx, %rdi
movq %rax, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xbd43
xorl %ebp, %ebp
jmp 0xbd43
movzwl 0x10(%r12), %edi
callq 0xef61
testw %ax, %ax
jne 0xbc37
movzwl 0x12(%r12), %edi
callq 0xef61
testw %ax, %ax
je 0xbd54
movzwl 0x12(%r12), %edi
callq 0xef61
movl %eax, %ebx
movq 0x1e375(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xef61
movzwl %ax, %r8d
movzwl %bx, %ebp
leaq 0x14b28(%rip), %rsi     # 0x20797
leaq 0x14da7(%rip), %rcx     # 0x20a1d
movq %r14, %rdi
movq %r15, %rdx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1f01b(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xbd39
callq 0xeb2f
movq %rax, %r14
movzwl 0x10(%r12), %edi
jmp 0xbd12
movzwl 0x12(%r13), %edi
callq 0xef61
movl %eax, %ebx
movq 0x1e304(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
movq %rax, %r15
movzwl 0x10(%r13), %edi
callq 0xef61
movzwl %ax, %r8d
movzwl %bx, %ebp
leaq 0x14ab8(%rip), %rsi     # 0x20797
leaq 0x14d37(%rip), %rcx     # 0x20a1d
movq %r14, %rdi
movq %r15, %rdx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1efab(%rip), %rax     # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0xbd39
callq 0xeb2f
movq %rax, %r14
movzwl 0x10(%r13), %edi
callq 0xef61
movzwl %ax, %r8d
leaq 0x14a75(%rip), %rsi     # 0x20797
leaq 0x14cf4(%rip), %rcx     # 0x20a1d
movq %rbx, %rdi
movq %r14, %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 0xa29c
movq %rax, %r15
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x1b, %esi
callq 0xa29c
movq %rax, %r14
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x1c, %esi
callq 0xa29c
movq %rax, %rbp
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x1d, %esi
callq 0xa29c
movq %rax, 0x20(%rsp)
movq 0x8(%rsp), %rdi
addq $0x9, %rdi
movl $0x11, %esi
callq 0xa29c
movq %rax, 0x18(%rsp)
testq %r15, %r15
je 0xbe09
movzwl 0x1(%r15), %edi
callq 0xef61
cmpw $0x3f, %ax
movl $0x3f, %ecx
cmovbl %eax, %ecx
movzwl %cx, %r12d
testw %ax, %ax
je 0xbe03
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 0xbe4b
movzwl 0x1(%r14), %edi
callq 0xef61
cmpw $0x3f, %ax
movl $0x3f, %ecx
cmovbl %eax, %ecx
movzwl %cx, %r12d
testw %ax, %ax
je 0xbe46
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 0xbe8c
movzwl 0x1(%rbp), %edi
callq 0xef61
cmpw $0x3f, %ax
movl $0x3f, %ecx
cmovbl %eax, %ecx
movzwl %cx, %r12d
testw %ax, %ax
je 0xbe87
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 0xbea5
movzbl 0x3(%rax), %eax
movl %eax, 0x316(%rbx)
movq %r15, %r14
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0xbebc
movzbl 0x3(%rax), %eax
movl %eax, 0x31a(%rbx)
movq 0x1e0fd(%rip), %rax     # 0x29fc0
movq (%rax), %r12
callq 0xeb2f
movl 0x48(%rbx), %r8d
movl 0x316(%rbx), %r10d
movslq 0x31a(%rbx), %r11
leaq 0x1d51c(%rip), %r15     # 0x29400
leaq 0x14ae1(%rip), %rsi     # 0x209cc
leaq 0x14b2b(%rip), %rcx     # 0x20a1d
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 0x1ed8a(%rip), %rax     # 0x2aca8
movq (%rax), %r12
testq %r12, %r12
je 0xbd39
callq 0xeb2f
movl 0x48(%rbx), %r8d
movl 0x316(%rbx), %r10d
movslq 0x31a(%rbx), %r11
leaq 0x14a84(%rip), %rsi     # 0x209cc
leaq 0x14ace(%rip), %rcx     # 0x20a1d
movq %r12, %rdi
movq %rax, %rdx
movq %r13, %r9
xorl %eax, %eax
leaq 0x1d49f(%rip), %rbx     # 0x29400
pushq (%rbx,%r11,8)
pushq %r10
pushq %r15
pushq %r14
callq 0x52c0
addq $0x20, %rsp
jmp 0xbd39