// File: /workspace/github_c_makefile_star2_O1/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 0x1cf5
testl %eax, %eax
jne 0x1cf5
leaq 0x168a(%rip), %rdi      # 0x3014
callq 0x1140
testq %rax, %rax
je 0x1cf5
leaq 0x1940(%rip), %rsi      # 0x32df
leaq 0x37aa(%rip), %rdx      # 0x5150
movq %rax, %rdi
xorl %eax, %eax
callq 0x10e0
cmpl $0x1, %eax
jne 0x1cf5
leaq 0x1662(%rip), %rdi      # 0x3022
callq 0x1140
testq %rax, %rax
je 0x1cf5
leaq 0x190a(%rip), %rsi      # 0x32df
leaq 0x3778(%rip), %rdx      # 0x5154
movq %rax, %rdi
xorl %eax, %eax
callq 0x10e0
cmpl $0x1, %eax
jne 0x1cf5
leaq 0x163b(%rip), %rdi      # 0x3031
callq 0x1140
testq %rax, %rax
je 0x1cf5
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 0x1cf5
leaq 0x1663(%rip), %r15      # 0x3091
movq %r15, %rdi
callq 0x1140
movq %rax, 0x18(%rsp)
movq %r15, %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 0x1d66
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 0xa12(%rip), %rsi       # 0x24ba
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 0xa99(%rip), %r15       # 0x257c
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 0xad4(%rip), %rsi       # 0x25e5
callq 0x1110
movq 0x10(%rsp), %rsi
movq (%rsi), %rdi
callq 0x1e32
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 0x1d44
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), %r15d     # 0x51a0
testq %r15, %r15
je 0x1ca9
movq 0x35b1(%rip), %r13      # 0x51a8
xorl %ebx, %ebx
movq %rbx, %rbp
shlq $0x6, %rbp
leaq 0x10(,%rbp), %r14
addq %r13, %r14
cmpl $0x0, 0x8(%r14)
je 0x1c32
xorl %r12d, %r12d
movq (%r14), %rax
movq (%rax,%r12,8), %rdi
testq %rdi, %rdi
je 0x1c26
callq 0x1120
incq %r12
movl 0x8(%r14), %eax
cmpq %rax, %r12
jb 0x1c15
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1c3f
callq 0x1120
movq $0x0, (%r14)
movl $0x0, 0x8(%r14)
movq 0x20(%r13,%rbp), %rdi
testq %rdi, %rdi
je 0x1c5d
callq 0x1120
leaq 0x20(,%rbp), %rax
addq %r13, %rax
movq $0x0, (%rax)
movl $0x0, 0x8(%rax)
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x1c84
callq 0x1120
leaq 0x30(,%rbp), %rax
addq %r13, %rax
movq $0x0, (%rax)
movl $0x0, 0x8(%rax)
incq %rbx
cmpq %r15, %rbx
jne 0x1bf9
xorl %ebx, %ebx
movl %ebx, 0x34ef(%rip)      # 0x51a0
movl %ebx, 0x34e5(%rip)      # 0x519c
movq %rbx, 0x3502(%rip)      # 0x51c0
movq 0x34e3(%rip), %rdi      # 0x51a8
callq 0x1120
movq %rbx, 0x34d7(%rip)      # 0x51a8
cmpb $0x0, 0x34c0(%rip)      # 0x5198
movl 0xc(%rsp), %ebp
jne 0x1a74
callq 0x11c0
cmpb $0x0, 0x34aa(%rip)      # 0x5198
je 0x1ce2
jmp 0x1a74
movq 0x32e4(%rip), %rbx      # 0x4fe0
movq (%rbx), %rcx
leaq 0x1339(%rip), %rdi      # 0x303f
movl $0x2f, %esi
movl $0x1, %edx
callq 0x1250
movq (%rbx), %rdi
leaq 0x1350(%rip), %rsi      # 0x306f
leaq 0x1359(%rip), %rdx      # 0x307f
leaq 0x1357(%rip), %rcx      # 0x3084
movl $0x277, %r8d            # imm = 0x277
xorl %eax, %eax
callq 0x11b0
movl $0x1, %edi
callq 0x1130
movq 0x3435(%rip), %rdi      # 0x5180
callq 0x10f0
movl 0x3432(%rip), %edi      # 0x5188
xorl %esi, %esi
xorl %edx, %edx
callq 0x10c0
xorl %edi, %edi
callq 0x1130