// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xd0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x1, -0x8(%rbp)
jne 0x1338
movq 0x3cca(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
leaq 0x1cdd(%rip), %rsi      # 0x3004
movb $0x0, %al
callq 0x1170
movl $0x1, %edi
callq 0x1140
callq 0x1540
callq 0x16f0
movl $0x63, %edi
callq 0x11a0
movl %eax, %edi
callq 0x11e0
cmpl $0x0, %eax
je 0x137f
movq 0x3c81(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
leaq 0x1cc3(%rip), %rsi      # 0x302c
movb $0x0, %al
callq 0x1170
movl $0x2, %edi
movl $0x63, %esi
callq 0x10e0
movl $0x63, %edi
leaq 0x1ce2(%rip), %rsi      # 0x306d
callq 0x1100
movq %rax, 0x3d89(%rip)      # 0x5120
cmpq $0x0, %rax
jne 0x13ed
jmp 0x139f
movq 0x3c3a(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
leaq 0x1cbf(%rip), %rsi      # 0x306f
movb $0x0, %al
callq 0x1170
movq 0x3c22(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
leaq 0x1cdb(%rip), %rsi      # 0x30a3
leaq 0x1ce4(%rip), %rdx      # 0x30b3
leaq 0x1ce2(%rip), %rcx      # 0x30b8
movl $0x1af, %r8d            # imm = 0x1AF
movb $0x0, %al
callq 0x1170
movl $0x1, %edi
callq 0x1140
leaq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x11b0
imulq $0x3e8, -0x20(%rbp), %rax # imm = 0x3E8
movq %rax, -0xd0(%rbp)
movq -0x18(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, %rcx
movq -0xd0(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq -0xb0(%rbp), %rax
movq %rax, -0xc8(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1070
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movl $0x80, %esi
leaq 0x1c71(%rip), %rdx      # 0x30c6
callq 0x10a0
movq 0x3cbf(%rip), %rdi      # 0x5120
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq -0xb0(%rbp), %rcx
leaq 0x1c61(%rip), %rsi      # 0x30d8
movb $0x0, %al
callq 0x1170
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
callq 0x1730
leaq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x11b0
imulq $0x3e8, -0x20(%rbp), %rax # imm = 0x3E8
movq %rax, -0xc0(%rbp)
movq -0x18(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, %rcx
movq -0xc0(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq 0x3c4b(%rip), %rdi      # 0x5120
movq -0x30(%rbp), %rax
subq -0x28(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divq %rcx
movl %eax, -0xb4(%rbp)
movq -0x30(%rbp), %rax
subq -0x28(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divq %rcx
movq %rdx, %rax
movl -0xb4(%rbp), %edx
movl %eax, %ecx
leaq 0x1c31(%rip), %rsi      # 0x3142
movb $0x0, %al
callq 0x1170
movq 0x3c01(%rip), %rdi      # 0x5120
callq 0x10f0
movl 0x3bfe(%rip), %edi      # 0x5128
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x10c0
xorl %edi, %edi
callq 0x1140
nopl (%rax)