// File: /workspace/github_c_makefile_star2_O2/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, 0x14(%rsp)
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq (%rdi), %rcx
movq %rcx, 0x8(%rsp)
leaq -0x1(%rcx), %r12
incq %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x80a0
testq %rax, %rax
je 0xb488
movq %rax, %r12
xorl %eax, %eax
cmpb $0x5c, -0x1(%r12,%rax)
leaq -0x1(%rax), %rax
je 0xb3ec
testb $0x1, %al
je 0xb3d0
movq %r13, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
xorl %ebp, %ebp
movabsq $0x3f0000003f, %rbx     # imm = 0x3F0000003F
movq 0x8(%rsp), %rax
cmpq %r12, %rax
jae 0xb49b
movb (%rax), %r13b
movq %r14, %rdi
callq 0xa083
cmpb $0x5c, %r13b
jne 0xb45e
movq (%r14), %rax
movzbl (%rax), %ecx
leaq 0x15d46(%rip), %rdx     # 0x21180
cmpl $0x4, (%rdx,%rcx,4)
je 0xb44e
leal -0x41(%rcx), %edx
cmpl $0x33, %edx
ja 0xb475
btq %rdx, %rbx
jae 0xb465
movq %r14, %rdi
callq 0xa083
movq %r14, %rdi
callq 0xa083
incl %ebp
movq (%r14), %rax
jmp 0xb417
movabsq $0xa200008000000, %rsi  # imm = 0xA200008000000
btq %rdx, %rsi
jb 0xb456
cmpb (%r15), %cl
je 0xb456
subl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x18e22(%rip)     # 0x242a8
jmp 0xb492
movl $0x1, 0x18e16(%rip)     # 0x242a8
pushq $0x5
popq %r13
jmp 0xb627
movl 0x14(%rsp), %ebx
testb %bl, %bl
setne %al
cmpl $0x1, %ebp
setne %cl
pushq $0x5
popq %r13
testb %cl, %al
jne 0xb627
cvtsi2sd %ebp, %xmm0
mulsd 0xdb56(%rip), %xmm0     # 0x19018
callq 0x8070
cvttsd2si %xmm0, %eax
cmpb $0x1, %bl
adcl $0x0, %eax
movq 0x18(%rsp), %rcx
movl %eax, (%rcx)
cltq
movq %rax, 0x18(%rsp)
leaq (,%rax,4), %rdi
callq 0x81d0
movl %ebx, %ecx
movq %rax, %rbx
movq 0x20(%rsp), %rax
movq %rbx, (%rax)
testq %rbx, %rbx
je 0xb506
testb %cl, %cl
je 0xb51c
xorl %eax, %eax
jmp 0xb521
movl (%r14), %eax
subl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x18d93(%rip)     # 0x242a8
pushq $0x1
jmp 0xb494
movl %ebp, (%rbx)
pushq $0x4
popq %rax
movq 0x18(%rsp), %rcx
andl $0x0, -0x4(%rbx,%rcx,4)
addq %rax, %rbx
movq 0x8(%rsp), %rax
movq %rax, (%r14)
cmpq %r12, %rax
jae 0xb60f
movb (%rax), %bpl
cmpb $0x5c, %bpl
jne 0xb5cf
movq %r14, %rdi
callq 0xa083
movq (%r14), %rax
movb (%rax), %bpl
movzbl %bpl, %eax
movb $-0x30, %cl
leaq 0x15c19(%rip), %rdx     # 0x21180
cmpl $0x4, (%rdx,%rax,4)
je 0xb581
leal -0x41(%rbp), %edx
movb $-0x37, %cl
cmpb $0x6, %dl
jb 0xb581
leal -0x61(%rbp), %edx
movb $-0x57, %cl
cmpb $0x5, %dl
ja 0xb5e5
addb %cl, %bpl
shlb $0x4, %bpl
movb %bpl, (%rbx)
movq %r14, %rdi
callq 0xa083
movq (%r14), %rax
movzbl (%rax), %ecx
leaq 0x15be0(%rip), %rdx     # 0x21180
cmpl $0x4, (%rdx,%rcx,4)
jne 0xb5af
addb %cl, %bpl
addb $-0x30, %bpl
jmp 0xb5cf
leal -0x41(%rcx), %edx
cmpb $0x5, %dl
ja 0xb5c0
addb %cl, %bpl
addb $-0x37, %bpl
jmp 0xb5cf
leal -0x61(%rcx), %edx
cmpb $0x5, %dl
ja 0xb639
addb %cl, %bpl
addb $-0x57, %bpl
movb %bpl, (%rbx)
movq %r14, %rdi
callq 0xa083
incq %rbx
movq (%r14), %rax
jmp 0xb536
cmpl $0x5c, %eax
je 0xb5cf
cmpl $0x74, %eax
je 0xb5fe
cmpl $0x72, %eax
je 0xb603
cmpl $0x6e, %eax
jne 0xb608
movb $0xa, %bpl
jmp 0xb5cf
movb $0x9, %bpl
jmp 0xb5cf
movb $0xd, %bpl
jmp 0xb5cf
cmpb (%r15), %bpl
je 0xb5cf
jmp 0xb5d2
xorl %r13d, %r13d
cmpb $0x0, 0x14(%rsp)
je 0xb627
movsbl -0x1(%rbx), %eax
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
movl %eax, (%rcx)
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x18c63(%rip)     # 0x242a8
movq 0x20(%rsp), %rax
movq (%rax), %rdi
callq 0x81c0
jmp 0xb627