// File: /workspace/github_c_makefile_star2_O2/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 0x11b50(%rip), %rax     # 0x1cea1
cmoveq %rax, %r13
testq %r12, %r12
cmoveq %rax, %r12
movq 0x10(%rdi), %r15
testq %r15, %r15
cmoveq %rax, %r15
movq 0x1dc4a(%rip), %rax     # 0x28fb8
movq (%rax), %rbp
callq 0xe343
movl 0x48(%r14), %r8d
movq (%r14), %r9
movups 0x8(%r14), %xmm0
movl 0x18(%r14), %ecx
movslq 0x1c(%r14), %rdx
leaq 0x1cfcf(%rip), %rbx     # 0x28360
movq (%rbx,%rdx,8), %rdx
movq %rdx, 0x18(%rsp)
movl %ecx, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x1361f(%rip), %rsi     # 0x1e9c8
leaq 0x13634(%rip), %rcx     # 0x1e9e4
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1e8e4(%rip), %rax     # 0x29ca8
movq (%rax), %rbp
testq %rbp, %rbp
je 0xb411
callq 0xe343
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 0x135cb(%rip), %rsi     # 0x1e9c8
leaq 0x135e0(%rip), %rcx     # 0x1e9e4
movq %rbp, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
cmpl $0x0, 0x48(%r14)
je 0xb64c
leaq 0x256(%r14), %rdi
movq %r13, %rsi
callq 0x52a0
testl %eax, %eax
jne 0xb4cf
leaq 0x296(%r14), %rdi
movq %r12, %rsi
callq 0x52a0
testl %eax, %eax
jne 0xb4cf
leaq 0x2d6(%r14), %rdi
movq %r15, %rsi
callq 0x52a0
testl %eax, %eax
jne 0xb4cf
movl 0x31a(%r14), %eax
cmpl 0x1c(%r14), %eax
jne 0xb4cf
movl 0x316(%r14), %eax
cmpl 0x18(%r14), %eax
jne 0xb4cf
movq 0x1db3a(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x13569(%rip), %rsi     # 0x1e9f6
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
leaq 0x1e805(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xb64e
callq 0xe343
leaq 0x1353b(%rip), %rsi     # 0x1e9f6
xorl %ebx, %ebx
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x52c0
jmp 0xb64e
leaq 0x24ec(%rip), %rdx      # 0xd9c2
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
movq %r14, %rcx
callq 0xd53c
leaq 0x134f9(%rip), %rcx     # 0x1e9e4
leaq 0x20(%rsp), %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x7530, %edx           # imm = 0x7530
callq 0x9e8b
movl %eax, %ebx
testl %eax, %eax
sets %al
movq (%r14), %r12
testq %r12, %r12
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0xb57f
movq 0x1da9a(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
leaq 0x13254(%rip), %rsi     # 0x1e781
leaq 0x134b0(%rip), %rcx     # 0x1e9e4
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
leaq 0x1e75d(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xb64e
callq 0xe343
leaq 0x1321e(%rip), %rsi     # 0x1e781
leaq 0x1347a(%rip), %rcx     # 0x1e9e4
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x52c0
jmp 0xb64e
movzwl 0x10(%r12), %edi
callq 0xe73e
testw %ax, %ax
jne 0xb5a3
movzwl 0x12(%r12), %edi
callq 0xe73e
testw %ax, %ax
je 0xb642
movzwl 0x12(%r12), %edi
callq 0xe73e
movl %eax, %ebx
movq 0x1da01(%rip), %rax     # 0x28fb8
movq (%rax), %r14
callq 0xe343
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xe73e
movzwl %ax, %r8d
movzwl %bx, %ebx
leaq 0x131b8(%rip), %rsi     # 0x1e793
leaq 0x13402(%rip), %rcx     # 0x1e9e4
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
leaq 0x1e6af(%rip), %rax     # 0x29ca8
movq (%rax), %r14
testq %r14, %r14
je 0xb636
callq 0xe343
movq %rax, %r15
movzwl 0x10(%r12), %edi
callq 0xe73e
movzwl %ax, %r8d
leaq 0x13174(%rip), %rsi     # 0x1e793
leaq 0x133be(%rip), %rcx     # 0x1e9e4
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x52c0
movq 0x20(%rsp), %rdi
callq 0x5040
jmp 0xb64e
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