// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x4d0, %rsp            # imm = 0x4D0
movq %rdi, -0x10(%rbp)
leaq -0x14(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
movl $0x1, %esi
movl $0x4, %edx
callq 0xc320
cmpq $0x4, %rax
jae 0x4c51c
movq 0x30b01(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdx
leaq 0x21cfa(%rip), %rsi     # 0x6e203
movb $0x0, %al
callq 0xc8f0
movl $0x1a, -0x4(%rbp)
jmp 0x4c76d
leaq -0x14(%rbp), %rdi
addq $0x1, %rdi
leaq 0x21d21(%rip), %rsi     # 0x6e24c
movl $0x3, %edx
callq 0xc830
cmpl $0x0, %eax
jne 0x4c559
movq -0x10(%rbp), %rdi
callq 0x5b280
cmpl $0x0, %eax
je 0x4c554
movl $0x1a, -0x4(%rbp)
jmp 0x4c76d
jmp 0x4c624
movzbl -0x14(%rbp), %eax
cmpl $0xff, %eax
jne 0x4c58e
movzbl -0x13(%rbp), %eax
cmpl $0xd8, %eax
jne 0x4c58e
movq -0x10(%rbp), %rdi
callq 0x5b6e0
cmpl $0x0, %eax
je 0x4c589
movl $0x1a, -0x4(%rbp)
jmp 0x4c76d
jmp 0x4c622
leaq -0x14(%rbp), %rax
movw (%rax), %ax
subw $0x4d42, %ax            # imm = 0x4D42
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4c5c0
movq -0x10(%rbp), %rdi
callq 0x5bb70
cmpl $0x0, %eax
je 0x4c5be
movl $0x1a, -0x4(%rbp)
jmp 0x4c76d
jmp 0x4c620
leaq -0x14(%rbp), %rax
movl (%rax), %eax
subl $0x38464947, %eax       # imm = 0x38464947
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4c5f2
movq -0x10(%rbp), %rdi
callq 0x5bcc0
cmpl $0x0, %eax
je 0x4c5f0
movl $0x1a, -0x4(%rbp)
jmp 0x4c76d
jmp 0x4c61e
movq 0x309ff(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdx
leaq 0x21c4d(%rip), %rsi     # 0x6e258
movb $0x0, %al
callq 0xc8f0
movl $0x1a, -0x4(%rbp)
jmp 0x4c76d
jmp 0x4c620
jmp 0x4c622
jmp 0x4c624
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0xc560
leaq -0xb0(%rbp), %rdi
callq 0xcf70
leaq -0x4c0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
movl $0x1, %esi
movl $0x400, %edx            # imm = 0x400
callq 0xc320
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0xb8(%rbp)
je 0x4c6ad
leaq -0x4c0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0xd0b0
leaq -0x4c0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rcx
movl $0x1, %esi
movl $0x400, %edx            # imm = 0x400
callq 0xc320
movq %rax, -0xb8(%rbp)
jmp 0x4c662
leaq -0x4d0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xc300
movl $0x1, %edi
movl $0x21, %esi
callq 0xc870
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa0(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
jne 0x4c718
movq 0x30906(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x199d4(%rip), %rsi     # 0x660d0
leaq 0x1fcf1(%rip), %rdx     # 0x6c3f4
movl $0x10b8, %ecx           # imm = 0x10B8
movb $0x0, %al
callq 0xc8f0
movl $0x0, -0x4(%rbp)
jmp 0x4c76d
jmp 0x4c71a
movb $0x0, -0x15(%rbp)
movzbl -0x15(%rbp), %eax
cmpl $0x10, %eax
jge 0x4c766
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rdi
movzbl -0x15(%rbp), %eax
shll %eax
cltq
addq %rax, %rdi
movzbl -0x15(%rbp), %eax
movzbl -0x4d0(%rbp,%rax), %ecx
movl $0x3, %esi
leaq 0x21b4c(%rip), %rdx     # 0x6e2a1
movb $0x0, %al
callq 0xc5d0
movb -0x15(%rbp), %al
addb $0x1, %al
movb %al, -0x15(%rbp)
jmp 0x4c71e
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x4d0, %rsp            # imm = 0x4D0
popq %rbp
retq
nopl (%rax)