// File: /workspace/github_c_makefile_star2_O2/mabdi[P]bunney/bunny-exec.c
// Function: main
int main(int argc,char** argv) {

  _u8* t, keep_alive;
  _u32 run_cnt = 0;
  
  if (close(dup(99)) || argc == 1   ||
      !(t=getenv("BUNNY_MAXTIME"))  || sscanf(t,"%u",&time_limit) != 1 ||
      !(t=getenv("BUNNY_MAXSTUCK")) || sscanf(t,"%u",&stuck_limit) != 1 ||
      !(t=getenv("BUNNY_MAXFUNC"))  || sscanf(t,"%u",&func_limit) != 1)
    fatal("not a standalone program");

#ifdef DEBUG_TRACE
  setbuffer(stdout,0,0);
#endif /* DEBUG_TRACE */

  keep_alive = (getenv("BUNNY_KEEPALIVE") != 0);

  unsetenv("BUNNY_KEEPALIVE");
  unsetenv("BUNNY_MAXFUNC");
  unsetenv("BUNNY_MAXTIME");
  unsetenv("BUNNY_MAXSTUCK");

#ifdef DEBUG_TRACE
  printf("[bunny-exec] Starting up (keepalive=%u).\n", keep_alive);
#endif /* DEBUG_TRACE */

  prepare_shm();

#ifdef DEBUG_TRACE
  printf("[bunny-exec] SHM setup complete.\n");
#endif /* DEBUG_TRACE */

  do {

    gettimeofday(&start_time,0);
    memcpy(&last_time,&start_time,sizeof(struct timeval));
  
    setup_signals();

#ifdef DEBUG_TRACE
    printf("[bunny-exec] Launching '%s'...\n",argv[1]);
#endif /* DEBUG_TRACE */

    handle_process(argv[1],(_u8**)argv+1);

    disable_timers();

    if (!((++run_cnt) % TRUNC_FREQ)) {
      /* Every TRUNC_FREQ execs, truncate stdin/stdout if possible, ignore errors. */
      lseek(1,0,SEEK_SET);
      lseek(2,0,SEEK_SET);
      ftruncate(1,0);
      ftruncate(2,0);
    }

  } while (keep_alive && reset_wait_keepalive());

  fclose(outfile);

  shmctl(shmid, IPC_RMID, 0);  

#ifdef DEBUG_TRACE
  printf("[bunny-exec] Shutdown OK.\n");
#endif /* DEBUG_TRACE */


  exit(0);
  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, 0x10(%rsp)
movl %edi, %ebp
pushq $0x63
popq %rdi
callq 0x11f0
movl %eax, %edi
callq 0x1260
cmpl $0x1, %ebp
je 0x14e1
testl %eax, %eax
jne 0x14e1
leaq 0x1c69(%rip), %rdi      # 0x3014
callq 0x1140
testq %rax, %rax
je 0x14e1
leaq 0x1f1f(%rip), %rsi      # 0x32df
leaq 0x3d89(%rip), %rdx      # 0x5150
movq %rax, %rdi
xorl %eax, %eax
callq 0x10e0
cmpl $0x1, %eax
jne 0x14e1
leaq 0x1c41(%rip), %rdi      # 0x3022
callq 0x1140
testq %rax, %rax
je 0x14e1
leaq 0x1ee9(%rip), %rsi      # 0x32df
leaq 0x3d57(%rip), %rdx      # 0x5154
movq %rax, %rdi
xorl %eax, %eax
callq 0x10e0
cmpl $0x1, %eax
jne 0x14e1
leaq 0x1c1a(%rip), %rdi      # 0x3031
callq 0x1140
testq %rax, %rax
je 0x14e1
leaq 0x1eb3(%rip), %rsi      # 0x32df
leaq 0x3d25(%rip), %rdx      # 0x5158
movq %rax, %rdi
xorl %eax, %eax
callq 0x10e0
cmpl $0x1, %eax
jne 0x14e1
leaq 0x1c44(%rip), %r14      # 0x3091
movq %r14, %rdi
callq 0x1140
movq %rax, 0x18(%rsp)
movq %r14, %rdi
callq 0x1160
leaq 0x1bc8(%rip), %rdi      # 0x3031
callq 0x1160
leaq 0x1b9f(%rip), %rdi      # 0x3014
callq 0x1160
leaq 0x1ba1(%rip), %rdi      # 0x3022
callq 0x1160
leaq 0x1c14(%rip), %rsi      # 0x30a1
pushq $0x63
popq %rdi
callq 0x1100
movq %rax, 0x3ce4(%rip)      # 0x5180
testq %rax, %rax
jne 0x152a
movq 0x3b34(%rip), %rbx      # 0x4fe0
movq (%rbx), %rcx
leaq 0x1bed(%rip), %rdi      # 0x30a3
pushq $0x35
popq %rsi
pushq $0x1
popq %rdx
callq 0x1250
movq (%rbx), %rdi
leaq 0x1ba4(%rip), %rsi      # 0x306f
leaq 0x1c07(%rip), %rdx      # 0x30d9
leaq 0x1bab(%rip), %rcx      # 0x3084
movl $0x201, %r8d            # imm = 0x201
jmp 0x151b
movq 0x3af8(%rip), %rbx      # 0x4fe0
movq (%rbx), %rcx
leaq 0x1b4d(%rip), %rdi      # 0x303f
pushq $0x2f
popq %rsi
pushq $0x1
popq %rdx
callq 0x1250
movq (%rbx), %rdi
leaq 0x1b68(%rip), %rsi      # 0x306f
leaq 0x1b71(%rip), %rdx      # 0x307f
leaq 0x1b6f(%rip), %rcx      # 0x3084
movl $0x277, %r8d            # imm = 0x277
xorl %eax, %eax
callq 0x11b0
pushq $0x1
popq %rdi
callq 0x1130
movl $0x80054, %esi          # imm = 0x80054
xorl %edi, %edi
movl $0x380, %edx            # imm = 0x380
callq 0x1070
movl %eax, 0x3c47(%rip)      # 0x5188
movl %eax, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1190
movq %rax, 0x3c3d(%rip)      # 0x5190
incq %rax
cmpq $0x1, %rax
ja 0x15ae
movq 0x3a7d(%rip), %rbx      # 0x4fe0
movq (%rbx), %rcx
leaq 0x1b88(%rip), %rdi      # 0x30f5
pushq $0x34
popq %rsi
pushq $0x1
popq %rdx
callq 0x1250
movq (%rbx), %rdi
leaq 0x1aed(%rip), %rsi      # 0x306f
leaq 0x1b50(%rip), %rdx      # 0x30d9
leaq 0x1af4(%rip), %rcx      # 0x3084
movl $0x207, %r8d            # imm = 0x207
xorl %eax, %eax
callq 0x11b0
leaq 0x1b41(%rip), %rdi      # 0x30e5
callq 0x10d0
jmp 0x1522
movl 0x3bd4(%rip), %edx      # 0x5188
leaq 0x1d24(%rip), %rsi      # 0x32df
xorl %ebx, %ebx
leaq 0x20(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1030
leaq 0x1b57(%rip), %rdi      # 0x312a
pushq $0x1
popq %rdx
movq %r14, %rsi
callq 0x11e0
movq 0x3bab(%rip), %rax      # 0x5190
movl $0x80000, 0x4(%rax)     # imm = 0x80000
movl $0x0, 0x10(%rax)
cmpq $0x10, %rbx
je 0x1608
movl 0x3b59(%rip), %ecx      # 0x5158
movl %ecx, 0x14(%rax,%rbx,4)
incq %rbx
jmp 0x15f3
addq $0x8, 0x10(%rsp)
xorl %ebx, %ebx
xorl %r12d, %r12d
leaq 0x3b46(%rip), %rdi      # 0x5160
xorl %esi, %esi
callq 0x1200
movups 0x3b38(%rip), %xmm0     # 0x5160
movups %xmm0, 0x3b41(%rip)     # 0x5170
movb %bl, 0x3b63(%rip)       # 0x5198
movb %bl, 0x3b5e(%rip)       # 0x5199
pushq $0xe
popq %rbp
movl %ebp, %edi
leaq 0xaef(%rip), %rsi       # 0x2136
callq 0x1110
andq $0x0, 0x20(%rsp)
movl $0x2710, %eax           # imm = 0x2710
movq %rax, 0x28(%rsp)
andq $0x0, 0x30(%rsp)
movq %rax, 0x38(%rsp)
xorl %edi, %edi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
xorl %edx, %edx
callq 0x11d0
pushq $0xf
popq %rdi
leaq 0xb59(%rip), %r15       # 0x21db
movq %r15, %rsi
callq 0x1110
pushq $0x2
popq %rdi
movq %r15, %rsi
callq 0x1110
pushq $0x1
popq %rdi
movq %r15, %rsi
callq 0x1110
pushq $0xa
popq %rdi
leaq 0xb9a(%rip), %rsi       # 0x2244
callq 0x1110
movq 0x10(%rsp), %rsi
movq (%rsi), %rdi
callq 0x185a
movl %ebp, %edi
pushq $0x1
popq %rsi
callq 0x1110
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x30(%rsp)
xorl %edi, %edi
movq %r14, %rsi
xorl %edx, %edx
callq 0x11d0
incl %r12d
movl %r12d, %eax
xorl %edx, %edx
movl $0x3e8, %ecx            # imm = 0x3E8
divl %ecx
testl %edx, %edx
jne 0x1723
pushq $0x1
popq %r14
movl %r14d, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1230
pushq $0x2
popq %rbp
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1230
movl %r14d, %edi
xorl %esi, %esi
callq 0x1170
movl %ebp, %edi
xorl %esi, %esi
callq 0x1170
cmpq $0x0, 0x18(%rsp)
je 0x1838
movb $0x0, 0x3a64(%rip)      # 0x519a
movq 0x3a53(%rip), %rax      # 0x5190
movl %ebx, 0x8(%rax)
movl %ebx, 0xc(%rax)
movl %ebx, (%rax)
movl %ebx, 0x10(%rax)
andl $0x0, 0x3a65(%rip)      # 0x51b4
xorl %ecx, %ecx
cmpq $0x10, %rcx
je 0x1766
movl 0x39fb(%rip), %edx      # 0x5158
movl %edx, 0x14(%rax,%rcx,4)
incq %rcx
jmp 0x1751
movl %r12d, 0xc(%rsp)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1230
movl 0x3a23(%rip), %r13d     # 0x51a0
movq 0x3a24(%rip), %r14      # 0x51a8
xorl %r15d, %r15d
cmpq %r13, %r15
je 0x17f7
movq %r15, %rbx
shlq $0x6, %rbx
leaq (%r14,%rbx), %rbp
addq $0x10, %rbp
xorl %r12d, %r12d
movl 0x8(%rbp), %eax
movq (%rbp), %rdi
cmpq %rax, %r12
jae 0x17b8
movq (%rdi,%r12,8), %rdi
callq 0x1120
incq %r12
jmp 0x179e
callq 0x1120
andq $0x0, (%rbp)
andl $0x0, 0x8(%rbp)
movq 0x20(%r14,%rbx), %rdi
callq 0x1120
andq $0x0, 0x20(%r14,%rbx)
andl $0x0, 0x28(%r14,%rbx)
movq 0x30(%r14,%rbx), %rdi
callq 0x1120
andq $0x0, 0x30(%r14,%rbx)
andl $0x0, 0x38(%r14,%rbx)
incq %r15
jmp 0x1787
andl $0x0, 0x39a2(%rip)      # 0x51a0
andl $0x0, 0x3997(%rip)      # 0x519c
andq $0x0, 0x39b3(%rip)      # 0x51c0
movq %r14, %rdi
callq 0x1120
andq $0x0, 0x398b(%rip)      # 0x51a8
xorl %ebx, %ebx
movl 0xc(%rsp), %r12d
cmpb $0x0, 0x396d(%rip)      # 0x5198
jne 0x1613
callq 0x11c0
jmp 0x1824
movq 0x3941(%rip), %rdi      # 0x5180
callq 0x10f0
movl 0x393e(%rip), %edi      # 0x5188
xorl %esi, %esi
xorl %edx, %edx
callq 0x10c0
xorl %edi, %edi
callq 0x1130