// File: /workspace/github_c_makefile_star2_O1/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: get_image_properties
STATIC lxw_error
_get_image_properties(lxw_object_properties *image_props)
{
    unsigned char signature[4];
#ifndef USE_NO_MD5
    uint8_t i;
    MD5_CTX md5_context;
    size_t size_read;
    char buffer[LXW_IMAGE_BUFFER_SIZE];
    unsigned char md5_checksum[LXW_MD5_SIZE];
#endif

    /* Read 4 bytes to look for the file header/signature. */
    if (fread(signature, 1, 4, image_props->stream) < 4) {
        LXW_WARN_FORMAT1("worksheet image insertion: "
                         "couldn't read image type for: %s.",
                         image_props->filename);
        return LXW_ERROR_IMAGE_DIMENSIONS;
    }

    if (memcmp(&signature[1], "PNG", 3) == 0) {
        if (_process_png(image_props) != LXW_NO_ERROR)
            return LXW_ERROR_IMAGE_DIMENSIONS;
    }
    else if (signature[0] == 0xFF && signature[1] == 0xD8) {
        if (_process_jpeg(image_props) != LXW_NO_ERROR)
            return LXW_ERROR_IMAGE_DIMENSIONS;
    }
    else if (memcmp(signature, "BM", 2) == 0) {
        if (_process_bmp(image_props) != LXW_NO_ERROR)
            return LXW_ERROR_IMAGE_DIMENSIONS;
    }
    else if (memcmp(signature, "GIF8", 4) == 0) {
        if (_process_gif(image_props) != LXW_NO_ERROR)
            return LXW_ERROR_IMAGE_DIMENSIONS;
    }
    else {
        LXW_WARN_FORMAT1("worksheet image insertion: "
                         "unsupported image format for: %s.",
                         image_props->filename);
        return LXW_ERROR_IMAGE_DIMENSIONS;
    }

#ifndef USE_NO_MD5
    /* Calculate an MD5 checksum for the image so that we can remove duplicate
     * images to reduce the xlsx file size.*/
    rewind(image_props->stream);

    MD5_Init(&md5_context);

    size_read = fread(buffer, 1, LXW_IMAGE_BUFFER_SIZE, image_props->stream);
    while (size_read) {
        MD5_Update(&md5_context, buffer, (unsigned long) size_read);
        size_read =
            fread(buffer, 1, LXW_IMAGE_BUFFER_SIZE, image_props->stream);
    }

    MD5_Final(md5_checksum, &md5_context);

    /* Create a 32 char hex string buffer for the MD5 checksum. */
    image_props->md5 = calloc(1, LXW_MD5_SIZE * 2 + 1);

    /* If this calloc fails we just return and don't remove duplicates. */
    RETURN_ON_MEM_ERROR(image_props->md5, LXW_NO_ERROR);

    /* Convert the 16 byte MD5 buffer to a 32 char hex string. */
    for (i = 0; i < LXW_MD5_SIZE; i++) {
        lxw_snprintf(&image_props->md5[2 * i], 3, "%02x", md5_checksum[i]);
    }
#endif

    return LXW_NO_ERROR;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4f8, %rsp            # imm = 0x4F8
movq %rdi, %rbx
movq 0x48(%rdi), %rcx
leaq 0x1c(%rsp), %rdi
movl $0x1, %esi
movl $0x4, %edx
callq 0xc2f0
cmpq $0x3, %rax
jbe 0x33c40
movzwl 0x1d(%rsp), %eax
xorl $0x4e50, %eax           # imm = 0x4E50
movzbl 0x1f(%rsp), %ecx
xorl $0x47, %ecx
orw %ax, %cx
je 0x33471
cmpb $-0x1, 0x1c(%rsp)
jne 0x33547
cmpb $-0x28, 0x1d(%rsp)
jne 0x33547
xorl %eax, %eax
movw %ax, 0x20(%rsp)
movw %ax, 0x10(%rsp)
movq 0x48(%rbx), %r14
movq %r14, %rdi
movq $-0x2, %rsi
movl $0x1, %edx
callq 0xcb40
testl %eax, %eax
jne 0x33c6b
movq %r14, %rdi
callq 0xc8a0
movsd 0x11f1f(%rip), %xmm0    # 0x452f0
testl %eax, %eax
je 0x339cd
movapd %xmm0, 0x30(%rsp)
movapd %xmm0, 0x40(%rsp)
movzwl 0x20(%rsp), %eax
testw %ax, %ax
je 0x33c6b
movb $0x2, 0x50(%rbx)
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x68(%rbx)
movzwl 0x10(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x70(%rbx)
xorpd %xmm0, %xmm0
movapd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm1
cmpneqsd %xmm0, %xmm1
andpd %xmm1, %xmm3
movsd 0x11eba(%rip), %xmm2    # 0x452f0
andnpd %xmm2, %xmm1
orpd %xmm3, %xmm1
movlpd %xmm1, 0x80(%rbx)
movapd 0x40(%rsp), %xmm1
cmpneqsd %xmm1, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movlpd %xmm0, 0x88(%rbx)
leaq 0xf7ff(%rip), %rdi      # 0x42c6b
jmp 0x338de
xorl %eax, %eax
movl %eax, 0x20(%rsp)
movl %eax, 0x10(%rsp)
movq 0x48(%rbx), %r14
movl $0x4, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0xcb40
testl %eax, %eax
jne 0x33c6b
movq %r14, %rdi
callq 0xc8a0
movsd 0x11e47(%rip), %xmm0    # 0x452f0
testl %eax, %eax
je 0x33631
movapd %xmm0, 0x30(%rsp)
movapd %xmm0, 0x40(%rsp)
movl 0x20(%rsp), %eax
testl %eax, %eax
je 0x33c6b
movb $0x1, 0x50(%rbx)
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x68(%rbx)
movl 0x10(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x70(%rbx)
xorpd %xmm0, %xmm0
movapd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm1
cmpneqsd %xmm0, %xmm1
andpd %xmm1, %xmm3
movsd 0x11de4(%rip), %xmm2    # 0x452f0
andnpd %xmm2, %xmm1
orpd %xmm3, %xmm1
movlpd %xmm1, 0x80(%rbx)
movapd 0x40(%rsp), %xmm1
cmpneqsd %xmm1, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movlpd %xmm0, 0x88(%rbx)
leaq 0xf71f(%rip), %rdi      # 0x42c61
jmp 0x338de
cmpw $0x4d42, 0x1c(%rsp)     # imm = 0x4D42
je 0x33816
cmpl $0x38464947, 0x1c(%rsp) # imm = 0x38464947
jne 0x33c57
xorl %eax, %eax
movw %ax, 0xf0(%rsp)
movw %ax, 0x58(%rsp)
movq 0x48(%rbx), %r14
movl $0x2, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0xcb40
testl %eax, %eax
jne 0x33c6b
leaq 0xf0(%rsp), %rdi
movl $0x2, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
jne 0x335b8
movw $0x0, 0xf0(%rsp)
leaq 0x58(%rsp), %rdi
movl $0x2, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
jne 0x335db
movw $0x0, 0x58(%rsp)
movzwl 0xf0(%rsp), %eax
testw %ax, %ax
je 0x33c6b
movb $0x4, 0x50(%rbx)
movzwl %ax, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x68(%rbx)
movzwl 0x58(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x70(%rbx)
movabsq $0x4058000000000000, %rax # imm = 0x4058000000000000
movq %rax, 0x80(%rbx)
movq %rax, 0x88(%rbx)
leaq 0xf654(%rip), %rdi      # 0x42c80
jmp 0x338de
leaq 0xf0(%rsp), %r15
leaq 0x58(%rsp), %r12
movapd %xmm0, 0x40(%rsp)
movapd %xmm0, 0x30(%rsp)
movl $0x4, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x334bd
movl $0x1, %esi
movl $0x4, %edx
movq %r12, %rdi
movq %r14, %rcx
callq 0xc2f0
cmpq $0x4, %rax
jb 0x334bd
movl 0xf0(%rsp), %ebp
bswapl %ebp
movl %ebp, 0xf0(%rsp)
cmpl $0x52444849, 0x58(%rsp) # imm = 0x52444849
je 0x336a6
addl $0x4, %ebp
jmp 0x336fd
movl $0x4, %esi
movl $0x1, %edx
leaq 0x20(%rsp), %rdi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x334bd
movl $0x4, %esi
movl $0x1, %edx
leaq 0x10(%rsp), %rdi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x334bd
movl 0x20(%rsp), %eax
bswapl %eax
movl %eax, 0x20(%rsp)
movl 0x10(%rsp), %eax
bswapl %eax
movl %eax, 0x10(%rsp)
addl $-0x4, %ebp
cmpl $0x73594870, 0x58(%rsp) # imm = 0x73594870
jne 0x337d0
xorl %r13d, %r13d
movl %r13d, 0x18(%rsp)
movl %r13d, 0x14(%rsp)
movb $0x1, 0xf(%rsp)
movl $0x4, %esi
movl $0x1, %edx
leaq 0x18(%rsp), %rdi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x337c7
movl $0x4, %esi
movl $0x1, %edx
leaq 0x14(%rsp), %rdi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x337c4
movl $0x1, %esi
movl $0x1, %edx
leaq 0xf(%rsp), %rdi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x337c4
cmpb $0x1, 0xf(%rsp)
jne 0x337bc
movl 0x18(%rsp), %eax
bswapl %eax
movl %eax, 0x18(%rsp)
movl 0x14(%rsp), %ecx
bswapl %ecx
movl %ecx, 0x14(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd 0x12e60(%rip), %xmm1    # 0x46600
mulsd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd %xmm1, %xmm0
movapd %xmm0, 0x40(%rsp)
addl $-0x9, %ebp
movb $0x1, %r13b
jmp 0x337c7
xorl %r13d, %r13d
testb %r13b, %r13b
je 0x334bd
cmpl $0x444e4549, 0x58(%rsp) # imm = 0x444E4549
je 0x334bd
movq %r14, %rdi
callq 0xc8a0
testl %eax, %eax
jne 0x33801
movl %ebp, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0xcb40
testl %eax, %eax
jne 0x33c6b
movq %r14, %rdi
callq 0xc8a0
testl %eax, %eax
je 0x3364a
jmp 0x334bd
xorl %eax, %eax
movl %eax, 0xf0(%rsp)
movl %eax, 0x58(%rsp)
movq 0x48(%rbx), %r14
movl $0xe, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0xcb40
testl %eax, %eax
jne 0x33c6b
leaq 0xf0(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
jne 0x3386b
movl $0x0, 0xf0(%rsp)
leaq 0x58(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
jne 0x3388f
movl $0x0, 0x58(%rsp)
movl 0xf0(%rsp), %eax
testl %eax, %eax
je 0x33c6b
movb $0x3, 0x50(%rbx)
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x68(%rbx)
movl 0x58(%rsp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x70(%rbx)
movabsq $0x4058000000000000, %rax # imm = 0x4058000000000000
movq %rax, 0x80(%rbx)
movq %rax, 0x88(%rbx)
leaq 0xf398(%rip), %rdi      # 0x42c76
callq 0xcce0
movq %rax, 0x78(%rbx)
movq 0x48(%rbx), %rdi
callq 0xc500
leaq 0x58(%rsp), %rdi
callq 0xcec0
movq 0x48(%rbx), %rcx
leaq 0xf0(%rsp), %rdi
movl $0x1, %esi
movl $0x400, %edx            # imm = 0x400
callq 0xc2f0
testq %rax, %rax
je 0x33950
leaq 0x58(%rsp), %r14
leaq 0xf0(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xd000
movq 0x48(%rbx), %rcx
movl $0x1, %esi
movl $0x400, %edx            # imm = 0x400
movq %r15, %rdi
callq 0xc2f0
testq %rax, %rax
jne 0x33927
leaq 0x20(%rsp), %r15
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
callq 0xc2d0
movl $0x1, %edi
movl $0x21, %esi
callq 0xc7f0
movq %rax, 0xa0(%rbx)
testq %rax, %rax
je 0x33c4a
xorl %r14d, %r14d
leaq 0x14e21(%rip), %r12     # 0x487ac
xorl %r13d, %r13d
movq 0xa0(%rbx), %rdi
addq %r13, %rdi
movzbl (%r15), %ecx
movl $0x3, %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0xc570
incq %r15
addq $0x2, %r13
cmpq $0x20, %r13
jne 0x3398e
movl %r14d, %eax
addq $0x4f8, %rsp            # imm = 0x4F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58(%rsp), %r15
movapd %xmm0, 0x40(%rsp)
movapd %xmm0, 0x30(%rsp)
movl $0x2, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x333e5
movl $0x2, %esi
movl $0x1, %edx
leaq 0xf0(%rsp), %rdi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x333e5
movzwl 0x58(%rsp), %eax
movzwl %ax, %ebp
rolw $0x8, %ax
movw %ax, 0x58(%rsp)
movzwl 0xf0(%rsp), %ecx
rolw $0x8, %cx
movw %cx, 0xf0(%rsp)
movzwl %cx, %r12d
leal -0x2(%r12), %r13d
andl $0xfff0, %eax           # imm = 0xFFF0
cmpw $-0x40, %ax
jne 0x33ae1
cmpl $0xc4ff, %ebp           # imm = 0xC4FF
je 0x33ae1
cmpl $0xc8ff, %ebp           # imm = 0xC8FF
je 0x33ae1
cmpl $0xccff, %ebp           # imm = 0xCCFF
je 0x33ae1
movl $0x1, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0xcb40
testl %eax, %eax
jne 0x33c6b
movl $0x2, %esi
movl $0x1, %edx
leaq 0x10(%rsp), %rdi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x333e5
movl $0x2, %esi
movl $0x1, %edx
leaq 0x20(%rsp), %rdi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x333e5
rolw $0x8, 0x10(%rsp)
rolw $0x8, 0x20(%rsp)
addl $-0xb, %r12d
movl %r12d, %r13d
cmpl $0xe0ff, %ebp           # imm = 0xE0FF
jne 0x33b1f
xorl %eax, %eax
movw %ax, 0x18(%rsp)
movw %ax, 0x14(%rsp)
movb $0x1, 0xf(%rsp)
movl $0x7, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0xcb40
movl $0x2, %r12d
testl %eax, %eax
je 0x33b64
testl %r12d, %r12d
jne 0x33c61
cmpl $0xdaff, %ebp           # imm = 0xDAFF
je 0x333e5
movq %r14, %rdi
callq 0xc8a0
testl %eax, %eax
jne 0x33b4f
movl %r13d, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0xcb40
testl %eax, %eax
jne 0x333e5
movq %r14, %rdi
callq 0xc8a0
testl %eax, %eax
je 0x339de
jmp 0x333e5
movl $0x1, %esi
movl $0x1, %edx
leaq 0xf(%rsp), %rdi
movq %r14, %rcx
callq 0xc2f0
movl $0x4, %r12d
testq %rax, %rax
je 0x33b16
movl $0x2, %esi
movl $0x1, %edx
leaq 0x18(%rsp), %rdi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x33b16
movl $0x2, %esi
movl $0x1, %edx
leaq 0x14(%rsp), %rdi
movq %r14, %rcx
callq 0xc2f0
testq %rax, %rax
je 0x33b16
movzwl 0x18(%rsp), %eax
rolw $0x8, %ax
movzwl 0x14(%rsp), %ecx
rolw $0x8, %cx
movw %ax, 0x18(%rsp)
movzwl %ax, %eax
cvtsi2sd %eax, %xmm1
movw %cx, 0x14(%rsp)
movzwl %cx, %eax
cvtsi2sd %eax, %xmm3
movb 0xf(%rsp), %al
movapd %xmm1, %xmm0
movapd %xmm3, %xmm2
cmpb $0x1, %al
je 0x33c0c
movapd 0x30(%rsp), %xmm0
movapd 0x40(%rsp), %xmm2
cmpb $0x2, %al
jne 0x33c28
movsd 0x129e0(%rip), %xmm0    # 0x465f8
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm3
movapd %xmm1, %xmm0
movapd %xmm3, %xmm2
addl $-0xc, %r13d
xorl %r12d, %r12d
movapd %xmm0, 0x30(%rsp)
movapd %xmm2, 0x40(%rsp)
jmp 0x33b16
movq %rbx, %rdi
callq 0xed8f
jmp 0x33c87
callq 0xed65
xorl %r14d, %r14d
jmp 0x339b8
movq %rbx, %rdi
callq 0xed46
jmp 0x33c87
cmpl $0x4, %r12d
je 0x333e5
movq 0x22386(%rip), %rax     # 0x55ff8
movq (%rax), %rdi
movq 0x20(%rbx), %rdx
leaq 0x14b40(%rip), %rsi     # 0x487c0
xorl %eax, %eax
callq 0xc870
movl $0x1a, %r14d
jmp 0x339b8