// File: /workspace/github_c_makefile_star2_O3/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 0x48d6(%rip), %rsi      # 0x94ac
movl $0x9, %edx
movq %rbx, %rdi
callq 0x32f0
leaq 0x140(%rsp), %rdi
movl %r14d, %esi
callq 0x34d0
leaq 0x48b6(%rip), %rsi      # 0x94b0
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 0x48ef(%rip), %rsi      # 0x9523
movq %r12, %rdi
callq 0x30d0
testl %eax, %eax
movl %r14d, 0x44(%rsp)
je 0x4ca9
leaq 0x4800(%rip), %rsi      # 0x944c
movq %r12, %rdi
callq 0x30d0
leaq 0x78(%rsp), %r14
testl %eax, %eax
je 0x4cf3
movq %r14, -0x10(%r14)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0x3ef0
leaq 0x48b4(%rip), %rsi      # 0x9537
leaq 0x68(%rsp), %rdi
callq 0x3520
leaq 0x2b8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movl $0x10, %edx
callq 0x3150
jmp 0x4d36
leaq 0x78(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0x3ef0
leaq 0x4857(%rip), %rsi      # 0x9527
leaq 0x68(%rsp), %rdi
callq 0x3520
leaq 0x2b8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movl $0x10, %edx
callq 0x3150
jmp 0x4d36
movq %r14, -0x10(%r14)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0x3ef0
leaq 0x481b(%rip), %rsi      # 0x9530
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 0x4d4d
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 0x4eb9
leaq 0x78(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x478d(%rip), %rdx      # 0x9522
leaq 0x68(%rsp), %rdi
movq %rdx, %rsi
callq 0x3f86
leaq 0x68(%rsp), %rsi
movq %rbp, %rdi
callq 0x33d0
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x4dc6
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 0x4758(%rip), %rsi      # 0x953f
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 0x4e2d
movq %r13, %rdi
movl $0x20, %esi
callq 0x3260
movb $0x1, 0xe1(%r13)
movb $0x30, 0xe0(%r13)
movl (%r15), %esi
movq %rbx, %rdi
callq 0x34d0
leaq 0x46fc(%rip), %rsi      # 0x9543
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 0x4e8f
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 0x4659(%rip), %rdx      # 0x9522
leaq 0x68(%rsp), %rdi
movq %rdx, %rsi
callq 0x3f86
leaq 0x68(%rsp), %rsi
movq %rbp, %rdi
callq 0x33d0
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x4efa
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x4622(%rip), %rsi      # 0x9523
movq %r12, %rdi
callq 0x30d0
testl %eax, %eax
je 0x4f37
leaq 0x4538(%rip), %rsi      # 0x944c
movq %r12, %rdi
callq 0x30d0
testl %eax, %eax
leaq 0x4650(%rip), %rax      # 0x9575
leaq 0x4680(%rip), %rsi      # 0x95ac
cmoveq %rax, %rsi
movl $0x36, %edx
jmp 0x4f43
movl $0x2e, %edx
leaq 0x4603(%rip), %rsi      # 0x9546
leaq 0x140(%rsp), %rdi
callq 0x32f0
cmpq $0x0, 0x90(%r15)
je 0x4fa2
leaq 0x4682(%rip), %rsi      # 0x95e3
leaq 0x140(%rsp), %rdi
movl $0x5, %edx
callq 0x32f0
movq 0x88(%r15), %rsi
movq 0x90(%r15), %rdx
leaq 0x140(%rsp), %rdi
callq 0x32f0
leaq 0x43a1(%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, 0x20(%r14)
movaps 0x4386(%rip), %xmm0     # 0x93b0
movups %xmm0, 0x10(%r14)
leaq 0x45b3(%rip), %rcx      # 0x95e9
movl $0xd, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x3400
leaq 0xa8(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x4340(%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 0x4575(%rip), %rcx      # 0x95f7
movl $0x13, %r8d
movq %r12, %rdi
xorl %esi, %esi
callq 0x3400
leaq 0x68(%rsp), %rsi
leaq 0x120(%rsp), %rdx
movl 0x44(%rsp), %edi
callq 0x401c
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x3ef0
leaq 0x453e(%rip), %rsi      # 0x960b
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 0x50fd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
cmpl $-0x1, %ebx
je 0x5359
cmpl $0x1, 0xcc(%r15)
jne 0x5355
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x43fc(%rip), %rdx      # 0x9522
movq %rdx, %rsi
callq 0x3f86
movq %rsp, %rsi
leaq 0x148(%rsp), %rdi
callq 0x33d0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5159
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x434c(%rip), %rsi      # 0x94ac
leaq 0x140(%rsp), %rdi
movl $0x9, %edx
callq 0x32f0
leaq 0x140(%rsp), %rdi
movl 0x40(%rsp), %esi
callq 0x34d0
leaq 0x4326(%rip), %rsi      # 0x94b0
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 0x3ef0
leaq 0x4447(%rip), %rsi      # 0x9614
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 0x5205
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 0x42e4(%rip), %rdx      # 0x9522
movq %rdx, %rsi
callq 0x3f86
leaq 0x20(%rsp), %rsi
leaq 0x148(%rsp), %rdi
callq 0x33d0
movq 0x20(%rsp), %rdi
cmpq %rbx, %rdi
je 0x526f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x43a5(%rip), %rsi      # 0x961b
leaq 0x140(%rsp), %rdi
movl $0x31, %edx
callq 0x32f0
movq 0xf0(%rsp), %rdx
leaq 0x43b6(%rip), %rcx      # 0x964d
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 0x401c
movq 0x20(%rsp), %rdi
cmpq %rbx, %rdi
je 0x52e3
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 0x3ef0
movq %rbx, %r15
leaq 0x435d(%rip), %rsi      # 0x9663
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 0x5335
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5350
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
cmpl $-0x1, %ebx
je 0x5360
xorl %ebx, %ebx
jmp 0x5365
movl $0x11, %ebx
jmp 0x5365
movl $0x13, %ebx
movq 0xe8(%rsp), %rdi
cmpq %r14, %rdi
je 0x5382
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0xc8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x539f
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x53c4
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x70(%rsp), %r14
movq 0x18(%r14), %rdi
cmpq %r13, %rdi
je 0x53e2
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r14, %rdi
callq 0x717e
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x540b
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x7b96(%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 0x545e
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x7b53(%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 0x54fe
jmp 0x54fe
jmp 0x5570
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
jne 0x54c7
jmp 0x551e
jmp 0x551b
jmp 0x54b7
jmp 0x551b
jmp 0x54b7
jmp 0x551b
jmp 0x54b7
movq %rbx, %rcx
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %rcx, %rdi
je 0x551e
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x551e
jmp 0x551b
jmp 0x5540
jmp 0x551b
jmp 0x5540
jmp 0x54fe
jmp 0x54fe
jmp 0x5570
jmp 0x54fe
jmp 0x54fe
jmp 0x5570
jmp 0x54fe
jmp 0x5570
jmp 0x54fe
jmp 0x5570
jmp 0x551b
jmp 0x5540
jmp 0x5570
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x5573
movq 0x78(%rsp), %rsi
jmp 0x5566
jmp 0x5570
movq %rax, %rbx
jmp 0x5580
jmp 0x553b
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x5543
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x5543
movq %rax, %rbx
jmp 0x559b
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x701a
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5573
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x5573
movq %rax, %rbx
leaq 0x2b8(%rsp), %rdi
callq 0x33c0
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x559b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x7a16(%rip), %rsi      # 0xcfb8
leaq 0x140(%rsp), %rdi
callq 0x3170
leaq 0x1b0(%rsp), %rdi
callq 0x3100
movq %rbx, %rdi
callq 0x34e0