// File: /workspace/github_c_makefile_star2_O3/Paxa[P]fast_excel/libxlsxwriter/src/worksheet.c
// Function: worksheet_write_string
lxw_error
worksheet_write_string(lxw_worksheet *self,
                       lxw_row_t row_num,
                       lxw_col_t col_num, const char *string,
                       lxw_format *format)
{
    lxw_cell *cell;
    int32_t string_id;
    char *string_copy;
    struct sst_element *sst_element;
    lxw_error err;

    if (!string || !*string) {
        /* Treat a NULL or empty string with formatting as a blank cell. */
        /* Null strings without formats should be ignored.      */
        if (format)
            return worksheet_write_blank(self, row_num, col_num, format);
        else
            return LXW_NO_ERROR;
    }

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

    if (lxw_utf8_strlen(string) > LXW_STR_MAX)
        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, string, LXW_FALSE);

        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(string)) {
            string_copy = lxw_escape_control_characters(string);
        }
        else {
            string_copy = lxw_strdup(string);
        }
        cell = _new_inline_string_cell(row_num, col_num, string_copy, format);
    }

    _insert_cell(self, row_num, col_num, cell);

    return LXW_NO_ERROR;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r15
movl %edx, %r12d
movl %esi, %ebx
movq %rdi, %r14
testq %rcx, %rcx
je 0x305c0
movq %rcx, %r13
cmpb $0x0, (%rcx)
je 0x305c0
movzwl %r12w, %ebp
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x39d04
testl %eax, %eax
jne 0x30655
movq %r13, %rdi
callq 0xd0d0
movq %rax, %rcx
movl $0x15, %eax
cmpq $0x7fff, %rcx           # imm = 0x7FFF
ja 0x30655
cmpb $0x0, 0x11c(%r14)
je 0x305e8
movq %r13, %rdi
callq 0xc920
movq %r13, %rdi
testb %al, %al
je 0x30612
callq 0xc9a0
jmp 0x30617
testq %r15, %r15
je 0x30653
movzwl %r12w, %edx
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc590
movq 0xb0(%r14), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xc340
testq %rax, %rax
je 0x30664
movl (%rax), %edx
movq 0x8(%rax), %rcx
movl %ebx, %edi
movl %ebp, %esi
movq %r15, %r8
callq 0x39ea7
jmp 0x30644
callq 0xcce0
movq %rax, %r13
movl $0x1, %edi
movl $0x68, %esi
callq 0xc7f0
testq %rax, %rax
je 0x3066b
movl %ebx, (%rax)
movw %r12w, 0x4(%rax)
movl $0x3, 0x8(%rax)
movq %r15, 0x10(%rax)
movq %r13, 0x20(%rax)
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
movq %rax, %rcx
callq 0x39de8
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x16, %eax
jmp 0x30655
callq 0xe981
xorl %eax, %eax
jmp 0x30644