// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/workbook.c
// Function: prepare_drawings
STATIC void
_prepare_drawings(lxw_workbook *self)
{
    lxw_sheet *sheet;
    lxw_worksheet *worksheet;
    lxw_object_properties *object_props;
    uint32_t chart_ref_id = 0;
    uint32_t image_ref_id = 0;
    uint32_t ref_id = 0;
    uint32_t drawing_id = 0;
    uint8_t is_chartsheet;
    lxw_image_md5 tmp_image_md5;
    lxw_image_md5 *new_image_md5 = NULL;
    lxw_image_md5 *found_duplicate_image = NULL;
    uint8_t i;

    STAILQ_FOREACH(sheet, self->sheets, list_pointers) {
        if (sheet->is_chartsheet) {
            worksheet = sheet->u.chartsheet->worksheet;
            is_chartsheet = LXW_TRUE;
        }
        else {
            worksheet = sheet->u.worksheet;
            is_chartsheet = LXW_FALSE;
        }

        if (STAILQ_EMPTY(worksheet->image_props)
            && STAILQ_EMPTY(worksheet->chart_data)
            && !worksheet->has_header_vml && !worksheet->has_background_image) {
            continue;
        }

        drawing_id++;

        /* Prepare background images. */
        if (worksheet->has_background_image) {

            object_props = worksheet->background_image;

            _store_image_type(self, object_props->image_type);

            /* Check for duplicate images and only store the first instance. */
            if (object_props->md5) {
                tmp_image_md5.md5 = object_props->md5;
                found_duplicate_image = RB_FIND(lxw_image_md5s,
                                                self->background_md5s,
                                                &tmp_image_md5);
            }

            if (found_duplicate_image) {
                ref_id = found_duplicate_image->id;
                object_props->is_duplicate = LXW_TRUE;
            }
            else {
                image_ref_id++;
                ref_id = image_ref_id;

#ifndef USE_NO_MD5
                new_image_md5 = calloc(1, sizeof(lxw_image_md5));
#endif
                if (new_image_md5 && object_props->md5) {
                    new_image_md5->id = ref_id;
                    new_image_md5->md5 = lxw_strdup(object_props->md5);

                    RB_INSERT(lxw_image_md5s, self->background_md5s,
                              new_image_md5);
                }
            }

            lxw_worksheet_prepare_background(worksheet, ref_id, object_props);
        }

        /* Prepare worksheet images. */
        STAILQ_FOREACH(object_props, worksheet->image_props, list_pointers) {

            /* Ignore background image added above. */
            if (object_props->is_background)
                continue;

            _store_image_type(self, object_props->image_type);

            /* Check for duplicate images and only store the first instance. */
            if (object_props->md5) {
                tmp_image_md5.md5 = object_props->md5;
                found_duplicate_image = RB_FIND(lxw_image_md5s,
                                                self->image_md5s,
                                                &tmp_image_md5);
            }

            if (found_duplicate_image) {
                ref_id = found_duplicate_image->id;
                object_props->is_duplicate = LXW_TRUE;
            }
            else {
                image_ref_id++;
                ref_id = image_ref_id;

#ifndef USE_NO_MD5
                new_image_md5 = calloc(1, sizeof(lxw_image_md5));
#endif
                if (new_image_md5 && object_props->md5) {
                    new_image_md5->id = ref_id;
                    new_image_md5->md5 = lxw_strdup(object_props->md5);

                    RB_INSERT(lxw_image_md5s, self->image_md5s,
                              new_image_md5);
                }
            }

            lxw_worksheet_prepare_image(worksheet, ref_id, drawing_id,
                                        object_props);
        }

        /* Prepare worksheet charts. */
        STAILQ_FOREACH(object_props, worksheet->chart_data, list_pointers) {
            chart_ref_id++;
            lxw_worksheet_prepare_chart(worksheet, chart_ref_id, drawing_id,
                                        object_props, is_chartsheet);
            if (object_props->chart)
                STAILQ_INSERT_TAIL(self->ordered_charts, object_props->chart,
                                   ordered_list_pointers);
        }

        /* Prepare worksheet header/footer images. */
        for (i = 0; i < LXW_HEADER_FOOTER_OBJS_MAX; i++) {

            object_props = *worksheet->header_footer_objs[i];
            if (!object_props)
                continue;

            _store_image_type(self, object_props->image_type);

            /* Check for duplicate images and only store the first instance. */
            if (object_props->md5) {
                tmp_image_md5.md5 = object_props->md5;
                found_duplicate_image = RB_FIND(lxw_image_md5s,
                                                self->header_image_md5s,
                                                &tmp_image_md5);
            }

            if (found_duplicate_image) {
                ref_id = found_duplicate_image->id;
                object_props->is_duplicate = LXW_TRUE;
            }
            else {
                image_ref_id++;
                ref_id = image_ref_id;

#ifndef USE_NO_MD5
                new_image_md5 = calloc(1, sizeof(lxw_image_md5));
#endif
                if (new_image_md5 && object_props->md5) {
                    new_image_md5->id = ref_id;
                    new_image_md5->md5 = lxw_strdup(object_props->md5);

                    RB_INSERT(lxw_image_md5s, self->header_image_md5s,
                              new_image_md5);
                }
            }

            lxw_worksheet_prepare_header_image(worksheet, ref_id,
                                               object_props);
        }

    }

    self->drawing_count = drawing_id;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x3effa
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x3eba4
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movb $0x1, -0x31(%rbp)
jmp 0x3ebb4
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movb $0x0, -0x31(%rbp)
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
cmpq $0x0, (%rax)
jne 0x3ebef
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
cmpq $0x0, (%rax)
jne 0x3ebef
movq -0x18(%rbp), %rax
cmpb $0x0, 0x2a2(%rax)
jne 0x3ebef
movq -0x18(%rbp), %rax
cmpb $0x0, 0x2a3(%rax)
jne 0x3ebef
jmp 0x3efe9
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x2a3(%rax)
je 0x3ecf6
movq -0x18(%rbp), %rax
movq 0x3a8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movzbl 0x50(%rax), %esi
callq 0x43710
movq -0x20(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x3ec5b
movq -0x20(%rbp), %rax
movq 0xa0(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
leaq -0x68(%rbp), %rsi
callq 0x43770
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x3ec78
movq -0x78(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movb $0x1, 0x98(%rax)
jmp 0x3ece6
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0x1, %edi
movl $0x30, %esi
callq 0xc870
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x3ece4
movq -0x20(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x3ece4
movl -0x2c(%rbp), %ecx
movq -0x70(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movq 0xa0(%rax), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x70(%rbp), %rsi
callq 0x437f0
jmp 0x3ece6
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0xcc60
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x3ee17
movq -0x20(%rbp), %rax
cmpb $0x0, 0x99(%rax)
je 0x3ed22
jmp 0x3ee03
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movzbl 0x50(%rax), %esi
callq 0x43710
movq -0x20(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x3ed65
movq -0x20(%rbp), %rax
movq 0xa0(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
leaq -0x68(%rbp), %rsi
callq 0x43770
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x3ed82
movq -0x78(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movb $0x1, 0x98(%rax)
jmp 0x3edf0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0x1, %edi
movl $0x30, %esi
callq 0xc870
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x3edee
movq -0x20(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x3edee
movl -0x2c(%rbp), %ecx
movq -0x70(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movq 0xa0(%rax), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x70(%rbp), %rsi
callq 0x437f0
jmp 0x3edf0
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
movq -0x20(%rbp), %rcx
callq 0xc6f0
movq -0x20(%rbp), %rax
movq 0xb8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x3ed05
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x3eec8
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x30(%rbp), %edx
movq -0x20(%rbp), %rcx
movzbl -0x31(%rbp), %r8d
callq 0xcf90
movq -0x20(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x3eeb2
jmp 0x3ee62
movq -0x20(%rbp), %rax
movq 0x90(%rax), %rax
movq $0x0, 0x170(%rax)
movq -0x20(%rbp), %rax
movq 0x90(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq 0x90(%rax), %rcx
addq $0x170, %rcx            # imm = 0x170
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0x3eeb2
jmp 0x3eeb4
movq -0x20(%rbp), %rax
movq 0xb8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x3ee26
movb $0x0, -0x79(%rbp)
movzbl -0x79(%rbp), %eax
cmpl $0x6, %eax
jge 0x3efe7
movq -0x18(%rbp), %rax
movzbl -0x79(%rbp), %ecx
movq 0x348(%rax,%rcx,8), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x3eefc
jmp 0x3efda
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movzbl 0x50(%rax), %esi
callq 0x43710
movq -0x20(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x3ef3f
movq -0x20(%rbp), %rax
movq 0xa0(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rdi
leaq -0x68(%rbp), %rsi
callq 0x43770
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x3ef5c
movq -0x78(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movb $0x1, 0x98(%rax)
jmp 0x3efca
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl $0x1, %edi
movl $0x30, %esi
callq 0xc870
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x3efc8
movq -0x20(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x3efc8
movl -0x2c(%rbp), %ecx
movq -0x70(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movq 0xa0(%rax), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x70(%rbp), %rsi
callq 0x437f0
jmp 0x3efca
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0xce40
movb -0x79(%rbp), %al
addb $0x1, %al
movb %al, -0x79(%rbp)
jmp 0x3eecc
jmp 0x3efe9
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0x3eb7a
movl -0x30(%rbp), %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0xc0(%rax)
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)