// File: /workspace/github_c_makefile_star2_O2/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_insert_image_opt
lxw_error
worksheet_insert_image_opt(lxw_worksheet *self,
                           lxw_row_t row_num, lxw_col_t col_num,
                           const char *filename,
                           lxw_image_options *user_options)
{
    FILE *image_stream;
    const char *description;
    lxw_object_properties *object_props;

    if (!filename) {
        LXW_WARN("worksheet_insert_image()/_opt(): "
                 "filename must be specified.");
        return LXW_ERROR_NULL_PARAMETER_IGNORED;
    }

    /* Check that the image file exists and can be opened. */
    image_stream = lxw_fopen(filename, "rb");
    if (!image_stream) {
        LXW_WARN_FORMAT1("worksheet_insert_image()/_opt(): "
                         "file doesn't exist or can't be opened: %s.",
                         filename);
        return LXW_ERROR_PARAMETER_VALIDATION;
    }

    /* Use the filename as the default description, like Excel. */
    description = lxw_basename(filename);
    if (!description) {
        LXW_WARN_FORMAT1("worksheet_insert_image()/_opt(): "
                         "couldn't get basename for file: %s.", filename);
        fclose(image_stream);
        return LXW_ERROR_PARAMETER_VALIDATION;
    }

    /* Create a new object to hold the image properties. */
    object_props = calloc(1, sizeof(lxw_object_properties));
    if (!object_props) {
        fclose(image_stream);
        return LXW_ERROR_MEMORY_MALLOC_FAILED;
    }

    if (user_options) {
        object_props->x_offset = user_options->x_offset;
        object_props->y_offset = user_options->y_offset;
        object_props->x_scale = user_options->x_scale;
        object_props->y_scale = user_options->y_scale;
        object_props->object_position = user_options->object_position;
        object_props->url = lxw_strdup(user_options->url);
        object_props->tip = lxw_strdup(user_options->tip);
        object_props->decorative = user_options->decorative;

        if (user_options->description)
            description = user_options->description;
    }

    /* Copy other options or set defaults. */
    object_props->filename = lxw_strdup(filename);
    object_props->description = lxw_strdup(description);
    object_props->stream = image_stream;
    object_props->row = row_num;
    object_props->col = col_num;

    if (object_props->x_scale == 0.0)
        object_props->x_scale = 1;

    if (object_props->y_scale == 0.0)
        object_props->y_scale = 1;

    if (_get_image_properties(object_props) == LXW_NO_ERROR) {
        STAILQ_INSERT_TAIL(self->image_props, object_props, list_pointers);
        fclose(image_stream);
        return LXW_NO_ERROR;
    }
    else {
        _free_object_properties(object_props);
        fclose(image_stream);
        return LXW_ERROR_IMAGE_DIMENSIONS;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rcx, %rcx
je 0x39a49
movq %r8, %rbp
movq %rcx, %r15
movl %edx, %r13d
movl %esi, %r14d
movq %rdi, %r12
leaq 0x3746(%rip), %rsi      # 0x3d000
movq %rcx, %rdi
callq 0xc270
testq %rax, %rax
je 0x39a69
movq %rax, %rbx
movl %r14d, 0x4(%rsp)
movq %r15, %rdi
callq 0xc9c0
testq %rax, %rax
je 0x39a86
movq %rax, %r14
movl %r13d, (%rsp)
movq %r12, 0x8(%rsp)
pushq $0x1
popq %rdi
movl $0xc0, %esi
callq 0xc850
testq %rax, %rax
je 0x39994
movq %rax, %r13
testq %rbp, %rbp
je 0x399a3
movq (%rbp), %rax
movq %rax, (%r13)
movupd 0x8(%rbp), %xmm0
movapd %xmm0, 0x10(%rsp)
movupd %xmm0, 0x8(%r13)
movb 0x18(%rbp), %al
movb %al, 0x40(%r13)
movq 0x30(%rbp), %rdi
callq 0xcd50
movq %rax, 0x30(%r13)
movq 0x38(%rbp), %rdi
callq 0xcd50
movq %rax, 0x38(%r13)
movb 0x28(%rbp), %al
movb %al, 0xb0(%r13)
movq 0x20(%rbp), %rax
testq %rax, %rax
cmovneq %rax, %r14
xorpd %xmm0, %xmm0
movapd 0x10(%rsp), %xmm2
movapd %xmm2, %xmm1
cmpeqsd %xmm0, %xmm1
movq %xmm1, %rbp
andl $0x1, %ebp
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
cmpeqsd %xmm0, %xmm1
movq %xmm1, %r12
andl $0x1, %r12d
jmp 0x399a9
movq %rbx, %rdi
callq 0xc450
pushq $0x1
jmp 0x39aab
movb $0x1, %r12b
movb $0x1, %bpl
movq %r15, %rdi
callq 0xcd50
movq %rax, 0x20(%r13)
movq %r14, %rdi
callq 0xcd50
movq %rax, 0x28(%r13)
movq %rbx, 0x48(%r13)
movl 0x4(%rsp), %eax
movl %eax, 0x18(%r13)
movl (%rsp), %eax
movw %ax, 0x1c(%r13)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
testb %bpl, %bpl
je 0x399e8
movq %rax, 0x8(%r13)
testb %r12b, %r12b
je 0x399f1
movq %rax, 0x10(%r13)
movq %r13, %rdi
callq 0x306b6
testl %eax, %eax
je 0x39a14
movq %r13, %rdi
callq 0x2c85b
movq %rbx, %rdi
callq 0xc450
pushq $0x1a
jmp 0x39aab
movq %r13, %rax
addq $0xb8, %rax
andq $0x0, 0xb8(%r13)
movq 0x8(%rsp), %rdx
movq 0x60(%rdx), %rcx
movq 0x8(%rcx), %rcx
movq %r13, (%rcx)
movq 0x60(%rdx), %rcx
movq %rax, 0x8(%rcx)
movq %rbx, %rdi
callq 0xc450
xorl %eax, %eax
jmp 0x39aac
movq 0x195a8(%rip), %rax     # 0x52ff8
movq (%rax), %rcx
leaq 0xb22d(%rip), %rdi      # 0x44c87
pushq $0x48
popq %rsi
pushq $0x1
popq %rdx
callq 0xd000
pushq $0xc
jmp 0x39aab
movq 0x19588(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0xb256(%rip), %rsi      # 0x44cd0
movq %r15, %rdx
xorl %eax, %eax
callq 0xc8d0
jmp 0x39aa9
movq 0x1956b(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0xb291(%rip), %rsi      # 0x44d28
movq %r15, %rdx
xorl %eax, %eax
callq 0xc8d0
movq %rbx, %rdi
callq 0xc450
pushq $0xd
popq %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq