// File: /workspace/github_c_makefile_star2_O3/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 0x39bc
leaq 0x8be8(%rip), %rsi      # 0xd425
movq %rbx, %rdi
callq 0x3190
testq %rax, %rax
je 0x48c5
movq %rax, %r15
movq 0x184ac(%rip), %r14     # 0x1cd00
leaq 0xfb55(%rip), %rax      # 0x143b0
movslq 0xc(%rax), %rax
movq %rax, %rcx
shlq $0x9, %rcx
leaq (%rcx,%rax,4), %rax
leaq 0xff6f(%rip), %rcx      # 0x147e0
leaq (%rcx,%rax), %rdi
addq $0x4, %rdi
movq %rbx, 0x10(%rsp)
movq %rbx, %rsi
callq 0x3070
movq %r15, 0x8(%rsp)
movq %r15, %rdi
callq 0x3140
xorl %r12d, %r12d
testl %eax, %eax
je 0x4965
xorl %r13d, %r13d
cmpb $0x20, -0x2(%r14,%r13)
jne 0x48ea
movq 0x8(%rsp), %rdi
movb $0xa, -0x1(%r14,%r13)
cmpb $0x20, -0x3(%r14,%r13)
leaq -0x1(%r13), %r13
je 0x48ae
addq %r13, %r14
jmp 0x48f2
leaq 0xfae4(%rip), %rax      # 0x143b0
decl 0xc(%rax)
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa1d8
addq %r13, %r14
movq 0x8(%rsp), %rdi
movb $0x0, (%r14)
incq %r14
callq 0x30a0
cmpq $0xffeff, %r13          # imm = 0xFFEFF
jl 0x4916
movl $0xffffffd6, %edi       # imm = 0xFFFFFFD6
movq 0x10(%rsp), %rsi
callq 0xa1d8
movq %r14, %rdi
subq 0x183e0(%rip), %rdi     # 0x1cd00
incq %rdi
callq 0x331c
leaq 0xfcd9(%rip), %rbx      # 0x14608
movq %rax, 0x198(%rbx)
movq 0x183c3(%rip), %rsi     # 0x1cd00
subq %rsi, %r14
movq %rax, %rdi
movq %r14, %rdx
callq 0x3150
movl $0x0, (%rbx)
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfa34(%rip), %rbp      # 0x143a0
movq %r14, %r15
xorl %r13d, %r13d
movl $0xfe, %edx
leaq 0x18392(%rip), %rbx     # 0x1cd10
movq %rbx, %rdi
xorl %esi, %esi
callq 0x30d0
movq %rbx, %rdi
movl $0xfe, %esi
movq 0x8(%rsp), %rdx
callq 0x30f0
testq %rax, %rax
je 0x48a1
movb 0x18367(%rip), %dl      # 0x1cd10
testl %r12d, %r12d
movl $0x20, %edi
je 0x4a9d
movq %r13, %rax
leaq 0x18350(%rip), %rcx     # 0x1cd11
cmpb $0xd, %dl
je 0x49d2
movzbl %dl, %esi
testl %esi, %esi
jne 0x49d7
jmp 0x4acd
movb (%rcx), %dl
incq %rcx
testl %r12d, %r12d
je 0x4a02
movl $0x1, %r12d
cmpb $0x2a, %dl
jne 0x4a93
xorl %edx, %edx
xorl %r12d, %r12d
cmpb $0x2f, (%rcx)
sete %dl
setne %r12b
addq %rdx, %rcx
jmp 0x4a93
cmpl $0x0, (%rbp)
jne 0x4a21
cmpb $0x2f, %dl
jne 0x4a21
movb (%rcx), %sil
cmpb $0x2a, %sil
jne 0x4a32
incq %rcx
movl $0x1, %r12d
jmp 0x4a93
cmpb $0x3b, %dl
je 0x4ab1
cmpb $0x2f, %dl
jne 0x4a61
movb (%rcx), %sil
cmpb $0x2f, %sil
je 0x4ab1
cmpb $0x9, %dl
movzbl %dl, %edx
cmovel %edi, %edx
cmpb $0x20, %dl
jne 0x4a58
movzbl (%rcx), %esi
cmpl $0x20, %esi
je 0x4a53
cmpl $0x9, %esi
jne 0x4a58
incq %rcx
jmp 0x4a46
movb %dl, (%r14,%rax)
incq %rax
jmp 0x4a90
cmpb $0x27, %dl
je 0x4a6e
movzbl %dl, %esi
cmpl $0x22, %esi
jne 0x4a38
incq %rax
movl %edx, %esi
movb %sil, -0x1(%r14,%rax)
movb (%rcx), %sil
incq %rcx
incq %rax
testb %sil, %sil
je 0x4a8b
cmpb %dl, %sil
jne 0x4a73
movb %sil, -0x1(%r14,%rax)
xorl %r12d, %r12d
movb (%rcx), %dl
incq %rcx
jmp 0x49c1
movzbl %dl, %ecx
xorl %eax, %eax
cmpl $0x23, %ecx
je 0x4ad9
cmpl $0x2a, %ecx
je 0x4ad9
jmp 0x49b7
leaq -0x1(%rax), %rcx
cmpb $0x20, -0x1(%r14,%rax)
cmovneq %rax, %rcx
movb $0xa, (%r14,%rcx)
incq %rcx
xorl %r12d, %r12d
movq %rcx, %rax
cmpq %r13, %rax
jne 0x4ae5
leaq (%r14,%r13), %r15
movl %r12d, %eax
incq %r13
movb $0xa, (%r15)
movl %eax, %r12d
jmp 0x4ae8
movq %rax, %r13
movq 0x8(%rsp), %rdi
callq 0x3140
testl %eax, %eax
jne 0x48a1
leaq (%r14,%r13), %r15
cmpq $0xfff01, %r13          # imm = 0xFFF01
jl 0x4972
jmp 0x48a1