// File: /workspace/github_c_makefile_star2_O1/Carton32[P]quectel-CM/QMIThread.c
// Function: requestSetProfile
static int requestSetProfile(PROFILE_T *profile) {
    PQCQMIMSG pRequest;
    PQCQMIMSG pResponse;
    PQMUX_MSG pMUXMsg;
    int err;
    const char *new_apn = profile->apn ? profile->apn : "";
    const char *new_user = profile->user ? profile->user : "";
    const char *new_password = profile->password ? profile->password : "";
    const char *ipStr[] = {"IPV4", "NULL", "IPV6", "IPV4V6"};

    dbg_time("%s[%d] %s/%s/%s/%d/%s", __func__, profile->pdp, profile->apn, profile->user, profile->password, profile->auth,ipStr[profile->iptype]);
    if (!profile->pdp)
        return 0;

    if ( !strcmp(profile->old_apn, new_apn) && !strcmp(profile->old_user, new_user)
        && !strcmp(profile->old_password, new_password)
        && profile->old_iptype == profile->iptype
        && profile->old_auth == profile->auth)
    {
        dbg_time("no need to set skip the rest");
        return 0;
    }

    pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_MODIFY_PROFILE_SETTINGS_REQ, WdsModifyProfileSettingsReq, profile);
    err = QmiThreadSendQMI(pRequest, &pResponse);
    qmi_rsp_check_and_return();

    free(pResponse);
#ifdef REBOOT_SIM_CARD_WHEN_APN_CHANGE //enable at only when customer asked 
    if (qmi_request_ops.requestRadioPower) {
        qmi_request_ops.requestRadioPower(0);
        qmi_request_ops.requestRadioPower(1);
    }
#endif
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
movq (%rdi), %r13
movq 0x8(%rdi), %r12
testq %r13, %r13
leaq 0x137e3(%rip), %rax     # 0x1eea5
cmoveq %rax, %r13
testq %r12, %r12
cmoveq %rax, %r12
movq 0x10(%rdi), %r15
testq %r15, %r15
cmoveq %rax, %r15
movq 0x1e8e1(%rip), %rax     # 0x29fc0
movq (%rax), %rbp
callq 0xeb2f
movl 0x48(%r14), %r8d
movq (%r14), %r9
movups 0x8(%r14), %xmm0
movl 0x18(%r14), %ecx
movslq 0x1c(%r14), %rdx
leaq 0x1dcfe(%rip), %rbx     # 0x29400
movq (%rbx,%rdx,8), %rdx
movq %rdx, 0x18(%rsp)
movl %ecx, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x152b2(%rip), %rsi     # 0x209cc
leaq 0x152c7(%rip), %rcx     # 0x209e8
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1f573(%rip), %rax     # 0x2aca8
movq (%rax), %rbp
testq %rbp, %rbp
je 0xb782
callq 0xeb2f
movl 0x48(%r14), %r8d
movq (%r14), %r9
movups 0x8(%r14), %xmm0
movl 0x18(%r14), %ecx
movslq 0x1c(%r14), %rdx
movq (%rbx,%rdx,8), %rdx
movq %rdx, 0x18(%rsp)
movl %ecx, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x1525e(%rip), %rsi     # 0x209cc
leaq 0x15273(%rip), %rcx     # 0x209e8
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
cmpl $0x0, 0x48(%r14)
je 0xb9c1
leaq 0x256(%r14), %rdi
movq %r13, %rsi
callq 0x52a0
testl %eax, %eax
jne 0xb840
leaq 0x296(%r14), %rdi
movq %r12, %rsi
callq 0x52a0
testl %eax, %eax
jne 0xb840
leaq 0x2d6(%r14), %rdi
movq %r15, %rsi
callq 0x52a0
testl %eax, %eax
jne 0xb840
movl 0x31a(%r14), %eax
cmpl 0x1c(%r14), %eax
jne 0xb840
movl 0x316(%r14), %eax
cmpl 0x18(%r14), %eax
jne 0xb840
movq 0x1e7d1(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
leaq 0x151fc(%rip), %rsi     # 0x209fa
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1f494(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xb9c3
callq 0xeb2f
leaq 0x151ce(%rip), %rsi     # 0x209fa
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0xb9c3
leaq 0x28f8(%rip), %rdx      # 0xe13f
movl $0x1, %edi
movl $0x28, %esi
movq %r14, %rcx
callq 0xda86
leaq 0x15188(%rip), %rcx     # 0x209e8
leaq 0x20(%rsp), %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0xa317
movl %eax, %ebx
testl %eax, %eax
sets %al
movq (%r14), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xb8f4
movq 0x1e72d(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
leaq 0x14ee3(%rip), %rsi     # 0x20785
leaq 0x1513f(%rip), %rcx     # 0x209e8
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1f3e8(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xb9c3
callq 0xeb2f
leaq 0x14ead(%rip), %rsi     # 0x20785
leaq 0x15109(%rip), %rcx     # 0x209e8
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xb9c3
movzwl 0x10(%r12), %edi
callq 0xef61
testw %ax, %ax
jne 0xb918
movzwl 0x12(%r12), %edi
callq 0xef61
testw %ax, %ax
je 0xb9b7
movzwl 0x12(%r12), %edi
callq 0xef61
movl %eax, %ebx
movq 0x1e694(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xeb2f
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xef61
movzwl %ax, %r8d
movzwl %bx, %ebx
leaq 0x14e47(%rip), %rsi     # 0x20797
leaq 0x15091(%rip), %rcx     # 0x209e8
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1f33a(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0xb9ab
callq 0xeb2f
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xef61
movzwl %ax, %r8d
leaq 0x14e03(%rip), %rsi     # 0x20797
leaq 0x1504d(%rip), %rcx     # 0x209e8
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x20(%rsp), %rdi
callq 0x5040
jmp 0xb9c3
movq 0x20(%rsp), %rdi
callq 0x5040
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq