// File: /workspace/github_c_makefile_star2_O2/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, %ebx
movl %esi, %ebp
movq %rdi, %r15
leaq 0x340(%rsp), %r14
movq %r14, %rdi
callq 0x3360
leaq 0x3e3a(%rip), %rsi      # 0x84ac
movq %r14, %rdi
callq 0x3290
movq %rax, %rdi
movl %ebp, %esi
callq 0x34c0
leaq 0x3e25(%rip), %rsi      # 0x84b0
movq %rax, %rdi
callq 0x3290
leaq 0x348(%rsp), %r14
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x140(%rsp), %rdi
callq 0x34b0
leaq 0x68(%r15), %r12
leaq 0x3e63(%rip), %rsi      # 0x8523
movq %r12, %rdi
callq 0x5b74
testb %al, %al
je 0x46f9
leaq 0x3e54(%rip), %rdx      # 0x8527
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x5d19
leaq 0x140(%rsp), %rdi
leaq 0x68(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x3190
jmp 0x4764
leaq 0x3d4c(%rip), %rsi      # 0x844c
movq %r12, %rdi
callq 0x5b74
testb %al, %al
je 0x4739
leaq 0x3e1d(%rip), %rdx      # 0x8530
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x5d19
leaq 0x140(%rsp), %rdi
leaq 0x68(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x3190
jmp 0x4764
leaq 0x3df7(%rip), %rdx      # 0x8537
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x5d19
leaq 0x140(%rsp), %rdi
leaq 0x68(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x3190
leaq 0x68(%rsp), %rdi
callq 0x3170
leaq 0x8(%r15), %rsi
leaq 0x140(%rsp), %rdi
callq 0x3280
movq %rax, %rdi
callq 0x31f0
leaq 0x140(%rsp), %rdi
callq 0x33b0
cmpl $0x2, 0xcc(%r15)
jne 0x487a
leaq 0x3d79(%rip), %rsi      # 0x8522
leaq 0x68(%rsp), %rdi
leaq 0x120(%rsp), %rdx
callq 0x3992
leaq 0x68(%rsp), %rsi
movq %r14, %rdi
callq 0x33e0
leaq 0x68(%rsp), %rdi
callq 0x3170
leaq 0x340(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x3280
leaq 0x3d54(%rip), %rsi      # 0x853f
movq %rax, %rdi
callq 0x3290
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x4, 0x10(%rax,%rcx)
pushq $0x30
popq %rsi
movq %rax, %rdi
callq 0x3410
movl (%r15), %esi
movq %rax, %rdi
callq 0x34c0
leaq 0x3d23(%rip), %rsi      # 0x8543
movq %rax, %rdi
callq 0x3290
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x140(%rsp), %rdi
leaq 0x68(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x3190
leaq 0x68(%rsp), %rdi
callq 0x3170
leaq 0x48(%r15), %rsi
leaq 0x140(%rsp), %rdi
callq 0x3280
movq %rax, %rdi
callq 0x31f0
leaq 0x140(%rsp), %rdi
callq 0x33b0
leaq 0x3ca1(%rip), %rsi      # 0x8522
leaq 0x68(%rsp), %rdi
leaq 0x120(%rsp), %rdx
callq 0x3992
leaq 0x68(%rsp), %rsi
movq %r14, %rdi
callq 0x33e0
leaq 0x68(%rsp), %rdi
callq 0x3170
leaq 0x3c72(%rip), %rsi      # 0x8523
movq %r12, %rdi
callq 0x5b74
testb %al, %al
je 0x48c6
leaq 0x3c82(%rip), %rsi      # 0x8546
jmp 0x48e9
leaq 0x3b7f(%rip), %rsi      # 0x844c
movq %r12, %rdi
callq 0x5b74
leaq 0x3c99(%rip), %rcx      # 0x8575
leaq 0x3cc9(%rip), %rsi      # 0x85ac
testb %al, %al
cmovneq %rcx, %rsi
leaq 0x340(%rsp), %rdi
callq 0x3290
cmpq $0x0, 0x90(%r15)
je 0x4932
leaq 0x3cdc(%rip), %rsi      # 0x85e3
leaq 0x340(%rsp), %rdi
callq 0x3290
leaq 0x88(%r15), %rsi
movq %rax, %rdi
callq 0x3280
leaq 0x3a0c(%rip), %rsi      # 0x8336
movq %rax, %rdi
callq 0x3290
leaq 0x120(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x98(%rsp), %rax
movw $0x101, -0x30(%rax)     # imm = 0x101
xorps %xmm0, %xmm0
movups %xmm0, -0x28(%rax)
andq $0x0, -0x18(%rax)
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0xb8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0xd8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0xf8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
andl $0x0, 0x20(%rax)
leaq 0xc8(%rsp), %rdi
movaps 0x39fb(%rip), %xmm0     # 0x83b0
movups %xmm0, 0x10(%rax)
leaq 0x3c29(%rip), %rsi      # 0x85e9
callq 0x3520
leaq 0xa8(%rsp), %rdi
leaq 0x39c4(%rip), %rsi      # 0x8398
callq 0x3520
leaq 0xe8(%rsp), %r12
movl $0xea60, 0x28(%r12)     # imm = 0xEA60
leaq 0x3c06(%rip), %rsi      # 0x85f7
movq %r12, %rdi
callq 0x3520
leaq 0x68(%rsp), %rsi
leaq 0x120(%rsp), %rdx
movl %ebp, %edi
callq 0x3d34
leaq 0x3bf7(%rip), %rdx      # 0x860b
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x5d19
leaq 0x28(%rsp), %r13
movq (%r13), %rdi
xorl %esi, %esi
callq 0x3490
movl %eax, %ebp
movq %r13, %rdi
callq 0x3170
cmpl $-0x1, %ebp
je 0x4bd3
cmpl $0x1, 0xcc(%r15)
jne 0x4bcf
leaq 0x3ac7(%rip), %rsi      # 0x8522
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x3992
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x33e0
leaq 0x28(%rsp), %rdi
callq 0x3170
leaq 0x3a24(%rip), %rsi      # 0x84ac
leaq 0x340(%rsp), %rdi
callq 0x3290
movq %rax, %rdi
movl %ebx, %esi
callq 0x34c0
leaq 0x3a0a(%rip), %rsi      # 0x84b0
movq %rax, %rdi
callq 0x3290
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x3b52(%rip), %rdx      # 0x8614
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x5d19
leaq 0x140(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x3190
leaq 0x8(%rsp), %rdi
callq 0x3170
addq $0x28, %r15
leaq 0x140(%rsp), %rdi
movq %r15, %rsi
callq 0x3280
movq %rax, %rdi
callq 0x31f0
leaq 0x140(%rsp), %rdi
callq 0x33b0
leaq 0x3a02(%rip), %rsi      # 0x8522
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3992
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x33e0
leaq 0x8(%rsp), %rdi
callq 0x3170
leaq 0x3ace(%rip), %rsi      # 0x861b
leaq 0x340(%rsp), %rdi
callq 0x3290
leaq 0x3aec(%rip), %rsi      # 0x864d
movq %r12, %rdi
callq 0x3520
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x68(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movl %ebx, %edi
callq 0x3d34
leaq 0x8(%rsp), %rdi
callq 0x3170
leaq 0x3acb(%rip), %rdx      # 0x8663
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x5d19
leaq 0x8(%rsp), %rbx
movq (%rbx), %rdi
xorl %esi, %esi
callq 0x3490
movl %eax, %ebp
movq %rbx, %rdi
callq 0x3170
leaq 0x28(%rsp), %rdi
callq 0x3170
cmpl $-0x1, %ebp
je 0x4bd7
xorl %ebx, %ebx
jmp 0x4bda
pushq $0x11
jmp 0x4bd9
pushq $0x13
popq %rbx
leaq 0x68(%rsp), %rdi
callq 0x5d52
leaq 0x120(%rsp), %rdi
callq 0x3170
leaq 0x140(%rsp), %rdi
callq 0x33d0
leaq 0x48(%rsp), %rdi
callq 0x3170
leaq 0x340(%rsp), %rdi
callq 0x30b0
movl %ebx, %eax
addq $0x4b8, %rsp            # imm = 0x4B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4c62
jmp 0x4c62
jmp 0x4ca5
jmp 0x4ca5
jmp 0x4c75
jmp 0x4c3b
jmp 0x4c75
jmp 0x4c3b
jmp 0x4c75
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3170
jmp 0x4c78
jmp 0x4c75
jmp 0x4c89
jmp 0x4c75
jmp 0x4c89
jmp 0x4c62
jmp 0x4ca5
jmp 0x4c62
jmp 0x4ca5
jmp 0x4c62
jmp 0x4ca5
jmp 0x4c89
jmp 0x4ca5
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x4c9e
jmp 0x4ca5
movq %rax, %rbx
jmp 0x4cb5
jmp 0x4c84
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3170
jmp 0x4c8c
movq %rax, %rbx
jmp 0x4cbf
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x5d52
leaq 0x120(%rsp), %rdi
callq 0x3170
jmp 0x4ca8
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x33d0
leaq 0x48(%rsp), %rdi
callq 0x3170
leaq 0x340(%rsp), %rdi
callq 0x30b0
movq %rbx, %rdi
callq 0x34d0