// File: /workspace/github_c_makefile_star2_O3/silverneko[P]miku/./src/main.cpp
// Function: main
int main(int argc, char *argv[])
{
   //initialize
   bool verbose = false;
   int ac;
   while((ac = getopt_long(argc, argv, optstring, longopts, NULL)) != -1){
      switch(ac){
         case 'v':
            verbose = true;
            break;
         case 'p':
            MAXPARNUM = cast(optarg).to<int>();
            break;
         case 'b':
            BOXOFFSET = cast(optarg).to<int>();
            break;
         case 'a':
            AGGUPDATE = true;
            break;
         default:
            usage();
      }
   }
   
   if(!verbose){
      freopen("/dev/null", "w", stderr);
   }
   
   //initialize done
   
   if(geteuid() != 0){
      cerr << "Must be started as root !" << endl;
      return 0;
   }
   
   while(true){
      submission sub;
      int status = fetchSubmission(sub);
      if(status != 0){
         if(status == -2){
            cerr << "[ERROR] Unable to connect to TIOJ url" << endl; 
         }
         usleep(1000000);
         continue;
      }
      cerr << "Recieved submission [" << sub.submission_id << "]" << endl;
      respondValidating(sub.submission_id);
      if(fetchProblem(sub) == -1){
         usleep(1000000);
         cerr << "[ERROR] Unable to fetch problem meta" << endl;
         continue;
      }
      
      int verdict = testsuite(sub);
      sendResult(sub, verdict, true);
   }

   return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10c8, %rsp           # imm = 0x10C8
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x40(%rsp), %r13
movq $0x0, 0x28(%rsp)
leaq 0x5b03(%rip), %r14      # 0x9270
leaq 0x956c(%rip), %r15      # 0xcce0
leaq 0x30(%rsp), %r12
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x3480
cmpl $0x61, %eax
jle 0x37e3
cmpl $0x62, %eax
je 0x37f5
cmpl $0x70, %eax
jne 0x3875
movq 0x97f2(%rip), %rax      # 0xcf98
movq (%rax), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3ad2
movq %r13, 0x30(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x3ef0
movq %r12, %rdi
callq 0x3b10
leaq 0x9ad7(%rip), %rcx      # 0xd2b8
jmp 0x3837
jne 0x388a
leaq 0x9ad4(%rip), %rax      # 0xd2c4
movb $0x1, (%rax)
jmp 0x3779
movq 0x979c(%rip), %rax      # 0xcf98
movq (%rax), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3ad2
movq %r13, 0x30(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x3ef0
movq %r12, %rdi
callq 0x3b10
leaq 0x9a85(%rip), %rcx      # 0xd2bc
movl %eax, (%rcx)
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x3850
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3779
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x3779
cmpl $0x76, %eax
jne 0x3916
movb $0x1, %al
movq %rax, 0x28(%rsp)
jmp 0x3779
cmpl $-0x1, %eax
jne 0x3916
testb $0x1, 0x28(%rsp)
jne 0x38b7
movq 0x9727(%rip), %rax      # 0xcfc8
movq (%rax), %rdx
leaq 0x5aed(%rip), %rdi      # 0x9398
leaq 0x58e8(%rip), %rsi      # 0x919a
callq 0x32d0
callq 0x31a0
testl %eax, %eax
je 0x391b
movq 0x9721(%rip), %rbx      # 0xcfe8
leaq 0x58ce(%rip), %rsi      # 0x919c
movl $0x19, %edx
movq %rbx, %rdi
callq 0x32f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
xorl %eax, %eax
addq $0x10c8, %rsp           # imm = 0x10C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x371c
leaq 0x30(%rsp), %rbx
movq 0x96c1(%rip), %r14      # 0xcfe8
leaq 0x58ae(%rip), %r15      # 0x91dc
leaq 0x58bd(%rip), %r12      # 0x91f2
leaq 0x587a(%rip), %rbp      # 0x91b6
movq %rbx, %rdi
callq 0x3b90
movq %rbx, %rdi
callq 0x7954
testl %eax, %eax
je 0x399b
cmpl $-0x2, %eax
jne 0x398c
movl $0x25, %edx
movq %r14, %rdi
movq %rbp, %rsi
callq 0x32f0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x3370
jmp 0x3a66
movl $0x15, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x32f0
movl 0x34(%rsp), %esi
movq %r14, %rdi
callq 0x34d0
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x32f0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
movl 0x34(%rsp), %edi
callq 0x7874
movq %rbx, %rdi
callq 0x845f
cmpl $-0x1, %eax
je 0x3a21
movq %rbx, %rdi
callq 0x47a8
movq %rbx, %rdi
movl %eax, %esi
movl $0x1, %edx
callq 0x8b54
jmp 0x3a66
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x3370
movl $0x24, %edx
movq %r14, %rdi
leaq 0x57ba(%rip), %rsi      # 0x91f4
callq 0x32f0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3260
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31d0
movq %rbx, %rdi
callq 0x3e2e
jmp 0x393c
jmp 0x3a75
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3e2e
jmp 0x3aca
jmp 0x3a8a
jmp 0x3aa6
jmp 0x3aab
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x3aae
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x3aae
movq %rax, %rbx
jmp 0x3aca
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3aca
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rbx, %rdi
callq 0x34e0