// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: lxw_worksheet_prepare_vml_objects
uint32_t
lxw_worksheet_prepare_vml_objects(lxw_worksheet *self,
                                  uint32_t vml_data_id,
                                  uint32_t vml_shape_id,
                                  uint32_t vml_drawing_id,
                                  uint32_t comment_id)
{
    lxw_row *row;
    lxw_cell *cell;
    lxw_rel_tuple *relationship;
    char filename[LXW_FILENAME_LENGTH];
    uint32_t comment_count = 0;
    uint32_t i;
    uint32_t tmp_data_id;
    size_t data_str_len = 0;
    size_t used = 0;
    char *vml_data_id_str;

    RB_FOREACH(row, lxw_table_rows, self->comments) {

        RB_FOREACH(cell, lxw_table_cells, row->cells) {
            /* Calculate the worksheet position of the comment. */
            _worksheet_position_vml_object(self, cell->comment);

            /* Store comment in a simple list for use by packager. */
            STAILQ_INSERT_TAIL(self->comment_objs, cell->comment,
                               list_pointers);
            comment_count++;
        }
    }

    /* Set up the VML relationship for comments/buttons/header images. */
    relationship = calloc(1, sizeof(lxw_rel_tuple));
    GOTO_LABEL_ON_MEM_ERROR(relationship, mem_error);

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

    lxw_snprintf(filename, 32, "../drawings/vmlDrawing%d.vml",
                 vml_drawing_id);

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

    self->external_vml_comment_link = relationship;

    if (self->has_comments) {
        /* Only need this relationship object for comment VMLs. */

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

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

        lxw_snprintf(filename, 32, "../comments%d.xml", comment_id);

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

        self->external_comment_link = relationship;
    }

    /* The vml.c <o:idmap> element data id contains a comma separated range
     * when there is more than one 1024 block of comments, like this:
     * data="1,2,3". Since this could potentially (but unlikely) exceed
     * LXW_MAX_ATTRIBUTE_LENGTH we need to allocate space dynamically. */

    /* Calculate the total space required for the ID for each 1024 block. */
    for (i = 0; i <= comment_count / 1024; i++) {
        tmp_data_id = vml_data_id + i;

        /* Calculate the space required for the digits in the id. */
        while (tmp_data_id) {
            data_str_len++;
            tmp_data_id /= 10;
        }

        /* Add an extra char for comma separator or '\O'. */
        data_str_len++;
    };

    /* If this allocation fails it will be dealt with in packager.c. */
    vml_data_id_str = calloc(1, data_str_len + 2);
    GOTO_LABEL_ON_MEM_ERROR(vml_data_id_str, mem_error);

    /* Create the CSV list in the allocated space. */
    for (i = 0; i <= comment_count / 1024; i++) {
        tmp_data_id = vml_data_id + i;
        lxw_snprintf(vml_data_id_str + used, data_str_len - used, "%d,",
                     tmp_data_id);

        used = strlen(vml_data_id_str);
    };

    self->vml_shape_id = vml_shape_id;
    self->vml_data_id_str = vml_data_id_str;

    return comment_count;

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

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl $0x0, -0xc4(%rbp)
movq $0x0, -0xd8(%rbp)
movq $0x0, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x46150
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x4abbb
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x4afb0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x4aba7
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0xcc70
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq $0x0, 0xb8(%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
addq $0xb8, %rcx
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movq %rcx, 0x8(%rax)
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
movq -0x30(%rbp), %rdi
callq 0x4b010
movq %rax, -0x30(%rbp)
jmp 0x4ab23
jmp 0x4aba9
movq -0x28(%rbp), %rdi
callq 0x461b0
movq %rax, -0x28(%rbp)
jmp 0x4ab02
movl $0x1, %edi
movl $0x20, %esi
callq 0xc870
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x4abfe
movq 0x3241c(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b4ea(%rip), %rsi     # 0x660d0
leaq 0x21807(%rip), %rdx     # 0x6c3f4
movl $0xe76, %ecx            # imm = 0xE76
movb $0x0, %al
callq 0xc8f0
jmp 0x4af5a
jmp 0x4ac00
leaq 0x21db3(%rip), %rdi     # 0x6c9ba
callq 0xcd80
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x4ac49
movq 0x323d1(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b49f(%rip), %rsi     # 0x660d0
leaq 0x217bc(%rip), %rdx     # 0x6c3f4
movl $0xe79, %ecx            # imm = 0xE79
movb $0x0, %al
callq 0xc8f0
jmp 0x4af5a
jmp 0x4ac4b
leaq -0xc0(%rbp), %rdi
movl -0x1c(%rbp), %ecx
movl $0x20, %esi
leaq 0x21d65(%rip), %rdx     # 0x6c9c6
movb $0x0, %al
callq 0xc5d0
leaq -0xc0(%rbp), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x4acb3
movq 0x32367(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b435(%rip), %rsi     # 0x660d0
leaq 0x21752(%rip), %rdx     # 0x6c3f4
movl $0xe7f, %ecx            # imm = 0xE7F
movb $0x0, %al
callq 0xc8f0
jmp 0x4af5a
jmp 0x4acb5
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x2a8(%rax)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x2a1(%rax)
je 0x4adde
movl $0x1, %edi
movl $0x20, %esi
callq 0xc870
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x4ad18
movq 0x32302(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b3d0(%rip), %rsi     # 0x660d0
leaq 0x216ed(%rip), %rdx     # 0x6c3f4
movl $0xe87, %ecx            # imm = 0xE87
movb $0x0, %al
callq 0xc8f0
jmp 0x4af5a
jmp 0x4ad1a
leaq 0x21cc2(%rip), %rdi     # 0x6c9e3
callq 0xcd80
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x4ad63
movq 0x322b7(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b385(%rip), %rsi     # 0x660d0
leaq 0x216a2(%rip), %rdx     # 0x6c3f4
movl $0xe8a, %ecx            # imm = 0xE8A
movb $0x0, %al
callq 0xc8f0
jmp 0x4af5a
jmp 0x4ad65
leaq -0xc0(%rbp), %rdi
movl -0x20(%rbp), %ecx
movl $0x20, %esi
leaq 0x21c72(%rip), %rdx     # 0x6c9ed
movb $0x0, %al
callq 0xc5d0
leaq -0xc0(%rbp), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x4adcd
movq 0x3224d(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b31b(%rip), %rsi     # 0x660d0
leaq 0x21638(%rip), %rdx     # 0x6c3f4
movl $0xe8f, %ecx            # imm = 0xE8F
movb $0x0, %al
callq 0xc8f0
jmp 0x4af5a
jmp 0x4adcf
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x2b0(%rax)
movl $0x0, -0xc8(%rbp)
movl -0xc8(%rbp), %eax
movl -0xc4(%rbp), %ecx
shrl $0xa, %ecx
cmpl %ecx, %eax
ja 0x4ae5f
movl -0x14(%rbp), %eax
addl -0xc8(%rbp), %eax
movl %eax, -0xcc(%rbp)
cmpl $0x0, -0xcc(%rbp)
je 0x4ae3c
movq -0xd8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd8(%rbp)
movl -0xcc(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, -0xcc(%rbp)
jmp 0x4ae0a
movq -0xd8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd8(%rbp)
movl -0xc8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
jmp 0x4ade8
movq -0xd8(%rbp), %rsi
addq $0x2, %rsi
movl $0x1, %edi
callq 0xc870
movq %rax, -0xe8(%rbp)
cmpq $0x0, -0xe8(%rbp)
jne 0x4aeae
movq 0x3216c(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1b23a(%rip), %rsi     # 0x660d0
leaq 0x21557(%rip), %rdx     # 0x6c3f4
movl $0xea9, %ecx            # imm = 0xEA9
movb $0x0, %al
callq 0xc8f0
jmp 0x4af5a
jmp 0x4aeb0
movl $0x0, -0xc8(%rbp)
movl -0xc8(%rbp), %eax
movl -0xc4(%rbp), %ecx
shrl $0xa, %ecx
cmpl %ecx, %eax
ja 0x4af30
movl -0x14(%rbp), %eax
addl -0xc8(%rbp), %eax
movl %eax, -0xcc(%rbp)
movq -0xe8(%rbp), %rdi
addq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
subq -0xe0(%rbp), %rsi
movl -0xcc(%rbp), %ecx
leaq 0x21afa(%rip), %rdx     # 0x6c9ff
movb $0x0, %al
callq 0xc5d0
movq -0xe8(%rbp), %rdi
callq 0xc4e0
movq %rax, -0xe0(%rbp)
movl -0xc8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
jmp 0x4aeba
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2e0(%rax)
movq -0xe8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x2d0(%rax)
movl -0xc4(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4af97
cmpq $0x0, -0x38(%rbp)
je 0x4af90
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0xc0d0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xc0d0
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xc0d0
movq -0x38(%rbp), %rdi
callq 0xc0d0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)