// File: /workspace/github_c_makefile_star2_O2/Paxa[P]fast_excel/libxlsxwriter/src/shared_strings.c
// Function: lxw_get_sst_index
struct sst_element *
lxw_get_sst_index(lxw_sst *sst, const char *string, uint8_t is_rich_string)
{
    struct sst_element *element;
    struct sst_element *existing_element;

    /* Create an sst element to potentially add to the table. */
    element = calloc(1, sizeof(struct sst_element));
    if (!element)
        return NULL;

    /* Create potential new element with the string and its index. */
    element->index = sst->unique_count;
    element->string = lxw_strdup(string);
    element->is_rich_string = is_rich_string;

    /* Try to insert it and see whether we already have that string. */
    existing_element = RB_INSERT(sst_rb_tree, sst->rb_tree, element);

    /* If existing_element is not NULL, then it already existed. */
    /* Free new created element. */
    if (existing_element) {
        free(element->string);
        free(element);
        sst->string_count++;
        return existing_element;
    }

    /* If it didn't exist, also add it to the insertion order linked list. */
    STAILQ_INSERT_TAIL(sst->order_list, element, sst_order_pointers);

    /* Update SST string counts. */
    sst->string_count++;
    sst->unique_count++;
    return element;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
pushq $0x1
popq %rdi
pushq $0x40
popq %rsi
callq 0xc850
xorl %r15d, %r15d
testq %rax, %rax
je 0x1ff9c
movq %rax, %r14
movl 0xc(%rbx), %eax
movl %eax, (%r14)
movq %r12, %rdi
callq 0xcd50
movq %rax, %r12
movq %rax, 0x8(%r14)
movq %r14, 0x8(%rsp)
movb %bpl, 0x10(%r14)
movq %rbx, 0x10(%rsp)
movq 0x18(%rbx), %r13
pushq $0x20
popq %rbp
pushq $0x28
popq %rbx
movq %r13, %rcx
xorl %eax, %eax
movq (%rcx), %r14
testq %r14, %r14
je 0x1ff73
movq 0x8(%r14), %rsi
movq %r12, %rdi
callq 0xc860
movl %eax, %r15d
movq %rbp, %rcx
testl %eax, %eax
js 0x1ff6b
movq %rbx, %rcx
je 0x1ffa4
addq %r14, %rcx
movq %r14, %rax
jmp 0x1ff48
movq 0x8(%rsp), %r14
movq %rax, 0x30(%r14)
movl $0x1, 0x38(%r14)
movq %r13, %rcx
testq %rax, %rax
movq 0x10(%rsp), %r10
je 0x1ffc7
testl %r15d, %r15d
js 0x1ffc3
leaq 0x28(%rax), %rcx
jmp 0x1ffc7
xorl %r14d, %r14d
jmp 0x201c8
movq %r12, %rdi
callq 0xc0d0
movq 0x8(%rsp), %rdi
callq 0xc0d0
movq 0x10(%rsp), %rax
incl 0x8(%rax)
jmp 0x201c8
leaq 0x20(%rax), %rcx
movq %r14, (%rcx)
movq %r14, %rdx
testq %rax, %rax
je 0x2018d
cmpl $0x1, 0x38(%rax)
jne 0x2018d
movq 0x30(%rax), %rcx
movq 0x20(%rcx), %rsi
cmpq %rsi, %rax
je 0x20012
testq %rsi, %rsi
je 0x1fffe
cmpl $0x1, 0x38(%rsi)
jne 0x1fffe
andl $0x0, 0x38(%rsi)
jmp 0x20025
movq 0x20(%rax), %rsi
cmpq %rdx, %rsi
je 0x2004c
movq %rax, %rsi
movq %rdx, %rax
jmp 0x200c3
movq 0x28(%rcx), %rdi
testq %rdi, %rdi
je 0x20038
cmpl $0x1, 0x38(%rdi)
jne 0x20038
andl $0x0, 0x38(%rdi)
andl $0x0, 0x38(%rax)
movl $0x1, 0x38(%rcx)
movq %rcx, %rax
jmp 0x20181
movq 0x28(%rax), %rdi
cmpq %rdx, %rdi
je 0x2006f
movq %rax, %rdi
movq %rdx, %rax
jmp 0x2013a
movq 0x28(%rsi), %rdi
movq %rdi, 0x20(%rax)
testq %rdi, %rdi
je 0x2009d
movq %rax, 0x30(%rdi)
movq 0x30(%rax), %rdi
movq %rdi, 0x30(%rsi)
movq %r13, %r8
testq %rdi, %rdi
jne 0x200a5
jmp 0x200b5
movq 0x20(%rdi), %rsi
movq %rsi, 0x28(%rax)
testq %rsi, %rsi
je 0x20110
movq %rax, 0x30(%rsi)
movq 0x30(%rax), %rsi
movq %rsi, 0x30(%rdi)
movq %r13, %r8
testq %rsi, %rsi
jne 0x20118
jmp 0x20128
movq %rcx, 0x30(%rsi)
movq 0x30(%rax), %rdi
leaq 0x20(%rdi), %r9
leaq 0x28(%rdi), %r8
cmpq 0x20(%rdi), %rax
cmoveq %r9, %r8
movq %rsi, (%r8)
movq %rax, 0x28(%rsi)
movq %rsi, 0x30(%rax)
movq %rdx, %rsi
andl $0x0, 0x38(%rsi)
movl $0x1, 0x38(%rcx)
movq 0x28(%rcx), %rdx
movq 0x20(%rdx), %rsi
movq %rsi, 0x28(%rcx)
testq %rsi, %rsi
je 0x200e3
movq %rcx, 0x30(%rsi)
movq 0x30(%rcx), %rdi
movq %rdi, 0x30(%rdx)
movq %r13, %rsi
testq %rdi, %rdi
je 0x20103
leaq 0x20(%rdi), %r8
leaq 0x28(%rdi), %rsi
cmpq 0x20(%rdi), %rcx
cmoveq %r8, %rsi
movq %rdx, (%rsi)
movq %rcx, 0x20(%rdx)
movq %rdx, 0x30(%rcx)
jmp 0x20181
movq %rcx, 0x30(%rdi)
movq 0x30(%rax), %rsi
leaq 0x20(%rsi), %r9
leaq 0x28(%rsi), %r8
cmpq 0x20(%rsi), %rax
cmoveq %r9, %r8
movq %rdi, (%r8)
movq %rax, 0x20(%rdi)
movq %rdi, 0x30(%rax)
movq 0x20(%rcx), %rsi
movq %rdx, %rdi
andl $0x0, 0x38(%rdi)
movl $0x1, 0x38(%rcx)
movq 0x28(%rsi), %rdx
movq %rdx, 0x20(%rcx)
testq %rdx, %rdx
je 0x20156
movq %rcx, 0x30(%rdx)
movq 0x30(%rcx), %rdi
movq %rdi, 0x30(%rsi)
movq %r13, %rdx
testq %rdi, %rdi
je 0x20176
leaq 0x20(%rdi), %r8
leaq 0x28(%rdi), %rdx
cmpq 0x20(%rdi), %rcx
cmoveq %r8, %rdx
movq %rsi, (%rdx)
movq %rcx, 0x28(%rsi)
movq %rsi, 0x30(%rcx)
movq %rax, %rdx
movq 0x30(%rax), %rax
jmp 0x1ffcd
movq (%r13), %rax
andl $0x0, 0x38(%rax)
movq %r14, %rax
addq $0x18, %rax
andq $0x0, 0x18(%r14)
movq 0x10(%r10), %rcx
movq 0x8(%rcx), %rcx
movq %r14, (%rcx)
movq 0x10(%r10), %rcx
movq %rax, 0x8(%rcx)
movq 0x8(%r10), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, 0x8(%r10)
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop