// File: /workspace/github_c_makefile_star2_O2/heltilda[P]cicada/ciclib.c
// Function: cclib_read_string
void cclib_read_string()
{
    view windowView;
    window *stringWindow;
    linkedlist *theString;
    ccInt counter, numArgs, oneLetterType;
    char *stringPositionMarker, *holdString, *stringOverflow[2];
    
    numArgs = numBIF_args();
    if (numArgs < 1)  {  setError(wrong_argument_count_err, pcCodePtr-1);  return;  }
    
    
        // read in the source string:  argument 1
    
    stringWindow = getBIFstringArg(1);
    if (errCode != passed)  return;
    theString = &(stringWindow->variable_ptr->mem.data);   
    
    
        // make a copy of the source string, just in case the copy process would overwrite the source string
    
    holdString = (char *) malloc(stringWindow->width+1);
    if (holdString == NULL)  {  setError(out_of_memory_err, pcCodePtr-1);  return;  }
    getElements(theString, stringWindow->offset+1, stringWindow->offset+stringWindow->width, (void *) holdString);
    holdString[stringWindow->width] = 0;
    stringOverflow[0] = holdString+stringWindow->width;     // the end of the string
    
    
        // get past any weird characters at the beginning
    
    stringPositionMarker = holdString;
    oneLetterType = lettertype(stringPositionMarker);
    while ((oneLetterType != a_symbol) && (oneLetterType != a_number) && (oneLetterType != a_letter)
                    && (stringPositionMarker < stringOverflow[0]))  {
        stringPositionMarker++;
        oneLetterType = lettertype(stringPositionMarker);     }
    
    
        // Read the string into the subsequent argument variables.  String variables are read up through the next space.
    
    for (counter = 2; counter <= numArgs; counter++)   {
        windowView.windowPtr = getBIFmember(counter);
        if (windowView.windowPtr != NULL)  {
            windowView.offset = windowView.windowPtr->offset;
            windowView.width = windowView.windowPtr->width;
            readViewString(&windowView, (void *) &stringPositionMarker, stringOverflow);
            if (warningCode != passed)  errIndex--;
            if (errCode != passed)  {  free((void *) holdString);  return;  }
    }   }
    
    
        // Finally, check to see if there seem to be any left-over useful fields in the string -- if so, set a warning.
    
    oneLetterType = lettertype(stringPositionMarker);
    while ((oneLetterType != a_symbol) && (oneLetterType != a_number)
                    && (oneLetterType != a_letter) && (stringPositionMarker < stringOverflow[0]))  {
        stringPositionMarker++;
        oneLetterType = lettertype(stringPositionMarker);         }
    
    if ((stringPositionMarker != holdString+stringWindow->width) && (warningCode == passed))  {
        stringOverflow[1] = stringPositionMarker;
        if (stringOverflow[1] >= stringOverflow[0])  stringOverflow[1] = stringOverflow[0]-1;
        setWarning(string_read_err, pcCodePtr-1);       }
    
    if ((warningCode != passed) && (doPrintError))  {
        printError(NULL, -1, holdString, (ccInt) (stringOverflow[1]-holdString), ccTrue);
        warningCode = passed;       }
    
    free((void *) holdString);      // clean up
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
callq 0x170b2
testl %eax, %eax
jle 0x15f0f
movl %eax, %r15d
pushq $0x1
popq %rdi
callq 0x17280
leaq 0xe93c(%rip), %r14      # 0x24760
cmpl $0x0, 0x18(%r14)
jne 0x15ffd
movq %rax, %rbp
movq 0x10(%rax), %r12
movslq 0x1c(%rax), %rbx
leaq 0x1(%rbx), %rdi
callq 0x81d0
testq %rax, %rax
je 0x15fe2
movq %rax, %r13
addq $0x10, %r12
movl 0x18(%rbp), %eax
leal 0x1(%rax), %esi
addl %eax, %ebx
movq %r12, %rdi
movl %ebx, %edx
movq %r13, %rcx
callq 0x8f8b
movq %rbp, 0x28(%rsp)
movslq 0x1c(%rbp), %rcx
leaq (%rcx,%r13), %rax
movb $0x0, (%r13,%rcx)
movq %rax, 0x10(%rsp)
leaq 0xb2f9(%rip), %rbp      # 0x21180
movq %r13, (%rsp)
movzbl (%r13), %edx
movl (%rbp,%rdx,4), %esi
addl $-0x6, %esi
leaq 0x1(%r13), %rdx
cmpl $-0x4, %esi
ja 0x15ea8
cmpq %rax, %r13
movq %rdx, %r13
jb 0x15e8b
decq %rdx
leaq 0x8(%rsp), %r12
movq %rdx, (%r12)
negl %r15d
pushq $0x2
popq %r13
leaq 0x10(%rsp), %rbx
leal (%r15,%r13), %eax
cmpl $0x1, %eax
je 0x15f37
movl %r13d, %edi
callq 0x170f5
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x15f0a
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0xd5d2
cmpl $0x0, 0x20(%r14)
je 0x15eff
decl 0x1c(%r14)
cmpl $0x0, 0x18(%r14)
jne 0x15ff4
incl %r13d
jmp 0x15ec0
leaq 0xe84a(%rip), %rax      # 0x24760
movq 0xb8(%rax), %rsi
addq $-0x4, %rsi
pushq $0x2d
popq %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc7c2
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq (%rsp), %rbx
movzbl (%rax), %edx
movl (%rbp,%rdx,4), %edx
addl $-0x6, %edx
cmpl $-0x4, %edx
ja 0x15f63
cmpq %rcx, %rax
jae 0x15f63
incq %rax
movq %rax, 0x8(%rsp)
jmp 0x15f45
movq 0x28(%rsp), %rdx
movslq 0x1c(%rdx), %rdx
movq %rbx, %rsi
addq %rdx, %rsi
cmpq %rsi, %rax
setne %sil
movl 0x20(%r14), %edx
testl %edx, %edx
sete %dil
andb %sil, %dil
cmpb $0x1, %dil
jne 0x15fb3
leaq -0x1(%rcx), %rdx
cmpq %rcx, %rax
cmovbq %rax, %rdx
movq %rdx, 0x18(%rsp)
movq 0xb8(%r14), %rsi
addq $-0x4, %rsi
pushq $0x5
popq %rdi
callq 0xc87d
movl 0x20(%r14), %edx
testl %edx, %edx
je 0x15fdd
cmpb $0x0, 0x2a9(%r14)
je 0x15fdd
movl 0x18(%rsp), %ecx
subl %ebx, %ecx
pushq $-0x1
popq %rsi
pushq $0x1
popq %r8
xorl %edi, %edi
movq %rbx, %rdx
callq 0x17f79
andl $0x0, 0x20(%r14)
movq %rbx, %rdi
jmp 0x15ff8
movq 0xb8(%r14), %rsi
addq $-0x4, %rsi
pushq $0x1
jmp 0x15f23
movq (%rsp), %rdi
callq 0x81c0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq