// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movq %rsi, 0x10(%rsp)
movl %edi, %ebp
movl $0x63, %edi
callq 0x11f0
movl %eax, %edi
callq 0x1260
cmpl $0x1, %ebp
je 0x1ceb
testl %eax, %eax
jne 0x1ceb
leaq 0x168a(%rip), %rdi      # 0x3014
callq 0x1140
testq %rax, %rax
je 0x1ceb
leaq 0x1940(%rip), %rsi      # 0x32df
leaq 0x37aa(%rip), %rdx      # 0x5150
movq %rax, %rdi
xorl %eax, %eax
callq 0x10e0
cmpl $0x1, %eax
jne 0x1ceb
leaq 0x1662(%rip), %rdi      # 0x3022
callq 0x1140
testq %rax, %rax
je 0x1ceb
leaq 0x190a(%rip), %rsi      # 0x32df
leaq 0x3778(%rip), %rdx      # 0x5154
movq %rax, %rdi
xorl %eax, %eax
callq 0x10e0
cmpl $0x1, %eax
jne 0x1ceb
leaq 0x163b(%rip), %rdi      # 0x3031
callq 0x1140
testq %rax, %rax
je 0x1ceb
leaq 0x18d4(%rip), %rsi      # 0x32df
leaq 0x3746(%rip), %rdx      # 0x5158
xorl %ebx, %ebx
movq %rax, %rdi
xorl %eax, %eax
callq 0x10e0
cmpl $0x1, %eax
jne 0x1ceb
leaq 0x1663(%rip), %r12      # 0x3091
movq %r12, %rdi
callq 0x1140
movq %rax, 0x18(%rsp)
movq %r12, %rdi
callq 0x1160
leaq 0x15e7(%rip), %rdi      # 0x3031
callq 0x1160
leaq 0x15be(%rip), %rdi      # 0x3014
callq 0x1160
leaq 0x15c0(%rip), %rdi      # 0x3022
callq 0x1160
callq 0x1d5c
addq $0x8, 0x10(%rsp)
xorl %ebp, %ebp
leaq 0x36e5(%rip), %rdi      # 0x5160
xorl %esi, %esi
callq 0x1200
movups 0x36d7(%rip), %xmm0     # 0x5160
movups %xmm0, 0x36e0(%rip)     # 0x5170
movb %bl, 0x3702(%rip)       # 0x5198
movb %bl, 0x36fd(%rip)       # 0x5199
movl $0xe, %edi
leaq 0xa29(%rip), %rsi       # 0x24d1
callq 0x1110
movq %rbx, 0x20(%rsp)
movl $0x2710, %eax           # imm = 0x2710
movq %rax, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %rax, 0x38(%rsp)
xorl %edi, %edi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
xorl %edx, %edx
callq 0x11d0
movl $0xf, %edi
leaq 0xab0(%rip), %r15       # 0x2593
movq %r15, %rsi
callq 0x1110
movl $0x2, %edi
movq %r15, %rsi
callq 0x1110
movl $0x1, %edi
movq %r15, %rsi
callq 0x1110
movl $0xa, %edi
leaq 0xaf5(%rip), %rsi       # 0x2606
callq 0x1110
movq 0x10(%rsp), %rsi
movq (%rsi), %rdi
callq 0x1e28
movl $0x1, %esi
movl $0xe, %edi
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 %ebp
imull $0x26e978d5, %ebp, %eax # imm = 0x26E978D5
rorl $0x3, %eax
cmpl $0x418937, %eax         # imm = 0x418937
ja 0x1b91
movl $0x1, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1230
movl $0x2, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1230
movl $0x1, %edi
xorl %esi, %esi
callq 0x1170
movl $0x2, %edi
xorl %esi, %esi
callq 0x1170
cmpq $0x0, 0x18(%rsp)
je 0x1d3a
movl %ebp, 0xc(%rsp)
movb $0x0, 0x35f2(%rip)      # 0x519a
movq 0x35e1(%rip), %rax      # 0x5190
movl %ebx, 0x8(%rax)
movl %ebx, 0xc(%rax)
movl %ebx, (%rax)
movl %ebx, 0x10(%rax)
movl %ebx, 0x35f4(%rip)      # 0x51b4
xorl %ecx, %ecx
movl 0x3590(%rip), %edx      # 0x5158
movl %edx, 0x14(%rax,%rcx,4)
incq %rcx
cmpq $0x10, %rcx
jne 0x1bc2
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1230
movl 0x35b9(%rip), %r13d     # 0x51a0
movq 0x35ba(%rip), %r12      # 0x51a8
testq %r13, %r13
je 0x1ca3
xorl %ebx, %ebx
movq %rbx, %rbp
shlq $0x6, %rbp
leaq (%r12,%rbp), %r14
addq $0x10, %r14
movl 0x8(%r14), %eax
testl %eax, %eax
je 0x1c32
xorl %r15d, %r15d
movq (%r14), %rcx
movq (%rcx,%r15,8), %rdi
testq %rdi, %rdi
je 0x1c28
callq 0x1120
movl 0x8(%r14), %eax
incq %r15
movl %eax, %ecx
cmpq %rcx, %r15
jb 0x1c13
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1c3f
callq 0x1120
movq $0x0, (%r14)
movl $0x0, 0x8(%r14)
movq 0x20(%r12,%rbp), %rdi
testq %rdi, %rdi
je 0x1c5d
callq 0x1120
leaq (%r12,%rbp), %rax
addq $0x20, %rax
movq $0x0, (%rax)
movl $0x0, 0x8(%rax)
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x1c81
callq 0x1120
leaq (%r12,%rbp), %rax
addq $0x30, %rax
movq $0x0, (%rax)
movl $0x0, 0x8(%rax)
incq %rbx
cmpq %r13, %rbx
jne 0x1bf9
xorl %ebx, %ebx
movl %ebx, 0x34f5(%rip)      # 0x51a0
movl %ebx, 0x34eb(%rip)      # 0x519c
movq %rbx, 0x3508(%rip)      # 0x51c0
movq %r12, %rdi
callq 0x1120
movq %rbx, 0x34e1(%rip)      # 0x51a8
cmpb $0x0, 0x34ca(%rip)      # 0x5198
movl 0xc(%rsp), %ebp
jne 0x1a74
callq 0x11c0
cmpb $0x0, 0x34b4(%rip)      # 0x5198
je 0x1cd8
jmp 0x1a74
movq 0x32ee(%rip), %rbx      # 0x4fe0
movq (%rbx), %rcx
leaq 0x1343(%rip), %rdi      # 0x303f
movl $0x2f, %esi
movl $0x1, %edx
callq 0x1250
movq (%rbx), %rdi
leaq 0x135a(%rip), %rsi      # 0x306f
leaq 0x1363(%rip), %rdx      # 0x307f
leaq 0x1361(%rip), %rcx      # 0x3084
movl $0x277, %r8d            # imm = 0x277
xorl %eax, %eax
callq 0x11b0
movl $0x1, %edi
callq 0x1130
movq 0x343f(%rip), %rdi      # 0x5180
callq 0x10f0
movl 0x343c(%rip), %edi      # 0x5188
xorl %esi, %esi
xorl %edx, %edx
callq 0x10c0
xorl %edi, %edi
callq 0x1130