// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/packager.c
// Function: write_workbook_rels_file
STATIC lxw_error
_write_workbook_rels_file(lxw_packager *self)
{
    lxw_relationships *rels = lxw_relationships_new();
    char *buffer = NULL;
    size_t buffer_size = 0;
    lxw_workbook *workbook = self->workbook;
    lxw_sheet *sheet;
    char sheetname[LXW_FILENAME_LENGTH] = { 0 };
    uint32_t worksheet_index = 1;
    uint32_t chartsheet_index = 1;
    lxw_error err = LXW_NO_ERROR;

    if (!rels) {
        err = LXW_ERROR_MEMORY_MALLOC_FAILED;
        goto mem_error;
    }

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

    STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
        if (sheet->is_chartsheet) {
            lxw_snprintf(sheetname,
                         LXW_FILENAME_LENGTH,
                         "chartsheets/sheet%d.xml", chartsheet_index++);
            lxw_add_document_relationship(rels, "/chartsheet", sheetname);
        }
        else {
            lxw_snprintf(sheetname,
                         LXW_FILENAME_LENGTH,
                         "worksheets/sheet%d.xml", worksheet_index++);
            lxw_add_document_relationship(rels, "/worksheet", sheetname);
        }
    }

    lxw_add_document_relationship(rels, "/theme", "theme/theme1.xml");
    lxw_add_document_relationship(rels, "/styles", "styles.xml");

    if (workbook->sst->string_count)
        lxw_add_document_relationship(rels, "/sharedStrings",
                                      "sharedStrings.xml");

    if (workbook->vba_project)
        lxw_add_ms_package_relationship(rels, "/vbaProject",
                                        "vbaProject.bin");

    if (workbook->has_metadata)
        lxw_add_document_relationship(rels, "/sheetMetadata", "metadata.xml");

    lxw_relationships_assemble_xml_file(rels);

    err = _add_to_zip(self, rels->file, &buffer, &buffer_size,
                      "xl/_rels/workbook.xml.rels");

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

mem_error:
    lxw_free_relationships(rels);

    return err;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
callq 0xcfb0
movq %rax, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
movl $0x80, %edx
callq 0xc6a0
movl $0x1, -0xb4(%rbp)
movl $0x1, -0xb8(%rbp)
movl $0x0, -0xbc(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x2d64b
movl $0x1, -0xbc(%rbp)
jmp 0x2d81e
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rdx
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xceb0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x2d683
movl $0x3, -0xbc(%rbp)
jmp 0x2d81e
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x2d73f
movq -0x30(%rbp), %rax
cmpb $0x0, (%rax)
je 0x2d6ea
leaq -0xb0(%rbp), %rdi
movl -0xb8(%rbp), %ecx
movl %ecx, %eax
addl $0x1, %eax
movl %eax, -0xb8(%rbp)
movl $0x80, %esi
leaq 0x3b4f2(%rip), %rdx     # 0x68bbc
movb $0x0, %al
callq 0xc5d0
movq -0x10(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
leaq 0x3b690(%rip), %rsi     # 0x68d73
callq 0xc420
jmp 0x2d72c
leaq -0xb0(%rbp), %rdi
movl -0xb4(%rbp), %ecx
movl %ecx, %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
movl $0x80, %esi
leaq 0x3b4ca(%rip), %rdx     # 0x68bd8
movb $0x0, %al
callq 0xc5d0
movq -0x10(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
leaq 0x3b658(%rip), %rsi     # 0x68d7f
callq 0xc420
jmp 0x2d72e
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x2d692
movq -0x10(%rbp), %rdi
leaq 0x3b640(%rip), %rsi     # 0x68d8a
leaq 0x3a6ec(%rip), %rdx     # 0x67e3d
callq 0xc420
movq -0x10(%rbp), %rdi
leaq 0x3b630(%rip), %rsi     # 0x68d91
leaq 0x3a67f(%rip), %rdx     # 0x67de7
callq 0xc420
movq -0x28(%rbp), %rax
movq 0x68(%rax), %rax
cmpl $0x0, 0x8(%rax)
je 0x2d792
movq -0x10(%rbp), %rdi
leaq 0x3b613(%rip), %rsi     # 0x68d99
leaq 0x3a8d6(%rip), %rdx     # 0x68063
callq 0xc420
movq -0x28(%rbp), %rax
cmpq $0x0, 0xe8(%rax)
je 0x2d7b7
movq -0x10(%rbp), %rdi
leaq 0x3b5fd(%rip), %rsi     # 0x68da8
leaq 0x3b7b1(%rip), %rdx     # 0x68f63
callq 0xc4b0
movq -0x28(%rbp), %rax
cmpb $0x0, 0xd5(%rax)
je 0x2d7db
movq -0x10(%rbp), %rdi
leaq 0x3b5e5(%rip), %rsi     # 0x68db4
leaq 0x3a9a6(%rip), %rdx     # 0x6817c
callq 0xc420
movq -0x10(%rbp), %rdi
callq 0xc340
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq -0x18(%rbp), %rdx
leaq -0x20(%rbp), %rcx
leaq 0x3b5c5(%rip), %r8      # 0x68dc3
callq 0x2fd50
movl %eax, -0xbc(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0xc460
movq -0x18(%rbp), %rdi
callq 0xc0d0
movq -0x10(%rbp), %rdi
callq 0xc2c0
movl -0xbc(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)