// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/scriptfile.c
// Function: scriptfile_preparse
void scriptfile_preparse (scriptfile *sf, char *tx, size_t flen)
{
	int cr, numcr, nflen, ws, cs, inquote;
	size_t i;

		//Count number of lines
	numcr = 1;
	for(i=0;i<flen;i++)
	{
			//detect all 4 types of carriage return (\r, \n, \r\n, \n\r :)
		cr=0;if (tx[i] == '\r') { i += (tx[i+1] == '\n'); cr = 1; }
		else if (tx[i] == '\n') { i += (tx[i+1] == '\r'); cr = 1; }
		if (cr) { numcr++; continue; }
	}

	sf->linenum = numcr;
	sf->lineoffs = (int *)malloc(sf->linenum*sizeof(int));

		//Preprocess file for comments (// and /*...*/, and convert all whitespace to single spaces)
	nflen = 0; ws = 0; cs = 0; numcr = 0; inquote = 0;
	for(i=0;i<flen;i++)
	{
			//detect all 4 types of carriage return (\r, \n, \r\n, \n\r :)
		cr=0;if (tx[i] == '\r') { i += (tx[i+1] == '\n'); cr = 1; }
		else if (tx[i] == '\n') { i += (tx[i+1] == '\r'); cr = 1; }
		if (cr)
		{
				//Remember line numbers by storing the byte index at the start of each line
				//Line numbers can be retrieved by doing a binary search on the byte index :)
			sf->lineoffs[numcr++] = nflen;
			if (cs == 1) cs = 0;
			ws = 1; continue; //strip CR/LF
		}

		if ((!inquote) && ((tx[i] == ' ') || (tx[i] == '\t'))) { ws = 1; continue; } //strip Space/Tab
		if ((tx[i] == ';') && (!cs)) cs = 1;	// ; comment
		if ((tx[i] == '/') && (tx[i+1] == '/') && (!cs)) cs = 1;
		if ((tx[i] == '/') && (tx[i+1] == '*') && (!cs)) { ws = 1; cs = 2; }
		if ((tx[i] == '*') && (tx[i+1] == '/') && (cs == 2)) { cs = 0; i++; continue; }
		if (cs) continue;

		if (ws) { tx[nflen++] = 0; ws = 0; }

			//quotes inside strings: \"
		if ((tx[i] == '\\') && (tx[i+1] == '\"')) { i++; tx[nflen++] = '\"'; continue; }
		if (tx[i] == '\"') { inquote ^= 1; continue; }
		tx[nflen++] = tx[i];
	}
	tx[nflen++] = 0; sf->lineoffs[numcr] = nflen;
	tx[nflen++] = 0;

#if 0
		//for debugging only:
	printf("pre-parsed file:flen=%d,nflen=%d\n",flen,nflen);
	for(i=0;i<nflen;i++) { if (tx[i] < 32) printf("_"); else printf("%c",tx[i]); }
	printf("[eof]\nnumlines=%d\n",sf->linenum);
	for(i=0;i<sf->linenum;i++) printf("line %d = byte %d\n",i,sf->lineoffs[i]);
#endif
	flen = nflen;

	sf->textbuf = sf->textptr = tx;
	sf->textlength = nflen;
	sf->eof = &sf->textbuf[nflen-1];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x1, -0x20(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x6fb74
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xd, %eax
jne 0x6fb14
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rax,%rcx), %eax
cmpl $0xa, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x1, -0x1c(%rbp)
jmp 0x6fb50
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x6fb4e
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rax,%rcx), %eax
cmpl $0xd, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x1, -0x1c(%rbp)
jmp 0x6fb50
cmpl $0x0, -0x1c(%rbp)
je 0x6fb61
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x6fb63
jmp 0x6fb63
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x6fac3
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rax
movslq 0x30(%rax), %rdi
shlq $0x2, %rdi
callq 0x68f0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x38(%rax)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x6fe49
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xd, %eax
jne 0x6fc16
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rax,%rcx), %eax
cmpl $0xa, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x1, -0x1c(%rbp)
jmp 0x6fc52
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x6fc50
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rax,%rcx), %eax
cmpl $0xd, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x1, -0x1c(%rbp)
jmp 0x6fc52
cmpl $0x0, -0x1c(%rbp)
je 0x6fc8d
movl -0x24(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movl -0x20(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
cmpl $0x1, -0x2c(%rbp)
jne 0x6fc81
movl $0x0, -0x2c(%rbp)
movl $0x1, -0x28(%rbp)
jmp 0x6fe38
cmpl $0x0, -0x30(%rbp)
jne 0x6fcc1
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
je 0x6fcb5
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x9, %eax
jne 0x6fcc1
movl $0x1, -0x28(%rbp)
jmp 0x6fe38
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3b, %eax
jne 0x6fcdf
cmpl $0x0, -0x2c(%rbp)
jne 0x6fcdf
movl $0x1, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x6fd0f
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x6fd0f
cmpl $0x0, -0x2c(%rbp)
jne 0x6fd0f
movl $0x1, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x6fd46
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rax,%rcx), %eax
cmpl $0x2a, %eax
jne 0x6fd46
cmpl $0x0, -0x2c(%rbp)
jne 0x6fd46
movl $0x1, -0x28(%rbp)
movl $0x2, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2a, %eax
jne 0x6fd87
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0x6fd87
cmpl $0x2, -0x2c(%rbp)
jne 0x6fd87
movl $0x0, -0x2c(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x6fe38
cmpl $0x0, -0x2c(%rbp)
je 0x6fd92
jmp 0x6fe38
cmpl $0x0, -0x28(%rbp)
je 0x6fdb5
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5c, %eax
jne 0x6fdfc
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rax,%rcx), %eax
cmpl $0x22, %eax
jne 0x6fdfc
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
movslq %ecx, %rcx
movb $0x22, (%rax,%rcx)
jmp 0x6fe38
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x22, %eax
jne 0x6fe18
movl -0x30(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x6fe38
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x24(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x6fbc5
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movl -0x24(%rbp), %edx
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x24(%rbp)
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movslq -0x24(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movl -0x24(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movl -0x24(%rbp), %eax
subl $0x1, %eax
cltq
addq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)