// File: /workspace/github_c_makefile_star2_O1/silverneko[P]miku/./src/testsuite.cpp
// Function: compile(submission const&, int, int)
int compile(const submission& target, int boxid, int spBoxid)
{
   ostringstream sout;
   sout << "/tmp/box/" << boxid << "/box/";
   string boxdir(sout.str());
   
   ofstream fout;
   if(target.lang == "c++"){
      fout.open(boxdir + "main.cpp");
   }else if(target.lang == "c"){
      fout.open(boxdir + "main.c");
   }else{
      fout.open(boxdir + "main.hs");
   }
   fout << target.code << flush;
   fout.close();
   
   if(target.problem_type == 2){
      sout.str("");
      sout << boxdir << "lib" << setw(4) << setfill('0') << target.problem_id << ".h";
      fout.open(sout.str());
      fout << target.interlib << flush;
      fout.close();
   }

   sout.str("");
   if(target.lang == "c++"){
      sout << "/usr/bin/env g++ ./main.cpp -o ./main.out -O2 ";
   }else if(target.lang == "c"){
      sout << "/usr/bin/env gcc ./main.c -o ./main.out -O2 -ansi -lm ";
   }else{
      sout << "/usr/bin/env ghc ./main.hs -o ./main.out -O -tmpdir . ";
   }
   if(!target.std.empty()){
      sout << "-std=" << target.std << " ";
   }
   string comm(sout.str());
   sandboxOptions opt;
   //opt.dirs.push_back("/etc");
   //opt.dirs.push_back("/var");
   opt.procs = 50;
   opt.preserve_env = true;
   opt.errout = "compile_error";
   opt.output = "/dev/null";
   opt.timeout = 60 * 1000;
   opt.meta = "./testzone/metacomp";

   sandboxExec(boxid, opt, comm);
   if(access((boxdir+"main.out").c_str(), F_OK) == -1){
      return CE;
   }
   
   if(target.problem_type == 1){
      sout.str("");
      sout << "/tmp/box/" << spBoxid << "/box/";
      string spBoxdir = sout.str();
      
      fout.open(spBoxdir + "sj.cpp");
      fout << target.sjcode << flush;
      fout.close();
      
      sout.str("");
      sout << "/usr/bin/g++ ./sj.cpp -o ./sj.out -O2 -std=c++11 ";
      
      opt.meta = "./testzone/metacompsj";

      sandboxExec(spBoxid, opt, sout.str());
      if(access((spBoxdir+"sj.out").c_str(), F_OK) == -1){
         return ER;
      }
   }
   
   return OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4b8, %rsp            # imm = 0x4B8
movl %edx, 0x40(%rsp)
movl %esi, %r14d
movq %rdi, %r15
leaq 0x140(%rsp), %rbx
movq %rbx, %rdi
callq 0x3350
leaq 0x47d8(%rip), %rsi      # 0x949c
movl $0x9, %edx
movq %rbx, %rdi
callq 0x32f0
leaq 0x140(%rsp), %rdi
movl %r14d, %esi
callq 0x34d0
leaq 0x47b8(%rip), %rsi      # 0x94a0
movl $0x5, %edx
movq %rax, %rdi
callq 0x32f0
leaq 0x148(%rsp), %rbp
leaq 0x48(%rsp), %rdi
movq %rbp, %rsi
callq 0x3430
leaq 0x2b8(%rsp), %rdi
callq 0x34c0
leaq 0x68(%r15), %r12
leaq 0x47f1(%rip), %rsi      # 0x9513
movq %r12, %rdi
callq 0x30d0
testl %eax, %eax
movl %r14d, 0x44(%rsp)
je 0x4d97
leaq 0x4702(%rip), %rsi      # 0x943c
movq %r12, %rdi
callq 0x30d0
leaq 0x78(%rsp), %r14
testl %eax, %eax
je 0x4de1
movq %r14, -0x10(%r14)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0x3fb0
leaq 0x47b6(%rip), %rsi      # 0x9527
leaq 0x68(%rsp), %rdi
callq 0x3520
leaq 0x2b8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movl $0x10, %edx
callq 0x3150
jmp 0x4e24
leaq 0x78(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0x3fb0
leaq 0x4759(%rip), %rsi      # 0x9517
leaq 0x68(%rsp), %rdi
callq 0x3520
leaq 0x2b8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movl $0x10, %edx
callq 0x3150
jmp 0x4e24
movq %r14, -0x10(%r14)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0x3fb0
leaq 0x471d(%rip), %rsi      # 0x9520
leaq 0x68(%rsp), %rdi
callq 0x3520
leaq 0x2b8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movl $0x10, %edx
callq 0x3150
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x4e3b
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
leaq 0x2b8(%rsp), %rdi
callq 0x32f0
movq %rax, %rdi
callq 0x31d0
leaq 0x2b8(%rsp), %rdi
callq 0x3390
cmpl $0x2, 0xcc(%r15)
jne 0x4fae
leaq 0x78(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x468f(%rip), %rdx      # 0x9512
leaq 0x68(%rsp), %rdi
movq %rdx, %rsi
callq 0x4040
leaq 0x68(%rsp), %rsi
movq %rbp, %rdi
callq 0x33d0
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x4eb4
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
leaq 0x140(%rsp), %rdi
callq 0x32f0
movq %rax, %rbx
leaq 0x465a(%rip), %rsi      # 0x952f
movl $0x3, %edx
movq %rax, %rdi
callq 0x32f0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movq $0x4, 0x10(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %rbx, %r13
addq %rax, %r13
cmpb $0x0, 0xe1(%rbx,%rax)
jne 0x4f22
movq %r13, %rdi
movl $0x20, %esi
callq 0x3260
movb %al, 0xe0(%r13)
movb $0x1, 0xe1(%r13)
movb $0x30, 0xe0(%r13)
movl (%r15), %esi
movq %rbx, %rdi
callq 0x34d0
leaq 0x45f7(%rip), %rsi      # 0x9533
movl $0x2, %edx
movq %rax, %rdi
callq 0x32f0
leaq 0x68(%rsp), %rdi
movq %rbp, %rsi
callq 0x3430
leaq 0x2b8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movl $0x10, %edx
callq 0x3150
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x4f84
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x48(%r15), %rsi
movq 0x50(%r15), %rdx
leaq 0x2b8(%rsp), %rdi
callq 0x32f0
movq %rax, %rdi
callq 0x31d0
leaq 0x2b8(%rsp), %rdi
callq 0x3390
leaq 0x78(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x4554(%rip), %rdx      # 0x9512
leaq 0x68(%rsp), %rdi
movq %rdx, %rsi
callq 0x4040
leaq 0x68(%rsp), %rsi
movq %rbp, %rdi
callq 0x33d0
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x4fef
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x451d(%rip), %rsi      # 0x9513
movq %r12, %rdi
callq 0x30d0
testl %eax, %eax
je 0x502c
leaq 0x4433(%rip), %rsi      # 0x943c
movq %r12, %rdi
callq 0x30d0
testl %eax, %eax
leaq 0x454b(%rip), %rax      # 0x9565
leaq 0x457b(%rip), %rsi      # 0x959c
cmoveq %rax, %rsi
movl $0x36, %edx
jmp 0x5038
movl $0x2e, %edx
leaq 0x44fe(%rip), %rsi      # 0x9536
leaq 0x140(%rsp), %rdi
callq 0x32f0
cmpq $0x0, 0x90(%r15)
je 0x5097
leaq 0x457d(%rip), %rsi      # 0x95d3
leaq 0x140(%rsp), %rdi
movl $0x5, %edx
callq 0x32f0
movq 0x88(%r15), %rsi
movq 0x90(%r15), %rdx
leaq 0x140(%rsp), %rdi
callq 0x32f0
leaq 0x42ac(%rip), %rsi      # 0x9336
movl $0x1, %edx
movq %rax, %rdi
callq 0x32f0
leaq 0x120(%rsp), %rdi
movq %rbp, %rsi
callq 0x3430
leaq 0x98(%rsp), %r13
movw $0x101, -0x30(%r13)     # imm = 0x101
xorps %xmm0, %xmm0
movups %xmm0, -0x28(%r13)
xorl %eax, %eax
movq %rax, -0x18(%r13)
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
leaq 0xb8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq %rax, -0x8(%rbp)
movb %al, (%rbp)
leaq 0xf8(%rsp), %r14
movq %r14, -0x10(%r14)
movq %rax, -0x8(%r14)
movb %al, (%r14)
movl $0x0, 0x10(%r14)
movq $0x40, 0x1c(%r14)
movq $0x32, 0x14(%r14)
leaq 0x44aa(%rip), %rcx      # 0x95d9
movl $0xd, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x3400
leaq 0xa8(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x4247(%rip), %rcx      # 0x9398
movl $0x9, %r8d
xorl %esi, %esi
callq 0x3400
leaq 0xe8(%rsp), %r12
movl $0xea60, 0x28(%r12)     # imm = 0xEA60
movq 0x8(%r12), %rdx
leaq 0x446c(%rip), %rcx      # 0x95e7
movl $0x13, %r8d
movq %r12, %rdi
xorl %esi, %esi
callq 0x3400
leaq 0x68(%rsp), %rsi
leaq 0x120(%rsp), %rdx
movl 0x44(%rsp), %edi
callq 0x40d0
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x3fb0
leaq 0x4435(%rip), %rsi      # 0x95fb
movq %rsp, %rdi
callq 0x3520
movq (%rsp), %rdi
xorl %esi, %esi
callq 0x34a0
movl %eax, %ebx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x51f6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
cmpl $-0x1, %ebx
je 0x5452
cmpl $0x1, 0xcc(%r15)
jne 0x544e
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x42f3(%rip), %rdx      # 0x9512
movq %rdx, %rsi
callq 0x4040
movq %rsp, %rsi
leaq 0x148(%rsp), %rdi
callq 0x33d0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5252
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x4243(%rip), %rsi      # 0x949c
leaq 0x140(%rsp), %rdi
movl $0x9, %edx
callq 0x32f0
leaq 0x140(%rsp), %rdi
movl 0x40(%rsp), %esi
callq 0x34d0
leaq 0x421d(%rip), %rsi      # 0x94a0
movl $0x5, %edx
movq %rax, %rdi
callq 0x32f0
movq %rsp, %rdi
leaq 0x148(%rsp), %rsi
callq 0x3430
leaq 0x30(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0x3fb0
leaq 0x433e(%rip), %rsi      # 0x9604
leaq 0x20(%rsp), %rdi
callq 0x3520
leaq 0x2b8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x10, %edx
callq 0x3150
movq 0x20(%rsp), %rdi
cmpq %rbx, %rdi
je 0x52fe
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x28(%r15), %rsi
movq 0x30(%r15), %rdx
leaq 0x2b8(%rsp), %rdi
callq 0x32f0
movq %rax, %rdi
callq 0x31d0
leaq 0x2b8(%rsp), %rdi
callq 0x3390
leaq 0x20(%rsp), %rdi
movq %rbx, (%rdi)
leaq 0x41db(%rip), %rdx      # 0x9512
movq %rdx, %rsi
callq 0x4040
leaq 0x20(%rsp), %rsi
leaq 0x148(%rsp), %rdi
callq 0x33d0
movq 0x20(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5368
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x429c(%rip), %rsi      # 0x960b
leaq 0x140(%rsp), %rdi
movl $0x31, %edx
callq 0x32f0
movq 0xf0(%rsp), %rdx
leaq 0x42ad(%rip), %rcx      # 0x963d
movl $0x15, %r8d
movq %r12, %rdi
xorl %esi, %esi
callq 0x3400
leaq 0x20(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x3430
leaq 0x68(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movl 0x40(%rsp), %edi
callq 0x40d0
movq 0x20(%rsp), %rdi
cmpq %rbx, %rdi
je 0x53dc
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x20(%rsp), %rdi
movq %rbx, (%rdi)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
callq 0x3fb0
movq %rbx, %r15
leaq 0x4254(%rip), %rsi      # 0x9653
leaq 0x20(%rsp), %rdi
callq 0x3520
movq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x34a0
movl %eax, %ebx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x542e
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5449
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
cmpl $-0x1, %ebx
je 0x5459
xorl %ebx, %ebx
jmp 0x545e
movl $0x11, %ebx
jmp 0x545e
movl $0x13, %ebx
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0x547b
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0xc8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x5498
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x54bd
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x70(%rsp), %r14
movq 0x18(%r14), %rdi
cmpq %r13, %rdi
je 0x54db
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r14, %rdi
callq 0x7260
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5504
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x7a9d(%rip), %rax      # 0xcfa8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x2c0(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x2b8(%rsp,%rcx)
callq 0x3230
leaq 0x3b0(%rsp), %rdi
callq 0x3100
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5557
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x7a5a(%rip), %rsi      # 0xcfb8
leaq 0x140(%rsp), %rdi
callq 0x3170
leaq 0x1b0(%rsp), %rdi
callq 0x3100
movl %ebx, %eax
addq $0x4b8, %rsp            # imm = 0x4B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x55f7
jmp 0x55f7
jmp 0x5669
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
jne 0x55c0
jmp 0x5617
jmp 0x5614
jmp 0x55b0
jmp 0x5614
jmp 0x55b0
jmp 0x5614
jmp 0x55b0
movq %rbx, %rcx
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %rcx, %rdi
je 0x5617
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x5617
jmp 0x5614
jmp 0x5639
jmp 0x5614
jmp 0x5639
jmp 0x55f7
jmp 0x55f7
jmp 0x5669
jmp 0x55f7
jmp 0x55f7
jmp 0x5669
jmp 0x55f7
jmp 0x5669
jmp 0x55f7
jmp 0x5669
jmp 0x5614
jmp 0x5639
jmp 0x5669
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x566c
movq 0x78(%rsp), %rsi
jmp 0x565f
jmp 0x5669
movq %rax, %rbx
jmp 0x5679
jmp 0x5634
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x563c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x563c
movq %rax, %rbx
jmp 0x5694
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x70fc
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x566c
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x566c
movq %rax, %rbx
leaq 0x2b8(%rsp), %rdi
callq 0x33c0
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5694
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x791d(%rip), %rsi      # 0xcfb8
leaq 0x140(%rsp), %rdi
callq 0x3170
leaq 0x1b0(%rsp), %rdi
callq 0x3100
movq %rbx, %rdi
callq 0x34e0