// File: /workspace/github_c_makefile_star2_O3/Paxa[P]fast_excel/libxlsxwriter/src/packager.c
// Function: write_worksheet_rels_file
STATIC lxw_error
_write_worksheet_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)
            continue;
        else
            worksheet = sheet->u.worksheet;

        index++;

        if (STAILQ_EMPTY(worksheet->external_hyperlinks) &&
            STAILQ_EMPTY(worksheet->external_drawing_links) &&
            STAILQ_EMPTY(worksheet->external_table_links) &&
            !worksheet->external_vml_header_link &&
            !worksheet->external_vml_comment_link &&
            !worksheet->external_background_link &&
            !worksheet->external_comment_link)
            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);
        }

        rel = worksheet->external_vml_comment_link;
        if (rel)
            lxw_add_worksheet_relationship(rels, rel->type, rel->target,
                                           rel->target_mode);

        rel = worksheet->external_vml_header_link;
        if (rel)
            lxw_add_worksheet_relationship(rels, rel->type, rel->target,
                                           rel->target_mode);

        rel = worksheet->external_background_link;
        if (rel)
            lxw_add_worksheet_relationship(rels, rel->type, rel->target,
                                           rel->target_mode);

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

        rel = worksheet->external_comment_link;
        if (rel)
            lxw_add_worksheet_relationship(rels, rel->type, rel->target,
                                           rel->target_mode);

        lxw_snprintf(sheetname, LXW_FILENAME_LENGTH,
                     "xl/worksheets/_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 %r13d, %r13d
movq %r13, 0x18(%rsp)
movq %r13, 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), %r14
testq %r14, %r14
je 0x21b27
leaq 0x18(%rsp), %r15
leaq 0x10(%rsp), %rbx
xorl %ebp, %ebp
cmpb $0x0, (%r14)
jne 0x21b07
movq 0x8(%r14), %r13
incl %ebp
movq 0x218(%r13), %rax
cmpq $0x0, (%rax)
jne 0x21980
movq 0x220(%r13), %rax
cmpq $0x0, (%rax)
jne 0x21980
movq 0x238(%r13), %rax
cmpq $0x0, (%rax)
jne 0x21980
cmpq $0x0, 0x2b8(%r13)
jne 0x21980
cmpq $0x0, 0x2a8(%r13)
jne 0x21980
cmpq $0x0, 0x2c0(%r13)
jne 0x21980
cmpq $0x0, 0x2b0(%r13)
je 0x21b07
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 0x21b19
movq %r15, %rbx
movq 0x218(%r13), %rax
movq (%rax), %r15
testq %r15, %r15
je 0x219d4
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x10(%r15), %rcx
movq %r12, %rdi
callq 0xca10
movq 0x18(%r15), %r15
jmp 0x219b6
movq 0x220(%r13), %rax
movq (%rax), %r15
testq %r15, %r15
je 0x219fc
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x10(%r15), %rcx
movq %r12, %rdi
callq 0xca10
movq 0x18(%r15), %r15
jmp 0x219de
movq 0x2a8(%r13), %rax
testq %rax, %rax
je 0x21a1b
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq %r12, %rdi
callq 0xca10
movq 0x2b8(%r13), %rax
testq %rax, %rax
je 0x21a3a
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq %r12, %rdi
callq 0xca10
movq 0x2c0(%r13), %rax
testq %rax, %rax
je 0x21a59
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq %r12, %rdi
callq 0xca10
movq 0x238(%r13), %rax
movq (%rax), %r15
testq %r15, %r15
je 0x21a81
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x10(%r15), %rcx
movq %r12, %rdi
callq 0xca10
movq 0x18(%r15), %r15
jmp 0x21a63
movq 0x2b0(%r13), %rax
testq %rax, %rax
je 0x21aa0
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq %r12, %rdi
callq 0xca10
movl $0x80, %esi
leaq 0x20(%rsp), %r13
movq %r13, %rdi
leaq 0x2154b(%rip), %rdx     # 0x42fff
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 %r13, %r8
callq 0x224f6
movl %eax, %r13d
movq (%r12), %rdi
callq 0xc420
movq 0x18(%rsp), %rdi
callq 0xc0c0
movq %r12, %rdi
callq 0xc290
testl %r13d, %r13d
jne 0x21b27
movq 0x10(%r14), %r14
testq %r14, %r14
jne 0x2191d
xorl %r13d, %r13d
jmp 0x21b27
movq %r12, %rdi
callq 0xc290
movl $0x3, %r13d
movl %r13d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq