// File: /workspace/github_c_makefile_star2_O3/Paxa[P]fast_excel/libxlsxwriter/src/packager.c
// Function: write_drawing_rels_file
STATIC lxw_error
_write_drawing_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 = 1;
    lxw_error err;

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

        if (STAILQ_EMPTY(worksheet->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->drawing_links, list_pointers) {
            lxw_add_worksheet_relationship(rels, rel->type, rel->target,
                                           rel->target_mode);

        }

        lxw_snprintf(sheetname, LXW_FILENAME_LENGTH,
                     "xl/drawings/_rels/drawing%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 $0x98, %rsp
xorl %r14d, %r14d
movq %r14, (%rsp)
movq %r14, 0x8(%rsp)
movq 0x8(%rdi), %rax
xorps %xmm0, %xmm0
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)
movaps %xmm0, 0x10(%rsp)
movq 0x8(%rax), %rax
movq (%rax), %r15
testq %r15, %r15
je 0x21e45
movq %rdi, %rbx
movl $0x1, %ebp
leaq 0x10(%rsp), %r13
cmpb $0x0, (%r15)
movq %r15, %rax
je 0x21d67
movq 0x8(%r15), %rax
movq 0x8(%rax), %r14
movq 0x228(%r14), %rax
cmpq $0x0, (%rax)
je 0x21e25
callq 0xcf00
movq %rax, %r12
movq 0x70(%rbx), %rdx
movq %rsp, %rdi
leaq 0x8(%rsp), %rsi
callq 0xce00
movq %rax, (%r12)
testq %rax, %rax
je 0x21e37
movq 0x228(%r14), %rax
movq (%rax), %r14
testq %r14, %r14
je 0x21dca
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x10(%r14), %rcx
movq %r12, %rdi
callq 0xca10
movq 0x18(%r14), %r14
jmp 0x21dac
movl $0x80, %esi
movq %r13, %rdi
leaq 0x21271(%rip), %rdx     # 0x4304a
movl %ebp, %ecx
xorl %eax, %eax
callq 0xc570
movq %r12, %rdi
callq 0xc310
movq (%r12), %rsi
movq %rbx, %rdi
movq %rsp, %rdx
leaq 0x8(%rsp), %rcx
movq %r13, %r8
callq 0x224f6
movl %eax, %r14d
movq (%r12), %rdi
callq 0xc420
movq (%rsp), %rdi
callq 0xc0c0
movq %r12, %rdi
callq 0xc290
testl %r14d, %r14d
jne 0x21e45
incl %ebp
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x21d5a
xorl %r14d, %r14d
jmp 0x21e45
movq %r12, %rdi
callq 0xc290
movl $0x3, %r14d
movl %r14d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq