// File: yhirose[P]fizzbuzzlang/fzbz.cc
// Function: main
int main(int argc, const char** argv) {
  if (argc < 2) {
    cerr << "usage: fzbz [source file path]" << endl;
    return 1;
  }

  ifstream file{argv[1]};
  if (!file) {
    cerr << "can't open the source file." << endl;
    return 2;
  }

  auto source =
      string(istreambuf_iterator<char>(file), istreambuf_iterator<char>());

  auto ast = parse(source, cerr);
  if (!ast) {
    return 3;
  }

  try {
    interpret(*ast);
  } catch (const exception& e) {
    cerr << e.what() << endl;
    return 4;
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0xbc9d
movq 0xe936a(%rip), %rdi     # 0xf4fe0
leaq 0x95f5e(%rip), %rsi     # 0xa1bdb
callq 0xa3a0
movq %rax, %rdi
movq 0xe92a4(%rip), %rsi     # 0xf4f30
callq 0xa3f0
movl $0x1, -0x4(%rbp)
jmp 0xbf77
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x218(%rbp), %rdi
movl $0x8, %edx
callq 0xa690
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0xa1c0
movb %al, -0x2b1(%rbp)
jmp 0xbcd6
movb -0x2b1(%rbp), %al
testb $0x1, %al
jne 0xbce2
jmp 0xbd40
movq 0xe92f7(%rip), %rdi     # 0xf4fe0
leaq 0x95f0a(%rip), %rsi     # 0xa1bfa
callq 0xa3a0
movq %rax, -0x2c0(%rbp)
jmp 0xbcfe
movq -0x2c0(%rbp), %rdi
movq 0xe9224(%rip), %rsi     # 0xf4f30
callq 0xa3f0
jmp 0xbd13
movl $0x2, -0x4(%rbp)
movl $0x1, -0x228(%rbp)
jmp 0xbf5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0xbf69
leaq -0x258(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x13a90
leaq -0x268(%rbp), %rdi
callq 0x13af0
leaq -0x269(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0xa660
movq -0x2c8(%rbp), %r9
movq -0x258(%rbp), %rsi
movl -0x250(%rbp), %edx
movq -0x268(%rbp), %rcx
movl -0x260(%rbp), %r8d
leaq -0x248(%rbp), %rdi
callq 0x13b20
jmp 0xbda2
leaq -0x269(%rbp), %rdi
callq 0xa410
movq 0xe922b(%rip), %rdx     # 0xf4fe0
leaq -0x280(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0xa870
jmp 0xbdca
leaq -0x280(%rbp), %rdi
callq 0x13bb0
testb $0x1, %al
jne 0xbe2a
movl $0x3, -0x4(%rbp)
movl $0x1, -0x228(%rbp)
jmp 0xbf27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x269(%rbp), %rdi
callq 0xa410
jmp 0xbf69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0xbf4d
leaq -0x280(%rbp), %rdi
callq 0x130e0
movq %rax, %rsi
leaq -0x2a8(%rbp), %rdi
callq 0xba40
jmp 0xbe47
leaq -0x2a8(%rbp), %rdi
callq 0x13210
jmp 0xbf16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
movl -0x224(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0xbf41
movq -0x220(%rbp), %rdi
callq 0xa160
movq %rax, -0x2b0(%rbp)
movq -0x2b0(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0xe9136(%rip), %rdi     # 0xf4fe0
callq 0xa3a0
movq %rax, -0x2d0(%rbp)
jmp 0xbeb8
movq -0x2d0(%rbp), %rdi
movq 0xe906a(%rip), %rsi     # 0xf4f30
callq 0xa3f0
jmp 0xbecd
movl $0x4, -0x4(%rbp)
movl $0x1, -0x228(%rbp)
callq 0xa600
jmp 0xbefe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
callq 0xa600
jmp 0xbf14
jmp 0xbf27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0xbf41
jmp 0xbf41
movl $0x0, -0x4(%rbp)
movl $0x1, -0x228(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x13040
leaq -0x248(%rbp), %rdi
callq 0xa250
jmp 0xbf5b
leaq -0x280(%rbp), %rdi
callq 0x13040
leaq -0x248(%rbp), %rdi
callq 0xa250
jmp 0xbf69
leaq -0x218(%rbp), %rdi
callq 0xa0d0
jmp 0xbf77
leaq -0x218(%rbp), %rdi
callq 0xa0d0
jmp 0xbf83
movl -0x4(%rbp), %eax
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
movq -0x220(%rbp), %rdi
callq 0xa650
movq %rax, %rdi
callq 0x13bd0
nopw (%rax,%rax)