// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/atc.c
// Function: requestSetProfile
static int requestSetProfile(PROFILE_T *profile) {
    int err;
    ATResponse *p_response = NULL;
    char *cmd = NULL;
    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[] = {"NULL", "IPV4", "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 ( !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;
    }

    if (QICSGP_C == 5)
        asprintf(&cmd, "AT+QICSGP=%d,%d,\"%s\",\"%s\",\"%s\",%d",
            profile->pdp, profile->iptype, new_apn, new_user, new_password, profile->auth);
    else if (QICSGP_C == 4)
        asprintf(&cmd, "AT+QICSGP=%d,\"%s\",\"%s\",\"%s\",%d",
            profile->pdp, new_apn, new_user, new_password, profile->auth);
    else
        goto _error;

    err = at_send_command(cmd, &p_response);
    safe_free(cmd);
    if (at_response_error(err, p_response)) {
        safe_at_response_free(p_response);
        asprintf(&cmd, "AT+CGDCONT=%d,\"%s\",\"%s\"", profile->pdp, ipStr[profile->iptype], new_apn);
        err = at_send_command(cmd, &p_response);
        safe_free(cmd);
    }

_error:
    safe_at_response_free(p_response);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0xc8, %rsp
movq %rdi, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x23d87
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x23d94
leaq 0x827b(%rip), %rax      # 0x2c009
movq %rax, -0x78(%rbp)
jmp 0x23d94
movq -0x78(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x23db5
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
jmp 0x23dc2
leaq 0x824d(%rip), %rax      # 0x2c009
movq %rax, -0x80(%rbp)
jmp 0x23dc2
movq -0x80(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x23de6
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0x23df6
leaq 0x821c(%rip), %rax      # 0x2c009
movq %rax, -0x88(%rbp)
jmp 0x23df6
movq -0x88(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x12fa8(%rip), %rax     # 0x36db0
movq %rax, -0x70(%rbp)
movq 0x12fa5(%rip), %rax     # 0x36db8
movq %rax, -0x68(%rbp)
movq 0x12fa2(%rip), %rax     # 0x36dc0
movq %rax, -0x60(%rbp)
movq 0x12f9f(%rip), %rax     # 0x36dc8
movq %rax, -0x58(%rbp)
movq 0x131ac(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x90(%rbp)
callq 0x13930
movq -0x90(%rbp), %rdi
movq %rax, %rdx
movq -0x18(%rbp), %rax
movl 0x48(%rax), %r8d
movq -0x18(%rbp), %rax
movq (%rax), %r9
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rbx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %r11
movq -0x18(%rbp), %rax
movl 0x18(%rax), %r10d
movq -0x18(%rbp), %rax
movslq 0x1c(%rax), %rax
movq -0x70(%rbp,%rax,8), %rax
leaq 0x9d20(%rip), %rsi      # 0x2dba8
leaq 0x9d35(%rip), %rcx      # 0x2dbc4
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x52c0
leaq 0x13fb8(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x23f32
leaq 0x13fab(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x98(%rbp)
callq 0x13930
movq -0x98(%rbp), %rdi
movq %rax, %rdx
movq -0x18(%rbp), %rax
movl 0x48(%rax), %r8d
movq -0x18(%rbp), %rax
movq (%rax), %r9
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rbx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %r11
movq -0x18(%rbp), %rax
movl 0x18(%rax), %r10d
movq -0x18(%rbp), %rax
movslq 0x1c(%rax), %rax
movq -0x70(%rbp,%rax,8), %rax
leaq 0x9c97(%rip), %rsi      # 0x2dba8
leaq 0x9cac(%rip), %rcx      # 0x2dbc4
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movb $0x0, %al
callq 0x52c0
jmp 0x23f34
movq -0x18(%rbp), %rdi
addq $0x256, %rdi            # imm = 0x256
movq -0x38(%rbp), %rsi
callq 0x52a0
cmpl $0x0, %eax
jne 0x2402e
movq -0x18(%rbp), %rdi
addq $0x296, %rdi            # imm = 0x296
movq -0x40(%rbp), %rsi
callq 0x52a0
cmpl $0x0, %eax
jne 0x2402e
movq -0x18(%rbp), %rdi
addq $0x2d6, %rdi            # imm = 0x2D6
movq -0x48(%rbp), %rsi
callq 0x52a0
cmpl $0x0, %eax
jne 0x2402e
movq -0x18(%rbp), %rax
movl 0x31a(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jne 0x2402e
movq -0x18(%rbp), %rax
movl 0x316(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jne 0x2402e
jmp 0x23fb7
movq 0x13022(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
callq 0x13930
movq -0xa0(%rbp), %rdi
movq %rax, %rdx
leaq 0x9bf8(%rip), %rsi      # 0x2dbd6
movb $0x0, %al
callq 0x52c0
leaq 0x13e7c(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x24020
leaq 0x13e6f(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
callq 0x13930
movq -0xa8(%rbp), %rdi
movq %rax, %rdx
leaq 0x9bbd(%rip), %rsi      # 0x2dbd6
movb $0x0, %al
callq 0x52c0
jmp 0x24022
movl $0x0, -0xc(%rbp)
jmp 0x2418f
cmpl $0x5, 0x150db(%rip)     # 0x39110
jne 0x24074
movq -0x18(%rbp), %rax
movl 0x48(%rax), %edx
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x38(%rbp), %r8
movq -0x40(%rbp), %r9
movq -0x48(%rbp), %r10
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
leaq -0x30(%rbp), %rdi
leaq 0xc2ef(%rip), %rsi      # 0x30352
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x53c0
jmp 0x240b5
cmpl $0x4, 0x15095(%rip)     # 0x39110
jne 0x240ae
movq -0x18(%rbp), %rax
movl 0x48(%rax), %edx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movq -0x48(%rbp), %r9
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
leaq -0x30(%rbp), %rdi
leaq 0xc2d2(%rip), %rsi      # 0x30374
movl %eax, (%rsp)
movb $0x0, %al
callq 0x53c0
jmp 0x240b3
jmp 0x24170
jmp 0x240b5
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x26d90
movl %eax, -0x1c(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x240dd
movq -0x30(%rbp), %rdi
callq 0x5040
movq $0x0, -0x30(%rbp)
jmp 0x240df
cmpl $0x0, -0x1c(%rbp)
jne 0x24100
cmpq $0x0, -0x28(%rbp)
je 0x24100
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x24100
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x2416e
cmpq $0x0, -0x28(%rbp)
je 0x24118
movq -0x28(%rbp), %rdi
callq 0x26d20
movq $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl 0x48(%rax), %edx
movq -0x18(%rbp), %rax
movslq 0x1c(%rax), %rax
movq -0x70(%rbp,%rax,8), %rcx
movq -0x38(%rbp), %r8
leaq -0x30(%rbp), %rdi
leaq 0xc258(%rip), %rsi      # 0x30393
movb $0x0, %al
callq 0x53c0
movq -0x30(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x26d90
movl %eax, -0x1c(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x2416a
movq -0x30(%rbp), %rdi
callq 0x5040
movq $0x0, -0x30(%rbp)
jmp 0x2416c
jmp 0x2416e
jmp 0x24170
cmpq $0x0, -0x28(%rbp)
je 0x24188
movq -0x28(%rbp), %rdi
callq 0x26d20
movq $0x0, -0x28(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
addq $0xc8, %rsp
popq %rbx
popq %rbp
retq
nopl (%rax)