// File: /workspace/github_c_makefile_star2_O0/42Bastian[P]lyxass/lyxass.c
// Function: main
int main(int argc, char **argv)
{
  // init
  label_t * l;

  my_stderr = stdout; //stderr;
  chgPathToUpper = 0;

  InitLabels();
  InitTransASCII();

  InitParser();

  memset( (char *)&Current, 0, sizeof(struct current_s) );
  memset( (char *)&Global, 0, sizeof(struct global_s) );
  Global.run = -1;
  sourceMode = LYNX;
  jaguar_mode = -1;

  code.Mem = my_malloc(MAX_CODE_SIZE);
  code.Size = 12;
  code.Ptr = code.Mem+12;

  bll_root = getenv("BLL_ROOT");
  bjl_root = getenv("BJL_ROOT");

  CommandLine( &argc, argv );

  l = newSymbol("CYCLES", 0);
  l->type |= VARIABLE;
  p_cycles = (uint32_t *)&l->value;

  l = newSymbol("__LYXASS__", VERSION);

  /*
  if ( argc != 2 ) {
    printf("Aufruf : dump filename \n");
    return FALSE;
  }
  */
  if (LoadSource(argv[argc])){

    mainloop(0);

    if ( refFirst ){
      REFERENCE *ptr1,*ptr = refFirst;

      Error(UNSOLVED_ERR,"\b");

      while ( ptr ){
        printf("<%32s> [%5d %s]\n",ptr->unknown->name,
               ptr->line+1,file_list[ptr->file].name);
        ptr1 = ptr;
        ptr = ptr->up;
        free(ptr1);
      }
    }
    if ( cntError ){
      printf("Total Errors :%d\nNo file written !\n",cntError);
    } else {
      if ( Global.run != -1 ){
        if ( Global.mainMode == LYNX ){
          code.Mem += 2;
          code.Size -=2;

          code.Mem[0] = -0x80;
          code.Mem[1] = 0x08;

          code.Mem[2] = Global.run >> 8;
          code.Mem[3] = Global.run & 0xff;
          code.Mem[4] = (char)(code.Size >> 8);
          code.Mem[5] = (char)(code.Size & 0xff);

          code.Mem[6] = 'B';
          code.Mem[7] = 'S';
          code.Mem[8] = '9';
          code.Mem[9] = '3';
          /*
          code.Mem += 4;
          code.Size -= 4;
          code.Mem[0] = (char)0x81;
          code.Mem[1] = 'P';
          code.Mem[2] = Global.run >> 8;
          code.Mem[3] = Global.run & 0xff;
          code.Mem[4] = ((code.Size-6) >> 8) ^ 0xff;
          code.Mem[5] = ((code.Size-6) & 0xff) ^ 0xff;
          */
        } else {
          code.Mem[0] = 'B';
          code.Mem[1] = 'S';
          code.Mem[2] = '9';
          code.Mem[3] = '4';
          code.Mem[4] = Global.run >> 24;
          code.Mem[5] = (Global.run >> 16) & 255;
          code.Mem[6] = (Global.run >>  8) & 255;
          code.Mem[7] = Global.run & 255;
          code.Mem[8] = (code.Size-12)>> 24;
          code.Mem[9] = ((code.Size-12) >> 16) & 255;
          code.Mem[10] = ((code.Size-12) >>  8) & 255;
          code.Mem[11] = (code.Size-12) & 255;
        }
        if ( data ){
          if (Global.mainMode == LYNX ){
            code.Size -= 10;
            code.Mem += 10;
          } else {
            code.Size -= 12;
            code.Mem += 12;
          }
          writeFile(outfile,code.Mem,code.Size);
        } else {
          writeFile(outfile,code.Mem,code.Size);
        }
        if ( symbols ){
          writeSymbols(outfile, hexsymbols);
        }
        if ( verbose ){
          printf("\nCode-size : %ld\n"
                 "Lines : %d\n"
                 "Macros expanded : %d\n"
                 "Pass 2 runs : %d\n"
                 "Start-address : $%04x\n"
                 "Memory usage : %ld\n",
                 code.Size,Global.Lines,
                 cntMacroExpand,cntRef,Global.run,totalMemory);
        }
      }else{
        printf("No RUN statement ! No outputfile generated.\n");
      }
    }
    if ( dumpGlobals ){
      DumpGlobals();
    }
  }

  //  hashStatistics();
  return cntError;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x12bd3(%rip), %rax     # 0x16fd0
movq (%rax), %rax
movq %rax, 0x141e1(%rip)     # 0x185e8
movl $0x0, 0x141df(%rip)     # 0x185f0
movb $0x0, %al
callq 0x6640
callq 0x9fc0
movb $0x0, %al
callq 0x65a0
leaq 0x141cd(%rip), %rdi     # 0x185f8
xorl %esi, %esi
movl $0x1c0, %edx            # imm = 0x1C0
callq 0x30c0
leaq 0x13f62(%rip), %rdi     # 0x183a0
xorl %esi, %esi
movl $0x220, %edx            # imm = 0x220
callq 0x30c0
movl $0xffffffff, 0x13f5c(%rip) # imm = 0xFFFFFFFF
movl $0x1, 0x14182(%rip)     # 0x185e0
movl $0xffffffff, 0x1417c(%rip) # imm = 0xFFFFFFFF
movl $0x200000, %edi         # imm = 0x200000
callq 0x32e0
movq %rax, 0x14147(%rip)     # 0x185c0
movq $0xc, 0x14144(%rip) # 0x185c8
movq 0x14135(%rip), %rax     # 0x185c0
addq $0xc, %rax
movq %rax, 0x1413a(%rip)     # 0x185d0
leaq 0xcb9b(%rip), %rdi      # 0x11038
callq 0x3030
movq %rax, 0x1430f(%rip)     # 0x187b8
leaq 0xcb91(%rip), %rdi      # 0x11041
callq 0x3030
movq %rax, 0x14304(%rip)     # 0x187c0
movq -0x10(%rbp), %rsi
leaq -0x8(%rbp), %rdi
callq 0x3eb0
leaq 0xcb7a(%rip), %rdi      # 0x1104a
xorl %eax, %eax
movl %eax, %esi
callq 0x76b0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
orl $0x10, %ecx
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, 0x142cf(%rip)     # 0x187c8
leaq 0xcb51(%rip), %rdi      # 0x11051
movl $0x11203, %esi          # imm = 0x11203
callq 0x76b0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movslq -0x8(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x5070
cmpl $0x0, %eax
je 0x48e2
xorl %edi, %edi
callq 0x48f0
leaq 0x2285a(%rip), %rax     # 0x26d90
cmpq $0x0, (%rax)
je 0x45c7
leaq 0x22849(%rip), %rax     # 0x26d90
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x1d, %edi
leaq 0xcb02(%rip), %rsi      # 0x1105c
callq 0xd130
cmpq $0x0, -0x28(%rbp)
je 0x45c5
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
addq $0x38, %rsi
movq -0x28(%rbp), %rax
movl 0x14(%rax), %edx
addl $0x1, %edx
movq -0x28(%rbp), %rax
movslq 0x18(%rax), %rax
leaq 0x14245(%rip), %rcx     # 0x187d0
imulq $0x204, %rax, %rax      # imm = 0x204
addq %rax, %rcx
addq $0x4, %rcx
leaq 0xcabe(%rip), %rdi      # 0x1105e
movb $0x0, %al
callq 0x30b0
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3040
jmp 0x455f
jmp 0x45c7
cmpl $0x0, 0x13db2(%rip)     # 0x18380
je 0x45e9
movl 0x13daa(%rip), %esi     # 0x18380
leaq 0xca92(%rip), %rdi      # 0x1106f
movb $0x0, %al
callq 0x30b0
jmp 0x48d0
cmpl $-0x1, 0x13dc0(%rip)    # 0x183b0
je 0x48c0
cmpl $0x1, 0x13dbf(%rip)     # 0x183bc
jne 0x46c9
movq 0x13fb6(%rip), %rax     # 0x185c0
addq $0x2, %rax
movq %rax, 0x13fab(%rip)     # 0x185c0
movq 0x13fac(%rip), %rax     # 0x185c8
subq $0x2, %rax
movq %rax, 0x13fa1(%rip)     # 0x185c8
movq 0x13f92(%rip), %rax     # 0x185c0
movb $-0x80, (%rax)
movq 0x13f88(%rip), %rax     # 0x185c0
movb $0x8, 0x1(%rax)
movl 0x13d6e(%rip), %eax     # 0x183b0
sarl $0x8, %eax
movb %al, %cl
movq 0x13f72(%rip), %rax     # 0x185c0
movb %cl, 0x2(%rax)
movl 0x13d59(%rip), %eax     # 0x183b0
andl $0xff, %eax
movb %al, %cl
movq 0x13f5b(%rip), %rax     # 0x185c0
movb %cl, 0x3(%rax)
movq 0x13f59(%rip), %rax     # 0x185c8
sarq $0x8, %rax
movb %al, %cl
movq 0x13f44(%rip), %rax     # 0x185c0
movb %cl, 0x4(%rax)
movq 0x13f42(%rip), %rax     # 0x185c8
andq $0xff, %rax
movb %al, %cl
movq 0x13f2b(%rip), %rax     # 0x185c0
movb %cl, 0x5(%rax)
movq 0x13f21(%rip), %rax     # 0x185c0
movb $0x42, 0x6(%rax)
movq 0x13f16(%rip), %rax     # 0x185c0
movb $0x53, 0x7(%rax)
movq 0x13f0b(%rip), %rax     # 0x185c0
movb $0x39, 0x8(%rax)
movq 0x13f00(%rip), %rax     # 0x185c0
movb $0x33, 0x9(%rax)
jmp 0x47ce
movq 0x13ef0(%rip), %rax     # 0x185c0
movb $0x42, (%rax)
movq 0x13ee6(%rip), %rax     # 0x185c0
movb $0x53, 0x1(%rax)
movq 0x13edb(%rip), %rax     # 0x185c0
movb $0x39, 0x2(%rax)
movq 0x13ed0(%rip), %rax     # 0x185c0
movb $0x34, 0x3(%rax)
movl 0x13cb6(%rip), %eax     # 0x183b0
sarl $0x18, %eax
movb %al, %cl
movq 0x13eba(%rip), %rax     # 0x185c0
movb %cl, 0x4(%rax)
movl 0x13ca1(%rip), %eax     # 0x183b0
sarl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq 0x13ea0(%rip), %rax     # 0x185c0
movb %cl, 0x5(%rax)
movl 0x13c87(%rip), %eax     # 0x183b0
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq 0x13e86(%rip), %rax     # 0x185c0
movb %cl, 0x6(%rax)
movl 0x13c6d(%rip), %eax     # 0x183b0
andl $0xff, %eax
movb %al, %cl
movq 0x13e6f(%rip), %rax     # 0x185c0
movb %cl, 0x7(%rax)
movq 0x13e6d(%rip), %rax     # 0x185c8
subq $0xc, %rax
sarq $0x18, %rax
movb %al, %cl
movq 0x13e54(%rip), %rax     # 0x185c0
movb %cl, 0x8(%rax)
movq 0x13e52(%rip), %rax     # 0x185c8
subq $0xc, %rax
sarq $0x10, %rax
andq $0xff, %rax
movb %al, %cl
movq 0x13e33(%rip), %rax     # 0x185c0
movb %cl, 0x9(%rax)
movq 0x13e31(%rip), %rax     # 0x185c8
subq $0xc, %rax
sarq $0x8, %rax
andq $0xff, %rax
movb %al, %cl
movq 0x13e12(%rip), %rax     # 0x185c0
movb %cl, 0xa(%rax)
movq 0x13e10(%rip), %rax     # 0x185c8
subq $0xc, %rax
andq $0xff, %rax
movb %al, %cl
movq 0x13df5(%rip), %rax     # 0x185c0
movb %cl, 0xb(%rax)
cmpl $0x0, 0x13b9b(%rip)     # 0x18370
je 0x4846
cmpl $0x1, 0x13bde(%rip)     # 0x183bc
jne 0x4806
movq 0x13de1(%rip), %rax     # 0x185c8
subq $0xa, %rax
movq %rax, 0x13dd6(%rip)     # 0x185c8
movq 0x13dc7(%rip), %rax     # 0x185c0
addq $0xa, %rax
movq %rax, 0x13dbc(%rip)     # 0x185c0
jmp 0x482a
movq 0x13dbb(%rip), %rax     # 0x185c8
subq $0xc, %rax
movq %rax, 0x13db0(%rip)     # 0x185c8
movq 0x13da1(%rip), %rax     # 0x185c0
addq $0xc, %rax
movq %rax, 0x13d96(%rip)     # 0x185c0
movq 0x13b2f(%rip), %rdi     # 0x18360
movq 0x13d88(%rip), %rsi     # 0x185c0
movq 0x13d89(%rip), %rdx     # 0x185c8
callq 0x3de0
jmp 0x4860
movq 0x13b13(%rip), %rdi     # 0x18360
movq 0x13d6c(%rip), %rsi     # 0x185c0
movq 0x13d6d(%rip), %rdx     # 0x185c8
callq 0x3de0
cmpl $0x0, 0x13b11(%rip)     # 0x18378
je 0x487b
movq 0x13af0(%rip), %rdi     # 0x18360
movl 0x13b06(%rip), %esi     # 0x1837c
callq 0x7260
cmpl $0x0, 0x13aea(%rip)     # 0x1836c
je 0x48be
movq 0x13d3d(%rip), %rsi     # 0x185c8
movl 0x13b17(%rip), %edx     # 0x183a8
movl 0x13af1(%rip), %ecx     # 0x18388
movl 0x13aee(%rip), %r8d     # 0x1838c
movl 0x13b0b(%rip), %r9d     # 0x183b0
movq 0x13aec(%rip), %rax     # 0x18398
leaq 0xc7e0(%rip), %rdi      # 0x11093
movq %rax, (%rsp)
movb $0x0, %al
callq 0x30b0
jmp 0x48ce
leaq 0xc838(%rip), %rdi      # 0x110ff
movb $0x0, %al
callq 0x30b0
jmp 0x48d0
cmpl $0x0, 0x13a9d(%rip)     # 0x18374
je 0x48e0
movb $0x0, %al
callq 0x70e0
jmp 0x48e2
movl 0x13a98(%rip), %eax     # 0x18380
addq $0x30, %rsp
popq %rbp
retq
nop