// File: /workspace/github_cpp_makefile_star2_O2/jmbjorndalen[P]Malbolge-gen/interp-orig.c
// Function: main
int main( int argc, char **argv )
{
  FILE *f;
  unsigned short i = 0, j;
  int x;
  unsigned short *mem;
  if ( argc != 2 )
  {
    fputs( "invalid command line\n", stderr );
    return ( 1 );
  }
  if ( ( f = fopen( argv[1], "r" ) ) == NULL )
  {
    fputs( "can't open file\n", stderr );
    return ( 1 );
  }
#ifdef _MSC_VER
  mem = (unsigned short *)_halloc( 59049, sizeof(unsigned short) );
#else
  mem = (unsigned short *)malloc( sizeof(unsigned short) * 59049 );
#endif
  if ( mem == NULL )
  {
    fclose( f );
    fputs( "can't allocate memory\n", stderr );
    return ( 1 );
  }
  while ( ( x = getc( f ) ) != EOF )
  {
    if ( isspace( x ) ) continue;
    if ( x < 127 && x > 32 )
    {
      if ( strchr( "ji*p</vo", xlat1[( x - 33 + i ) % 94] ) == NULL )
      {
        fputs( "invalid character in source file\n", stderr );
        free( mem );
        fclose( f );
        return ( 1 );
      }
    }
    if ( i == 59049 )
    {
      fputs( "input file too long\n", stderr );
      free( mem );
      fclose( f );
      return ( 1 );
    }
    mem[i++] = x;
  }
  fclose( f );
  while ( i < 59049 ) mem[i] = op( mem[i - 1], mem[i - 2] ), i++;
  exec( mem );
  free( mem );
  // This printf added by John Markus Bj�rndalen. Output without newline tends to disappear under the shell prompt. This will prevent some 
  // confusion.
  printf("\n");  
  return ( 0 );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x2, %edi
jne 0x40199d
movq 0x8(%rsi), %rdi
leaq 0xadd40(%rip), %rsi     # 0x4af487
callq 0x40c430
testq %rax, %rax
je 0x4019b0
movq %rax, %r14
movl $0x1cd52, %edi          # imm = 0x1CD52
callq 0x419e50
testq %rax, %rax
je 0x4019c3
movq %rax, %rbx
xorl %r15d, %r15d
leaq 0x96a48(%rip), %r12     # 0x4981c0
pushq $0x9
popq %rbp
movq %r14, %rdi
callq 0x40e6d0
cmpl $-0x1, %eax
je 0x4017e6
movl %eax, %r13d
callq 0x404770
movq (%rax), %rax
movslq %r13d, %rcx
testb $0x20, 0x1(%rax,%rcx,2)
jne 0x40177b
leal -0x21(%r13), %eax
cmpl $0x5d, %eax
ja 0x4017cf
addl %r15d, %eax
xorl %edx, %edx
pushq $0x5e
popq %rcx
divl %ecx
leaq 0x96859(%rip), %rax     # 0x498010
movsbl (%rdx,%rax), %esi
movq %r12, %rdi
movq %rbp, %rdx
callq 0x401068
testq %rax, %rax
je 0x401a06
cmpq $0xe6a9, %r15           # imm = 0xE6A9
je 0x4019f3
movw %r13w, (%rbx,%r15,2)
incq %r15
jmp 0x40177b
movq %r14, %rdi
callq 0x40bff0
cmpq $0xe6a9, %r15           # imm = 0xE6A9
je 0x401812
movzwl -0x2(%rbx,%r15,2), %edi
movzwl -0x4(%rbx,%r15,2), %esi
callq 0x401a2e
movw %ax, (%rbx,%r15,2)
incq %r15
jmp 0x4017ee
xorl %r9d, %r9d
leaq 0x96854(%rip), %r10     # 0x498070
movw $0xe6a8, %r11w          # imm = 0xE6A8
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %ebp, %ebp
pushq $0x5e
popq %rsi
leaq 0x967dd(%rip), %r8      # 0x498010
movzwl %r13w, %r14d
movzwl (%rbx,%r14,2), %eax
leal -0x7f(%rax), %ecx
cmpw $-0x5f, %cx
jbe 0x401987
addl %r14d, %eax
addl $-0x21, %eax
xorl %edx, %edx
divl %esi
movzbl (%rdx,%r8), %eax
movzwl %r12w, %r15d
cmpl $0x2a, %eax
je 0x401938
cmpl $0x2f, %eax
je 0x401901
movzwl %bp, %edi
cmpl $0x3c, %eax
je 0x401893
cmpl $0x69, %eax
je 0x4018ca
cmpl $0x6a, %eax
je 0x4018c0
cmpl $0x70, %eax
je 0x4018d5
cmpl $0x76, %eax
jne 0x401953
jmp 0x401989
movq $0x4c86f0, %rax         # imm = 0x4C86F0
movq (%rax), %rsi
callq 0x40e7f0
movw $0xe6a8, %r11w          # imm = 0xE6A8
leaq 0x967c2(%rip), %r10     # 0x498070
xorl %r9d, %r9d
leaq 0x96758(%rip), %r8      # 0x498010
pushq $0x5e
popq %rsi
jmp 0x401953
movzwl (%rbx,%r15,2), %r12d
jmp 0x401953
movzwl (%rbx,%r15,2), %r13d
movzwl %r13w, %r14d
jmp 0x401953
movzwl (%rbx,%r15,2), %esi
callq 0x401a2e
movw $0xe6a8, %r11w          # imm = 0xE6A8
leaq 0x96785(%rip), %r10     # 0x498070
xorl %r9d, %r9d
leaq 0x9671b(%rip), %r8      # 0x498010
pushq $0x5e
popq %rsi
movl %eax, %ebp
movw %ax, (%rbx,%r15,2)
jmp 0x401953
movq $0x4c86f8, %rax         # imm = 0x4C86F8
movq (%rax), %rdi
callq 0x40e6d0
movw $0xe6a8, %r11w          # imm = 0xE6A8
leaq 0x96754(%rip), %r10     # 0x498070
xorl %r9d, %r9d
leaq 0x966ea(%rip), %r8      # 0x498010
pushq $0x5e
popq %rsi
movl %eax, %ebp
cmpl $-0x1, %eax
movl $0xe6a8, %eax           # imm = 0xE6A8
cmovel %eax, %ebp
jmp 0x401953
movzwl (%rbx,%r15,2), %eax
xorl %edx, %edx
movw $0x3, %cx
divw %cx
imull $0x4ce3, %edx, %ebp     # imm = 0x4CE3
addl %eax, %ebp
movw %bp, (%rbx,%r15,2)
movzwl (%rbx,%r14,2), %eax
movsbl -0x21(%rax,%r10), %eax
movw %ax, (%rbx,%r14,2)
cmpw %r11w, %r13w
leal 0x1(%r13), %eax
cmovel %r9d, %eax
cmpw %r11w, %r12w
leal 0x1(%r12), %ecx
cmovel %r9d, %ecx
movl %eax, %r13d
movl %ecx, %r12d
jmp 0x401833
jmp 0x401987
movq %rbx, %rdi
callq 0x41a190
pushq $0xa
popq %rdi
callq 0x40c660
xorl %eax, %eax
jmp 0x4019e4
movq $0x4c86e8, %rax         # imm = 0x4C86E8
movq (%rax), %rsi
leaq 0x967d4(%rip), %rdi     # 0x498182
jmp 0x4019dc
movq $0x4c86e8, %rax         # imm = 0x4C86E8
movq (%rax), %rsi
leaq 0x967d7(%rip), %rdi     # 0x498198
jmp 0x4019dc
movq %r14, %rdi
callq 0x40bff0
movq $0x4c86e8, %rax         # imm = 0x4C86E8
movq (%rax), %rsi
leaq 0x967cd(%rip), %rdi     # 0x4981a9
callq 0x40c530
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x4c86e8, %rax         # imm = 0x4C86E8
movq (%rax), %rsi
leaq 0x967e7(%rip), %rdi     # 0x4981eb
jmp 0x401a17
movq $0x4c86e8, %rax         # imm = 0x4C86E8
movq (%rax), %rsi
leaq 0x967b2(%rip), %rdi     # 0x4981c9
callq 0x40c530
movq %rbx, %rdi
callq 0x41a190
movq %r14, %rdi
callq 0x40bff0
jmp 0x4019e1