// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
testq %rcx, %rcx
je 0x3cd73
movq %rcx, %rbx
cmpb $0x0, 0x94(%rcx)
jne 0x3cd7f
movq 0x128(%rbx), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x3cd86
movq %r8, %r12
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %r14
movq 0x8(%rax), %rcx
cmpq $0x0, (%rcx)
jne 0x3cc5c
cmpq $0x0, 0x8(%rcx)
je 0x3cd99
movq 0x110(%rax), %rax
testq %rax, %rax
jne 0x3cc47
movl $0x1, %edi
movl $0xc0, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3cd8d
movq %rax, %r13
testq %r12, %r12
je 0x3ccd6
movl (%r12), %eax
movl %eax, (%r13)
movl 0x4(%r12), %eax
movl %eax, 0x4(%r13)
movsd 0x8(%r12), %xmm0
movsd %xmm0, 0x8(%r13)
movsd 0x10(%r12), %xmm0
movsd %xmm0, 0x10(%r13)
movb 0x18(%r12), %al
movb %al, 0x40(%r13)
movq 0x20(%r12), %rdi
callq 0xcce0
movq %rax, 0x28(%r13)
movb 0x28(%r12), %al
movb %al, 0xb0(%r13)
movl %r15d, 0x18(%r13)
movw %bp, 0x1c(%r13)
movabsq $0x407e000000000000, %rax # imm = 0x407E000000000000
movq %rax, 0x68(%r13)
movabsq $0x4072000000000000, %rax # imm = 0x4072000000000000
movq %rax, 0x70(%r13)
movsd 0x8(%r13), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
jne 0x3cd1b
jp 0x3cd1b
movq %rax, 0x8(%r13)
movsd 0x10(%r13), %xmm1
ucomisd %xmm0, %xmm1
jne 0x3cd2d
jp 0x3cd2d
movq %rax, 0x10(%r13)
movq %rbx, 0x90(%r13)
movq %r13, %rax
addq $0xb8, %rax
movq $0x0, 0xb8(%r13)
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 $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xf675
movl $0xc, %eax
jmp 0x3cd64
callq 0xf5fd
jmp 0x3cd9e
callq 0xf659
jmp 0x3cd9e
callq 0xf619
movl $0x1, %eax
jmp 0x3cd64
callq 0xf63d
movl $0xd, %eax
jmp 0x3cd64