// File: /workspace/github_c_makefile_star2_O3/Paxa[P]fast_excel/libxlsxwriter/src/packager.c
// Function: write_chartsheet_rels_file
STATIC lxw_error
_write_chartsheet_rels_file(lxw_packager *self)
{
    lxw_relationships *rels;
    char *buffer = NULL;
    size_t buffer_size = 0;
    lxw_rel_tuple *rel;
    lxw_workbook *workbook = self->workbook;
    lxw_sheet *sheet;
    lxw_worksheet *worksheet;
    char sheetname[LXW_FILENAME_LENGTH] = { 0 };
    uint32_t index = 0;
    lxw_error err;

    STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
        if (sheet->is_chartsheet)
            worksheet = sheet->u.chartsheet->worksheet;
        else
            continue;

        index++;

        if (STAILQ_EMPTY(worksheet->external_drawing_links))
            continue;

        rels = lxw_relationships_new();

        rels->file = lxw_get_filehandle(&buffer, &buffer_size, self->tmpdir);
        if (!rels->file) {
            lxw_free_relationships(rels);
            return LXW_ERROR_CREATING_TMPFILE;
        }

        STAILQ_FOREACH(rel, worksheet->external_hyperlinks, list_pointers) {
            lxw_add_worksheet_relationship(rels, rel->type, rel->target,
                                           rel->target_mode);
        }

        STAILQ_FOREACH(rel, worksheet->external_drawing_links, list_pointers) {
            lxw_add_worksheet_relationship(rels, rel->type, rel->target,
                                           rel->target_mode);
        }

        lxw_snprintf(sheetname, LXW_FILENAME_LENGTH,
                     "xl/chartsheets/_rels/sheet%d.xml.rels", index);

        lxw_relationships_assemble_xml_file(rels);

        err = _add_to_zip(self, rels->file, &buffer, &buffer_size, sheetname);

        fclose(rels->file);
        free(buffer);
        lxw_free_relationships(rels);

        RETURN_ON_ERROR(err);
    }

    return LXW_NO_ERROR;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
xorl %r14d, %r14d
movq %r14, 0x18(%rsp)
movq %r14, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
movq 0x8(%rdi), %rax
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq 0x8(%rax), %rax
movq (%rax), %r13
testq %r13, %r13
je 0x21cd9
leaq 0x18(%rsp), %r15
leaq 0x10(%rsp), %rbx
xorl %ebp, %ebp
cmpb $0x0, (%r13)
je 0x21cb9
movq 0x8(%r13), %rax
movq 0x8(%rax), %r14
incl %ebp
movq 0x220(%r14), %rax
cmpq $0x0, (%rax)
je 0x21cb9
callq 0xcf00
movq %rax, %r12
movq 0x8(%rsp), %rax
movq 0x70(%rax), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0xce00
movq %rax, (%r12)
testq %rax, %rax
je 0x21ccb
movq %r15, %rbx
movq 0x218(%r14), %rax
movq (%rax), %r15
testq %r15, %r15
je 0x21c2a
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x10(%r15), %rcx
movq %r12, %rdi
callq 0xca10
movq 0x18(%r15), %r15
jmp 0x21c0c
movq 0x220(%r14), %rax
movq (%rax), %r14
testq %r14, %r14
je 0x21c52
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x10(%r14), %rcx
movq %r12, %rdi
callq 0xca10
movq 0x18(%r14), %r14
jmp 0x21c34
movl $0x80, %esi
leaq 0x20(%rsp), %r14
movq %r14, %rdi
leaq 0x213be(%rip), %rdx     # 0x43024
movl %ebp, %ecx
xorl %eax, %eax
callq 0xc570
movq %r12, %rdi
callq 0xc310
movq (%r12), %rsi
movq 0x8(%rsp), %rdi
movq %rbx, %r15
movq %rbx, %rdx
leaq 0x10(%rsp), %rbx
movq %rbx, %rcx
movq %r14, %r8
callq 0x224f6
movl %eax, %r14d
movq (%r12), %rdi
callq 0xc420
movq 0x18(%rsp), %rdi
callq 0xc0c0
movq %r12, %rdi
callq 0xc290
testl %r14d, %r14d
jne 0x21cd9
movq 0x10(%r13), %r13
testq %r13, %r13
jne 0x21bb0
xorl %r14d, %r14d
jmp 0x21cd9
movq %r12, %rdi
callq 0xc290
movl $0x3, %r14d
movl %r14d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq