// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: process_jpeg
STATIC lxw_error
_process_jpeg(lxw_object_properties *image_props)
{
    uint16_t length;
    uint16_t marker;
    uint32_t offset;
    uint16_t width = 0;
    uint16_t height = 0;
    double x_dpi = 96;
    double y_dpi = 96;
    int fseek_err;

    FILE *stream = image_props->stream;

    /* Read back 2 bytes to the end of the initial 0xFFD8 marker. */
    fseek_err = fseek(stream, -2, SEEK_CUR);
    if (fseek_err)
        goto file_error;

    /* Search through the image data and read the JPEG markers. */
    while (!feof(stream)) {

        /* Read the JPEG marker and length fields for the sub-section. */
        if (fread(&marker, sizeof(marker), 1, stream) < 1)
            break;

        if (fread(&length, sizeof(length), 1, stream) < 1)
            break;

        /* Convert the marker and length to network order. */
        marker = LXW_UINT16_NETWORK(marker);
        length = LXW_UINT16_NETWORK(length);

        /* The offset for next fseek() is the field length + type length. */
        offset = length - 2;

        /* Read the height and width in the 0xFFCn elements (except C4, C8 */
        /* and CC which aren't SOF markers). */
        if ((marker & 0xFFF0) == 0xFFC0 && marker != 0xFFC4
            && marker != 0xFFC8 && marker != 0xFFCC) {
            /* Skip 1 byte to height and width. */
            fseek_err = fseek(stream, 1, SEEK_CUR);
            if (fseek_err)
                goto file_error;

            if (fread(&height, sizeof(height), 1, stream) < 1)
                break;

            if (fread(&width, sizeof(width), 1, stream) < 1)
                break;

            height = LXW_UINT16_NETWORK(height);
            width = LXW_UINT16_NETWORK(width);

            offset -= 9;
        }

        /* Read the DPI in the 0xFFE0 element. */
        if (marker == 0xFFE0) {
            uint16_t x_density = 0;
            uint16_t y_density = 0;
            uint8_t units = 1;

            fseek_err = fseek(stream, 7, SEEK_CUR);
            if (fseek_err)
                goto file_error;

            if (fread(&units, sizeof(units), 1, stream) < 1)
                break;

            if (fread(&x_density, sizeof(x_density), 1, stream) < 1)
                break;

            if (fread(&y_density, sizeof(y_density), 1, stream) < 1)
                break;

            x_density = LXW_UINT16_NETWORK(x_density);
            y_density = LXW_UINT16_NETWORK(y_density);

            if (units == 1) {
                x_dpi = x_density;
                y_dpi = y_density;
            }

            if (units == 2) {
                x_dpi = x_density * 2.54;
                y_dpi = y_density * 2.54;
            }

            offset -= 12;
        }

        if (marker == 0xFFDA)
            break;

        if (!feof(stream)) {
            fseek_err = fseek(stream, offset, SEEK_CUR);
            if (fseek_err)
                break;
        }
    }

    /* Ensure that we read some valid data from the file. */
    if (width == 0)
        goto file_error;

    /* Set the image metadata. */
    image_props->image_type = LXW_IMAGE_JPEG;
    image_props->width = width;
    image_props->height = height;
    image_props->x_dpi = x_dpi ? x_dpi : 96;
    image_props->y_dpi = y_dpi ? y_dpi : 96;
    image_props->extension = lxw_strdup("jpeg");

    return LXW_NO_ERROR;

file_error:
    LXW_WARN_FORMAT1("worksheet image insertion: "
                     "no size data found in: %s.", image_props->filename);

    return LXW_ERROR_IMAGE_DIMENSIONS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movw $0x0, -0x1a(%rbp)
movw $0x0, -0x1c(%rbp)
movsd 0xf8e8(%rip), %xmm0     # 0x6afe8
movsd %xmm0, -0x28(%rbp)
movsd 0xf8db(%rip), %xmm0     # 0x6afe8
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq $-0x2, %rsi
movl $0x1, %edx
callq 0xcbe0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x5b741
jmp 0x5bb33
jmp 0x5b743
movq -0x40(%rbp), %rdi
callq 0xc920
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x5b75d
jmp 0x5ba5f
movq -0x40(%rbp), %rcx
leaq -0x14(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0xc320
cmpq $0x1, %rax
jae 0x5b77f
jmp 0x5ba5f
movq -0x40(%rbp), %rcx
leaq -0x12(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0xc320
cmpq $0x1, %rax
jae 0x5b7a1
jmp 0x5ba5f
movzwl -0x14(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
movzwl -0x14(%rbp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
sarl $0x8, %ecx
orl %ecx, %eax
movw %ax, -0x14(%rbp)
movzwl -0x12(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
movzwl -0x12(%rbp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
sarl $0x8, %ecx
orl %ecx, %eax
movw %ax, -0x12(%rbp)
movzwl -0x12(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x18(%rbp)
movzwl -0x14(%rbp), %eax
andl $0xfff0, %eax           # imm = 0xFFF0
cmpl $0xffc0, %eax           # imm = 0xFFC0
jne 0x5b8d6
movzwl -0x14(%rbp), %eax
cmpl $0xffc4, %eax           # imm = 0xFFC4
je 0x5b8d6
movzwl -0x14(%rbp), %eax
cmpl $0xffc8, %eax           # imm = 0xFFC8
je 0x5b8d6
movzwl -0x14(%rbp), %eax
cmpl $0xffcc, %eax           # imm = 0xFFCC
je 0x5b8d6
movq -0x40(%rbp), %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0xcbe0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x5b84b
jmp 0x5bb33
movq -0x40(%rbp), %rcx
leaq -0x1c(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0xc320
cmpq $0x1, %rax
jae 0x5b86d
jmp 0x5ba5f
movq -0x40(%rbp), %rcx
leaq -0x1a(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0xc320
cmpq $0x1, %rax
jae 0x5b88f
jmp 0x5ba5f
movzwl -0x1c(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
movzwl -0x1c(%rbp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
sarl $0x8, %ecx
orl %ecx, %eax
movw %ax, -0x1c(%rbp)
movzwl -0x1a(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
movzwl -0x1a(%rbp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
sarl $0x8, %ecx
orl %ecx, %eax
movw %ax, -0x1a(%rbp)
movl -0x18(%rbp), %eax
subl $0x9, %eax
movl %eax, -0x18(%rbp)
movzwl -0x14(%rbp), %eax
cmpl $0xffe0, %eax           # imm = 0xFFE0
jne 0x5ba1f
movw $0x0, -0x42(%rbp)
movw $0x0, -0x44(%rbp)
movb $0x1, -0x45(%rbp)
movq -0x40(%rbp), %rdi
movl $0x7, %esi
movl $0x1, %edx
callq 0xcbe0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x5b916
jmp 0x5bb33
movq -0x40(%rbp), %rcx
leaq -0x45(%rbp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0xc320
cmpq $0x1, %rax
jae 0x5b936
jmp 0x5ba5f
movq -0x40(%rbp), %rcx
leaq -0x42(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0xc320
cmpq $0x1, %rax
jae 0x5b958
jmp 0x5ba5f
movq -0x40(%rbp), %rcx
leaq -0x44(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0xc320
cmpq $0x1, %rax
jae 0x5b97a
jmp 0x5ba5f
movzwl -0x42(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
movzwl -0x42(%rbp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
sarl $0x8, %ecx
orl %ecx, %eax
movw %ax, -0x42(%rbp)
movzwl -0x44(%rbp), %eax
andl $0xff, %eax
shll $0x8, %eax
movzwl -0x44(%rbp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
sarl $0x8, %ecx
orl %ecx, %eax
movw %ax, -0x44(%rbp)
movzbl -0x45(%rbp), %eax
cmpl $0x1, %eax
jne 0x5b9db
movzwl -0x42(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x28(%rbp)
movzwl -0x44(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x30(%rbp)
movzbl -0x45(%rbp), %eax
cmpl $0x2, %eax
jne 0x5ba16
movzwl -0x42(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd 0x10934(%rip), %xmm1    # 0x6c328
mulsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movzwl -0x44(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd 0x1091b(%rip), %xmm1    # 0x6c328
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x18(%rbp), %eax
subl $0xc, %eax
movl %eax, -0x18(%rbp)
movzwl -0x14(%rbp), %eax
cmpl $0xffda, %eax           # imm = 0xFFDA
jne 0x5ba2c
jmp 0x5ba5f
movq -0x40(%rbp), %rdi
callq 0xc920
cmpl $0x0, %eax
jne 0x5ba5a
movq -0x40(%rbp), %rdi
movl -0x18(%rbp), %eax
movl %eax, %esi
movl $0x1, %edx
callq 0xcbe0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x5ba58
jmp 0x5ba5f
jmp 0x5ba5a
jmp 0x5b743
movzwl -0x1a(%rbp), %eax
cmpl $0x0, %eax
jne 0x5ba6d
jmp 0x5bb33
movq -0x10(%rbp), %rax
movb $0x2, 0x50(%rax)
movzwl -0x1a(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x68(%rax)
movzwl -0x1c(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x70(%rax)
movsd -0x28(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x5baa9
jp 0x5baa9
jmp 0x5bab5
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0x5bac4
movsd 0xf52b(%rip), %xmm0     # 0x6afe8
movsd %xmm0, -0x50(%rbp)
jmp 0x5bac4
movsd -0x50(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x80(%rax)
movsd -0x30(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x5bae7
jp 0x5bae7
jmp 0x5baf3
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x5bb02
movsd 0xf4ed(%rip), %xmm0     # 0x6afe8
movsd %xmm0, -0x58(%rbp)
jmp 0x5bb02
movsd -0x58(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x88(%rax)
leaq 0xcf85(%rip), %rdi      # 0x68a9f
callq 0xcd80
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x78(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x5bb5a
movq 0x214be(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdx
leaq 0x12769(%rip), %rsi     # 0x6e2b5
movb $0x0, %al
callq 0xc8f0
movl $0x1a, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)