// File: /workspace/github_c_makefile_star2_O2/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 0x1335
movq 0x3cc4(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x1ceb(%rip), %rsi      # 0x3014
xorl %eax, %eax
callq 0x1170
jmp 0x13f5
movl $0x80054, %esi          # imm = 0x80054
xorl %edi, %edi
movl $0x380, %edx            # imm = 0x380
callq 0x1060
movl %eax, 0x3ddc(%rip)      # 0x5128
testl %eax, %eax
jns 0x138d
movq 0x3c89(%rip), %rbx      # 0x4fe0
movq (%rbx), %rdi
leaq 0x1e18(%rip), %rsi      # 0x3179
movl $0x200, %edx            # imm = 0x200
xorl %eax, %eax
callq 0x1170
movq (%rbx), %rdi
leaq 0x1d3c(%rip), %rsi      # 0x30b3
leaq 0x1e36(%rip), %rdx      # 0x31b4
leaq 0x1d43(%rip), %rcx      # 0x30c8
movl $0x18c, %r8d            # imm = 0x18C
jmp 0x13e2
movl %eax, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1150
movq %rax, 0x3d91(%rip)      # 0x5130
incq %rax
cmpq $0x1, %rax
ja 0x13fd
movq 0x3c31(%rip), %rbx      # 0x4fe0
movq (%rbx), %rcx
leaq 0x1e17(%rip), %rdi      # 0x31d0
pushq $0x34
popq %rsi
pushq $0x1
popq %rdx
callq 0x11e0
movq (%rbx), %rdi
leaq 0x1ce5(%rip), %rsi      # 0x30b3
leaq 0x1ddf(%rip), %rdx      # 0x31b4
leaq 0x1cec(%rip), %rcx      # 0x30c8
movl $0x18f, %r8d            # imm = 0x18F
xorl %eax, %eax
callq 0x1170
leaq 0x1dd0(%rip), %rdi      # 0x31c0
callq 0x10d0
pushq $0x1
popq %rdi
callq 0x1140
movl 0x3d25(%rip), %edx      # 0x5128
leaq 0x21f5(%rip), %rsi      # 0x35ff
xorl %r15d, %r15d
leaq 0x10(%rsp), %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x1030
leaq 0x1de2(%rip), %rdi      # 0x3205
pushq $0x1
popq %rdx
movq %r14, %rsi
callq 0x1190
movq 0x3cfb(%rip), %rax      # 0x5130
movl $0x80000, 0x4(%rax)     # imm = 0x80000
movl $0x0, 0x10(%rax)
cmpq $0x10, %r15
je 0x1457
movl $0x40000000, 0x14(%rax,%r15,4) # imm = 0x40000000
incq %r15
jmp 0x1443
leaq 0x901(%rip), %r14       # 0x1d5f
pushq $0xf
popq %rdi
movq %r14, %rsi
callq 0x1120
pushq $0x2
popq %rdi
movq %r14, %rsi
callq 0x1120
pushq $0x1
popq %rdi
movq %r14, %rsi
callq 0x1120
pushq $0x63
popq %rdi
callq 0x11a0
movl %eax, %edi
callq 0x11f0
testl %eax, %eax
je 0x14b9
movq 0x3b47(%rip), %rax      # 0x4fe0
movq (%rax), %rcx
leaq 0x1b99(%rip), %rdi      # 0x303c
pushq $0x40
popq %rsi
pushq $0x1
popq %rdx
callq 0x11e0
pushq $0x2
popq %rdi
pushq $0x63
popq %rsi
callq 0x10e0
leaq 0x1bbd(%rip), %rsi      # 0x307d
pushq $0x63
popq %rdi
callq 0x1100
movq %rax, 0x3c51(%rip)      # 0x5120
testq %rax, %rax
jne 0x151a
movq 0x3b05(%rip), %rbx      # 0x4fe0
movq (%rbx), %rcx
leaq 0x1b9a(%rip), %rdi      # 0x307f
pushq $0x33
popq %rsi
pushq $0x1
popq %rdx
callq 0x11e0
movq (%rbx), %rdi
leaq 0x1bb9(%rip), %rsi      # 0x30b3
leaq 0x1bc2(%rip), %rdx      # 0x30c3
leaq 0x1bc0(%rip), %rcx      # 0x30c8
movl $0x1af, %r8d            # imm = 0x1AF
xorl %eax, %eax
callq 0x1170
jmp 0x13f5
movq %rsp, %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x11b0
movq (%r15), %rbp
movq 0x8(%r15), %rax
movq $-0x3e8, %rcx           # imm = 0xFC18
cqto
idivq %rcx
movq %rax, %r14
movq %r15, %rdi
callq 0x1070
leaq 0x1b8a(%rip), %rdx      # 0x30d6
leaq 0x10(%rsp), %r12
movl $0x80, %esi
movq %r12, %rdi
movq %rax, %rcx
callq 0x10a0
movq 0x3bb8(%rip), %rdi      # 0x5120
leaq 0x8(%rbx), %r13
movq 0x8(%rbx), %rdx
leaq 0x1b71(%rip), %rsi      # 0x30e8
movq %r12, %rcx
xorl %eax, %eax
callq 0x1170
movq 0x8(%rbx), %rdi
movq %r13, %rsi
callq 0x15f9
movq %r15, %rdi
xorl %esi, %esi
callq 0x11b0
movq (%r15), %rcx
movq 0x8(%r15), %rax
movl $0x3e8, %esi            # imm = 0x3E8
cqto
idivq %rsi
movq 0x3b71(%rip), %rdi      # 0x5120
subq %rbp, %rcx
imulq $0x3e8, %rcx, %rcx      # imm = 0x3E8
addq %r14, %rax
addq %rcx, %rax
xorl %edx, %edx
divq %rsi
movq %rdx, %rcx
leaq 0x1b84(%rip), %rsi      # 0x3152
movl %eax, %edx
xorl %eax, %eax
callq 0x1170
movq 0x3b42(%rip), %rdi      # 0x5120
callq 0x10f0
movl 0x3b3f(%rip), %edi      # 0x5128
xorl %esi, %esi
xorl %edx, %edx
callq 0x10c0
xorl %edi, %edi
callq 0x1140