// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: lxw_worksheet_prepare_chart
void
lxw_worksheet_prepare_chart(lxw_worksheet *self,
                            uint32_t chart_ref_id,
                            uint32_t drawing_id,
                            lxw_object_properties *object_props,
                            uint8_t is_chartsheet)
{
    lxw_drawing_object *drawing_object;
    lxw_rel_tuple *relationship;
    double width;
    double height;
    char filename[LXW_FILENAME_LENGTH];

    if (!self->drawing) {
        self->drawing = lxw_drawing_new();
        RETURN_VOID_ON_MEM_ERROR(self->drawing);

        if (is_chartsheet) {
            self->drawing->embedded = LXW_FALSE;
            self->drawing->orientation = self->orientation;
        }
        else {
            self->drawing->embedded = LXW_TRUE;
        }

        relationship = calloc(1, sizeof(lxw_rel_tuple));
        GOTO_LABEL_ON_MEM_ERROR(relationship, mem_error);

        relationship->type = lxw_strdup("/drawing");
        GOTO_LABEL_ON_MEM_ERROR(relationship->type, mem_error);

        lxw_snprintf(filename, LXW_FILENAME_LENGTH,
                     "../drawings/drawing%d.xml", drawing_id);

        relationship->target = lxw_strdup(filename);
        GOTO_LABEL_ON_MEM_ERROR(relationship->target, mem_error);

        STAILQ_INSERT_TAIL(self->external_drawing_links, relationship,
                           list_pointers);
    }

    drawing_object = calloc(1, sizeof(lxw_drawing_object));
    RETURN_VOID_ON_MEM_ERROR(drawing_object);

    drawing_object->anchor = LXW_OBJECT_MOVE_AND_SIZE;
    if (object_props->object_position)
        drawing_object->anchor = object_props->object_position;

    drawing_object->type = LXW_DRAWING_CHART;
    drawing_object->description = lxw_strdup(object_props->description);
    drawing_object->tip = NULL;
    drawing_object->rel_index = _get_drawing_rel_index(self, NULL);
    drawing_object->url_rel_index = 0;
    drawing_object->decorative = object_props->decorative;

    /* Scale to user scale. */
    width = object_props->width * object_props->x_scale;
    height = object_props->height * object_props->y_scale;

    /* Convert to the nearest pixel. */
    object_props->width = width;
    object_props->height = height;

    _worksheet_position_object_emus(self, object_props, drawing_object);

    /* Convert from pixels to emus. */
    drawing_object->width = (uint32_t) (0.5 + width * 9525);
    drawing_object->height = (uint32_t) (0.5 + height * 9525);

    lxw_add_drawing_object(self->drawing, drawing_object);

    relationship = calloc(1, sizeof(lxw_rel_tuple));
    GOTO_LABEL_ON_MEM_ERROR(relationship, mem_error);

    relationship->type = lxw_strdup("/chart");
    GOTO_LABEL_ON_MEM_ERROR(relationship->type, mem_error);

    lxw_snprintf(filename, 32, "../charts/chart%d.xml", chart_ref_id);

    relationship->target = lxw_strdup(filename);
    GOTO_LABEL_ON_MEM_ERROR(relationship->target, mem_error);

    STAILQ_INSERT_TAIL(self->drawing_links, relationship, list_pointers);

    return;

mem_error:
    if (relationship) {
        free(relationship->type);
        free(relationship->target);
        free(relationship->target_mode);
        free(relationship);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movb %al, -0x19(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x290(%rax)
jne 0x4a7c2
callq 0xc9b0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x290(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x290(%rax)
jne 0x4a64b
movq 0x329cf(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1ba9d(%rip), %rsi     # 0x660d0
leaq 0x21dba(%rip), %rdx     # 0x6c3f4
movl $0xe02, %ecx            # imm = 0xE02
movb $0x0, %al
callq 0xc8f0
jmp 0x4aaa3
jmp 0x4a64d
cmpb $0x0, -0x19(%rbp)
je 0x4a67c
movq -0x8(%rbp), %rax
movq 0x290(%rax), %rax
movb $0x0, 0x8(%rax)
movq -0x8(%rbp), %rax
movb 0x13d(%rax), %cl
movq -0x8(%rbp), %rax
movq 0x290(%rax), %rax
movb %cl, 0x9(%rax)
jmp 0x4a68b
movq -0x8(%rbp), %rax
movq 0x290(%rax), %rax
movb $0x1, 0x8(%rax)
movl $0x1, %edi
movl $0x20, %esi
callq 0xc870
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4a6ce
movq 0x3294c(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1ba1a(%rip), %rsi     # 0x660d0
leaq 0x21d37(%rip), %rdx     # 0x6c3f4
movl $0xe0d, %ecx            # imm = 0xE0D
movb $0x0, %al
callq 0xc8f0
jmp 0x4aa6d
jmp 0x4a6d0
leaq 0x221ed(%rip), %rdi     # 0x6c8c4
callq 0xcd80
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x4a719
movq 0x32901(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b9cf(%rip), %rsi     # 0x660d0
leaq 0x21cec(%rip), %rdx     # 0x6c3f4
movl $0xe10, %ecx            # imm = 0xE10
movb $0x0, %al
callq 0xc8f0
jmp 0x4aa6d
jmp 0x4a71b
leaq -0xc0(%rbp), %rdi
movl -0x10(%rbp), %ecx
movl $0x80, %esi
leaq 0x2219c(%rip), %rdx     # 0x6c8cd
movb $0x0, %al
callq 0xc5d0
leaq -0xc0(%rbp), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x4a783
movq 0x32897(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b965(%rip), %rsi     # 0x660d0
leaq 0x21c82(%rip), %rdx     # 0x6c3f4
movl $0xe16, %ecx            # imm = 0xE16
movb $0x0, %al
callq 0xc8f0
jmp 0x4aa6d
jmp 0x4a785
jmp 0x4a787
movq -0x30(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x220(%rax), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
addq $0x18, %rcx
movq -0x8(%rbp), %rax
movq 0x220(%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x4a7c2
movl $0x1, %edi
movl $0x80, %esi
callq 0xc870
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x4a805
movq 0x32815(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b8e3(%rip), %rsi     # 0x660d0
leaq 0x21c00(%rip), %rdx     # 0x6c3f4
movl $0xe1d, %ecx            # imm = 0xE1D
movb $0x0, %al
callq 0xc8f0
jmp 0x4aaa3
jmp 0x4a807
movq -0x28(%rbp), %rax
movb $0x1, 0x1(%rax)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x40(%rax)
je 0x4a827
movq -0x18(%rbp), %rax
movb 0x40(%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x28(%rbp), %rax
movb $0x2, (%rax)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x68(%rax)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x49e60
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x58(%rax)
movq -0x18(%rbp), %rax
movb 0xb0(%rax), %cl
movq -0x28(%rbp), %rax
movb %cl, 0x70(%rax)
movq -0x18(%rbp), %rax
movsd 0x8(%rax), %xmm1
movsd 0x68(%rax), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x18(%rbp), %rax
movsd 0x10(%rax), %xmm1
movsd 0x70(%rax), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x38(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x68(%rax)
movsd -0x40(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x70(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x49d20
movsd -0x38(%rbp), %xmm0
movsd 0x219ec(%rip), %xmm2    # 0x6c2d8
mulsd %xmm2, %xmm0
movsd 0x1ba28(%rip), %xmm1    # 0x66320
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x48(%rax)
movsd -0x40(%rbp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4c(%rax)
movq -0x8(%rbp), %rax
movq 0x290(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0xcef0
movl $0x1, %edi
movl $0x20, %esi
callq 0xc870
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4a97c
movq 0x3269e(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b76c(%rip), %rsi     # 0x660d0
leaq 0x21a89(%rip), %rdx     # 0x6c3f4
movl $0xe3b, %ecx            # imm = 0xE3B
movb $0x0, %al
callq 0xc8f0
jmp 0x4aa6d
jmp 0x4a97e
leaq 0x22018(%rip), %rdi     # 0x6c99d
callq 0xcd80
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x4a9c7
movq 0x32653(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b721(%rip), %rsi     # 0x660d0
leaq 0x21a3e(%rip), %rdx     # 0x6c3f4
movl $0xe3e, %ecx            # imm = 0xE3E
movb $0x0, %al
callq 0xc8f0
jmp 0x4aa6d
jmp 0x4a9c9
leaq -0xc0(%rbp), %rdi
movl -0xc(%rbp), %ecx
movl $0x20, %esi
leaq 0x21fc5(%rip), %rdx     # 0x6c9a4
movb $0x0, %al
callq 0xc5d0
leaq -0xc0(%rbp), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x4aa2e
movq 0x325e9(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b6b7(%rip), %rsi     # 0x660d0
leaq 0x219d4(%rip), %rdx     # 0x6c3f4
movl $0xe43, %ecx            # imm = 0xE43
movb $0x0, %al
callq 0xc8f0
jmp 0x4aa6d
jmp 0x4aa30
jmp 0x4aa32
movq -0x30(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x228(%rax), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
addq $0x18, %rcx
movq -0x8(%rbp), %rax
movq 0x228(%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x4aaa3
cmpq $0x0, -0x30(%rbp)
je 0x4aaa3
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0xc0d0
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xc0d0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xc0d0
movq -0x30(%rbp), %rdi
callq 0xc0d0
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)