// File: /workspace/github_c_makefile_star2_O1/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 0x30457
movq %rcx, %r13
cmpb $0x0, (%rcx)
je 0x30457
movzwl %r12w, %ebp
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x39aa6
testl %eax, %eax
jne 0x304fa
movq %r13, %rdi
callq 0xd0d0
movq %rax, %rcx
movl $0x15, %eax
cmpq $0x7fff, %rcx           # imm = 0x7FFF
ja 0x304fa
cmpb $0x0, 0x11c(%r14)
je 0x3047f
movq %r13, %rdi
callq 0xc920
movq %r13, %rdi
testb %al, %al
je 0x304ac
callq 0xc9a0
jmp 0x304b1
testq %r15, %r15
je 0x304f8
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 0x30509
movl (%rax), %edx
movq 0x8(%rax), %rcx
movl %ebx, %edi
movl %ebp, %esi
movq %r15, %r8
callq 0x39c49
movq %rax, %r13
jmp 0x304e9
callq 0xcce0
movq %rax, (%rsp)
movl $0x1, %edi
movl $0x68, %esi
callq 0xc7f0
movq %rax, %r13
testq %rax, %rax
je 0x30510
movl %ebx, (%r13)
movw %r12w, 0x4(%r13)
movl $0x3, 0x8(%r13)
movq %r15, 0x10(%r13)
movq (%rsp), %rax
movq %rax, 0x20(%r13)
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
movq %r13, %rcx
callq 0x39b8a
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x16, %eax
jmp 0x304fa
callq 0xe697
jmp 0x304e9