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

  struct timeval x;
  _u64 st, en;
  _u8 buf[128];

  if (argc == 1) {
    debug("Usage: %s /program/to/trace [ params ]\n",argv[0]);
    exit(1);
  }
 
  prepare_shm(); 
  setup_signals(); 
  
  if (close(dup(99))) {
    debug("NOTE: File descriptor #99 closed, defaulting to stderr instead.\n");
    dup2(2,99);
  }

  if (!(outfile=fdopen(99,"a"))) fatal("unable to create FILE object");
  
  gettimeofday(&x,0);
  st = x.tv_sec * 1000 + x.tv_usec / 1000;

  strftime(buf,128,"%Y/%m/%d %H:%M:%S",localtime((time_t*)&x.tv_sec));

  outf("bunny-trace " VERSION " (" __DATE__ " " __TIME__ ") by <lcamtuf@google.com>\n"
       "+++ Trace of '%s' started at %s +++\n", argv[1], buf);
  
  handle_process(argv[1],(_u8**)argv+1);
  
  gettimeofday(&x,0);
  en = x.tv_sec * 1000 + x.tv_usec / 1000;

  outf("+++ Trace complete (%u.%03u secs) +++\n",(_u32)((en-st)/1000), (_u32)((en-st) % 1000));
  fclose(outfile);
  
  shmctl(shmid, IPC_RMID, 0);
  
  exit(0);
  
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %rbx
cmpl $0x1, %edi
jne 0x17e5
movq 0x3814(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x183b(%rip), %rsi      # 0x3014
xorl %eax, %eax
callq 0x1170
jmp 0x18a9
movl $0x80054, %esi          # imm = 0x80054
xorl %edi, %edi
movl $0x380, %edx            # imm = 0x380
callq 0x1060
movl %eax, 0x392c(%rip)      # 0x5128
testl %eax, %eax
jns 0x183d
movq 0x37d9(%rip), %rbx      # 0x4fe0
movq (%rbx), %rdi
leaq 0x1968(%rip), %rsi      # 0x3179
movl $0x200, %edx            # imm = 0x200
xorl %eax, %eax
callq 0x1170
movq (%rbx), %rdi
leaq 0x188c(%rip), %rsi      # 0x30b3
leaq 0x1986(%rip), %rdx      # 0x31b4
leaq 0x1893(%rip), %rcx      # 0x30c8
movl $0x18c, %r8d            # imm = 0x18C
jmp 0x1896
movl %eax, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1150
movq %rax, 0x38e1(%rip)      # 0x5130
incq %rax
cmpq $0x1, %rax
ja 0x18b3
movq 0x3781(%rip), %rbx      # 0x4fe0
movq (%rbx), %rcx
leaq 0x1967(%rip), %rdi      # 0x31d0
movl $0x34, %esi
movl $0x1, %edx
callq 0x11e0
movq (%rbx), %rdi
leaq 0x1831(%rip), %rsi      # 0x30b3
leaq 0x192b(%rip), %rdx      # 0x31b4
leaq 0x1838(%rip), %rcx      # 0x30c8
movl $0x18f, %r8d            # imm = 0x18F
xorl %eax, %eax
callq 0x1170
leaq 0x191c(%rip), %rdi      # 0x31c0
callq 0x10d0
movl $0x1, %edi
callq 0x1140
movl 0x386f(%rip), %edx      # 0x5128
leaq 0x1d3f(%rip), %rsi      # 0x35ff
xorl %r15d, %r15d
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1030
leaq 0x192c(%rip), %rdi      # 0x3205
movq %r14, %rsi
movl $0x1, %edx
callq 0x1190
movq 0x3843(%rip), %rax      # 0x5130
movl $0x80000, 0x4(%rax)     # imm = 0x80000
movl $0x0, 0x10(%rax)
movl $0x40000000, 0x14(%rax,%r15,4) # imm = 0x40000000
incq %r15
cmpq $0x10, %r15
jne 0x18fb
leaq 0x6c3(%rip), %r14       # 0x1fd7
movl $0xf, %edi
movq %r14, %rsi
callq 0x1120
movl $0x2, %edi
movq %r14, %rsi
callq 0x1120
movl $0x1, %edi
movq %r14, %rsi
callq 0x1120
movl $0x63, %edi
callq 0x11a0
movl %eax, %edi
callq 0x11f0
testl %eax, %eax
je 0x197f
movq 0x3689(%rip), %rax      # 0x4fe0
movq (%rax), %rcx
leaq 0x16db(%rip), %rdi      # 0x303c
movl $0x40, %esi
movl $0x1, %edx
callq 0x11e0
movl $0x2, %edi
movl $0x63, %esi
callq 0x10e0
leaq 0x16f7(%rip), %rsi      # 0x307d
movl $0x63, %edi
callq 0x1100
movq %rax, 0x3789(%rip)      # 0x5120
testq %rax, %rax
jne 0x19e6
movq 0x363d(%rip), %rbx      # 0x4fe0
movq (%rbx), %rcx
leaq 0x16d2(%rip), %rdi      # 0x307f
movl $0x33, %esi
movl $0x1, %edx
callq 0x11e0
movq (%rbx), %rdi
leaq 0x16ed(%rip), %rsi      # 0x30b3
leaq 0x16f6(%rip), %rdx      # 0x30c3
leaq 0x16f4(%rip), %rcx      # 0x30c8
movl $0x1af, %r8d            # imm = 0x1AF
xorl %eax, %eax
callq 0x1170
jmp 0x18a9
movq %rsp, %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x11b0
movq (%r14), %rbp
movabsq $-0x20c49ba5e353f7cf, %rax # imm = 0xDF3B645A1CAC0831
imulq 0x8(%r14)
movq %rdx, %r13
shrq $0x3f, %r13
sarq $0x7, %rdx
addq %rdx, %r13
movq %r14, %rdi
callq 0x1070
leaq 0x16b5(%rip), %rdx      # 0x30d6
leaq 0x10(%rsp), %r15
movl $0x80, %esi
movq %r15, %rdi
movq %rax, %rcx
callq 0x10a0
movq 0x36e3(%rip), %rdi      # 0x5120
leaq 0x8(%rbx), %r12
movq 0x8(%rbx), %rdx
leaq 0x169c(%rip), %rsi      # 0x30e8
movq %r15, %rcx
xorl %eax, %eax
callq 0x1170
movq 0x8(%rbx), %rdi
movq %r12, %rsi
callq 0x1aeb
movq %r14, %rdi
xorl %esi, %esi
callq 0x11b0
movabsq $0x20c49ba5e353f7cf, %rsi # imm = 0x20C49BA5E353F7CF
movq %rsi, %rax
imulq 0x8(%r14)
movq (%r14), %rax
subq %rbp, %rax
movq %rdx, %r8
shrq $0x3f, %r8
sarq $0x7, %rdx
addq %rdx, %r8
addq %r13, %r8
movq 0x3685(%rip), %rdi      # 0x5120
imulq $0x3e8, %rax, %rcx      # imm = 0x3E8
addq %r8, %rcx
movq %rcx, %rax
shrq $0x3, %rax
mulq %rsi
shrq $0x4, %rdx
imull $0x3e8, %edx, %eax      # imm = 0x3E8
subl %eax, %ecx
leaq 0x1690(%rip), %rsi      # 0x3152
xorl %eax, %eax
callq 0x1170
movq 0x3650(%rip), %rdi      # 0x5120
callq 0x10f0
movl 0x364d(%rip), %edi      # 0x5128
xorl %esi, %esi
xorl %edx, %edx
callq 0x10c0
xorl %edi, %edi
callq 0x1140