// File: /workspace/github_c_makefile_star2_O2/Paxa[P]fast_excel/libxlsxwriter/src/chartsheet.c
// Function: chartsheet_set_chart_opt
lxw_error
chartsheet_set_chart_opt(lxw_chartsheet *self,
                         lxw_chart *chart, lxw_chart_options *user_options)
{
    lxw_object_properties *object_props;
    lxw_chart_series *series;

    if (!chart) {
        LXW_WARN("chartsheet_set_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("chartsheet_set_chart()/_opt(): the same chart object "
                 "cannot be set for a chartsheet more than once.");

        return LXW_ERROR_PARAMETER_VALIDATION;
    }

    /* Check that the chart has a data series. */
    if (STAILQ_EMPTY(chart->series_list)) {
        LXW_WARN("chartsheet_set_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("chartsheet_set_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->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;

    /* Store the chart data in the embedded worksheet. */
    STAILQ_INSERT_TAIL(self->worksheet->chart_data, object_props,
                       list_pointers);

    chart->in_use = LXW_TRUE;
    chart->is_chartsheet = LXW_TRUE;

    chart->is_protected = self->is_protected;

    self->chart = chart;

    return LXW_NO_ERROR;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rsi, %rsi
je 0x18c37
movq %rsi, %rbx
cmpb $0x0, 0x94(%rsi)
jne 0x18c57
movq 0x128(%rbx), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x18c6c
movq %rdx, %r15
movq %rdi, %r14
testq %rax, %rax
je 0x18b6e
movq 0x8(%rax), %rcx
cmpq $0x0, (%rcx)
jne 0x18b65
cmpq $0x0, 0x8(%rcx)
je 0x18ca9
movq 0x110(%rax), %rax
jmp 0x18b4b
pushq $0x1
popq %rdi
movl $0xc0, %esi
callq 0xc850
testq %rax, %rax
je 0x18c81
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
testq %r15, %r15
je 0x18bc9
movq (%r15), %rdx
movq %rdx, (%rax)
movupd 0x8(%r15), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movupd %xmm0, 0x8(%rax)
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movaps 0x26089(%rip), %xmm2    # 0x3ec40
movups %xmm2, 0x68(%rax)
jne 0x18bdc
jp 0x18bdc
ucomisd %xmm1, %xmm0
movq %rcx, 0x8(%rax)
jmp 0x18be0
movapd 0x2606f(%rip), %xmm0    # 0x3ec40
movupd %xmm0, 0x68(%rax)
movq %rcx, 0x8(%rax)
jmp 0x18be4
ucomisd %xmm1, %xmm0
jne 0x18be8
jp 0x18be8
movq %rcx, 0x10(%rax)
movq %rbx, 0x90(%rax)
movq %rax, %rcx
addq $0xb8, %rcx
movq 0x8(%r14), %rdx
movq 0x68(%rdx), %rdx
movq 0x8(%rdx), %rdx
movq %rax, (%rdx)
movq 0x8(%r14), %rax
movq 0x68(%rax), %rax
movq %rcx, 0x8(%rax)
movb $0x1, %al
movb %al, 0x94(%rbx)
movb %al, 0x97(%rbx)
movb 0x30(%r14), %al
movb %al, 0x169(%rbx)
movq %rbx, 0x10(%r14)
xorl %eax, %eax
jmp 0x18cc8
movq 0x3a3ba(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0x26015(%rip), %rdi     # 0x3ec5d
pushq $0x42
popq %rsi
pushq $0x1
popq %rdx
callq 0xd000
pushq $0xc
jmp 0x18cc7
movq 0x3a39a(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0x26038(%rip), %rdi     # 0x3eca0
pushq $0x6f
jmp 0x18cbc
movq 0x3a385(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0x26093(%rip), %rdi     # 0x3ed10
pushq $0x44
jmp 0x18cbc
movq 0x3a370(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0x2444e(%rip), %rsi     # 0x3d0e0
leaq 0x25fb7(%rip), %rdx     # 0x3ec50
movl $0x109, %ecx            # imm = 0x109
xorl %eax, %eax
callq 0xc8d0
pushq $0x1
jmp 0x18cc7
movq 0x3a348(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0x2609b(%rip), %rdi     # 0x3ed55
pushq $0x4d
popq %rsi
pushq $0x1
popq %rdx
callq 0xd000
pushq $0xd
popq %rax
popq %rbx
popq %r14
popq %r15
retq