// File: /workspace/github_c_makefile_star2_O3/heltilda[P]cicada/cmpile.c
// Function: readTextString
ccInt readTextString(char **scanPtr, char *closingString, ccInt **stringBuffer, ccInt *stringSizeInInts, ccBool isChar)
{
    ccInt chars_num = 0, numPriorSlashes;
    char *startPtr = *scanPtr, *endPtr, *charPtr;
    
    
        // First, count the number of characters in the string.
    
    endPtr = startPtr-1;
    do  {
        endPtr = strstr(endPtr+1, closingString);
        if (endPtr == NULL)  {
            errPosition = 1;
            return string_read_err;     }
        
        numPriorSlashes = 0;
        charPtr = endPtr-1;
        while (*charPtr == '\\')  {  numPriorSlashes++;  charPtr--;  }
    }  while (numPriorSlashes % 2 == 1);
    
    while (*scanPtr < endPtr)   {
        if (**scanPtr == '\\')  {      // deal with special characters
            nextChar(scanPtr);
            if ((lettertype(*scanPtr) == a_number) ||
                        ((**scanPtr >= 'A') && (**scanPtr <= 'F')) || ((**scanPtr >= 'a') && (**scanPtr <= 'f')))   {
                nextChar(scanPtr);
                nextChar(scanPtr);    }
            else if ((**scanPtr == '\\') || (**scanPtr == 'r') || (**scanPtr == 'n') || (**scanPtr == 't')
                                            || (**scanPtr == closingString[0]))
                nextChar(scanPtr);
            else    {
                errPosition = (ccInt) (*scanPtr-startPtr) + 1;
                return string_read_err;   }    }
        else    {
            nextChar(scanPtr);    }
        chars_num++;    }
    
    if ((isChar) && (chars_num != 1))  return char_read_err;
    
    
        // get a buffer to store the string in
    
    *stringSizeInInts = ceil(1.*chars_num/sizeof(ccInt));    // align along a ccInt boundary
    if (!isChar)  (*stringSizeInInts)++;
    *stringBuffer = (ccInt *) malloc((size_t) (*stringSizeInInts)*sizeof(ccInt));
    if (*stringBuffer == NULL)   {
        errPosition = (ccInt) (*scanPtr-startPtr) + 1;
        return out_of_memory_err;     }
    
    if (!isChar)  **stringBuffer = chars_num;
    (*stringBuffer)[(*stringSizeInInts)-1] = 0;         // in case the final int isn't completely overwritten
    
    charPtr = ((char *) *stringBuffer);
    if (!isChar)  charPtr += sizeof(ccInt);
    *scanPtr = startPtr;
    
    
        // Now re-read the string, this time storing the characters in the buffer as we go.
    
    while (*scanPtr < endPtr)   {
        if (**scanPtr == '\\')  {
            nextChar(scanPtr);
            
                // general special character:  \xy where x, y are hexadecimal
            
            if ((lettertype(*scanPtr) == a_number) ||
                        ((**scanPtr >= 'A') && (**scanPtr <= 'F')) || ((**scanPtr >= 'a') && (**scanPtr <= 'f')))   {
                
                if (lettertype(*scanPtr) == a_number)  *charPtr = **scanPtr - '0';
                else if ((**scanPtr >= 'A') && (**scanPtr <= 'F'))  *charPtr = **scanPtr - 'A' + 10;
                else if ((**scanPtr >= 'a') && (**scanPtr <= 'f'))  *charPtr = **scanPtr - 'a' + 10;
                else  {
                    errPosition = (ccInt) (*scanPtr - startPtr) + 1;
                    free((void *) *stringBuffer);
                    return string_read_err;         }
                
                *charPtr *= 16;
                nextChar(scanPtr);
                
                if (lettertype(*scanPtr) == a_number)  *charPtr += **scanPtr - '0';
                else if ((**scanPtr >= 'A') && (**scanPtr <= 'F'))  *charPtr += **scanPtr - 'A' + 10;
                else if ((**scanPtr >= 'a') && (**scanPtr <= 'f'))  *charPtr += **scanPtr - 'a' + 10;
                else  {
                    errPosition = (ccInt) (*scanPtr - startPtr) + 1;
                    free((void *) *stringBuffer);
                    return string_read_err;     }     }
            
            else if (**scanPtr == '\\')     // backslash
                    *charPtr = '\\';
            else if (**scanPtr == 'n')      // end-of-line
                    *charPtr = '\n';
            else if (**scanPtr == 'r')      // carriage return
                    *charPtr = '\r';
            else if (**scanPtr == 't')      // tab
                    *charPtr = '\t';
            else if (**scanPtr == closingString[0])      // quote
                    *charPtr = closingString[0];        }
        
        else    {
            *charPtr = **scanPtr;    }       // if it's a normal character, just copy it over
        
        nextChar(scanPtr);
        charPtr++;    }
    
    
        // characters are just stored as ints -- do the conversion
    
    if (isChar)  (*stringBuffer)[0] = (ccInt) *(charPtr-1);
    
    return passed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0xc(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq (%rdi), %rcx
movq %rcx, (%rsp)
leaq -0x1(%rcx), %r12
incq %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x80a0
testq %rax, %rax
je 0xbaac
movq %rax, %r12
xorl %eax, %eax
cmpb $0x5c, -0x1(%r12,%rax)
leaq -0x1(%rax), %rax
je 0xb94d
testb $0x1, %al
je 0xb931
movq %rbx, 0x10(%rsp)
xorl %ebx, %ebx
cmpq %r12, (%rsp)
jae 0xbac0
movq (%rsp), %r8
movb (%r8), %r9b
movl 0x16975(%rip), %eax     # 0x222f0
movl $0x1, %ecx
subl %r8d, %ecx
movq %rcx, 0x20(%rsp)
xorl %ebx, %ebx
leaq 0x167ef(%rip), %rdx     # 0x22180
cmpb $0x5c, %r9b
jne 0xba47
movb $0x5c, %r9b
cmpl $0x6, %eax
je 0xba68
leaq 0x1(%r8), %rcx
movq 0x20(%rsp), %rsi
leal (%rsi,%r8), %r11d
leaq 0x2(%r8), %r10
addq $0x3, %r8
movq %r8, %r13
movq %rcx, %r8
movq %r10, %rbp
movq %r13, %rcx
movq %r8, (%r14)
movb (%r8), %r9b
movzbl %r9b, %esi
movl (%rdx,%rsi,4), %edi
incq %r8
incl %r11d
incq %r10
incq %r13
testl %edi, %edi
je 0xb9c2
cmpl $0x4, %edi
je 0xba0e
decq %r8
addl $-0x41, %esi
cmpl $0x33, %esi
ja 0xba9e
movabsq $0x3f0000003f, %r10     # imm = 0x3F0000003F
btq %rsi, %r10
jae 0xba75
cmpl $0x6, %edi
je 0xba68
movq %rcx, %r8
movq %rbp, (%r14)
movzbl (%rbp), %r9d
movl (%rdx,%r9,4), %esi
incq %rbp
incq %rcx
testl %esi, %esi
je 0xba0e
cmpl $0x6, %esi
jne 0xba34
decq %rbp
movq %rbp, %r8
jmp 0xba68
movq %r8, (%r14)
movzbl (%r8), %r9d
incq %r8
cmpl $0x0, (%rdx,%r9,4)
je 0xba34
jmp 0xba65
movzbl %r9b, %ecx
cmpl $0x6, (%rdx,%rcx,4)
je 0xba68
incq %r8
movq %r8, (%r14)
movzbl (%r8), %r9d
incq %r8
cmpl $0x0, (%rdx,%r9,4)
je 0xba54
decq %r8
incl %ebx
cmpq %r12, %r8
jb 0xb991
jmp 0xbac0
movabsq $0xa200008000000, %rcx  # imm = 0xA200008000000
btq %rsi, %rcx
jae 0xba9e
cmpl $0x6, %edi
je 0xba68
movq %rbp, (%r14)
movzbl (%rbp), %r9d
incq %rbp
cmpl $0x0, (%rdx,%r9,4)
je 0xba8a
jmp 0xba2c
cmpb (%r15), %r9b
je 0xba85
movl %r11d, 0x197fe(%rip)    # 0x252a8
jmp 0xbab6
movl $0x1, 0x197f2(%rip)     # 0x252a8
movl $0x5, %edx
jmp 0xbcc6
movl 0xc(%rsp), %ebp
testb %bpl, %bpl
setne %al
cmpl $0x1, %ebx
setne %cl
movl $0x5, %edx
testb %cl, %al
jne 0xbcc6
cvtsi2sd %ebx, %xmm0
mulsd 0xf52f(%rip), %xmm0     # 0x1b018
callq 0x8070
cvttsd2si %xmm0, %eax
cmpb $0x1, %bpl
adcl $0x0, %eax
movq 0x18(%rsp), %rcx
movl %eax, (%rcx)
movslq %eax, %r13
leaq (,%r13,4), %rdi
callq 0x81d0
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0xbb29
movq %rax, %rcx
testb %bpl, %bpl
je 0xbb41
xorl %edx, %edx
jmp 0xbb48
movl (%r14), %eax
subl (%rsp), %eax
incl %eax
movl %eax, 0x19771(%rip)     # 0x252a8
movl $0x1, %edx
jmp 0xbcc6
movl %ebx, (%rcx)
movl $0x4, %edx
movq 0x10(%rsp), %rbx
addq %rdx, %rax
movl $0x0, -0x4(%rcx,%r13,4)
movq (%rsp), %rdi
movq %rdi, (%r14)
cmpq %r12, %rdi
jae 0xbcb4
movb (%rdi), %sil
movl 0x1677e(%rip), %ecx     # 0x222f0
leaq 0x16607(%rip), %rdx     # 0x22180
cmpb $0x5c, %sil
jne 0xbc4e
cmpl $0x6, %ecx
je 0xbc4e
leaq 0x1(%rdi), %rsi
addq $0x2, %rdi
movq %rdi, %r11
movq %rsi, %rdi
movq %r11, %r8
movq %rdi, (%r14)
movb (%rdi), %sil
movzbl %sil, %r9d
movl (%rdx,%r9,4), %r10d
incq %rdi
incq %r11
testl %r10d, %r10d
je 0xbb9a
cmpl $0x4, %r10d
jne 0xbbc1
movb $-0x30, %r10b
jmp 0xbbdf
leal -0x41(%rsi), %r11d
movb $-0x37, %r10b
cmpb $0x6, %r11b
jb 0xbbdf
leal -0x61(%rsi), %r11d
movb $-0x57, %r10b
cmpb $0x6, %r11b
jae 0xbc7d
addb %r10b, %sil
shlb $0x4, %sil
movb %sil, (%rax)
movzbl -0x1(%rdi), %r9d
cmpl $0x6, (%rdx,%r9,4)
jne 0xbbfa
decq %rdi
jmp 0xbc26
movq %r8, (%r14)
movzbl (%r8), %r9d
movl (%rdx,%r9,4), %edi
incq %r8
testl %edi, %edi
je 0xbbfa
cmpl $0x4, %edi
jne 0xbc20
addb %r9b, %sil
addb $-0x30, %sil
decq %r8
movq %r8, %rdi
jmp 0xbc4e
decq %r8
movq %r8, %rdi
leal -0x41(%r9), %r8d
cmpb $0x5, %r8b
ja 0xbc39
addb %r9b, %sil
addb $-0x37, %sil
jmp 0xbc4e
leal -0x61(%r9), %r8d
cmpb $0x5, %r8b
ja 0xbcd7
addb %r9b, %sil
addb $-0x57, %sil
movb %sil, (%rax)
movzbl (%rdi), %esi
cmpl $0x6, (%rdx,%rsi,4)
je 0xbc6f
incq %rdi
movq %rdi, (%r14)
movzbl (%rdi), %esi
incq %rdi
cmpl $0x0, (%rdx,%rsi,4)
je 0xbc5d
decq %rdi
incq %rax
cmpq %r12, %rdi
jb 0xbb79
jmp 0xbcb4
decq %rdi
cmpl $0x71, %r9d
jg 0xbc97
cmpl $0x5c, %r9d
je 0xbc4e
cmpl $0x6e, %r9d
jne 0xbca8
movb $0xa, %sil
jmp 0xbc4e
cmpl $0x72, %r9d
je 0xbcaf
cmpl $0x74, %r9d
jne 0xbca8
movb $0x9, %sil
jmp 0xbc4e
cmpb (%r15), %sil
je 0xbc4e
jmp 0xbc51
movb $0xd, %sil
jmp 0xbc4e
xorl %edx, %edx
cmpb $0x0, 0xc(%rsp)
je 0xbcc6
movsbl -0x1(%rax), %eax
movq (%rbx), %rcx
movl %eax, (%rcx)
movl %edx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subl (%rsp), %edi
incl %edi
movl %edi, 0x195c6(%rip)     # 0x252a8
movq (%rbx), %rdi
callq 0x81c0
jmp 0xbab6