// File: /workspace/github_c_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rdi, %rbx
movl $0x500000, %edi         # imm = 0x500000
callq 0x3030
movq %rax, %r15
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0x3350
leaq 0x128f(%rip), %rsi      # 0x9723
movl $0xe, %edx
movq %r14, %rdi
callq 0x32f0
movl 0x4(%rbx), %esi
leaq 0x60(%rsp), %rdi
callq 0x34d0
leaq 0x68(%rsp), %r14
movq %rsp, %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x10(%rsp), %rbp
movq -0x10(%rbp), %rdi
leaq 0x1323(%rip), %rsi      # 0x97f1
callq 0x30e0
movq %rax, %r12
movq -0x10(%rbp), %rdi
cmpq %rbp, %rdi
je 0x84ec
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0x1029(%rip), %rdx      # 0x9522
movq %rdx, %rsi
callq 0x3f86
movq %rsp, %rsi
movq %r14, %rdi
callq 0x33d0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8522
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x60(%rsp), %r13
movq %r15, %rdi
movl $0x500000, %esi         # imm = 0x500000
movq %r12, %rdx
callq 0x3420
testq %rax, %rax
je 0x8554
movq %r15, %rdi
callq 0x3130
movq %r13, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x32f0
jmp 0x8527
movq %rsp, %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x8(%rbx), %rdi
movq %rsp, %r13
movq %r13, %rsi
callq 0x3310
movq (%r13), %rdi
cmpq %rbp, %rdi
je 0x8584
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
callq 0x3380
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0xf89(%rip), %rdx       # 0x9522
movq %rdx, %rsi
callq 0x3f86
movq %rsp, %rsi
movq %r14, %rdi
callq 0x33d0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x85c2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x1169(%rip), %rsi      # 0x9732
leaq 0x60(%rsp), %rdi
movl $0x10, %edx
callq 0x32f0
movl (%rbx), %esi
leaq 0x60(%rsp), %rdi
callq 0x34d0
movq %rsp, %rdi
movq %r14, %rsi
callq 0x3430
movq (%rsp), %rdi
leaq 0x11f7(%rip), %rsi      # 0x97f1
callq 0x30e0
movq %rax, %r12
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8618
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0xefd(%rip), %rdx       # 0x9522
movq %rdx, %rsi
callq 0x3f86
movq %rsp, %rsi
movq %r14, %rdi
callq 0x33d0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x864e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x60(%rsp), %r13
movq %r15, %rdi
movl $0x500000, %esi         # imm = 0x500000
movq %r12, %rdx
callq 0x3420
testq %rax, %rax
je 0x8680
movq %r15, %rdi
callq 0x3130
movq %r13, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x32f0
jmp 0x8653
movq %rsp, %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x28(%rbx), %rdi
movq %rsp, %r13
movq %r13, %rsi
callq 0x3310
movq (%r13), %rdi
cmpq %rbp, %rdi
je 0x86b0
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
callq 0x3380
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0xe5d(%rip), %rdx       # 0x9522
movq %rdx, %rsi
callq 0x3f86
movq %rsp, %rsi
movq %r14, %rdi
callq 0x33d0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x86ee
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x104e(%rip), %rsi      # 0x9743
leaq 0x60(%rsp), %rdi
movl $0x12, %edx
callq 0x32f0
movl (%rbx), %esi
leaq 0x60(%rsp), %rdi
callq 0x34d0
movq %rsp, %rdi
movq %r14, %rsi
callq 0x3430
movq (%rsp), %rdi
leaq 0x10cb(%rip), %rsi      # 0x97f1
callq 0x30e0
movq %rax, %r12
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8744
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0xdd1(%rip), %rdx       # 0x9522
movq %rdx, %rsi
callq 0x3f86
movq %rsp, %rsi
movq %r14, %rdi
callq 0x33d0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x877a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x60(%rsp), %r13
movq %r15, %rdi
movl $0x500000, %esi         # imm = 0x500000
movq %r12, %rdx
callq 0x3420
testq %rax, %rax
je 0x87ac
movq %r15, %rdi
callq 0x3130
movq %r13, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x32f0
jmp 0x877f
movq %rsp, %rdi
movq %r14, %rsi
callq 0x3430
leaq 0x48(%rbx), %rdi
movq %rsp, %r13
movq %r13, %rsi
callq 0x3310
movq (%r13), %rdi
cmpq %rbp, %rdi
je 0x87dc
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
callq 0x3380
movq %r15, %rdi
callq 0x3340
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0xd29(%rip), %rdx       # 0x9522
movq %rdx, %rsi
callq 0x3f86
movq %rsp, %rsi
movq %r14, %rdi
callq 0x33d0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8822
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0xc9a(%rip), %rsi       # 0x94c3
leaq 0x60(%rsp), %rdi
movl $0xb, %edx
callq 0x32f0
movq 0x60(%rsp), %rax
movq -0x18(%rax), %rcx
leaq (%rsp,%rcx), %r15
addq $0x60, %r15
cmpb $0x0, 0xe1(%r15)
jne 0x886d
movq %r15, %rdi
movl $0x20, %esi
callq 0x3260
movb $0x1, 0xe1(%r15)
movq 0x60(%rsp), %rax
movb $0x30, 0xe0(%r15)
movq -0x18(%rax), %rax
movq $0x4, 0x70(%rsp,%rax)
movl (%rbx), %esi
leaq 0x60(%rsp), %rdi
callq 0x34d0
movq %rsp, %rdi
movq %r14, %rsi
callq 0x3430
movq (%rsp), %rdi
xorl %esi, %esi
callq 0x34a0
testl %eax, %eax
je 0x8953
leaq 0xea3(%rip), %rsi       # 0x9756
leaq 0x40(%rsp), %rdi
movq %rsp, %rdx
callq 0x8e71
leaq 0xe96(%rip), %rsi       # 0x975d
leaq 0x40(%rsp), %rdi
callq 0x3520
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x88f8
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x88ff
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x20(%rsp), %rdi
callq 0x3240
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x8938
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8953
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rbx, %rdi
callq 0x7c62
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xbb7(%rip), %rdx       # 0x9522
leaq 0x20(%rsp), %rdi
movq %rdx, %rsi
callq 0x3f86
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x33d0
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x899c
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0xdc7(%rip), %rsi       # 0x976a
leaq 0x60(%rsp), %rdi
movl $0x10, %edx
callq 0x32f0
movl (%rbx), %esi
leaq 0x60(%rsp), %rdi
callq 0x34d0
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
movq 0x20(%rsp), %rdi
leaq 0xe1a(%rip), %rsi       # 0x97f1
callq 0x30e0
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x89f6
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
cmpl $0x0, 0xf0(%rbx)
jle 0x8a3a
leaq 0x414(%rbx), %r15
leaq 0xd6e(%rip), %r12       # 0x977b
xorl %r13d, %r13d
leaq -0x320(%r15), %rcx
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3500
incq %r13
movslq 0xf0(%rbx), %rax
addq $0x4, %r15
cmpq %rax, %r13
jl 0x8a10
movq %r14, %rdi
callq 0x3380
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8a58
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x4559(%rip), %rsi      # 0xcfb8
leaq 0x60(%rsp), %rdi
callq 0x3170
leaq 0xd0(%rsp), %rdi
callq 0x3100
xorl %eax, %eax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x8aa9
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x8aa9
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8b0f
movq 0x50(%rsp), %rsi
jmp 0x8ad4
jmp 0x8b0c
jmp 0x8b0c
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x8b0f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x8b0f
jmp 0x8b0c
jmp 0x8b2b
jmp 0x8b0c
jmp 0x8b2b
jmp 0x8b2b
jmp 0x8b0c
jmp 0x8b2b
jmp 0x8b2b
jmp 0x8b0c
jmp 0x8b2b
jmp 0x8b2b
jmp 0x8b0c
jmp 0x8b2b
jmp 0x8b2b
jmp 0x8b0c
jmp 0x8b2b
jmp 0x8b2b
jmp 0x8b0c
jmp 0x8b2b
jmp 0x8b2b
jmp 0x8b2b
jmp 0x8b0c
jmp 0x8b2b
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8b2e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x8b2e
jmp 0x8b2b
jmp 0x8b2b
movq %rax, %rbx
movq 0x4483(%rip), %rsi      # 0xcfb8
leaq 0x60(%rsp), %rdi
callq 0x3170
leaq 0xd0(%rsp), %rdi
callq 0x3100
movq %rbx, %rdi
callq 0x34e0