// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_write_rich_string
lxw_error
worksheet_write_rich_string(lxw_worksheet *self,
                            lxw_row_t row_num,
                            lxw_col_t col_num,
                            lxw_rich_string_tuple *rich_strings[],
                            lxw_format *format)
{
    lxw_cell *cell;
    int32_t string_id;
    struct sst_element *sst_element;
    lxw_error err;
    uint8_t i;
    long file_size;
    char *rich_string = NULL;
    const char *string_copy = NULL;
    lxw_styles *styles = NULL;
    lxw_format *default_format = NULL;
    lxw_rich_string_tuple *rich_string_tuple = NULL;
    FILE *tmpfile;

    err = _check_dimensions(self, row_num, col_num, LXW_FALSE, LXW_FALSE);
    if (err)
        return err;

    /* Iterate through rich string fragments to check for input errors. */
    i = 0;
    err = LXW_NO_ERROR;
    while ((rich_string_tuple = rich_strings[i++]) != NULL) {

        /* Check for NULL or empty strings. */
        if (!rich_string_tuple->string || !*rich_string_tuple->string) {
            err = LXW_ERROR_PARAMETER_VALIDATION;
        }
    }

    /* If there are less than 2 fragments it isn't a rich string. */
    if (i <= 2)
        err = LXW_ERROR_PARAMETER_VALIDATION;

    if (err)
        return err;

    /* Create a tmp file for the styles object. */
    tmpfile = lxw_get_filehandle(&rich_string, NULL, self->tmpdir);
    if (!tmpfile)
        return LXW_ERROR_CREATING_TMPFILE;

    /* Create a temp styles object for writing the font data. */
    styles = lxw_styles_new();
    GOTO_LABEL_ON_MEM_ERROR(styles, mem_error);
    styles->file = tmpfile;

    /* Create a default format for non-formatted text. */
    default_format = lxw_format_new();
    GOTO_LABEL_ON_MEM_ERROR(default_format, mem_error);

    /* Iterate through the rich string fragments and write each one out. */
    i = 0;
    while ((rich_string_tuple = rich_strings[i++]) != NULL) {
        lxw_xml_start_tag(tmpfile, "r", NULL);

        if (rich_string_tuple->format) {
            /* Write the user defined font format. */
            lxw_styles_write_rich_font(styles, rich_string_tuple->format);
        }
        else {
            /* Write a default font format. Except for the first fragment. */
            if (i > 1)
                lxw_styles_write_rich_font(styles, default_format);
        }

        lxw_styles_write_string_fragment(styles, rich_string_tuple->string);
        lxw_xml_end_tag(tmpfile, "r");
    }

    /* Free the temp objects. */
    lxw_styles_free(styles);
    lxw_format_free(default_format);

    /* Flush the file. */
    fflush(tmpfile);

    if (!rich_string) {
        /* Read the size to calculate the required memory. */
        file_size = ftell(tmpfile);
        /* Allocate a buffer for the rich string xml data. */
        rich_string = calloc(file_size + 1, 1);
        GOTO_LABEL_ON_MEM_ERROR(rich_string, mem_error);

        /* Rewind the file and read the data into the memory buffer. */
        rewind(tmpfile);
        if (fread((void *) rich_string, file_size, 1, tmpfile) < 1) {
            fclose(tmpfile);
            free((void *) rich_string);
            return LXW_ERROR_READING_TMPFILE;
        }
    }

    /* Close the temp file. */
    fclose(tmpfile);

    if (lxw_utf8_strlen(rich_string) > LXW_STR_MAX) {
        free((void *) rich_string);
        return LXW_ERROR_MAX_STRING_LENGTH_EXCEEDED;
    }

    if (!self->optimize) {
        /* Get the SST element and string id. */
        sst_element = lxw_get_sst_index(self->sst, rich_string, LXW_TRUE);
        free((void *) rich_string);

        if (!sst_element)
            return LXW_ERROR_SHARED_STRING_INDEX_NOT_FOUND;

        string_id = sst_element->index;
        cell = _new_string_cell(row_num, col_num, string_id,
                                sst_element->string, format);
    }
    else {
        /* Look for and escape control chars in the string. */
        if (lxw_has_control_characters(rich_string)) {
            string_copy = lxw_escape_control_characters(rich_string);
            free((void *) rich_string);
        }
        else {
            string_copy = rich_string;
        }
        cell = _new_inline_rich_string_cell(row_num, col_num, string_copy,
                                            format);
    }

    _insert_cell(self, row_num, col_num, cell);

    return LXW_NO_ERROR;

mem_error:
    lxw_styles_free(styles);
    lxw_format_free(default_format);
    fclose(tmpfile);

    return LXW_ERROR_MEMORY_MALLOC_FAILED;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movw %dx, %ax
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movw %ax, -0x16(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
xorl %r8d, %r8d
movzwl -0x16(%rbp), %edx
movl %r8d, %ecx
callq 0x4ff90
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x518a3
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x51c3e
movb $0x0, -0x45(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x20(%rbp), %rax
movb -0x45(%rbp), %cl
movb %cl, %dl
addb $0x1, %dl
movb %dl, -0x45(%rbp)
movzbl %cl, %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
je 0x518ef
movq -0x78(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x518e6
movq -0x78(%rbp), %rax
movq 0x8(%rax), %rax
cmpb $0x0, (%rax)
jne 0x518ed
movl $0xd, -0x44(%rbp)
jmp 0x518ae
movzbl -0x45(%rbp), %eax
cmpl $0x2, %eax
jg 0x518ff
movl $0xd, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x51910
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x51c3e
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rdx
leaq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xceb0
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
jne 0x5193f
movl $0x3, -0x4(%rbp)
jmp 0x51c3e
callq 0xc770
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x51978
movq 0x2b6a2(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x14770(%rip), %rsi     # 0x660d0
leaq 0x1aa8d(%rip), %rdx     # 0x6c3f4
movl $0x210c, %ecx           # imm = 0x210C
movb $0x0, %al
callq 0xc8f0
jmp 0x51c1c
jmp 0x5197a
movq -0x80(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, (%rax)
callq 0xcdf0
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x519be
movq 0x2b65c(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1472a(%rip), %rsi     # 0x660d0
leaq 0x1aa47(%rip), %rdx     # 0x6c3f4
movl $0x2111, %ecx           # imm = 0x2111
movb $0x0, %al
callq 0xc8f0
jmp 0x51c1c
jmp 0x519c0
movb $0x0, -0x45(%rbp)
movq -0x20(%rbp), %rax
movb -0x45(%rbp), %cl
movb %cl, %dl
addb $0x1, %dl
movb %dl, -0x45(%rbp)
movzbl %cl, %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
je 0x51a52
movq -0x80(%rbp), %rdi
leaq 0x156da(%rip), %rsi     # 0x670c9
xorl %eax, %eax
movl %eax, %edx
callq 0xc390
movq -0x78(%rbp), %rax
cmpq $0x0, (%rax)
je 0x51a14
movq -0x68(%rbp), %rdi
movq -0x78(%rbp), %rax
movq (%rax), %rsi
callq 0xca60
jmp 0x51a2c
movzbl -0x45(%rbp), %eax
cmpl $0x1, %eax
jle 0x51a2a
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0xca60
jmp 0x51a2c
movq -0x68(%rbp), %rdi
movq -0x78(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0xc7f0
movq -0x80(%rbp), %rdi
leaq 0x15681(%rip), %rsi     # 0x670c9
callq 0xc060
jmp 0x519c4
movq -0x68(%rbp), %rdi
callq 0xc600
movq -0x70(%rbp), %rdi
callq 0xd080
movq -0x80(%rbp), %rdi
callq 0xcb00
cmpq $0x0, -0x58(%rbp)
jne 0x51b12
movq -0x80(%rbp), %rdi
callq 0xc900
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
addq $0x1, %rdi
movl $0x1, %esi
callq 0xc870
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x51acb
movq 0x2b54f(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x1461d(%rip), %rsi     # 0x660d0
leaq 0x1a93a(%rip), %rdx     # 0x6c3f4
movl $0x2132, %ecx           # imm = 0x2132
movb $0x0, %al
callq 0xc8f0
jmp 0x51c1c
jmp 0x51acd
movq -0x80(%rbp), %rdi
callq 0xc560
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x80(%rbp), %rcx
movl $0x1, %edx
callq 0xc320
cmpq $0x1, %rax
jae 0x51b10
movq -0x80(%rbp), %rdi
callq 0xc460
movq -0x58(%rbp), %rdi
callq 0xc0d0
movl $0x4, -0x4(%rbp)
jmp 0x51c3e
jmp 0x51b12
movq -0x80(%rbp), %rdi
callq 0xc460
movq -0x58(%rbp), %rdi
callq 0xd180
cmpq $0x7fff, %rax           # imm = 0x7FFF
jbe 0x51b41
movq -0x58(%rbp), %rdi
callq 0xc0d0
movl $0x15, -0x4(%rbp)
jmp 0x51c3e
movq -0x10(%rbp), %rax
cmpb $0x0, 0x11c(%rax)
jne 0x51bb4
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rdi
movq -0x58(%rbp), %rsi
movl $0x1, %edx
callq 0xc380
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rdi
callq 0xc0d0
cmpq $0x0, -0x40(%rbp)
jne 0x51b87
movl $0x16, -0x4(%rbp)
jmp 0x51c3e
movq -0x40(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x14(%rbp), %edi
movw -0x16(%rbp), %ax
movl -0x34(%rbp), %edx
movq -0x40(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq -0x28(%rbp), %r8
movzwl %ax, %esi
callq 0x502b0
movq %rax, -0x30(%rbp)
jmp 0x51bfc
movq -0x58(%rbp), %rdi
callq 0xc9a0
cmpb $0x0, %al
je 0x51bd9
movq -0x58(%rbp), %rdi
callq 0xca20
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
callq 0xc0d0
jmp 0x51be1
movq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x14(%rbp), %edi
movw -0x16(%rbp), %ax
movq -0x60(%rbp), %rdx
movq -0x28(%rbp), %rcx
movzwl %ax, %esi
callq 0x51c50
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movw -0x16(%rbp), %ax
movq -0x30(%rbp), %rcx
movzwl %ax, %edx
callq 0x50170
movl $0x0, -0x4(%rbp)
jmp 0x51c3e
movq -0x68(%rbp), %rdi
callq 0xc600
movq -0x70(%rbp), %rdi
callq 0xd080
movq -0x80(%rbp), %rdi
callq 0xc460
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)