// File: /workspace/github_c_makefile_star2_O2/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
movq $0x0, 0x8(%rsp)
leaq 0x4b3a(%rip), %r14      # 0x8270
leaq 0x85c3(%rip), %r15      # 0xbd00
leaq 0x10(%rsp), %r12
leaq 0x30(%rsp), %r13
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x3470
cmpl $0x61, %eax
je 0x37ec
cmpl $0x62, %eax
je 0x37a4
cmpl $0x70, %eax
jne 0x37fb
movq 0x8840(%rip), %rax      # 0xbfb8
movq (%rax), %rsi
movq %r12, %rdi
leaq 0x7(%rsp), %rdx
callq 0x3992
movq %r13, %rdi
movq %r12, %rsi
callq 0x3370
movq %r13, %rdi
callq 0x39ce
leaq 0x8b1e(%rip), %rcx      # 0xc2c0
jmp 0x37d5
movq 0x880d(%rip), %rax      # 0xbfb8
movq (%rax), %rsi
movq %r12, %rdi
leaq 0x7(%rsp), %rdx
callq 0x3992
movq %r13, %rdi
movq %r12, %rsi
callq 0x3370
movq %r13, %rdi
callq 0x39ce
leaq 0x8aef(%rip), %rcx      # 0xc2c4
movl %eax, (%rcx)
movq %r13, %rdi
callq 0x3170
movq %r12, %rdi
callq 0x3170
jmp 0x3747
leaq 0x8ad9(%rip), %rax      # 0xc2cc
movb $0x1, (%rax)
jmp 0x3747
cmpl $-0x1, %eax
je 0x3811
cmpl $0x76, %eax
jne 0x386d
movb $0x1, %al
movq %rax, 0x8(%rsp)
jmp 0x3747
testb $0x1, 0x8(%rsp)
jne 0x3835
movq 0x87b1(%rip), %rax      # 0xbfd0
movq (%rax), %rdx
leaq 0x4b6f(%rip), %rdi      # 0x8398
leaq 0x496a(%rip), %rsi      # 0x819a
callq 0x32e0
callq 0x31c0
testl %eax, %eax
je 0x3872
movq 0x87ab(%rip), %rdi      # 0xbff0
leaq 0x4950(%rip), %rsi      # 0x819c
callq 0x3290
movq %rax, %rdi
callq 0x31a0
xorl %eax, %eax
addq $0x10c8, %rsp           # imm = 0x10C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x36ec
leaq 0x30(%rsp), %rbx
movq 0x8772(%rip), %r14      # 0xbff0
leaq 0x4957(%rip), %r15      # 0x81dc
leaq 0x4966(%rip), %r12      # 0x81f2
pushq $0x1
popq %rbp
leaq 0x4920(%rip), %r13      # 0x81b6
movq %rbx, %rdi
callq 0x3a24
movq %rbx, %rdi
callq 0x671f
testl %eax, %eax
je 0x38ce
cmpl $-0x2, %eax
jne 0x38c2
movq %r14, %rdi
movq %r13, %rsi
callq 0x3290
movq %rax, %rdi
callq 0x31a0
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x3390
jmp 0x3945
movq %r14, %rdi
movq %r15, %rsi
callq 0x3290
movl 0x34(%rsp), %esi
movq %rax, %rdi
callq 0x34c0
movq %rax, %rdi
movq %r12, %rsi
callq 0x3290
movq %rax, %rdi
callq 0x31a0
movl 0x34(%rsp), %edi
callq 0x6694
movq %rbx, %rdi
callq 0x6daf
cmpl $-0x1, %eax
je 0x3924
movq %rbx, %rdi
callq 0x4274
movq %rbx, %rdi
movl %eax, %esi
movl %ebp, %edx
callq 0x72d6
jmp 0x3945
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x3390
movq %r14, %rdi
leaq 0x48bc(%rip), %rsi      # 0x81f4
callq 0x3290
movq %rax, %rdi
callq 0x31a0
movq %rbx, %rdi
callq 0x3c4e
jmp 0x3896
jmp 0x3954
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3c4e
jmp 0x398a
jmp 0x3978
jmp 0x3969
jmp 0x397d
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3170
jmp 0x3980
movq %rax, %rbx
jmp 0x398a
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x34d0