// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movb %al, -0x19(%rbp)
leaq -0x70(%rbp), %rdi
leaq 0x308b0(%rip), %rsi     # 0x7cbe0
movl $0x30, %edx
callq 0xc980
cmpq $0x0, -0x18(%rbp)
jne 0x4c34d
movl $0x0, -0x4(%rbp)
jmp 0x4c4af
movq -0x18(%rbp), %rdi
leaq 0x19ca8(%rip), %rsi     # 0x66000
callq 0xc280
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x4c390
movq 0x30c89(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x206bd(%rip), %rsi     # 0x6ca3a
movb $0x0, %al
callq 0xc8f0
movl $0xd, -0x4(%rbp)
jmp 0x4c4af
movq -0x18(%rbp), %rdi
callq 0xc9e0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x4c3d5
movq 0x30c4d(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x206df(%rip), %rsi     # 0x6ca98
movb $0x0, %al
callq 0xc8f0
movq -0x28(%rbp), %rdi
callq 0xc460
movl $0xd, -0x4(%rbp)
jmp 0x4c4af
movl $0x1, %edi
movl $0xc0, %esi
callq 0xc870
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x4c404
movq -0x28(%rbp), %rdi
callq 0xc460
movl $0x1, -0x4(%rbp)
jmp 0x4c4af
movq -0x18(%rbp), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x48(%rax)
movzbl -0x19(%rbp), %eax
movq -0x70(%rbp,%rax,8), %rdi
callq 0xcd80
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0xa8(%rax)
movq -0x38(%rbp), %rdi
callq 0x4c4c0
cmpl $0x0, %eax
jne 0x4c496
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movzbl -0x19(%rbp), %edx
movq 0x348(%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x2a2(%rax)
movq -0x28(%rbp), %rdi
callq 0xc460
movl $0x0, -0x4(%rbp)
jmp 0x4c4af
movq -0x38(%rbp), %rdi
callq 0x46550
movq -0x28(%rbp), %rdi
callq 0xc460
movl $0x1a, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)