// File: jstaursky[P]hutch/src/Sleigh/slgh_compile.cc
// Function: run_compilation(char const*, char const*, SleighCompile&)
static int4 run_compilation(const char *filein,const char *fileout,SleighCompile &compiler)

{
  compiler.parseFromNewFile(filein);
  slgh = &compiler;		// Set global pointer up for parser
  yyin = fopen(filein,"r");	// Open the file for the lexer
  if (yyin == (FILE *)0) {
    cerr << "Unable to open specfile: " << filein << endl;
    return 2;
  }

  try {
    int4 parseres = yyparse();	// Try to parse
    fclose(yyin);
    if (parseres==0)
      compiler.process();	// Do all the post-processing
    if ((parseres==0)&&(compiler.numErrors()==0)) { // If no errors
      ofstream s(fileout);
      if (!s) {
	ostringstream errs;
	errs << "Unable to open output file: " << fileout;
	throw SleighError(errs.str());
      }
      compiler.saveXml(s);	// Dump output xml
      s.close();
    }
    else {
      cerr << "No output produced" <<endl;
      return 2;
    }
    yylex_destroy();		// Make sure lexer is reset so we can parse multiple files
  } catch(LowlevelError &err) {
    cerr << "Unrecoverable error: " << err.explain << endl;
    return 2;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x450, %rsp            # imm = 0x450
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x418(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x410(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x408(%rbp)
callq 0x118c0
movq -0x410(%rbp), %rsi
movq -0x408(%rbp), %rdx
leaq -0x40(%rbp), %rdi
callq 0x14430
jmp 0x69646
movq -0x418(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x63770
jmp 0x69658
leaq -0x40(%rbp), %rdi
callq 0x11300
leaq -0x41(%rbp), %rdi
callq 0x114d0
movq -0x20(%rbp), %rax
movq %rax, 0xc917b(%rip)     # 0x1327f0
movq -0x10(%rbp), %rdi
leaq 0x77ab2(%rip), %rsi     # 0xe1132
callq 0x11570
movq %rax, %rcx
leaq 0xc9189(%rip), %rax     # 0x132818
movq %rcx, (%rax)
leaq 0xc917f(%rip), %rax     # 0x132818
cmpq $0x0, (%rax)
jne 0x6970a
movq 0xc8942(%rip), %rdi     # 0x131fe8
leaq 0x70658(%rip), %rsi     # 0xd9d05
callq 0x11420
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x11420
movq %rax, %rdi
movq 0xc88d8(%rip), %rsi     # 0x131fa0
callq 0x114a0
movl $0x2, -0x4(%rbp)
jmp 0x699ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x696fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x11300
leaq -0x41(%rbp), %rdi
callq 0x114d0
jmp 0x699f8
callq 0x7dae0
movl %eax, -0x41c(%rbp)
jmp 0x69717
movl -0x41c(%rbp), %eax
movl %eax, -0x58(%rbp)
leaq 0xc90f1(%rip), %rax     # 0x132818
movq (%rax), %rdi
callq 0x11430
jmp 0x69731
cmpl $0x0, -0x58(%rbp)
jne 0x69755
movq -0x20(%rbp), %rdi
callq 0x63160
jmp 0x69742
jmp 0x69755
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x69912
cmpl $0x0, -0x58(%rbp)
jne 0x6998d
movq -0x20(%rbp), %rdi
callq 0x71f60
movl %eax, -0x420(%rbp)
jmp 0x69770
movl -0x420(%rbp), %eax
cmpl $0x0, %eax
jne 0x6998d
movq -0x18(%rbp), %rsi
leaq -0x258(%rbp), %rdi
movl $0x10, %edx
callq 0x114e0
jmp 0x69796
movq -0x258(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x258(%rbp,%rax), %rdi
callq 0x11230
movb %al, -0x421(%rbp)
jmp 0x697b6
movb -0x421(%rbp), %al
testb $0x1, %al
jne 0x697c5
jmp 0x698d5
leaq -0x3d0(%rbp), %rdi
callq 0x116c0
jmp 0x697d3
leaq 0x70545(%rip), %rsi     # 0xd9d1f
leaq -0x3d0(%rbp), %rdi
callq 0x11420
movq %rax, -0x430(%rbp)
jmp 0x697ef
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x11420
jmp 0x69801
movb $0x1, -0x3f1(%rbp)
movl $0x20, %edi
callq 0x11250
movq %rax, -0x438(%rbp)
leaq -0x3f0(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x11460
jmp 0x6982e
movq -0x438(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0x3faa0
jmp 0x69843
movq -0x438(%rbp), %rdi
movb $0x0, -0x3f1(%rbp)
leaq 0xc58f8(%rip), %rsi     # 0x12f150
leaq -0x29d8f(%rip), %rdx    # 0x3fad0
callq 0x11860
jmp 0x69a09
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x69906
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x698c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x698ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x11300
testb $0x1, -0x3f1(%rbp)
jne 0x698b9
jmp 0x698c5
movq -0x438(%rbp), %rdi
callq 0x11360
jmp 0x698c7
leaq -0x3d0(%rbp), %rdi
callq 0x11120
jmp 0x69906
movq -0x20(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x56480
jmp 0x698e7
leaq -0x258(%rbp), %rdi
callq 0x11720
jmp 0x698f5
leaq -0x258(%rbp), %rdi
callq 0x11750
jmp 0x699c7
leaq -0x258(%rbp), %rdi
callq 0x11750
movl -0x54(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x699f8
movq -0x50(%rbp), %rdi
callq 0x111e0
movq %rax, -0x400(%rbp)
movq 0xc86af(%rip), %rdi     # 0x131fe8
leaq 0x7040f(%rip), %rsi     # 0xd9d4f
callq 0x11420
movq %rax, -0x440(%rbp)
jmp 0x6994e
movq -0x440(%rbp), %rdi
movq -0x400(%rbp), %rsi
callq 0x113e0
movq %rax, -0x448(%rbp)
jmp 0x6996a
movq -0x448(%rbp), %rdi
movq 0xc8628(%rip), %rsi     # 0x131fa0
callq 0x114a0
jmp 0x6997f
movl $0x2, -0x4(%rbp)
callq 0x11810
jmp 0x699ec
movq 0xc8654(%rip), %rdi     # 0x131fe8
leaq 0x703a1(%rip), %rsi     # 0xd9d3c
callq 0x11420
movq %rax, -0x450(%rbp)
jmp 0x699a9
movq -0x450(%rbp), %rdi
movq 0xc85e9(%rip), %rsi     # 0x131fa0
callq 0x114a0
jmp 0x699be
movl $0x2, -0x4(%rbp)
jmp 0x699ec
callq 0xa19b0
jmp 0x699ce
jmp 0x699e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0x11810
jmp 0x699e3
jmp 0x699f8
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x450, %rsp            # imm = 0x450
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x118b0
movq %rax, %rdi
callq 0x15590
nopl (%rax)