// File: /workspace/github_c_makefile_star2_O2/42Bastian[P]lyxass/parser.c
// Function: LoadSource
int LoadSource(char fn[])
{
  FILE *f;

  ConvertFilename(fn);

  f = fopen(fn,"r");

  if ( f != NULL ){
    char * ptr, *ptr_end, *ptr_start;
    int comment;

    comment = 0;
    ptr = loadBuffer;

    ptr_end = ptr + LOAD_BUFFER_SIZE - 256;

    strcpy(file_list[Global.Files].name,fn);

    while ( ! feof(f) && ptr <= ptr_end){
      char c;
      char *ptrLine = line;

      memset(line,0,254);
      if ( fgets(line,254,f) == NULL ){
        break;
      }
      ptr_start = ptr;
      ptrLine = line;
      // remove comment
      c = *ptrLine++;
      if (comment == 0 && (c == '*' || c == '#') )  {
        *ptr++ = '\n';
      } else {
        for( ; c ; c = *ptrLine++){
          // skip CR
          if ( c == '\r' ) {
            c = *ptrLine++;
          }
          if ( comment ) {
            if ( c == '*' && *ptrLine == '/' ){
              ++ptrLine;
              comment = 0;
            }
            continue;
          }
          if ( (noCcomment == 0) && (c == '/' && *ptrLine == '*') ){
            comment = 1;
            ++ptrLine;
            continue;
          }
          // comment ? => finished
          if ( c == ';' || (c == '/' && *ptrLine == '/') ){
            if ( *(ptr-1) == ' ' ){
              --ptr;
            }
            *ptr++ = '\n';
            break;
          }

          // do not delete Space within strings
          if ( c == '\'' || c == '"' ){
            char end;
            end = c;
            do{
              *ptr++ = c;
              c = *ptrLine++;
            }while ( c && c != end );
            *ptr++ = c;
            continue;
          }

          // collapse white spaces
          if ( c == '\t' ) {
            c = ' ';
          }
          while ( (c == ' ' || c == '\t') &&
                  (*ptrLine == ' ' || *ptrLine == '\t' ) ) {
            ++ptrLine;
          }
          *ptr++ = c;
        }
      } // if ( c == '*' || c == '#' )
      if ( ptr == ptr_start ){
        *ptr++ = '\n';
      }

    } // while

    while( *(ptr-2) == ' ' ){
      --ptr;
      *ptr = '\n';
    }
    *ptr++ = 0;

    fclose(f);

    if ( ptr >= ptr_end ) Error(-LOAD_ERR,fn);

    Current.SrcPtr = my_malloc( (long)(ptr-loadBuffer + 1));
    memcpy(Current.SrcPtr, loadBuffer, ptr-loadBuffer);

    Current.Line = 0;

  } else {
    Global.Files--;
    return Error(-FILE_ERR,fn);
  }
  return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
callq 0x393c
leaq 0x7c4f(%rip), %rsi      # 0xc3bc
movq %rbx, %rdi
callq 0x3190
movq %rax, (%rsp)
testq %rax, %rax
je 0x496b
movq 0x18577(%rip), %r12     # 0x1cd00
leaq 0xfc20(%rip), %rax      # 0x143b0
movslq 0xc(%rax), %rax
imulq $0x204, %rax, %rax      # imm = 0x204
leaq 0x1003e(%rip), %rcx     # 0x147e0
leaq (%rcx,%rax), %rdi
addq $0x4, %rdi
movq %rbx, 0x10(%rsp)
movq %rbx, %rsi
callq 0x3070
xorl %eax, %eax
leaq 0xfbe0(%rip), %rbx      # 0x143a0
pushq $0x1
popq %r14
pushq $0x20
popq %r15
xorl %ebp, %ebp
movq %rax, %r13
movq (%rsp), %rdi
callq 0x3140
testl %eax, %eax
jne 0x499e
cmpq $0xfff01, %r13          # imm = 0xFFF01
jge 0x499e
movq %r13, 0x8(%rsp)
movl %r14d, %r13d
movq %rbx, %r14
movl %r15d, %ebx
movl $0xfe, %edx
leaq 0x1850b(%rip), %r15     # 0x1cd10
movq %r15, %rdi
xorl %esi, %esi
callq 0x30d0
movq %r15, %rdi
movl $0xfe, %esi
movq (%rsp), %rdx
callq 0x30f0
testq %rax, %rax
je 0x498e
movb 0x184e1(%rip), %dl      # 0x1cd10
testl %ebp, %ebp
movl %ebx, %r15d
movq %r14, %rbx
movl %r13d, %r14d
movq 0x8(%rsp), %r8
je 0x491f
movq %r8, %rax
leaq 0x184c2(%rip), %rcx     # 0x1cd11
cmpb $0xd, %dl
je 0x4860
movzbl %dl, %esi
testl %esi, %esi
jne 0x4865
jmp 0x494e
movb (%rcx), %dl
incq %rcx
testl %ebp, %ebp
je 0x4884
cmpb $0x2a, %dl
jne 0x489d
xorl %edx, %edx
xorl %ebp, %ebp
cmpb $0x2f, (%rcx)
sete %dl
setne %bpl
addq %rdx, %rcx
jmp 0x4915
cmpl $0x0, (%rbx)
movzbl %dl, %esi
jne 0x48a2
cmpb $0x2f, %dl
jne 0x48a2
movb (%rcx), %dil
cmpb $0x2a, %dil
jne 0x48b3
incq %rcx
movl %r14d, %ebp
jmp 0x4915
cmpb $0x3b, %dl
je 0x4933
cmpb $0x2f, %dl
jne 0x48db
movb (%rcx), %dil
cmpb $0x2f, %dil
je 0x4933
cmpb $0x9, %dl
cmovel %r15d, %esi
movq %rcx, %rdx
cmpb $0x20, %sil
jne 0x490c
movzbl (%rdx), %edi
cmpl $0x20, %edi
je 0x48d6
cmpl $0x9, %edi
jne 0x4909
incq %rdx
jmp 0x48c3
cmpb $0x27, %dl
je 0x48e5
cmpl $0x22, %esi
jne 0x48b9
incq %rax
movl %edx, %esi
movb %sil, -0x1(%r12,%rax)
movb (%rcx), %sil
incq %rcx
incq %rax
testb %sil, %sil
je 0x4902
cmpb %dl, %sil
jne 0x48ea
movb %sil, -0x1(%r12,%rax)
jmp 0x4913
movq %rdx, %rcx
movb %sil, (%r12,%rax)
incq %rax
xorl %ebp, %ebp
movb (%rcx), %dl
incq %rcx
jmp 0x484f
movzbl %dl, %eax
xorl %ecx, %ecx
cmpl $0x23, %eax
je 0x4959
cmpl $0x2a, %eax
je 0x4959
jmp 0x4845
leaq -0x1(%rax), %rcx
cmpb $0x20, -0x1(%r12,%rax)
cmovneq %rax, %rcx
movb $0xa, (%r12,%rcx)
incq %rcx
xorl %ebp, %ebp
movq %rcx, %rax
movl %ebp, %ecx
cmpq %r8, %rax
jne 0x47ca
movb $0xa, (%r12,%r8)
incq %r8
movq %r8, %rax
movl %ecx, %ebp
jmp 0x47ca
leaq 0xfa3e(%rip), %rax      # 0x143b0
decl 0xc(%rax)
pushq $-0x2
popq %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x96cc
movq 0x8(%rsp), %r13
jmp 0x499e
movb $0xa, -0x1(%r12,%r13)
decq %r13
cmpb $0x20, -0x2(%r12,%r13)
je 0x4995
movb $0x0, (%r12,%r13)
movq (%rsp), %rdi
callq 0x30a0
cmpq $0xffeff, %r13          # imm = 0xFFEFF
jl 0x49ca
pushq $-0x2a
popq %rdi
movq 0x10(%rsp), %rsi
callq 0x96cc
movq %r12, %rax
subq 0x1832c(%rip), %rax     # 0x1cd00
leaq (%rax,%r13), %rdi
addq $0x2, %rdi
callq 0x32ec
leaq 0xfc20(%rip), %rbx      # 0x14608
movq %rax, 0x198(%rbx)
movq 0x1830a(%rip), %rsi     # 0x1cd00
subq %rsi, %r12
leaq (%r12,%r13), %rdx
incq %rdx
movq %rax, %rdi
callq 0x3150
andl $0x0, (%rbx)
pushq $0x1
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq