// File: /workspace/github_c_makefile_star2_O1/Paxa[P]fast_excel/libxlsxwriter/src/chart.c
// Function: chart_add_series
lxw_chart_series *
chart_add_series(lxw_chart *self, const char *categories, const char *values)
{
    lxw_chart_series *series;

    /* Scatter charts require categories and values. */
    if (self->chart_group == LXW_CHART_SCATTER && values && !categories) {
        LXW_WARN("chart_add_series(): scatter charts must have "
                 "'categories' and 'values'");

        return NULL;
    }

    /* Create a new object to hold the series. */
    series = calloc(1, sizeof(lxw_chart_series));
    GOTO_LABEL_ON_MEM_ERROR(series, mem_error);

    series->categories = calloc(1, sizeof(lxw_series_range));
    GOTO_LABEL_ON_MEM_ERROR(series->categories, mem_error);

    series->values = calloc(1, sizeof(lxw_series_range));
    GOTO_LABEL_ON_MEM_ERROR(series->values, mem_error);

    series->title.range = calloc(1, sizeof(lxw_series_range));
    GOTO_LABEL_ON_MEM_ERROR(series->title.range, mem_error);

    series->x_error_bars = calloc(1, sizeof(lxw_series_error_bars));
    GOTO_LABEL_ON_MEM_ERROR(series->x_error_bars, mem_error);

    series->y_error_bars = calloc(1, sizeof(lxw_series_error_bars));
    GOTO_LABEL_ON_MEM_ERROR(series->y_error_bars, mem_error);

    if (categories) {
        if (categories[0] == '=')
            series->categories->formula = lxw_strdup(categories + 1);
        else
            series->categories->formula = lxw_strdup(categories);
    }

    if (values) {
        if (values[0] == '=')
            series->values->formula = lxw_strdup(values + 1);
        else
            series->values->formula = lxw_strdup(values);
    }

    if (_chart_init_data_cache(series->categories) != LXW_NO_ERROR)
        goto mem_error;

    if (_chart_init_data_cache(series->values) != LXW_NO_ERROR)
        goto mem_error;

    if (_chart_init_data_cache(series->title.range) != LXW_NO_ERROR)
        goto mem_error;

    if (self->type == LXW_CHART_SCATTER_SMOOTH)
        series->smooth = LXW_TRUE;

    if (self->type == LXW_CHART_SCATTER_SMOOTH_WITH_MARKERS)
        series->smooth = LXW_TRUE;

    series->y_error_bars->chart_group = self->chart_group;
    series->x_error_bars->chart_group = self->chart_group;
    series->x_error_bars->is_x = LXW_TRUE;

    series->default_label_position = self->default_label_position;

    STAILQ_INSERT_TAIL(self->series_list, series, list_pointers);

    return series;

mem_error:
    _chart_series_free(series);
    return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
testq %rsi, %rsi
jne 0x1540a
testq %r15, %r15
je 0x1540a
cmpb $0xf, 0x95(%r14)
je 0x15590
movl $0x1, %edi
movl $0x118, %esi            # imm = 0x118
callq 0xc7f0
movq %rax, %rbx
testq %rax, %rax
je 0x15597
movl $0x1, %edi
movl $0x28, %esi
callq 0xc7f0
movq %rax, (%rbx)
testq %rax, %rax
je 0x1559e
movl $0x1, %edi
movl $0x28, %esi
callq 0xc7f0
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x155a5
movl $0x1, %edi
movl $0x28, %esi
callq 0xc7f0
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0x155ac
movl $0x1, %edi
movl $0x18, %esi
callq 0xc7f0
movq %rax, 0xc8(%rbx)
testq %rax, %rax
je 0x155b3
movl $0x1, %edi
movl $0x18, %esi
callq 0xc7f0
movq %rax, 0xd0(%rbx)
testq %rax, %rax
je 0x155ba
testq %r12, %r12
je 0x154d4
xorl %edi, %edi
cmpb $0x3d, (%r12)
sete %dil
addq %r12, %rdi
callq 0xcce0
movq (%rbx), %rcx
movq %rax, (%rcx)
testq %r15, %r15
je 0x154f2
xorl %edi, %edi
cmpb $0x3d, (%r15)
sete %dil
addq %r15, %rdi
callq 0xcce0
movq 0x8(%rbx), %rcx
movq %rax, (%rcx)
movq (%rbx), %rdi
callq 0x146bf
testl %eax, %eax
jne 0x155c4
movq 0x8(%rbx), %rdi
callq 0x146bf
testl %eax, %eax
jne 0x155c4
movq 0x30(%rbx), %rdi
callq 0x146bf
testl %eax, %eax
jne 0x155c4
movb 0x8(%r14), %al
andb $-0x2, %al
cmpb $0x12, %al
jne 0x15535
movb $0x1, 0x94(%rbx)
movb 0x95(%r14), %al
movq 0xd0(%rbx), %rcx
movb %al, 0x6(%rcx)
movq 0xc8(%rbx), %rcx
movb %al, 0x6(%rcx)
movb $0x1, 0x5(%rcx)
movb 0x168(%r14), %al
movb %al, 0x9f(%rbx)
movq %rbx, %rax
addq $0x110, %rax            # imm = 0x110
movq $0x0, 0x110(%rbx)
movq 0x128(%r14), %rcx
movq 0x8(%rcx), %rcx
movq %rbx, (%rcx)
movq 0x128(%r14), %rcx
movq %rax, 0x8(%rcx)
jmp 0x155ce
callq 0xd2a3
jmp 0x155cc
movl $0x1451, %edi           # imm = 0x1451
jmp 0x155bf
movl $0x1454, %edi           # imm = 0x1454
jmp 0x155bf
movl $0x1457, %edi           # imm = 0x1457
jmp 0x155bf
movl $0x145a, %edi           # imm = 0x145A
jmp 0x155bf
movl $0x145d, %edi           # imm = 0x145D
jmp 0x155bf
movl $0x1460, %edi           # imm = 0x1460
callq 0xd2bf
movq %rbx, %rdi
callq 0x13ff3
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq