// File: /workspace/github_c_makefile_star2_O2/silverneko[P]miku/./src/server_io.cpp
// Function: fetchProblem(submission&)
int fetchProblem(submission &sub)
{
   //get submission code
   char *buff = new char[5*1024*1024];
   ostringstream sout;
   sout << "fetch_code.py " << sub.submission_id;
   FILE* Pipe = popen(sout.str().c_str(), "r");
   sout.str("");
   while(fgets(buff, 5*1024*1024, Pipe) != NULL)
      sout << buff;
   sub.code = sout.str();
   pclose(Pipe);
   
   //get sjcode
   sout.str("");
   sout << "fetch_sjcode.py " << sub.problem_id;
   Pipe = popen(sout.str().c_str(), "r");
   sout.str("");
   while(fgets(buff, 5*1024*1024, Pipe) != NULL)
      sout << buff;
   sub.sjcode = sout.str();
   pclose(Pipe);
   
   //get interlib
   sout.str("");
   sout << "fetch_interlib.py " << sub.problem_id;
   Pipe = popen(sout.str().c_str(), "r");
   sout.str("");
   while(fgets(buff, 5*1024*1024, Pipe) != NULL)
      sout << buff;
   sub.interlib = sout.str();
   pclose(Pipe);
   
   delete [] buff;
   //check if testdata dir exists
   sout.str("");
   sout << "./testdata/";
   sout << setfill('0') << setw(4) << sub.problem_id;
   string testdata_dir(sout.str());
   if(access(testdata_dir.c_str(), F_OK)){
      system(("mkdir " + testdata_dir + " 2>/dev/null").c_str());
   }

   //download testdata
   if(downloadTestdata(sub) == -1){
      return -1;
   }
   
   //get memlimit, timelimit
   sout.str("");
   sout << "fetch_limits.py " << sub.problem_id;
   Pipe = popen(sout.str().c_str(), "r");
   for(int i = 0; i < sub.testdata_count; ++i){
      fscanf(Pipe, "%d %d", &sub.time_limit[i], &sub.mem_limit[i]);
   }
   pclose(Pipe);
   
   return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, %rbx
movl $0x500000, %edi         # imm = 0x500000
callq 0x3030
movq %rax, %r15
leaq 0x68(%rsp), %r14
movq %r14, %rdi
callq 0x3360
leaq 0x18f5(%rip), %rsi      # 0x86d8
movq %r14, %rdi
callq 0x3290
movl 0x4(%rbx), %esi
movq %rax, %rdi
callq 0x34c0
leaq 0x70(%rsp), %r14
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x8(%rsp), %r13
movq (%r13), %rdi
leaq 0x198e(%rip), %rsi      # 0x87a6
callq 0x3110
movq %rax, %r12
movq %r13, %rdi
callq 0x3170
leaq 0x16f3(%rip), %rsi      # 0x8522
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x3992
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x33e0
leaq 0x8(%rsp), %rdi
callq 0x3170
leaq 0x68(%rsp), %r13
movq %r15, %rdi
movl $0x500000, %esi         # imm = 0x500000
movq %r12, %rdx
callq 0x3420
testq %rax, %rax
je 0x6e7c
movq %r13, %rdi
movq %r15, %rsi
callq 0x3290
jmp 0x6e5a
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x8(%rbx), %rdi
leaq 0x8(%rsp), %r13
movq %r13, %rsi
callq 0x3310
movq %r13, %rdi
callq 0x3170
movq %r12, %rdi
callq 0x33a0
leaq 0x1671(%rip), %rsi      # 0x8522
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x3992
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x33e0
leaq 0x8(%rsp), %rdi
callq 0x3170
leaq 0x1809(%rip), %rsi      # 0x86e7
leaq 0x68(%rsp), %rdi
callq 0x3290
movl (%rbx), %esi
movq %rax, %rdi
callq 0x34c0
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x8(%rsp), %r13
movq (%r13), %rdi
leaq 0x1897(%rip), %rsi      # 0x87a6
callq 0x3110
movq %rax, %r12
movq %r13, %rdi
callq 0x3170
leaq 0x15fc(%rip), %rsi      # 0x8522
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x3992
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x33e0
leaq 0x8(%rsp), %rdi
callq 0x3170
leaq 0x68(%rsp), %r13
movq %r15, %rdi
movl $0x500000, %esi         # imm = 0x500000
movq %r12, %rdx
callq 0x3420
testq %rax, %rax
je 0x6f73
movq %r13, %rdi
movq %r15, %rsi
callq 0x3290
jmp 0x6f51
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x28(%rbx), %rdi
leaq 0x8(%rsp), %r13
movq %r13, %rsi
callq 0x3310
movq %r13, %rdi
callq 0x3170
movq %r12, %rdi
callq 0x33a0
leaq 0x157a(%rip), %rsi      # 0x8522
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x3992
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x33e0
leaq 0x8(%rsp), %rdi
callq 0x3170
leaq 0x1723(%rip), %rsi      # 0x86f8
leaq 0x68(%rsp), %rdi
callq 0x3290
movl (%rbx), %esi
movq %rax, %rdi
callq 0x34c0
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x8(%rsp), %r13
movq (%r13), %rdi
leaq 0x17a0(%rip), %rsi      # 0x87a6
callq 0x3110
movq %rax, %r12
movq %r13, %rdi
callq 0x3170
leaq 0x1505(%rip), %rsi      # 0x8522
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x3992
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x33e0
leaq 0x8(%rsp), %rdi
callq 0x3170
leaq 0x68(%rsp), %r13
movq %r15, %rdi
movl $0x500000, %esi         # imm = 0x500000
movq %r12, %rdx
callq 0x3420
testq %rax, %rax
je 0x706a
movq %r13, %rdi
movq %r15, %rsi
callq 0x3290
jmp 0x7048
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x48(%rbx), %rdi
leaq 0x8(%rsp), %r13
movq %r13, %rsi
callq 0x3310
movq %r13, %rdi
callq 0x3170
movq %r12, %rdi
callq 0x33a0
movq %r15, %rdi
callq 0x3340
leaq 0x147b(%rip), %rsi      # 0x8522
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x3992
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x33e0
leaq 0x8(%rsp), %rdi
callq 0x3170
leaq 0x13ef(%rip), %rsi      # 0x84c3
leaq 0x68(%rsp), %rdi
callq 0x3290
leaq 0x68(%rsp), %rdi
pushq $0x30
popq %rsi
callq 0x3410
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x4, 0x10(%rax,%rcx)
movl (%rbx), %esi
movq %rax, %rdi
callq 0x34c0
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
movq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x3490
testl %eax, %eax
je 0x716c
leaq 0x15e2(%rip), %rsi      # 0x870b
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x7530
leaq 0x15d3(%rip), %rdx      # 0x8712
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x7511
movq 0x28(%rsp), %rdi
callq 0x3260
leaq 0x28(%rsp), %rdi
callq 0x3170
leaq 0x48(%rsp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x6933
leaq 0x13a7(%rip), %rsi      # 0x8522
leaq 0x28(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x3992
leaq 0x28(%rsp), %rsi
movq %r14, %rdi
callq 0x33e0
leaq 0x28(%rsp), %rdi
callq 0x3170
leaq 0x1577(%rip), %rsi      # 0x871f
leaq 0x68(%rsp), %rdi
callq 0x3290
movl (%rbx), %esi
movq %rax, %rdi
callq 0x34c0
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x28(%rsp), %r15
movq (%r15), %rdi
leaq 0x15ce(%rip), %rsi      # 0x87a6
callq 0x3110
movq %rax, %r14
movq %r15, %rdi
callq 0x3170
leaq 0x414(%rbx), %r15
leaq 0x153a(%rip), %r12      # 0x8730
xorl %r13d, %r13d
movslq 0xf0(%rbx), %rax
cmpq %rax, %r13
jge 0x7225
leaq -0x320(%r15), %rcx
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3500
incq %r13
addq $0x4, %r15
jmp 0x71f9
movq %r14, %rdi
callq 0x33a0
leaq 0x8(%rsp), %rdi
callq 0x3170
leaq 0x68(%rsp), %rdi
callq 0x30b0
xorl %eax, %eax
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3170
jmp 0x7266
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x7279
jmp 0x72ae
jmp 0x72ae
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3170
jmp 0x72b1
jmp 0x72ae
jmp 0x72c1
jmp 0x72ae
jmp 0x72c1
jmp 0x72c1
jmp 0x72ae
jmp 0x72c1
jmp 0x72c1
jmp 0x72ae
jmp 0x72c1
jmp 0x72c1
jmp 0x72ae
jmp 0x72c1
jmp 0x72c1
jmp 0x72ae
jmp 0x72c1
jmp 0x72c1
jmp 0x72ae
jmp 0x72c1
jmp 0x72c1
jmp 0x72c1
jmp 0x72ae
jmp 0x72c1
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3170
jmp 0x72c4
jmp 0x72c1
jmp 0x72c1
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x30b0
movq %rbx, %rdi
callq 0x34d0