// File: /workspace/github_c_makefile_star2_O3/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_set_header_footer_image
lxw_error
_worksheet_set_header_footer_image(lxw_worksheet *self, const char *filename,
                                   uint8_t image_position)
{
    FILE *image_stream;
    const char *description;
    lxw_object_properties *object_props;
    char *image_strings[] = { "LH", "CH", "RH", "LF", "CF", "RF" };

    /* Not all slots will have image files. */
    if (!filename)
        return LXW_NO_ERROR;

    /* Check that the image file exists and can be opened. */
    image_stream = lxw_fopen(filename, "rb");
    if (!image_stream) {
        LXW_WARN_FORMAT1("worksheet_set_header_opt/footer_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_set_header_opt/footer_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;
    }

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

    /* Set VML image position string based on the header/footer/position. */
    object_props->image_position = lxw_strdup(image_strings[image_position]);

    if (_get_image_properties(object_props) == LXW_NO_ERROR) {
        *self->header_footer_objs[image_position] = object_props;
        self->has_header_vml = LXW_TRUE;
        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
pushq %rax
xorl %ebx, %ebx
testq %rsi, %rsi
je 0x33600
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r13
leaq 0xcb14(%rip), %rsi      # 0x40000
movq %r12, %rdi
callq 0xc250
testq %rax, %rax
je 0x335bb
movq %rax, %r14
movq %r12, %rdi
callq 0xc960
testq %rax, %rax
je 0x335d8
movq %rax, %r15
movq %r13, (%rsp)
movl $0x1, %edi
movl $0xc0, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3358c
movq %rax, %r13
movq %r12, %rdi
callq 0xcce0
movq %rax, 0x20(%r13)
movq %r15, %rdi
callq 0xcce0
movq %rax, 0x28(%r13)
movq %r14, 0x48(%r13)
movzbl %bpl, %r15d
leaq 0x13332(%rip), %rax     # 0x46888
movslq (%rax,%r15,4), %rdi
addq %rax, %rdi
callq 0xcce0
movq %rax, 0xa8(%r13)
movq %r13, %rdi
callq 0x33611
testl %eax, %eax
je 0x3359b
movq %r13, %rdi
callq 0x2fa62
movq %r14, %rdi
callq 0xc420
movl $0x1a, %ebx
jmp 0x33600
movq %r14, %rdi
callq 0xc420
movl $0x1, %ebx
jmp 0x33600
movq (%rsp), %rcx
movq 0x348(%rcx,%r15,8), %rax
movq %r13, (%rax)
movb $0x1, 0x2a2(%rcx)
movq %r14, %rdi
callq 0xc420
jmp 0x33600
movq 0x23a36(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0x13a65(%rip), %rsi     # 0x47031
movq %r12, %rdx
xorl %eax, %eax
callq 0xc870
jmp 0x335fb
movq 0x23a19(%rip), %rax     # 0x56ff8
movq (%rax), %rdi
leaq 0x13aa6(%rip), %rsi     # 0x4708f
movq %r12, %rdx
xorl %eax, %eax
callq 0xc870
movq %r14, %rdi
callq 0xc420
movl $0xd, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq