// File: /workspace/github_c_makefile_star2_O3/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_insert_chart_opt
lxw_error
worksheet_insert_chart_opt(lxw_worksheet *self,
                           lxw_row_t row_num, lxw_col_t col_num,
                           lxw_chart *chart, lxw_chart_options *user_options)
{
    lxw_object_properties *object_props;
    lxw_chart_series *series;

    if (!chart) {
        LXW_WARN("worksheet_insert_chart()/_opt(): chart must be non-NULL.");
        return LXW_ERROR_NULL_PARAMETER_IGNORED;
    }

    /* Check that the chart isn't being used more than once. */
    if (chart->in_use) {
        LXW_WARN("worksheet_insert_chart()/_opt(): the same chart object "
                 "cannot be inserted in a worksheet more than once.");

        return LXW_ERROR_PARAMETER_VALIDATION;
    }

    /* Check that the chart has a data series. */
    if (STAILQ_EMPTY(chart->series_list)) {
        LXW_WARN
            ("worksheet_insert_chart()/_opt(): chart must have a series.");

        return LXW_ERROR_PARAMETER_VALIDATION;
    }

    /* Check that the chart has a 'values' series. */
    STAILQ_FOREACH(series, chart->series_list, list_pointers) {
        if (!series->values->formula && !series->values->sheetname) {
            LXW_WARN("worksheet_insert_chart()/_opt(): chart must have a "
                     "'values' series.");

            return LXW_ERROR_PARAMETER_VALIDATION;
        }
    }

    /* Create a new object to hold the chart image properties. */
    object_props = calloc(1, sizeof(lxw_object_properties));
    RETURN_ON_MEM_ERROR(object_props, LXW_ERROR_MEMORY_MALLOC_FAILED);

    if (user_options) {
        object_props->x_offset = user_options->x_offset;
        object_props->y_offset = user_options->y_offset;
        object_props->x_scale = user_options->x_scale;
        object_props->y_scale = user_options->y_scale;
        object_props->object_position = user_options->object_position;
        object_props->description = lxw_strdup(user_options->description);
        object_props->decorative = user_options->decorative;
    }

    /* Copy other options or set defaults. */
    object_props->row = row_num;
    object_props->col = col_num;

    object_props->width = 480;
    object_props->height = 288;

    if (object_props->x_scale == 0.0)
        object_props->x_scale = 1;

    if (object_props->y_scale == 0.0)
        object_props->y_scale = 1;

    /* Store chart references so they can be ordered in the workbook. */
    object_props->chart = chart;

    STAILQ_INSERT_TAIL(self->chart_data, object_props, list_pointers);

    chart->in_use = LXW_TRUE;

    return LXW_NO_ERROR;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rcx, %rcx
je 0x3cfee
movq %rcx, %rbx
cmpb $0x0, 0x94(%rcx)
jne 0x3cffa
movq 0x128(%rbx), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x3d001
movq %r8, %r12
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %r14
movq 0x8(%rax), %rcx
cmpq $0x0, (%rcx)
jne 0x3cecf
cmpq $0x0, 0x8(%rcx)
je 0x3d014
movq 0x110(%rax), %rax
testq %rax, %rax
jne 0x3ceba
movl $0x1, %edi
movl $0xc0, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3d008
movq %rax, %r13
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
testq %r12, %r12
je 0x3cf80
movq (%r12), %rax
movq %rax, (%r13)
movupd 0x8(%r12), %xmm0
movapd %xmm0, (%rsp)
movupd %xmm0, 0x8(%r13)
movb 0x18(%r12), %al
movb %al, 0x40(%r13)
movq 0x20(%r12), %rdi
callq 0xcce0
movapd (%rsp), %xmm2
movq %rax, 0x28(%r13)
movb 0x28(%r12), %al
movb %al, 0xb0(%r13)
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
movl %r15d, 0x18(%r13)
movw %bp, 0x1c(%r13)
movaps 0x4cdd(%rip), %xmm1     # 0x41c40
movups %xmm1, 0x68(%r13)
jne 0x3cf9d
jp 0x3cf9d
ucomisd %xmm0, %xmm2
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x8(%r13)
jmp 0x3cfab
movl %r15d, 0x18(%r13)
movw %bp, 0x1c(%r13)
movapd 0x4caf(%rip), %xmm0     # 0x41c40
movupd %xmm0, 0x68(%r13)
movq %rax, 0x8(%r13)
jmp 0x3cfaf
ucomisd %xmm0, %xmm2
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
jne 0x3cfb3
jp 0x3cfb3
movq %rax, 0x10(%r13)
movq %rbx, 0x90(%r13)
movq %r13, %rax
addq $0xb8, %rax
movq 0x68(%r14), %rcx
movq 0x8(%rcx), %rcx
movq %r13, (%rcx)
movq 0x68(%r14), %rcx
movq %rax, 0x8(%rcx)
movb $0x1, 0x94(%rbx)
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xfa58
movl $0xc, %eax
jmp 0x3cfdf
callq 0xf9e0
jmp 0x3d019
callq 0xfa3c
jmp 0x3d019
callq 0xf9fc
movl $0x1, %eax
jmp 0x3cfdf
callq 0xfa20
movl $0xd, %eax
jmp 0x3cfdf