// File: /workspace/github_c_makefile_star2_O0/Paxa[P]fast_excel/libxlsxwriter/src/utility.c
// Function: lxw_quote_sheetname
char *
lxw_quote_sheetname(const char *str)
{

    uint8_t needs_quoting = 0;
    size_t number_of_quotes = 2;
    size_t i, j;
    size_t len = strlen(str);

    /* Don't quote the sheetname if it is already quoted. */
    if (str[0] == '\'')
        return lxw_strdup(str);

    /* Check if the sheetname contains any characters that require it
     * to be quoted. Also check for single quotes within the string. */
    for (i = 0; i < len; i++) {
        if (!isalnum((unsigned char) str[i]) && str[i] != '_'
            && str[i] != '.')
            needs_quoting = 1;

        if (str[i] == '\'') {
            needs_quoting = 1;
            number_of_quotes++;
        }
    }

    if (!needs_quoting) {
        return lxw_strdup(str);
    }
    else {
        /* Add single quotes to the start and end of the string. */
        char *quoted_name = calloc(1, len + number_of_quotes + 1);
        RETURN_ON_MEM_ERROR(quoted_name, NULL);

        quoted_name[0] = '\'';

        for (i = 0, j = 1; i < len; i++, j++) {
            quoted_name[j] = str[i];

            /* Double quote inline single quotes. */
            if (str[i] == '\'') {
                quoted_name[++j] = '\'';
            }
        }
        quoted_name[j++] = '\'';
        quoted_name[j++] = '\0';

        return quoted_name;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movq $0x2, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0xc4e0
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x27, %eax
jne 0x372b3
movq -0x10(%rbp), %rdi
callq 0xcd80
movq %rax, -0x8(%rbp)
jmp 0x37460
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x37342
callq 0xd190
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x3730e
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5f, %eax
je 0x3730e
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2e, %eax
je 0x3730e
movb $0x1, -0x11(%rbp)
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x27, %eax
jne 0x3732f
movb $0x1, -0x11(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x37331
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x372bb
cmpb $0x0, -0x11(%rbp)
jne 0x3735a
movq -0x10(%rbp), %rdi
callq 0xcd80
movq %rax, -0x8(%rbp)
jmp 0x37460
movq -0x38(%rbp), %rsi
addq -0x20(%rbp), %rsi
addq $0x1, %rsi
movl $0x1, %edi
callq 0xc870
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x373ac
movq 0x45c76(%rip), %rax     # 0x7cff8
movq (%rax), %rdi
leaq 0x2ed44(%rip), %rsi     # 0x660d0
leaq 0x33bf5(%rip), %rdx     # 0x6af88
movl $0x227, %ecx            # imm = 0x227
movb $0x0, %al
callq 0xc8f0
movq $0x0, -0x8(%rbp)
jmp 0x37460
jmp 0x373ae
movq -0x40(%rbp), %rax
movb $0x27, (%rax)
movq $0x0, -0x28(%rbp)
movq $0x1, -0x30(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x3742a
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x27, %eax
jne 0x3740e
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb $0x27, 0x1(%rax,%rcx)
jmp 0x37410
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x373c5
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb $0x27, (%rax,%rcx)
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb $0x0, (%rax,%rcx)
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)