// File: josh0xA[P]bf/src/bf.cc
// Function: main
int main(int argc, char** argv) {

  bf::Environment env;
  bf::Stream<std::string, std::istream, bf_word> bf_stream;
  bf::Parser parser;

  if (argc == BF_SUCCESS_CODE_STANDARD + 1) {
    bf::User usr;
    std::cout << "The Brainfuck Interactive Console Interpreter\n\t\tJosh Schiavone\n";
    usr.load_interactive_interpreter(env);
  } else {
      if (env.check_program_file_extension(argv[1])) {
        std::ifstream stream = std::ifstream(argv[1]);
        if (stream.is_open()) {
          bfint_t bracks = bf_stream.entry_point_stream(env, stream);
          if (bracks == BF_SUCCESS_CODE_STANDARD) {
            parser.interpret_bf_instructions(env);
          } else {
              throw bf::exp::BFException("(error): could not match brackets\n");
          }
        } else {
            throw bf::exp::BFException("(error): .bf source could not be located\n");
        }
      } else {
          throw bf::exp::BFException("(error): source file must contain a valid brainfuck extension\n");
      }
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x840, %rsp            # imm = 0x840
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x24f0
leaq -0x210(%rbp), %rdi
callq 0x3490
jmp 0x2cc0
leaq -0x3e8(%rbp), %rdi
callq 0x34e0
jmp 0x2cce
cmpl $0x1, -0x8(%rbp)
jne 0x2d86
leaq -0x5d0(%rbp), %rdi
callq 0x3500
jmp 0x2ce6
movq 0x52db(%rip), %rdi      # 0x7fc8
leaq 0x2407(%rip), %rsi      # 0x50fb
callq 0x21c0
jmp 0x2cfb
leaq -0x5d0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2b50
jmp 0x2d0d
leaq -0x5d0(%rbp), %rdi
callq 0x3540
jmp 0x3037
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x3083
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x3077
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x306b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x5d0(%rbp), %rdi
callq 0x3540
jmp 0x306b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x818(%rbp)
leaq -0x5f1(%rbp), %rdi
movq %rdi, -0x810(%rbp)
callq 0x2360
movq -0x818(%rbp), %rsi
movq -0x810(%rbp), %rdx
leaq -0x5f0(%rbp), %rdi
callq 0x3570
jmp 0x2dc4
leaq -0x50(%rbp), %rdi
leaq -0x5f0(%rbp), %rsi
callq 0x2620
movb %al, -0x819(%rbp)
jmp 0x2ddc
leaq -0x5f0(%rbp), %rdi
callq 0x2120
leaq -0x5f1(%rbp), %rdi
callq 0x2230
movb -0x819(%rbp), %al
testb $0x1, %al
jne 0x2e03
jmp 0x2fd1
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x800(%rbp), %rdi
movl $0x8, %edx
callq 0x2380
jmp 0x2e1e
leaq -0x800(%rbp), %rdi
callq 0x22d0
movb %al, -0x81a(%rbp)
jmp 0x2e32
movb -0x81a(%rbp), %al
testb $0x1, %al
jne 0x2e41
jmp 0x2f4e
leaq -0x210(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x800(%rbp), %rdx
xorl %ecx, %ecx
callq 0x3620
movl %eax, -0x820(%rbp)
jmp 0x2e62
movl -0x820(%rbp), %eax
movl %eax, -0x804(%rbp)
cmpl $0x0, -0x804(%rbp)
jne 0x2ee8
leaq -0x3e8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2810
jmp 0x2e89
jmp 0x2f4c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x2ec0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x5f0(%rbp), %rdi
callq 0x2120
leaq -0x5f1(%rbp), %rdi
callq 0x2230
jmp 0x306b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x2fc0
movl $0x10, %edi
callq 0x20e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x828(%rbp)
leaq 0x2235(%rip), %rsi      # 0x513b
callq 0x37a0
jmp 0x2f0d
movq -0x828(%rbp), %rdi
leaq 0x4e3d(%rip), %rsi      # 0x7d58
leaq 0x8be(%rip), %rdx       # 0x37e0
callq 0x2320
jmp 0x3098
movq -0x828(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
callq 0x2160
jmp 0x2fc0
jmp 0x2fb2
movl $0x10, %edi
callq 0x20e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x830(%rbp)
leaq 0x21f2(%rip), %rsi      # 0x515e
callq 0x37a0
jmp 0x2f73
movq -0x830(%rbp), %rdi
leaq 0x4dd7(%rip), %rsi      # 0x7d58
leaq 0x858(%rip), %rdx       # 0x37e0
callq 0x2320
jmp 0x3098
movq -0x830(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
callq 0x2160
jmp 0x2fc0
leaq -0x800(%rbp), %rdi
callq 0x2050
jmp 0x3035
leaq -0x800(%rbp), %rdi
callq 0x2050
jmp 0x306b
movl $0x10, %edi
callq 0x20e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x838(%rbp)
leaq 0x2199(%rip), %rsi      # 0x5188
callq 0x37a0
jmp 0x2ff6
movq -0x838(%rbp), %rdi
leaq 0x4d54(%rip), %rsi      # 0x7d58
leaq 0x7d5(%rip), %rdx       # 0x37e0
callq 0x2320
jmp 0x3098
movq -0x838(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
callq 0x2160
jmp 0x306b
jmp 0x3037
movl $0x0, -0x4(%rbp)
leaq -0x3e8(%rbp), %rdi
callq 0x3800
leaq -0x210(%rbp), %rdi
callq 0x3820
leaq -0x50(%rbp), %rdi
callq 0x3850
movl -0x4(%rbp), %eax
addq $0x840, %rsp            # imm = 0x840
popq %rbp
retq
leaq -0x3e8(%rbp), %rdi
callq 0x3800
leaq -0x210(%rbp), %rdi
callq 0x3820
leaq -0x50(%rbp), %rdi
callq 0x3850
movq -0x218(%rbp), %rdi
callq 0x2340
nopl (%rax,%rax)