// File: /workspace/github_c_makefile_star2_O1/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
pushq %rax
movq %rdi, %rbx
callq 0x399b
leaq 0x8b4a(%rip), %rsi      # 0xd3bc
movq %rbx, %rdi
callq 0x3190
testq %rax, %rax
je 0x4aef
movq %rax, %r15
movq 0x18473(%rip), %r14     # 0x1cd00
leaq 0xfb1c(%rip), %rax      # 0x143b0
movslq 0xc(%rax), %rax
movq %rax, %rcx
shlq $0x9, %rcx
leaq (%rcx,%rax,4), %rax
leaq 0xff36(%rip), %rcx      # 0x147e0
leaq (%rcx,%rax), %rdi
addq $0x4, %rdi
movq %rbx, (%rsp)
movq %rbx, %rsi
callq 0x3070
xorl %r13d, %r13d
leaq 0x18448(%rip), %r12     # 0x1cd10
leaq 0xfad1(%rip), %rbp      # 0x143a0
xorl %ebx, %ebx
movq %r15, %rdi
callq 0x3140
testl %eax, %eax
jne 0x4a5d
cmpq $0xfff00, %r13          # imm = 0xFFF00
jg 0x4a5d
movl $0xfe, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x30d0
movq %r12, %rdi
movl $0xfe, %esi
movq %r15, %rdx
callq 0x30f0
testq %rax, %rax
je 0x4a54
movb 0x183f3(%rip), %sil     # 0x1cd10
testl %ebx, %ebx
je 0x4a10
movq %r13, %rcx
leaq 0x183e2(%rip), %rdx     # 0x1cd11
cmpb $0xd, %sil
je 0x4942
movzbl %sil, %edi
testl %edi, %edi
jne 0x4948
jmp 0x4a44
movb (%rdx), %sil
incq %rdx
testl %ebx, %ebx
je 0x4971
movl $0x1, %ebx
cmpb $0x2a, %sil
jne 0x4a05
xorl %esi, %esi
xorl %ebx, %ebx
cmpb $0x2f, (%rdx)
sete %sil
setne %bl
addq %rsi, %rdx
jmp 0x4a05
cmpl $0x0, (%rbp)
jne 0x498c
cmpb $0x2f, %sil
jne 0x498c
cmpb $0x2a, (%rdx)
jne 0x498c
incq %rdx
movl $0x1, %ebx
jmp 0x4a05
cmpb $0x3b, %sil
je 0x4a2a
cmpb $0x2f, %sil
jne 0x49a5
cmpb $0x2f, (%rdx)
je 0x4a2a
cmpb $0x27, %sil
je 0x49b4
movzbl %sil, %edi
cmpl $0x22, %edi
jne 0x49d8
incq %rcx
movl %esi, %edi
movb %dil, -0x1(%r14,%rcx)
movb (%rdx), %dil
incq %rdx
incq %rcx
testb %dil, %dil
je 0x49d1
cmpb %sil, %dil
jne 0x49b9
movb %dil, -0x1(%r14,%rcx)
jmp 0x4a03
cmpb $0x9, %sil
movl $0x20, %esi
cmovel %esi, %edi
cmpb $0x20, %dil
jne 0x49fc
movzbl (%rdx), %esi
cmpl $0x20, %esi
je 0x49f7
cmpl $0x9, %esi
jne 0x49fc
incq %rdx
jmp 0x49e4
movb %dil, (%r14,%rcx)
incq %rcx
xorl %ebx, %ebx
movb (%rdx), %sil
incq %rdx
jmp 0x492f
leaq (%r14,%r13), %rdx
movzbl %sil, %edi
movq %r13, %rcx
cmpl $0x23, %edi
je 0x4a3c
cmpl $0x2a, %edi
je 0x4a3c
jmp 0x4925
cmpb $0x20, -0x1(%r14,%rcx)
leaq -0x1(%rcx), %rdx
cmoveq %rdx, %rcx
leaq (%r14,%rcx), %rdx
incq %rcx
movb $0xa, (%rdx)
xorl %ebx, %ebx
cmpq %r13, %rcx
jne 0x4a51
movb $0xa, (%r14,%rcx)
incq %rcx
movq %rcx, %r13
testq %rax, %rax
jne 0x48d1
cmpb $0x20, -0x2(%r14,%r13)
jne 0x4a77
movb $0xa, -0x1(%r14,%r13)
cmpb $0x20, -0x3(%r14,%r13)
leaq -0x1(%r13), %r13
je 0x4a65
addq %r13, %r14
movb $0x0, (%r14)
incq %r14
movq %r15, %rdi
callq 0x30a0
cmpq $0xffeff, %r13          # imm = 0xFFEFF
jl 0x4aa0
movl $0xffffffd6, %edi       # imm = 0xFFFFFFD6
movq (%rsp), %rsi
callq 0xa2c8
movq %r14, %rdi
subq 0x18256(%rip), %rdi     # 0x1cd00
incq %rdi
callq 0x331c
leaq 0xfb4f(%rip), %rbx      # 0x14608
movq %rax, 0x198(%rbx)
movq 0x18239(%rip), %rsi     # 0x1cd00
subq %rsi, %r14
movq %rax, %rdi
movq %r14, %rdx
callq 0x3150
movl $0x0, (%rbx)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf8ba(%rip), %rax      # 0x143b0
decl 0xc(%rax)
movl $0xfffffffe, %edi       # imm = 0xFFFFFFFE
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa2c8