// File: /workspace/github_c_makefile_star2_O2/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 0x2d38d
movq %rcx, %r13
cmpb $0x0, (%rcx)
je 0x2d38d
movzwl %r12w, %ebp
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x36a6c
testl %eax, %eax
jne 0x2d449
movq %r13, %rdi
callq 0xd150
cmpq $0x7fff, %rax           # imm = 0x7FFF
jbe 0x2d3b5
pushq $0x15
popq %rax
jmp 0x2d449
testq %r15, %r15
je 0x2d447
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 0xc5d0
cmpb $0x0, 0x11c(%r14)
je 0x2d3d5
movq %r13, %rdi
callq 0xc980
movq %r13, %rdi
testb %al, %al
je 0x2d402
callq 0xca00
jmp 0x2d407
movq 0xb0(%r14), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xc370
testq %rax, %rax
je 0x2d458
movl (%rax), %edx
movq 0x8(%rax), %rcx
movl %ebx, %edi
movl %ebp, %esi
movq %r15, %r8
callq 0x36c24
movq %rax, %r13
jmp 0x2d438
callq 0xcd50
movq %rax, (%rsp)
pushq $0x1
popq %rdi
pushq $0x68
popq %rsi
callq 0xc850
testq %rax, %rax
je 0x2d45f
movq %rax, %r13
movl %ebx, (%rax)
movw %r12w, 0x4(%rax)
movl $0x3, 0x8(%rax)
movq %r15, 0x10(%rax)
movq (%rsp), %rax
movq %rax, 0x20(%r13)
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
movq %r13, %rcx
callq 0x36b65
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x16
jmp 0x2d387
movq 0x25b92(%rip), %rax     # 0x52ff8
movq (%rax), %rdi
leaq 0xfc70(%rip), %rsi      # 0x3d0e0
leaq 0x16569(%rip), %rdx     # 0x439e0
xorl %r13d, %r13d
movl $0x373, %ecx            # imm = 0x373
xorl %eax, %eax
callq 0xc8d0
jmp 0x2d438