// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x730, %rsp            # imm = 0x730
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
leaq -0x190(%rbp), %rdi
movq %rdi, -0x678(%rbp)
callq 0x4480
movq -0x678(%rbp), %rdi
leaq 0x8ece(%rip), %rsi      # 0xf4f4
callq 0x4320
movq %rax, -0x670(%rbp)
jmp 0x6634
movq -0x670(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x45e0
movq %rax, -0x680(%rbp)
jmp 0x664c
movq -0x680(%rbp), %rdi
leaq 0x8e9e(%rip), %rsi      # 0xf4f8
callq 0x4320
jmp 0x6661
leaq -0x1c0(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x4350
jmp 0x6676
leaq -0x3c0(%rbp), %rdi
callq 0x45c0
jmp 0x6684
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
leaq 0x8ed8(%rip), %rsi      # 0xf56b
callq 0x8e90
movb %al, -0x681(%rbp)
jmp 0x66a0
movb -0x681(%rbp), %al
testb $0x1, %al
jne 0x66af
jmp 0x675e
leaq 0x8eb9(%rip), %rdx      # 0xf56f
leaq -0x3e0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x9310
jmp 0x66cb
leaq -0x3c0(%rbp), %rdi
leaq -0x3e0(%rbp), %rsi
movl $0x10, %edx
callq 0x41e0
jmp 0x66e5
leaq -0x3e0(%rbp), %rdi
callq 0x4240
jmp 0x6859
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x71a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x7199
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x718d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x3e0(%rbp), %rdi
callq 0x4240
jmp 0x718d
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
leaq 0x8d27(%rip), %rsi      # 0xf494
callq 0x8e90
movb %al, -0x682(%rbp)
jmp 0x677a
movb -0x682(%rbp), %al
testb $0x1, %al
jne 0x6786
jmp 0x67f0
leaq 0x8deb(%rip), %rdx      # 0xf578
leaq -0x400(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x9310
jmp 0x67a2
leaq -0x3c0(%rbp), %rdi
leaq -0x400(%rbp), %rsi
movl $0x10, %edx
callq 0x41e0
jmp 0x67bc
leaq -0x400(%rbp), %rdi
callq 0x4240
jmp 0x6857
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x400(%rbp), %rdi
callq 0x4240
jmp 0x718d
leaq 0x8d88(%rip), %rdx      # 0xf57f
leaq -0x420(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x9310
jmp 0x680c
leaq -0x3c0(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl $0x10, %edx
callq 0x41e0
jmp 0x6826
leaq -0x420(%rbp), %rdi
callq 0x4240
jmp 0x6857
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x420(%rbp), %rdi
callq 0x4240
jmp 0x718d
jmp 0x6859
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
leaq -0x3c0(%rbp), %rdi
callq 0x4310
movq %rax, -0x690(%rbp)
jmp 0x6876
movq -0x690(%rbp), %rdi
movq 0xe744(%rip), %rsi      # 0x14fc8
callq 0x4370
jmp 0x688b
leaq -0x3c0(%rbp), %rdi
callq 0x44d0
jmp 0x6899
movq -0x10(%rbp), %rax
cmpl $0x2, 0xcc(%rax)
jne 0x6ac4
leaq -0x441(%rbp), %rdi
movq %rdi, -0x698(%rbp)
callq 0x4600
movq -0x698(%rbp), %rdx
leaq 0x8c9f(%rip), %rsi      # 0xf56a
leaq -0x440(%rbp), %rdi
callq 0x4d90
jmp 0x68d9
leaq -0x190(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x41c0
jmp 0x68ee
leaq -0x440(%rbp), %rdi
callq 0x4240
leaq -0x441(%rbp), %rdi
callq 0x43a0
leaq -0x190(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x4310
movq %rax, -0x6a0(%rbp)
jmp 0x6922
movq -0x6a0(%rbp), %rdi
leaq 0x8c57(%rip), %rsi      # 0xf587
callq 0x4320
movq %rax, -0x6a8(%rbp)
jmp 0x693e
movl $0x4, %edi
callq 0x91a0
movl %eax, -0x6ac(%rbp)
jmp 0x6950
movq -0x6a8(%rbp), %rdi
movl -0x6ac(%rbp), %eax
movl %eax, -0x448(%rbp)
movl -0x448(%rbp), %esi
callq 0x43d0
movq %rax, -0x6b8(%rbp)
jmp 0x6977
movl $0x30, %edi
callq 0x9180
movb %al, -0x6b9(%rbp)
jmp 0x6989
movq -0x6b8(%rbp), %rdi
movb -0x6b9(%rbp), %al
movb %al, -0x449(%rbp)
movzbl -0x449(%rbp), %esi
callq 0x4520
movq %rax, -0x6c8(%rbp)
jmp 0x69b1
movq -0x6c8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %esi
callq 0x45e0
movq %rax, -0x6d0(%rbp)
jmp 0x69cc
movq -0x6d0(%rbp), %rdi
leaq 0x8bb1(%rip), %rsi      # 0xf58b
callq 0x4320
jmp 0x69e1
leaq -0x470(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x4350
jmp 0x69f6
leaq -0x3c0(%rbp), %rdi
leaq -0x470(%rbp), %rsi
movl $0x10, %edx
callq 0x41e0
jmp 0x6a10
leaq -0x470(%rbp), %rdi
callq 0x4240
movq -0x10(%rbp), %rsi
addq $0x48, %rsi
leaq -0x3c0(%rbp), %rdi
callq 0x4310
movq %rax, -0x6d8(%rbp)
jmp 0x6a39
movq -0x6d8(%rbp), %rdi
movq 0xe581(%rip), %rsi      # 0x14fc8
callq 0x4370
jmp 0x6a4e
leaq -0x3c0(%rbp), %rdi
callq 0x44d0
jmp 0x6a5c
jmp 0x6ac4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x6a90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x440(%rbp), %rdi
callq 0x4240
leaq -0x441(%rbp), %rdi
callq 0x43a0
jmp 0x718d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x470(%rbp), %rdi
callq 0x4240
jmp 0x718d
leaq -0x491(%rbp), %rdi
movq %rdi, -0x6e0(%rbp)
callq 0x4600
movq -0x6e0(%rbp), %rdx
leaq 0x8a85(%rip), %rsi      # 0xf56a
leaq -0x490(%rbp), %rdi
callq 0x4d90
jmp 0x6af3
leaq -0x190(%rbp), %rdi
leaq -0x490(%rbp), %rsi
callq 0x41c0
jmp 0x6b08
leaq -0x490(%rbp), %rdi
callq 0x4240
leaq -0x491(%rbp), %rdi
callq 0x43a0
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
leaq 0x8a3c(%rip), %rsi      # 0xf56b
callq 0x8e90
movb %al, -0x6e1(%rbp)
jmp 0x6b3c
movb -0x6e1(%rbp), %al
testb $0x1, %al
jne 0x6b48
jmp 0x6ba5
leaq 0x8a3f(%rip), %rsi      # 0xf58e
leaq -0x190(%rbp), %rdi
callq 0x4320
jmp 0x6b5d
jmp 0x6bfd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x6b94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x490(%rbp), %rdi
callq 0x4240
leaq -0x491(%rbp), %rdi
callq 0x43a0
jmp 0x718d
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
leaq 0x88e0(%rip), %rsi      # 0xf494
callq 0x8e90
movb %al, -0x6e2(%rbp)
jmp 0x6bc1
movb -0x6e2(%rbp), %al
testb $0x1, %al
jne 0x6bcd
jmp 0x6be4
leaq 0x89e9(%rip), %rsi      # 0xf5bd
leaq -0x190(%rbp), %rdi
callq 0x4320
jmp 0x6be2
jmp 0x6bfb
leaq 0x8a09(%rip), %rsi      # 0xf5f4
leaq -0x190(%rbp), %rdi
callq 0x4320
jmp 0x6bf9
jmp 0x6bfb
jmp 0x6bfd
movq -0x10(%rbp), %rdi
addq $0x88, %rdi
callq 0x4590
testb $0x1, %al
jne 0x6c64
leaq 0x8a13(%rip), %rsi      # 0xf62b
leaq -0x190(%rbp), %rdi
callq 0x4320
movq %rax, -0x6f0(%rbp)
jmp 0x6c2d
movq -0x6f0(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x88, %rsi
callq 0x4310
movq %rax, -0x6f8(%rbp)
jmp 0x6c4d
movq -0x6f8(%rbp), %rdi
leaq 0x8733(%rip), %rsi      # 0xf38e
callq 0x4320
jmp 0x6c62
jmp 0x6c64
leaq -0x4b8(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x4350
jmp 0x6c79
leaq -0x570(%rbp), %rdi
callq 0x9390
jmp 0x6c87
movl $0x32, -0x4cc(%rbp)
movb $0x1, -0x56f(%rbp)
leaq -0x510(%rbp), %rdi
leaq 0x898b(%rip), %rsi      # 0xf631
callq 0x4490
jmp 0x6cad
leaq -0x530(%rbp), %rdi
leaq 0x8735(%rip), %rsi      # 0xf3f0
callq 0x4490
jmp 0x6cc2
movl $0xea60, -0x4c8(%rbp)   # imm = 0xEA60
leaq -0x4f0(%rbp), %rdi
leaq 0x8965(%rip), %rsi      # 0xf63f
callq 0x4490
jmp 0x6ce1
movl -0x14(%rbp), %edi
leaq -0x570(%rbp), %rsi
leaq -0x4b8(%rbp), %rdx
callq 0x5560
jmp 0x6cf9
leaq 0x8953(%rip), %rdx      # 0xf653
leaq -0x590(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x9310
jmp 0x6d15
leaq -0x590(%rbp), %rdi
callq 0x4180
movq %rax, %rdi
xorl %esi, %esi
callq 0x45a0
movl %eax, -0x6fc(%rbp)
leaq -0x590(%rbp), %rdi
callq 0x4240
movl -0x6fc(%rbp), %eax
cmpl $-0x1, %eax
jne 0x6d8c
movl $0x11, -0x4(%rbp)
movl $0x1, -0x594(%rbp)
jmp 0x712d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x7181
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x7175
movq -0x10(%rbp), %rax
cmpl $0x1, 0xcc(%rax)
jne 0x711c
leaq -0x5b9(%rbp), %rdi
movq %rdi, -0x708(%rbp)
callq 0x4600
movq -0x708(%rbp), %rdx
leaq 0x87ac(%rip), %rsi      # 0xf56a
leaq -0x5b8(%rbp), %rdi
callq 0x4d90
jmp 0x6dcc
leaq -0x190(%rbp), %rdi
leaq -0x5b8(%rbp), %rsi
callq 0x41c0
jmp 0x6de1
leaq -0x5b8(%rbp), %rdi
callq 0x4240
leaq -0x5b9(%rbp), %rdi
callq 0x43a0
leaq 0x86f4(%rip), %rsi      # 0xf4f4
leaq -0x190(%rbp), %rdi
callq 0x4320
movq %rax, -0x710(%rbp)
jmp 0x6e15
movq -0x710(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x45e0
movq %rax, -0x718(%rbp)
jmp 0x6e2d
movq -0x718(%rbp), %rdi
leaq 0x86bd(%rip), %rsi      # 0xf4f8
callq 0x4320
jmp 0x6e42
leaq -0x5e0(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x4350
jmp 0x6e57
leaq 0x87fe(%rip), %rdx      # 0xf65c
leaq -0x600(%rbp), %rdi
leaq -0x5e0(%rbp), %rsi
callq 0x9310
jmp 0x6e73
leaq -0x3c0(%rbp), %rdi
leaq -0x600(%rbp), %rsi
movl $0x10, %edx
callq 0x41e0
jmp 0x6e8d
leaq -0x600(%rbp), %rdi
callq 0x4240
movq -0x10(%rbp), %rsi
addq $0x28, %rsi
leaq -0x3c0(%rbp), %rdi
callq 0x4310
movq %rax, -0x720(%rbp)
jmp 0x6eb6
movq -0x720(%rbp), %rdi
movq 0xe104(%rip), %rsi      # 0x14fc8
callq 0x4370
jmp 0x6ecb
leaq -0x3c0(%rbp), %rdi
callq 0x44d0
jmp 0x6ed9
leaq -0x621(%rbp), %rdi
movq %rdi, -0x728(%rbp)
callq 0x4600
movq -0x728(%rbp), %rdx
leaq 0x8670(%rip), %rsi      # 0xf56a
leaq -0x620(%rbp), %rdi
callq 0x4d90
jmp 0x6f08
leaq -0x190(%rbp), %rdi
leaq -0x620(%rbp), %rsi
callq 0x41c0
jmp 0x6f1d
leaq -0x620(%rbp), %rdi
callq 0x4240
leaq -0x621(%rbp), %rdi
callq 0x43a0
leaq 0x8727(%rip), %rsi      # 0xf663
leaq -0x190(%rbp), %rdi
callq 0x4320
jmp 0x6f4a
leaq -0x4f0(%rbp), %rdi
leaq 0x873d(%rip), %rsi      # 0xf695
callq 0x4490
jmp 0x6f5f
movl -0x18(%rbp), %eax
movl %eax, -0x72c(%rbp)
leaq -0x648(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x4350
jmp 0x6f7d
movl -0x72c(%rbp), %edi
leaq -0x570(%rbp), %rsi
leaq -0x648(%rbp), %rdx
callq 0x5560
jmp 0x6f98
leaq -0x648(%rbp), %rdi
callq 0x4240
leaq 0x8700(%rip), %rdx      # 0xf6ab
leaq -0x668(%rbp), %rdi
leaq -0x5e0(%rbp), %rsi
callq 0x9310
jmp 0x6fc0
leaq -0x668(%rbp), %rdi
callq 0x4180
movq %rax, %rdi
xorl %esi, %esi
callq 0x45a0
movl %eax, -0x730(%rbp)
leaq -0x668(%rbp), %rdi
callq 0x4240
movl -0x730(%rbp), %eax
cmpl $-0x1, %eax
jne 0x70ea
movl $0x13, -0x4(%rbp)
movl $0x1, -0x594(%rbp)
jmp 0x70f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x703f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x5b8(%rbp), %rdi
callq 0x4240
leaq -0x5b9(%rbp), %rdi
callq 0x43a0
jmp 0x7175
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x710e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x600(%rbp), %rdi
callq 0x4240
jmp 0x710e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
jmp 0x70bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x620(%rbp), %rdi
callq 0x4240
leaq -0x621(%rbp), %rdi
callq 0x43a0
jmp 0x710e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x198(%rbp)
movl %eax, -0x19c(%rbp)
leaq -0x648(%rbp), %rdi
callq 0x4240
jmp 0x710e
movl $0x0, -0x594(%rbp)
leaq -0x5e0(%rbp), %rdi
callq 0x4240
movl -0x594(%rbp), %eax
testl %eax, %eax
jne 0x712d
jmp 0x710c
jmp 0x711c
leaq -0x5e0(%rbp), %rdi
callq 0x4240
jmp 0x7175
movl $0x0, -0x4(%rbp)
movl $0x1, -0x594(%rbp)
leaq -0x570(%rbp), %rdi
callq 0x9430
leaq -0x4b8(%rbp), %rdi
callq 0x4240
leaq -0x3c0(%rbp), %rdi
callq 0x44f0
leaq -0x1c0(%rbp), %rdi
callq 0x4240
leaq -0x190(%rbp), %rdi
callq 0x40d0
movl -0x4(%rbp), %eax
addq $0x730, %rsp            # imm = 0x730
popq %rbp
retq
leaq -0x570(%rbp), %rdi
callq 0x9430
leaq -0x4b8(%rbp), %rdi
callq 0x4240
leaq -0x3c0(%rbp), %rdi
callq 0x44f0
leaq -0x1c0(%rbp), %rdi
callq 0x4240
leaq -0x190(%rbp), %rdi
callq 0x40d0
movq -0x198(%rbp), %rdi
callq 0x45f0
nopl (%rax)