// File: /workspace/github_c_makefile_star2_O2/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 0x18(%rsp), %rdi
pushq $0x1
popq %rsi
pushq $0x4
popq %rdx
callq 0xc310
cmpq $0x3, %rax
jbe 0x30d3c
leaq 0x19(%rsp), %rdi
leaq 0x15138(%rip), %rsi     # 0x4582c
pushq $0x3
popq %rdx
callq 0xcb60
testl %eax, %eax
je 0x309d7
cmpb $-0x1, 0x18(%rsp)
jne 0x30bbf
cmpb $-0x28, 0x19(%rsp)
jne 0x30bbf
andw $0x0, 0x20(%rsp)
andw $0x0, 0xc(%rsp)
movq 0x48(%rbx), %r14
pushq $-0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0xcbb0
testl %eax, %eax
jne 0x30f02
movaps 0x12f19(%rip), %xmm0    # 0x43660
movaps %xmm0, 0x30(%rsp)
movl $0x0, 0x1c(%rsp)
pushq $0x2
popq %r12
pushq $0x1
popq %r13
movd 0x12f1c(%rip), %xmm0    # 0x43680
punpcklbw %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
movdqa %xmm0, 0x40(%rsp)
movq %r14, %rdi
callq 0xc900
testl %eax, %eax
jne 0x30df5
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
je 0x30df5
leaq 0xf0(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
je 0x30df5
movq %r12, %r13
movzwl 0x58(%rsp), %eax
movl %eax, %ebp
rolw $0x8, %bp
movw %bp, 0x58(%rsp)
movzwl 0xf0(%rsp), %ecx
rolw $0x8, %cx
movw %cx, 0xf0(%rsp)
movzwl %cx, %r12d
leal -0x2(%r12), %r15d
movl %ebp, %ecx
andl $0xfff0, %ecx           # imm = 0xFFF0
cmpw $-0x40, %cx
jne 0x30886
cmpw $0xc4ff, %ax            # imm = 0xC4FF
je 0x30886
movzwl %ax, %eax
cmpl $0xc8ff, %eax           # imm = 0xC8FF
je 0x30886
cmpl $0xccff, %eax           # imm = 0xCCFF
je 0x30886
movq %r14, %rdi
pushq $0x1
popq %rsi
pushq $0x1
popq %rdx
callq 0xcbb0
testl %eax, %eax
jne 0x30f02
leaq 0xc(%rsp), %rdi
movq %r13, %r15
movq %r13, %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
je 0x30df5
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0xc310
movzwl 0x20(%rsp), %ecx
testq %rax, %rax
je 0x30df1
rolw $0x8, 0xc(%rsp)
rolw $0x8, %cx
movl %ecx, 0x1c(%rsp)
movw %cx, 0x20(%rsp)
addl $-0xb, %r12d
movl %r12d, %r15d
cmpw $-0x20, %bp
je 0x308a6
movzwl %bp, %eax
cmpl $0xffda, %eax           # imm = 0xFFDA
movq %r13, %r12
pushq $0x1
popq %r13
jne 0x309ac
jmp 0x30df5
andw $0x0, 0x14(%rsp)
andw $0x0, 0x10(%rsp)
movb $0x1, 0xb(%rsp)
movq %r14, %rdi
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
callq 0xcbb0
testl %eax, %eax
jne 0x30f02
movq %r13, %r12
leaq 0xb(%rsp), %rdi
pushq $0x1
popq %r13
movq %r13, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
je 0x30df5
leaq 0x14(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
je 0x30df5
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
je 0x30df5
movzbl 0xb(%rsp), %eax
movd %eax, %xmm0
punpcklbw %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
punpcklbw %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
movzwl 0x14(%rsp), %eax
movd %eax, %xmm1
pinsrw $0x1, 0x10(%rsp), %xmm1
pcmpeqb 0x40(%rsp), %xmm0
movdqa %xmm1, %xmm2
psrlw $0x8, %xmm2
psllw $0x8, %xmm1
por %xmm2, %xmm1
punpcklwd 0x12d37(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1],xmm1[2],mem[2],xmm1[3],mem[3]
cvtdq2pd %xmm1, %xmm1
pshuflw $0x50, %xmm0, %xmm0     # xmm0 = xmm0[0,0,1,1,4,5,6,7]
pshufd $0x55, %xmm0, %xmm2     # xmm2 = xmm0[1,1,1,1]
movdqa %xmm1, %xmm3
pand %xmm2, %xmm3
pandn 0x30(%rsp), %xmm2
por %xmm3, %xmm2
mulpd 0x12cff(%rip), %xmm1    # 0x43690
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
andpd %xmm0, %xmm1
pandn %xmm2, %xmm0
por %xmm1, %xmm0
movdqa %xmm0, 0x30(%rsp)
addl $-0xc, %r15d
movq %r14, %rdi
callq 0xc900
testl %eax, %eax
jne 0x3076e
movl %r15d, %esi
movq %r14, %rdi
pushq $0x1
popq %rdx
callq 0xcbb0
testl %eax, %eax
je 0x3076e
jmp 0x30df5
andl $0x0, 0x20(%rsp)
andl $0x0, 0xc(%rsp)
movq 0x48(%rbx), %r14
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0xcbb0
testl %eax, %eax
jne 0x30f02
movsd 0x118fd(%rip), %xmm0    # 0x42300
xorl %ebp, %ebp
pushq $0x4
popq %r12
pushq $0x1
popq %r13
movapd %xmm0, 0x30(%rsp)
movapd %xmm0, 0x40(%rsp)
movq %r14, %rdi
callq 0xc900
testl %eax, %eax
jne 0x30d5a
leaq 0xf0(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
je 0x30d5a
leaq 0x58(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0xc310
cmpq $0x4, %rax
jb 0x30d5a
movl 0xf0(%rsp), %r15d
bswapl %r15d
movl %r15d, 0xf0(%rsp)
cmpl $0x52444849, 0x58(%rsp) # imm = 0x52444849
je 0x30a88
addl $0x4, %r15d
jmp 0x30ad8
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
je 0x30d56
leaq 0xc(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xc310
movl 0x20(%rsp), %ebp
testq %rax, %rax
je 0x30d5a
bswapl %ebp
movl %ebp, 0x20(%rsp)
movl 0xc(%rsp), %eax
bswapl %eax
movl %eax, 0xc(%rsp)
addl $-0x4, %r15d
cmpl $0x73594870, 0x58(%rsp) # imm = 0x73594870
jne 0x30b86
andl $0x0, 0x14(%rsp)
andl $0x0, 0x10(%rsp)
movb $0x1, 0xb(%rsp)
leaq 0x14(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
je 0x30d5a
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
je 0x30d5a
leaq 0xb(%rsp), %rdi
movq %r13, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
je 0x30d5a
cmpb $0x1, 0xb(%rsp)
jne 0x30b82
movl 0x14(%rsp), %eax
bswapl %eax
movl 0x10(%rsp), %ecx
bswapl %ecx
cvtsi2sd %rax, %xmm0
movsd 0x12b6f(%rip), %xmm1    # 0x436d8
mulsd %xmm1, %xmm0
movapd %xmm0, 0x30(%rsp)
cvtsi2sd %rcx, %xmm0
mulsd %xmm1, %xmm0
movapd %xmm0, 0x40(%rsp)
addl $-0x9, %r15d
cmpl $0x444e4549, 0x58(%rsp) # imm = 0x444E4549
je 0x30d5a
movq %r14, %rdi
callq 0xc900
testl %eax, %eax
jne 0x30a19
movl %r15d, %esi
movq %r14, %rdi
pushq $0x1
popq %rdx
callq 0xcbb0
testl %eax, %eax
je 0x30a19
jmp 0x30f02
cmpw $0x4d42, 0x18(%rsp)     # imm = 0x4D42
je 0x30c8c
cmpl $0x38464947, 0x18(%rsp) # imm = 0x38464947
jne 0x30dd7
andw $0x0, 0xf0(%rsp)
andw $0x0, 0x58(%rsp)
movq 0x48(%rbx), %r14
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0xcbb0
testl %eax, %eax
jne 0x30f02
leaq 0xf0(%rsp), %rdi
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
jne 0x30c27
andw $0x0, 0xf0(%rsp)
leaq 0x58(%rsp), %rdi
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
jne 0x30c45
andw $0x0, 0x58(%rsp)
movzwl 0xf0(%rsp), %eax
testw %ax, %ax
je 0x30f02
movb $0x4, 0x50(%rbx)
movzwl %ax, %eax
movd %eax, %xmm0
pinsrw $0x2, 0x58(%rsp), %xmm0
cvtdq2pd %xmm0, %xmm0
movups %xmm0, 0x68(%rbx)
movapd 0x129e8(%rip), %xmm0    # 0x43660
movupd %xmm0, 0x80(%rbx)
leaq 0xf009(%rip), %rdi      # 0x3fc90
jmp 0x30e4b
andl $0x0, 0xf0(%rsp)
andl $0x0, 0x58(%rsp)
movq 0x48(%rbx), %r14
pushq $0xe
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0xcbb0
testl %eax, %eax
jne 0x30f02
leaq 0xf0(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
jne 0x30cd6
andl $0x0, 0xf0(%rsp)
leaq 0x58(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0xc310
testq %rax, %rax
jne 0x30cf3
andl $0x0, 0x58(%rsp)
movl 0xf0(%rsp), %eax
testl %eax, %eax
je 0x30f02
movb $0x3, 0x50(%rbx)
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x68(%rbx)
movl 0x58(%rsp), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x70(%rbx)
movapd 0x12938(%rip), %xmm0    # 0x43660
movupd %xmm0, 0x80(%rbx)
leaq 0xef4f(%rip), %rdi      # 0x3fc86
jmp 0x30e4b
movq 0x222b5(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
movq 0x20(%rbx), %rdx
leaq 0x14a92(%rip), %rsi     # 0x457e3
jmp 0x30f17
movl 0x20(%rsp), %ebp
testl %ebp, %ebp
je 0x30f02
movb $0x1, 0x50(%rbx)
movl %ebp, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x68(%rbx)
movl 0xc(%rsp), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x70(%rbx)
xorpd %xmm0, %xmm0
movapd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm1
cmpneqsd %xmm0, %xmm1
andpd %xmm1, %xmm3
movsd 0x11561(%rip), %xmm2    # 0x42300
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 0xee9c(%rip), %rdi      # 0x3fc71
jmp 0x30e4b
movq 0x2221a(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
movq 0x20(%rbx), %rdx
leaq 0x14a4c(%rip), %rsi     # 0x45838
jmp 0x30f17
movl %ecx, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
testw %ax, %ax
je 0x30f02
movb $0x2, 0x50(%rbx)
movzwl %ax, %eax
movd %eax, %xmm0
pinsrw $0x2, 0xc(%rsp), %xmm0
cvtdq2pd %xmm0, %xmm0
movupd %xmm0, 0x68(%rbx)
xorpd %xmm0, %xmm0
movapd 0x30(%rsp), %xmm1
cmpneqpd %xmm1, %xmm0
andpd %xmm0, %xmm1
andnpd 0x12828(%rip), %xmm0    # 0x43660
orpd %xmm1, %xmm0
movupd %xmm0, 0x80(%rbx)
leaq 0xee30(%rip), %rdi      # 0x3fc7b
callq 0xcd50
movq %rax, 0x78(%rbx)
movq 0x48(%rbx), %rdi
callq 0xc540
leaq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0xcf40
leaq 0xf0(%rsp), %r15
pushq $0x1
popq %r12
movq 0x48(%rbx), %rcx
movl $0x400, %edx            # imm = 0x400
movq %r15, %rdi
movq %r12, %rsi
callq 0xc310
testq %rax, %rax
je 0x30e9f
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xd080
jmp 0x30e76
leaq 0x20(%rsp), %r15
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
callq 0xc2f0
pushq $0x1
popq %rdi
pushq $0x21
popq %rsi
callq 0xc850
movq %rax, 0xa0(%rbx)
testq %rax, %rax
je 0x30f24
xorl %r14d, %r14d
leaq 0x149af(%rip), %r12     # 0x45881
pushq $0x3
popq %r13
xorl %ebp, %ebp
cmpq $0x20, %rbp
je 0x30f4b
movq 0xa0(%rbx), %rdi
addq %rbp, %rdi
movzbl (%r15), %ecx
movq %r13, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0xc5b0
addq $0x2, %rbp
incq %r15
jmp 0x30ed8
movq 0x220ef(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
movq 0x20(%rbx), %rdx
leaq 0x1497e(%rip), %rsi     # 0x45895
xorl %eax, %eax
callq 0xc8d0
pushq $0x1a
popq %r14
jmp 0x30f4b
movq 0x220cd(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0xc1ab(%rip), %rsi      # 0x3d0e0
leaq 0x12aa4(%rip), %rdx     # 0x439e0
xorl %r14d, %r14d
movl $0x10b8, %ecx           # imm = 0x10B8
xorl %eax, %eax
callq 0xc8d0
movl %r14d, %eax
addq $0x4f8, %rsp            # imm = 0x4F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq