// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_set_background_buffer
lxw_error
worksheet_set_background_buffer(lxw_worksheet *self,
                                const unsigned char *image_buffer,
                                size_t image_size)
{
    FILE *image_stream;
    lxw_object_properties *object_props;

    if (!image_size) {
        LXW_WARN("worksheet_set_background(): " "size must be non-zero.");
        return LXW_ERROR_NULL_PARAMETER_IGNORED;
    }

    /* Write the image buffer to a file (preferably in memory) so we can read
     * the dimensions like an ordinary file. */
#ifdef USE_FMEMOPEN
    image_stream = fmemopen((void *) image_buffer, image_size, "rb");

    if (!image_stream)
        return LXW_ERROR_CREATING_TMPFILE;
#else
    image_stream = lxw_tmpfile(self->tmpdir);

    if (!image_stream)
        return LXW_ERROR_CREATING_TMPFILE;

    if (fwrite(image_buffer, 1, image_size, image_stream) != image_size) {
        fclose(image_stream);
        return LXW_ERROR_CREATING_TMPFILE;
    }

    rewind(image_stream);
#endif

    /* 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;
    }

    /* Store the image data in the properties structure. */
    object_props->image_buffer = calloc(1, image_size);
    if (!object_props->image_buffer) {
        _free_object_properties(object_props);
        fclose(image_stream);
        return LXW_ERROR_MEMORY_MALLOC_FAILED;
    }
    else {
        memcpy(object_props->image_buffer, image_buffer, image_size);
        object_props->image_buffer_size = image_size;
        object_props->is_image_buffer = LXW_TRUE;
    }

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

    if (_get_image_properties(object_props) == LXW_NO_ERROR) {
        _free_object_properties(self->background_image);
        self->background_image = object_props;
        self->has_background_image = 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 $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x5582f
movq 0x277e6(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1806c(%rip), %rsi     # 0x6d888
movb $0x0, %al
callq 0xc8f0
movl $0xc, -0x4(%rbp)
jmp 0x559bb
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rdi
callq 0xc8b0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x55856
movl $0x3, -0x4(%rbp)
jmp 0x559bb
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x1, %esi
callq 0xd030
cmpq -0x20(%rbp), %rax
je 0x55887
movq -0x28(%rbp), %rdi
callq 0xc460
movl $0x3, -0x4(%rbp)
jmp 0x559bb
movq -0x28(%rbp), %rdi
callq 0xc560
movl $0x1, %edi
movl $0xc0, %esi
callq 0xc870
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x558bf
movq -0x28(%rbp), %rdi
callq 0xc460
movl $0x1, -0x4(%rbp)
jmp 0x559bb
movq -0x20(%rbp), %rsi
movl $0x1, %edi
callq 0xc870
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x58(%rax)
jne 0x55901
movq -0x30(%rbp), %rdi
callq 0x46550
movq -0x28(%rbp), %rdi
callq 0xc460
movl $0x1, -0x4(%rbp)
jmp 0x559bb
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xc980
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x30(%rbp), %rax
movb $0x1, 0x51(%rax)
leaq 0x17eb3(%rip), %rdi     # 0x6d7e4
callq 0xcd80
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x30(%rbp), %rax
movb $0x1, 0x99(%rax)
movq -0x30(%rbp), %rdi
callq 0x4c4c0
cmpl $0x0, %eax
jne 0x559a2
movq -0x10(%rbp), %rax
movq 0x3a8(%rax), %rdi
callq 0x46550
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x3a8(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x2a3(%rax)
movq -0x28(%rbp), %rdi
callq 0xc460
movl $0x0, -0x4(%rbp)
jmp 0x559bb
movq -0x30(%rbp), %rdi
callq 0x46550
movq -0x28(%rbp), %rdi
callq 0xc460
movl $0x1a, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)