// File: /workspace/github_c_makefile_star2_O1/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 0x5ac3(%rip), %r14      # 0x9270
leaq 0x952c(%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 0x3823
cmpl $0x62, %eax
je 0x3835
cmpl $0x70, %eax
jne 0x38b5
movq 0x97b2(%rip), %rax      # 0xcf98
movq (%rax), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3b12
movq %r13, 0x30(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x3fb0
movq %r12, %rdi
callq 0x3b50
leaq 0x9a97(%rip), %rcx      # 0xd2b8
jmp 0x3877
jne 0x38ca
leaq 0x9a94(%rip), %rax      # 0xd2c4
movb $0x1, (%rax)
jmp 0x37b9
movq 0x975c(%rip), %rax      # 0xcf98
movq (%rax), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x3b12
movq %r13, 0x30(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x3fb0
movq %r12, %rdi
callq 0x3b50
leaq 0x9a45(%rip), %rcx      # 0xd2bc
movl %eax, (%rcx)
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x3890
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3290
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x37b9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x37b9
cmpl $0x76, %eax
jne 0x3956
movb $0x1, %al
movq %rax, 0x28(%rsp)
jmp 0x37b9
cmpl $-0x1, %eax
jne 0x3956
testb $0x1, 0x28(%rsp)
jne 0x38f7
movq 0x96e7(%rip), %rax      # 0xcfc8
movq (%rax), %rdx
leaq 0x5aad(%rip), %rdi      # 0x9398
leaq 0x58a8(%rip), %rsi      # 0x919a
callq 0x32d0
callq 0x31a0
testl %eax, %eax
je 0x395b
movq 0x96e1(%rip), %rbx      # 0xcfe8
leaq 0x588e(%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 0x375c
leaq 0x30(%rsp), %rbx
movq 0x9681(%rip), %r14      # 0xcfe8
leaq 0x586e(%rip), %r15      # 0x91dc
leaq 0x587d(%rip), %r12      # 0x91f2
leaq 0x583a(%rip), %rbp      # 0x91b6
movq %rbx, %rdi
callq 0x3bd0
movq %rbx, %rdi
callq 0x7a34
testl %eax, %eax
je 0x39db
cmpl $-0x2, %eax
jne 0x39cc
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 0x3aa6
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 0x7954
movq %rbx, %rdi
callq 0x8547
cmpl $-0x1, %eax
je 0x3a61
movq %rbx, %rdi
callq 0x485c
movq %rbx, %rdi
movl %eax, %esi
movl $0x1, %edx
callq 0x8c41
jmp 0x3aa6
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x3370
movl $0x24, %edx
movq %r14, %rdi
leaq 0x577a(%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 0x3eee
jmp 0x397c
jmp 0x3ab5
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3eee
jmp 0x3b0a
jmp 0x3aca
jmp 0x3ae6
jmp 0x3aeb
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x3aee
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3290
jmp 0x3aee
movq %rax, %rbx
jmp 0x3b0a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3b0a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3290
movq %rbx, %rdi
callq 0x34e0