// File: /workspace/github_c_makefile_star2_O2/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 0x3a07c
movq %rcx, %rbx
cmpb $0x0, 0x94(%rcx)
jne 0x3a09c
movq 0x128(%rbx), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x3a0b1
movq %r8, %r13
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %r14
testq %rax, %rax
je 0x39f86
movq 0x8(%rax), %rcx
cmpq $0x0, (%rcx)
jne 0x39f7d
cmpq $0x0, 0x8(%rcx)
je 0x3a0ee
movq 0x110(%rax), %rax
jmp 0x39f63
pushq $0x1
popq %rdi
movl $0xc0, %esi
callq 0xc850
testq %rax, %rax
je 0x3a0c6
movq %rax, %r12
testq %r13, %r13
je 0x3a012
movq (%r13), %rax
movq %rax, (%r12)
movupd 0x8(%r13), %xmm0
movapd %xmm0, (%rsp)
movupd %xmm0, 0x8(%r12)
movb 0x18(%r13), %al
movb %al, 0x40(%r12)
movq 0x20(%r13), %rdi
callq 0xcd50
movq %rax, 0x28(%r12)
movb 0x28(%r13), %al
movb %al, 0xb0(%r12)
xorpd %xmm0, %xmm0
movapd (%rsp), %xmm2
movapd %xmm2, %xmm1
cmpeqsd %xmm0, %xmm1
movq %xmm1, %rax
andl $0x1, %eax
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
cmpeqsd %xmm0, %xmm1
movq %xmm1, %rcx
andl $0x1, %ecx
jmp 0x3a016
movb $0x1, %cl
movb $0x1, %al
movl %r15d, 0x18(%r12)
movw %bp, 0x1c(%r12)
movaps 0x4c18(%rip), %xmm0     # 0x3ec40
movups %xmm0, 0x68(%r12)
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
testb %al, %al
je 0x3a041
movq %rdx, 0x8(%r12)
testb %cl, %cl
je 0x3a04a
movq %rdx, 0x10(%r12)
movq %rbx, 0x90(%r12)
movq %r12, %rax
addq $0xb8, %rax
movq 0x68(%r14), %rcx
movq 0x8(%rcx), %rcx
movq %r12, (%rcx)
movq 0x68(%r14), %rcx
movq %rax, 0x8(%rcx)
movb $0x1, 0x94(%rbx)
xorl %eax, %eax
jmp 0x3a10d
movq 0x18f75(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0xae1a(%rip), %rdi      # 0x44ea7
pushq $0x44
popq %rsi
pushq $0x1
popq %rdx
callq 0xd000
pushq $0xc
jmp 0x3a10c
movq 0x18f55(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0xae3f(%rip), %rdi      # 0x44eec
pushq $0x74
jmp 0x3a101
movq 0x18f40(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0xae9f(%rip), %rdi      # 0x44f61
pushq $0x46
jmp 0x3a101
movq 0x18f2b(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0x3009(%rip), %rsi      # 0x3d0e0
leaq 0x9902(%rip), %rdx      # 0x439e0
movl $0x2990, %ecx           # imm = 0x2990
xorl %eax, %eax
callq 0xc8d0
pushq $0x1
jmp 0x3a10c
movq 0x18f03(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0xaea9(%rip), %rdi      # 0x44fa8
pushq $0x4f
popq %rsi
pushq $0x1
popq %rdx
callq 0xd000
pushq $0xd
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq