// File: /workspace/github_c_makefile_star2_O2/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: lxw_worksheet_prepare_tables
void
lxw_worksheet_prepare_tables(lxw_worksheet *self, uint32_t table_id)
{
    lxw_table_obj *table_obj;
    lxw_rel_tuple *relationship;
    char name[LXW_ATTR_32];
    char filename[LXW_FILENAME_LENGTH];

    STAILQ_FOREACH(table_obj, self->table_objs, list_pointers) {

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

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

        lxw_snprintf(filename, LXW_FILENAME_LENGTH,
                     "../tables/table%d.xml", table_id);

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

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

        if (!table_obj->name) {
            lxw_snprintf(name, LXW_ATTR_32, "Table%d", table_id);
            table_obj->name = lxw_strdup(name);
            GOTO_LABEL_ON_MEM_ERROR(table_obj->name, mem_error);
        }
        table_obj->id = table_id;
        table_id++;
    }

    return;

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

    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %esi, %ebp
movq %rdi, %r14
movq 0x98(%rdi), %r15
leaq 0x20(%rsp), %r13
movq (%r15), %r15
testq %r15, %r15
je 0x2f914
pushq $0x1
popq %rdi
pushq $0x20
popq %rsi
callq 0xc850
testq %rax, %rax
je 0x2f89a
movq %rax, %rbx
leaq 0x147f0(%rip), %rdi     # 0x43fe6
callq 0xcd50
movq %rax, (%rbx)
testq %rax, %rax
je 0x2f8c0
movl $0x80, %esi
movq %r13, %rdi
leaq 0x147d7(%rip), %rdx     # 0x43fed
movl %ebp, %ecx
xorl %eax, %eax
callq 0xc5b0
movq %r13, %rdi
callq 0xcd50
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x2f8c7
movq %rbx, %rax
andq $0x0, 0x18(%rbx)
addq $0x18, %rax
movq 0x238(%r14), %rcx
movq 0x8(%rcx), %rcx
movq %rbx, (%rcx)
movq 0x238(%r14), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, (%r15)
jne 0x2f888
movq %rsp, %r12
movq %r12, %rdi
pushq $0x20
popq %rsi
leaq 0x14794(%rip), %rdx     # 0x44003
movl %ebp, %ecx
xorl %eax, %eax
callq 0xc5b0
movq %r12, %rdi
callq 0xcd50
movq %rax, (%r15)
testq %rax, %rax
je 0x2f8ce
movl %ebp, 0x34(%r15)
incl %ebp
addq $0x1078, %r15           # imm = 0x1078
jmp 0x2f7cc
movq 0x23757(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0xd835(%rip), %rsi      # 0x3d0e0
leaq 0x1412e(%rip), %rdx     # 0x439e0
movl $0xf05, %ecx            # imm = 0xF05
xorl %eax, %eax
callq 0xc8d0
jmp 0x2f914
movl $0xf08, %ecx            # imm = 0xF08
jmp 0x2f8d3
movl $0xf0e, %ecx            # imm = 0xF0E
jmp 0x2f8d3
movl $0xf16, %ecx            # imm = 0xF16
movq 0x2371e(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0xd7fc(%rip), %rsi      # 0x3d0e0
leaq 0x140f5(%rip), %rdx     # 0x439e0
xorl %eax, %eax
callq 0xc8d0
movq (%rbx), %rdi
callq 0xc0d0
movq 0x8(%rbx), %rdi
callq 0xc0d0
movq 0x10(%rbx), %rdi
callq 0xc0d0
movq %rbx, %rdi
callq 0xc0d0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq