// File: /workspace/github_c_makefile_star2_O1/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 0x1197(%rip), %rsi      # 0x9713
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 0x122b(%rip), %rsi      # 0x97e1
callq 0x30e0
movq %rax, %r12
movq -0x10(%rbp), %rdi
cmpq %rbp, %rdi
je 0x85d4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0xf31(%rip), %rdx       # 0x9512
movq %rdx, %rsi
callq 0x4040
movq %rsp, %rsi
movq %r14, %rdi
callq 0x33d0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x860a
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 0x863c
movq %r15, %rdi
callq 0x3130
movq %r13, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x32f0
jmp 0x860f
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 0x866c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
callq 0x3380
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0xe91(%rip), %rdx       # 0x9512
movq %rdx, %rsi
callq 0x4040
movq %rsp, %rsi
movq %r14, %rdi
callq 0x33d0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x86aa
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x1071(%rip), %rsi      # 0x9722
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 0x10ff(%rip), %rsi      # 0x97e1
callq 0x30e0
movq %rax, %r12
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8700
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0xe05(%rip), %rdx       # 0x9512
movq %rdx, %rsi
callq 0x4040
movq %rsp, %rsi
movq %r14, %rdi
callq 0x33d0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8736
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 0x8768
movq %r15, %rdi
callq 0x3130
movq %r13, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x32f0
jmp 0x873b
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 0x8798
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq %r12, %rdi
callq 0x3380
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0xd65(%rip), %rdx       # 0x9512
movq %rdx, %rsi
callq 0x4040
movq %rsp, %rsi
movq %r14, %rdi
callq 0x33d0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x87d6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0xf56(%rip), %rsi       # 0x9733
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 0xfd3(%rip), %rsi       # 0x97e1
callq 0x30e0
movq %rax, %r12
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x882c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rsp, %rdi
movq %rbp, (%rdi)
leaq 0xcd9(%rip), %rdx       # 0x9512
movq %rdx, %rsi
callq 0x4040
movq %rsp, %rsi
movq %r14, %rdi
callq 0x33d0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8862
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 0x8894
movq %r15, %rdi
callq 0x3130
movq %r13, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x32f0
jmp 0x8867
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 0x88c4
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 0xc31(%rip), %rdx       # 0x9512
movq %rdx, %rsi
callq 0x4040
movq %rsp, %rsi
movq %r14, %rdi
callq 0x33d0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x890a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0xba2(%rip), %rsi       # 0x94b3
leaq 0x60(%rsp), %rdi
movl $0xb, %edx
callq 0x32f0
movq 0x60(%rsp), %rax
movq -0x18(%rax), %rax
leaq (%rsp,%rax), %r15
addq $0x60, %r15
cmpb $0x0, 0xe1(%r15)
jne 0x8957
movq %r15, %rdi
movl $0x20, %esi
callq 0x3260
movb %al, 0xe0(%r15)
movb $0x1, 0xe1(%r15)
movb $0x30, 0xe0(%r15)
leaq 0x60(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movq $0x4, 0x70(%rsp,%rax)
movl (%rbx), %esi
callq 0x34d0
movq %rsp, %rdi
movq %r14, %rsi
callq 0x3430
movq (%rsp), %rdi
xorl %esi, %esi
callq 0x34a0
testl %eax, %eax
je 0x8a40
leaq 0xda6(%rip), %rsi       # 0x9746
leaq 0x40(%rsp), %rdi
movq %rsp, %rdx
callq 0x8f5e
leaq 0xd99(%rip), %rsi       # 0x974d
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 0x89e5
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x89ec
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 0x8a25
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8a40
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rbx, %rdi
callq 0x7d42
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xaba(%rip), %rdx       # 0x9512
leaq 0x20(%rsp), %rdi
movq %rdx, %rsi
callq 0x4040
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x33d0
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x8a89
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
leaq 0xcca(%rip), %rsi       # 0x975a
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 0xd1d(%rip), %rsi       # 0x97e1
callq 0x30e0
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x8ae3
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
cmpl $0x0, 0xf0(%rbx)
jle 0x8b27
leaq 0x414(%rbx), %r15
leaq 0xc71(%rip), %r12       # 0x976b
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 0x8afd
movq %r14, %rdi
callq 0x3380
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8b45
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x446c(%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 0x8b96
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x8b96
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8bfc
movq 0x50(%rsp), %rsi
jmp 0x8bc1
jmp 0x8bf9
jmp 0x8bf9
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x8bfc
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x8bfc
jmp 0x8bf9
jmp 0x8c18
jmp 0x8bf9
jmp 0x8c18
jmp 0x8c18
jmp 0x8bf9
jmp 0x8c18
jmp 0x8c18
jmp 0x8bf9
jmp 0x8c18
jmp 0x8c18
jmp 0x8bf9
jmp 0x8c18
jmp 0x8c18
jmp 0x8bf9
jmp 0x8c18
jmp 0x8c18
jmp 0x8bf9
jmp 0x8c18
jmp 0x8c18
jmp 0x8c18
jmp 0x8bf9
jmp 0x8c18
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8c1b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x8c1b
jmp 0x8c18
jmp 0x8c18
movq %rax, %rbx
movq 0x4396(%rip), %rsi      # 0xcfb8
leaq 0x60(%rsp), %rdi
callq 0x3170
leaq 0xd0(%rsp), %rdi
callq 0x3100
movq %rbx, %rdi
callq 0x34e0