// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_set_footer_opt
lxw_error
worksheet_set_footer_opt(lxw_worksheet *self, const char *string,
                         lxw_header_footer_options *options)
{
    lxw_error err;
    char *tmp_footer;
    char *found_string;
    char *offset_string;
    uint8_t placeholder_count = 0;
    uint8_t image_count = 0;

    if (!string) {
        LXW_WARN_FORMAT("worksheet_set_header_opt/footer_opt(): "
                        "header/footer string cannot be NULL.");
        return LXW_ERROR_NULL_PARAMETER_IGNORED;
    }

    if (lxw_utf8_strlen(string) > LXW_HEADER_FOOTER_MAX) {
        LXW_WARN_FORMAT("worksheet_set_header_opt/footer_opt(): "
                        "header/footer string exceeds Excel's limit of "
                        "255 characters.");
        return LXW_ERROR_255_STRING_LENGTH_EXCEEDED;
    }

    tmp_footer = lxw_strdup(string);
    RETURN_ON_MEM_ERROR(tmp_footer, LXW_ERROR_MEMORY_MALLOC_FAILED);

    /* Replace &[Picture] with &G which is used internally by Excel. */
    while ((found_string = strstr(tmp_footer, "&[Picture]"))) {
        found_string++;
        *found_string = 'G';

        do {
            found_string++;
            offset_string = found_string + sizeof("Picture");
            *found_string = *offset_string;
        } while (*offset_string);
    }

    /* Count &G placeholders and ensure there are sufficient images. */
    found_string = tmp_footer;
    while (*found_string) {
        if (*found_string == '&' && *(found_string + 1) == 'G')
            placeholder_count++;
        found_string++;
    }

    if (placeholder_count > 0 && !options) {
        LXW_WARN_FORMAT1("worksheet_set_header_opt/footer_opt(): "
                         "the number of &G/&[Picture] placeholders in option "
                         "string \"%s\" does not match the number of supplied "
                         "images.", string);

        free(tmp_footer);
        return LXW_ERROR_PARAMETER_VALIDATION;
    }

    /* Free any previous footer string so we can overwrite it. */
    free(self->footer);
    self->footer = NULL;

    if (options) {
        /* Ensure there are enough images to match the placeholders. There is
         * a potential bug where there are sufficient images but in the wrong
         * positions but we don't currently try to deal with that.*/
        if (options->image_left)
            image_count++;
        if (options->image_center)
            image_count++;
        if (options->image_right)
            image_count++;

        if (placeholder_count != image_count) {
            LXW_WARN_FORMAT1("worksheet_set_header_opt/footer_opt(): "
                             "the number of &G/&[Picture] placeholders in option "
                             "string \"%s\" does not match the number of supplied "
                             "images.", string);

            free(tmp_footer);
            return LXW_ERROR_PARAMETER_VALIDATION;
        }

        /* Free any existing footer image objects. */
        _free_object_properties(self->footer_left_object_props);
        _free_object_properties(self->footer_center_object_props);
        _free_object_properties(self->footer_right_object_props);

        if (options->margin > 0.0)
            self->margin_footer = options->margin;

        err = _worksheet_set_header_footer_image(self,
                                                 options->image_left,
                                                 FOOTER_LEFT);
        if (err) {
            free(tmp_footer);
            return err;
        }

        err = _worksheet_set_header_footer_image(self,
                                                 options->image_center,
                                                 FOOTER_CENTER);
        if (err) {
            free(tmp_footer);
            return err;
        }

        err = _worksheet_set_header_footer_image(self,
                                                 options->image_right,
                                                 FOOTER_RIGHT);
        if (err) {
            free(tmp_footer);
            return err;
        }
    }

    self->footer = tmp_footer;
    self->header_footer_changed = LXW_TRUE;

    return LXW_NO_ERROR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movb $0x0, -0x41(%rbp)
movb $0x0, -0x42(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x54407
movq 0x28c0e(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x190e9(%rip), %rsi     # 0x6d4dd
movb $0x0, %al
callq 0xc8f0
movl $0xc, -0x4(%rbp)
jmp 0x5470c
movq -0x18(%rbp), %rdi
callq 0xd180
cmpq $0xff, %rax
jbe 0x5443c
movq 0x28bd9(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1910c(%rip), %rsi     # 0x6d535
movb $0x0, %al
callq 0xc8f0
movl $0x14, -0x4(%rbp)
jmp 0x5470c
movq -0x18(%rbp), %rdi
callq 0xcd80
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x54480
movq 0x28ba1(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x11c6f(%rip), %rsi     # 0x660d0
leaq 0x17f8c(%rip), %rdx     # 0x6c3f4
movl $0x2635, %ecx           # imm = 0x2635
movb $0x0, %al
callq 0xc8f0
movl $0x1, -0x4(%rbp)
jmp 0x5470c
jmp 0x54482
jmp 0x54484
movq -0x30(%rbp), %rdi
leaq 0x19117(%rip), %rsi     # 0x6d5a6
callq 0xd130
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x544e0
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movb $0x47, (%rax)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movb (%rax), %cl
movq -0x38(%rbp), %rax
movb %cl, (%rax)
movq -0x40(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x544b1
jmp 0x54484
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpb $0x0, (%rax)
je 0x54520
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x26, %eax
jne 0x54512
movq -0x38(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x47, %eax
jne 0x54512
movb -0x41(%rbp), %al
addb $0x1, %al
movb %al, -0x41(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x544e8
movzbl -0x41(%rbp), %eax
cmpl $0x0, %eax
jle 0x54561
cmpq $0x0, -0x20(%rbp)
jne 0x54561
movq 0x28ac1(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x1906c(%rip), %rsi     # 0x6d5b1
movb $0x0, %al
callq 0xc8f0
movq -0x30(%rbp), %rdi
callq 0xc0d0
movl $0xd, -0x4(%rbp)
jmp 0x5470c
movq -0x10(%rbp), %rax
movq 0x1b8(%rax), %rdi
callq 0xc0d0
movq -0x10(%rbp), %rax
movq $0x0, 0x1b8(%rax)
cmpq $0x0, -0x20(%rbp)
je 0x546eb
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x5459e
movb -0x42(%rbp), %al
addb $0x1, %al
movb %al, -0x42(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x545b1
movb -0x42(%rbp), %al
addb $0x1, %al
movb %al, -0x42(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x545c4
movb -0x42(%rbp), %al
addb $0x1, %al
movb %al, -0x42(%rbp)
movzbl -0x41(%rbp), %eax
movzbl -0x42(%rbp), %ecx
cmpl %ecx, %eax
je 0x54601
movq 0x28a21(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x18fcc(%rip), %rsi     # 0x6d5b1
movb $0x0, %al
callq 0xc8f0
movq -0x30(%rbp), %rdi
callq 0xc0d0
movl $0xd, -0x4(%rbp)
jmp 0x5470c
movq -0x10(%rbp), %rax
movq 0x390(%rax), %rdi
callq 0x46550
movq -0x10(%rbp), %rax
movq 0x398(%rax), %rdi
callq 0x46550
movq -0x10(%rbp), %rax
movq 0x3a0(%rax), %rdi
callq 0x46550
movq -0x20(%rbp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x54656
movq -0x20(%rbp), %rax
movsd (%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x190(%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movl $0x3, %edx
callq 0xc0b0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x54689
movq -0x30(%rbp), %rdi
callq 0xc0d0
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5470c
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movl $0x4, %edx
callq 0xc0b0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x546b9
movq -0x30(%rbp), %rdi
callq 0xc0d0
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5470c
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
movl $0x5, %edx
callq 0xc0b0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x546e9
movq -0x30(%rbp), %rdi
callq 0xc0d0
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x5470c
jmp 0x546eb
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x1b8(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x1ac(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)