// File: /workspace/github_c_makefile_star2_O2/ryancdotorg[P]bloomslice/bfstool.c
// Function: main
int main(int argc, char **argv) {
  hash160_t hash;
  FILE *ifile = stdin, *ofile = stdout;
  FILE *dfile = NULL, *hfile = NULL, *bfile = NULL, *ffile = NULL, *rfile = NULL;

  mmapf_ctx bloom_mmapf, reference_mmapf, diff_mmapf;
  struct stat sb;

  uint8_t kopt = 0;
  uint8_t wopt = DEFAULT_MAX_BIT_WIDTH;
  double sopt = DEFAULT_MAX_SATURATION;
  double eopt = DEFAULT_MAX_ERROR_RATE;

  unsigned char *bopt = NULL, *xopt = NULL, *ropt = NULL;
  unsigned char *dopt = NULL, *iopt = NULL, *oopt = NULL;

  char mode = 0;
  char hfmt = 0;

  unsigned char *bloom;

  char *line = NULL;
  size_t line_sz = 0;

  unsigned char buf[41];

  double pct, err_rate, sat;
  uint64_t mask = 0, bloom_size = 0, i, items;
  uint8_t h = 254;

  int c, r;

  while ((c = getopt(argc, argv, "hABHWRDPb:x:d:r:f:i:o:w:k:e:s:")) != -1) {
    switch (c) {
      case 'A':
        for (int i = 0; i < 256; ++i) {
          printf("%3u: %8s        ", i, bloom_deschash(i));
          if (i % 4 == 3) printf("\n");
        }
        return 0;
      case 'W':
      case 'R':
      case 'D':
      case 'P':
        if (mode) bail(1, "[!] Mode '%c' already selected, can't also specify '%c'\n", mode, c);
        mode = c; break;
      case 'H':
      case 'B':
        if (hfmt) bail(1, "[!] Format '%c' already selected, can't also specify '%c'\n", hfmt, c);
        hfmt = c; break;
      case 'b':
        bopt = optarg; break;
      case 'x':
        xopt = optarg; break;
      case 'r':
        ropt = optarg; break;
      case 'd':
        dopt = optarg; break;
      case 'i':
        iopt = optarg; break;
      case 'o':
        oopt = optarg; break;
      case 'w':
        wopt = atoi(optarg); break;
      case 'k':
        kopt = atoi(optarg); break;
      case 'e':
        eopt = atof(optarg); break;
      case 's':
        sopt = atof(optarg); break;
      case 'h':
        // show help
        usage(argv[0]);
        return 0;
      case '?':
        // show error
        return 1;
      default:
        // should never be reached...
        printf("got option '%c' (%d)\n", c, c);
        return 1;
    }
  }

  if (mode == 'W') {
    // #####################
    // ##                 ##
    // ##   CREATE MODE   ##
    // ##                 ##
    // #####################
    if (!bopt) bail(1, "[!] Bloom filter file must be specified with '-b'\n");
    if (!xopt) bail(1, "[!] Hash file must be specified with '-x'\n");
    if (dopt || ropt || iopt || oopt) {
      bail(1, "[!] Invalid combination of file options for create mode\n");
    }

    // manually specified number of hashes
    if (kopt) {
      fprintf(stderr, "bloom_pick_hash_wk w:%u k:%u\n", wopt, kopt);
      if ((h = bloom_pick_hash_wk(wopt, kopt)) == 255) {
        bail(1, "[!] No hash routine found for specified parameters\n");
      }
    }

    // open input hash file
    if ((hfile = fopen(xopt, "r")) == NULL) {
      bail(1, "[!] Failed to open hash file '%s': %s\n", xopt, strerror(errno));
    }
    if ((r = fstat(fileno(hfile), &sb)) != 0) {
      bail(1, "[!] Failed to stat hash file '%s': %s\n", xopt, strerror(errno));
    }
    if ((sb.st_size % 20) && (sb.st_size % 41)) {
      bail(1, "[!] Hash file '%s' is not a valid size\n", xopt);
    }
    if (hfmt == 0) {
      if (!(sb.st_size % 20) != !(sb.st_size % 41)) {
        hfmt = !(sb.st_size % 20) ? 'B' : 'H';
        fprintf(stderr, "[*] Auto-detected hash format %c by size\n", hfmt);
      } else {
        if ((hfmt = hash_file_type(hfile)) < 0) {
          bail(1, "[!] fgetc/ungetc failed on hash file\n");
        }
        if (hfmt == 0) {
          bail(1, "[!] Unable to determine type of hash file, please specify -B or -H\n");
        }
        fprintf(stderr, "[*] Auto-detected hash format %c by content\n", hfmt);
      }
    }

    items = sb.st_size / (hfmt == 'H' ? 41 : 20);

    fprintf(stderr, "defaults h:%u w:%u\n", h, wopt);
    // if a hash routine still hasn't been chosen, pick one now
    if (items == 0) {
      bail(1, "[!] No hashes to load\n");
    } else if (items == 1) {
      bloom_size = bloom_width_to_size(BFS_TYPE_SINGLE);
      h = BFS_TYPE_SINGLE;
    } else if (h >= 254) {
      if (eopt < 0) {
        fprintf(stderr, "bloom_pick_hash_wi w:%u i:%lu\n", wopt, items);
        if ((h = bloom_pick_hash_wi(wopt, items, &kopt)) >= 254) {
          bail(1, "[!] No hash routine found for specified parameters\n");
        }
      } else {
        fprintf(stderr, "bloom_pick_hash_es e:%.3e s:%.3f i:%lu w:%u k:%u\n", eopt, sopt, items, wopt, kopt);
        if ((h = bloom_pick_hash_es(eopt, sopt, items, &wopt, &kopt)) >= 254) {
          bail(1, "[!] No hash routine found for specified parameters\n");
        }
      }
    }

    if (bloom_size == 0 && (bloom_size = bloom_width_to_size(wopt)) == 0) {
      bail(1, "[!] Failed to compute bloom filter file size (bug?)\n");
    }

    if (stat(bopt, &sb) == 0) {
      bail(1, "[!] Bloom filter file '%s' already exists\n", bopt);
    } else {
      if ((r = open64(bopt, O_RDWR|O_CREAT|O_EXCL, 0644)) < 0) {
        bail(1, "[!] Failed to create bloom filter file '%s': %s\n", bopt, strerror(errno));
      } else if ((bfile = fdopen(r, "w+")) == NULL) {
        bail(1, "[!] Failed fdopen on bloom filter file descriptor\n");
      }
    }

    fprintf(stderr, "parameters h:%u w:%u k:%u i:%lu\n", h, wopt, kopt, items);
    mask = bloom_width_to_mask(wopt);
    sat = bloom_saturation(kopt, 1ULL<<wopt, items);
    err_rate = pow(sat, kopt);

    fprintf(stderr, "[*] Selected function %s (%u) with mask 0x%zx\n", bloom_deschash(h), h, mask);
    fprintf(stderr, "[*] Have %zu hashes to load into %zu bit filter (%zu bytes)\n", items, (bloom_size - 9) * 8, bloom_size);
    if (items > 0) {
      fprintf(stderr, "[*] Saturation: ~%.3f\n", sat);
      fprintf(stderr, "[*] False positive rate: ~%.3e (1 in ~%.3e)\n", err_rate, 1/err_rate);
    }

    bloom = chkmalloc(bloom_size);
    fprintf(stderr, "[*] Zeroing memory...\n");
    memset(bloom, 0, bloom_size);

    fprintf(stderr, "[*] Loading hash160s from '%s'   0.0%%", xopt);
    for (i = 0; i < items; ++i) {
      if (hfmt == 'H') {
        if ((r = fread(buf, 41, 1, hfile)) != 1) {
          bail(1, "[!] Error reading hex hashes\n");
        }
        unhex(buf, 40, hash.uc, sizeof(hash.uc));
      } else { // hfmt == 'B'
        if ((r = fread(hash.uc, 20, 1, hfile)) != 1) {
          bail(1, "[!] Error reading binary hashes\n");
        }
      }

      bloom_h160_set(bloom, hash.uc, h, mask);

      if ((i & 0x7ffff) == 0) {
        pct = 100.0 * i / items;
        fprintf(stderr, "\033[7D %5.1f%%", pct);
        fflush(stderr);
      }
    }

    fprintf(stderr, "\033[7D 100.0%%\n");

    bloom_set_hash(bloom, bloom_size, h);
    bloom_set_items(bloom, bloom_size, items);

    fprintf(stderr, "[*] Writing bloom filter to '%s'...\n", bopt);
    if (fwrite(bloom, bloom_size, 1, bfile) != 1) {
      bail(1, "[!] Failed to write bloom filter file '%s'\n", bopt);
    }
    fprintf(stderr, "[+] Success!\n");

    return 0;
  } else if (mode == 'R') {
    // ####################
    // ##                ##
    // ##   CHECK MODE   ##
    // ##                ##
    // ####################
    if (!bopt) bail(1, "[!] Bloom filter file must be specified with '-b'\n");
    if (dopt || xopt || ropt) {
      bail(1, "[!] Invalid combination of file options for check mode\n");
    }
    if (iopt && (ifile = fopen(iopt, "r")) == NULL) {
      bail(1, "[!] Failed to open input file '%s': %s\n", iopt, strerror(errno));
    }

    if (stat(bopt, &sb) == 0) {
      if (!S_ISREG(sb.st_mode)) {
        bail(1, "[!] Bloom filter file '%s' is not a regular file\n", bopt);
      }
      bloom_size = sb.st_size;
      if (!bloom_chk_size(bloom_size)) {
        bail(1, "[!] Bloom filter file '%s' is not a valid size\n", bopt);
      }
    } else {
      bail(1, "[!] Failed to stat '%s': %s\n", bopt, strerror(errno));
    }

    if ((r = mmapf(&bloom_mmapf, bopt, bloom_size, MMAPF_RNDRD)) != MMAPF_OKAY) {
      bail(1, "[!] Failed to open bloom filter '%s': %s\n", bopt, mmapf_strerror(r));
    } else if (bloom_mmapf.mem == NULL) {
      bail(1, "[!] Got NULL pointer trying to set up bloom filter\n");
    }

    bloom = bloom_mmapf.mem;
    h = bloom_get_hash(bloom, bloom_size);

    mask = bloom_size_to_mask(sb.st_size); // h == BFS_TYPE_SINGLE ? 0 : ((sb.st_size<<3ULL) & 0xffffffffff00)-1;
    //items = bloom_get_items(bloom, bloom_size);

    fprintf(stderr, "[*] Using function %s (0x%02x) with mask 0x%zx\n", bloom_deschash(h), h, mask);

    while ((r = getline(&line, &line_sz, ifile)) > 0) {
      if (r > 40) {
        unhex(line, 40, hash.uc, sizeof(hash.uc));
        if (bloom_h160_chk(bloom, hash.ul, h, mask)) {
          fprintf(ofile, "%s", line);
        }
      }
    }
  } else if (mode == 'D') {
    // ###################
    // ##               ##
    // ##   DIFF MODE   ##
    // ##               ##
    // ###################
    if (!ropt) bail(1, "[!] Old bloom filter file must be specified with '-r'\n");
    if (!bopt) bail(1, "[!] New bloom filter file must be specified with '-b'\n");
    if (!dopt) bail(1, "[!] Bloom filter diff file must be specified with '-d'\n");
    if (xopt) {
      bail(1, "[!] Invalid combination of file options for diff mode\n");
    }

    if (stat(bopt, &sb) == 0) {
      if (!S_ISREG(sb.st_mode)) {
        bail(1, "[!] Bloom filter file '%s' is not a regular file\n", bopt);
      }
      if (!bloom_chk_size(sb.st_size)) {
        bail(1, "[!] Bloom filter file '%s' is not a valid size\n", bopt);
      }
    } else {
      bail(1, "[!] Failed to stat '%s': %s\n", bopt, strerror(errno));
    }

    if ((r = mmapf(&bloom_mmapf, bopt, sb.st_size, MMAPF_SEQRD)) != MMAPF_OKAY) {
      bail(1, "[!] Failed to open bloom filter '%s': %s\n", bopt, mmapf_strerror(r));
    } else if (bloom_mmapf.mem == NULL) {
      bail(1, "[!] Got NULL pointer trying to set up bloom filter '%s'\n", bopt);
    }

    if (stat(ropt, &sb) == 0) {
      if (!S_ISREG(sb.st_mode)) {
        bail(1, "[!] Bloom filter file '%s' is not a regular file\n", ropt);
      }
      if (!bloom_chk_size(sb.st_size)) {
        bail(1, "[!] Bloom filter file '%s' is not a valid size\n", ropt);
      }
    } else {
      bail(1, "[!] Failed to stat '%s': %s\n", ropt, strerror(errno));
    }

    if ((r = mmapf(&reference_mmapf, ropt, sb.st_size, MMAPF_SEQRD)) != MMAPF_OKAY) {
      bail(1, "[!] Failed to open bloom filter '%s': %s\n", ropt, mmapf_strerror(r));
    } else if (reference_mmapf.mem == NULL) {
      bail(1, "[!] Got NULL pointer trying to set up bloom filter '%s'\n", ropt);
    }

    if (bloom_mmapf.file_sz != reference_mmapf.file_sz) {
      bail(1, "[!] Old and new bloom filter files are different sizes!\n");
    }

    if ((r = mmapf(&diff_mmapf, dopt, bloom_mmapf.file_sz, MMAPF_SEQCR)) != MMAPF_OKAY) {
      bail(1, "[!] Failed to open bloom filter diff '%s': %s\n", dopt, mmapf_strerror(r));
    } else if (diff_mmapf.mem == NULL) {
      bail(1, "[!] Got NULL pointer trying to set up bloom filter diff '%s'\n", ropt);
    }

    fprintf(stderr, "[*] Generating diff between '%s' and '%s'   0.0%%", ropt, bopt);
    for (int i = 0; i < bloom_mmapf.file_sz; ++i) {
      ((unsigned char *)diff_mmapf.mem)[i] = ((unsigned char *)reference_mmapf.mem)[i] ^ ((unsigned char *)bloom_mmapf.mem)[i];
      if ((i & 0x7ffff) == 0) {
        pct = 100.0 * i / bloom_mmapf.file_sz;
        fprintf(stderr, "\033[7D %5.1f%%", pct);
        fflush(stderr);
      }
    }
    fprintf(stderr, "\033[7D 100.0%%\n");
  } else if (mode == 'P') {
    // ####################
    // ##                ##
    // ##   PATCH MODE   ##
    // ##                ##
    // ####################
    if (!ropt) bail(1, "[!] Old bloom filter file must be specified with '-r'\n");
    if (!bopt) bail(1, "[!] New bloom filter file must be specified with '-b'\n");
    if (!dopt) bail(1, "[!] Bloom filter diff file must be specified with '-d'\n");
    if (xopt) {
      bail(1, "[!] Invalid combination of file options for diff mode\n");
    }
  } else {
    bail(1, "[!] No valid mode selected\n");
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rsi, %r15
movl %edi, %r12d
movq 0x7bc8(%rip), %rax      # 0x8fc8
movq (%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x7bb1(%rip), %rax      # 0x8fc0
andq $0x0, 0x60(%rsp)
movq (%rax), %rax
movq %rax, 0x70(%rsp)
andq $0x0, 0x78(%rsp)
movsd 0x4bdd(%rip), %xmm0     # 0x6008
movsd %xmm0, 0x20(%rsp)
movsd 0x4bd7(%rip), %xmm0     # 0x6010
movsd %xmm0, 0x58(%rsp)
movb $0x23, %al
movl %eax, 0x4(%rsp)
movq $0x0, 0x8(%rsp)
leaq 0x4ea3(%rip), %r13      # 0x62f8
leaq 0x4c1c(%rip), %rbx      # 0x6078
movq 0x7b75(%rip), %rbp      # 0x8fd8
movq $0x0, 0x50(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
xorl %r14d, %r14d
movl $0x0, 0x18(%rsp)
movl %r12d, %edi
movq %r15, %rsi
movq %r13, %rdx
callq 0x1210
leal -0x62(%rax), %ecx
cmpl $0x16, %ecx
ja 0x14ce
movslq (%rbx,%rcx,4), %rcx
addq %rbx, %rcx
jmpq *%rcx
movq (%rbp), %rax
movq %rax, 0x50(%rsp)
jmp 0x14a4
leal -0x3f(%rax), %ecx
cmpl $0x9, %ecx
ja 0x14f8
leaq 0x4b73(%rip), %rdx      # 0x6050
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl 0x18(%rsp), %edx
testb %dl, %dl
jne 0x2033
movl %eax, 0x18(%rsp)
jmp 0x14a4
cmpl $0x50, %eax
je 0x150b
cmpl $0x52, %eax
je 0x150b
cmpl $0x57, %eax
jne 0x15ac
testb %r14b, %r14b
jne 0x201c
movl %eax, %r14d
jmp 0x14a4
movq (%rbp), %rdi
callq 0x1230
movl %eax, 0x4(%rsp)
jmp 0x14a4
movq (%rbp), %rdi
callq 0x1230
movq %rax, 0x8(%rsp)
jmp 0x14a4
movq (%rbp), %rdi
callq 0x1070
movsd %xmm0, 0x20(%rsp)
jmp 0x14a4
movq (%rbp), %rax
movq %rax, 0x28(%rsp)
jmp 0x14a4
movq (%rbp), %rax
movq %rax, 0x40(%rsp)
jmp 0x14a4
movq (%rbp), %rdi
callq 0x1070
movsd %xmm0, 0x58(%rsp)
jmp 0x14a4
movq (%rbp), %rax
movq %rax, 0x48(%rsp)
jmp 0x14a4
movq (%rbp), %rax
movq %rax, 0x10(%rsp)
jmp 0x14a4
movq (%rbp), %rax
movq %rax, 0x30(%rsp)
jmp 0x14a4
cmpl $-0x1, %eax
jne 0x1604
movq 0x8(%rsp), %rsi
movb %sil, 0x3(%rsp)
movl 0x4(%rsp), %ecx
movb %cl, 0x2(%rsp)
cmpb $0x50, %r14b
jne 0x1675
cmpq $0x0, 0x10(%rsp)
movq 0x50(%rsp), %rax
je 0x2090
testq %rax, %rax
movq 0x28(%rsp), %rax
je 0x20bb
testq %rax, %rax
je 0x20ce
xorl %ebp, %ebp
cmpq $0x0, 0x30(%rsp)
je 0x1619
jmp 0x20e4
leaq 0x4d91(%rip), %rdi      # 0x639c
movl %eax, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x10c0
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
leaq 0x4ce1(%rip), %rbx      # 0x6317
pushq $0xa
popq %r14
xorl %r15d, %r15d
cmpl $0x100, %r15d           # imm = 0x100
je 0x1619
movzbl %r15b, %edi
callq 0x554d
movq %rbx, %rdi
movl %r15d, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x10c0
movl %r15d, %eax
notl %eax
testb $0x3, %al
jne 0x1670
movl %r14d, %edi
callq 0x1030
incl %r15d
jmp 0x163d
movzbl %r14b, %eax
cmpl $0x44, %eax
movq 0x50(%rsp), %rbp
movq 0x10(%rsp), %r12
je 0x1975
cmpl $0x52, %eax
movq 0x28(%rsp), %rdx
je 0x17fa
cmpl $0x57, %eax
jne 0x238d
testq %rbp, %rbp
je 0x20a3
cmpq $0x0, 0x30(%rsp)
je 0x2167
testq %rdx, %rdx
jne 0x2197
testq %r12, %r12
jne 0x2197
cmpq $0x0, 0x40(%rsp)
jne 0x2197
cmpq $0x0, 0x48(%rsp)
jne 0x2197
movb $-0x2, %r15b
movzbl %cl, %ebx
movzbl %sil, %r12d
testb %sil, %sil
je 0x1723
movq 0x7900(%rip), %r14      # 0x8ff8
movq (%r14), %rdi
leaq 0x4d47(%rip), %rsi      # 0x6449
movl %ebx, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x1130
movl %ebx, %edi
movl %r12d, %esi
callq 0x562b
movl %eax, %r15d
cmpb $-0x1, %al
je 0x23f5
leaq 0x59b2(%rip), %rsi      # 0x70dc
movq 0x30(%rsp), %rdi
callq 0x11f0
testq %rax, %rax
je 0x21ad
movq %rax, %r14
movl %r12d, 0x8(%rsp)
movq %rax, %rdi
callq 0x1160
leaq 0xf8(%rsp), %rsi
movl %eax, %edi
callq 0x1280
testl %eax, %eax
jne 0x21cc
movq %r14, 0x10(%rsp)
movq 0x128(%rsp), %r14
pushq $0x14
popq %r12
movq %r14, %rax
cqto
idivq %r12
movq %rdx, %rcx
testq %rdx, %rdx
sete %sil
pushq $0x29
popq %rdi
movq %r14, %rax
cqto
idivq %rdi
testq %rdx, %rdx
sete %al
orb %sil, %al
je 0x21f6
movl 0x18(%rsp), %r13d
testb %r13b, %r13b
jne 0x1bc3
testq %rcx, %rcx
sete %al
testq %rdx, %rdx
setne %dl
xorb %al, %dl
je 0x1b97
movq 0x10(%rsp), %rdi
callq 0x138c
testb %al, %al
js 0x2409
movq 0x781c(%rip), %rcx      # 0x8ff8
movq (%rcx), %rcx
je 0x241e
movl %eax, %r13d
movsbl %al, %edx
leaq 0x4db3(%rip), %rsi      # 0x65a5
movq %rcx, %rdi
jmp 0x1bb9
testq %rbp, %rbp
je 0x20a3
testq %rdx, %rdx
jne 0x217f
cmpq $0x0, 0x30(%rsp)
jne 0x217f
testq %r12, %r12
jne 0x217f
movq 0x40(%rsp), %rbx
testq %rbx, %rbx
je 0x1848
leaq 0x58aa(%rip), %rsi      # 0x70dc
movq %rbx, %rdi
callq 0x11f0
movq %rax, 0x68(%rsp)
testq %rax, %rax
je 0x23c3
leaq 0xf8(%rsp), %rsi
movq %rbp, %rdi
callq 0x1140
testl %eax, %eax
jne 0x20fc
movl $0xf000, %eax           # imm = 0xF000
andl 0x110(%rsp), %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x211e
movq 0x128(%rsp), %rbx
movq %rbx, %rdi
callq 0x55d5
testl %eax, %eax
je 0x2134
leaq 0x80(%rsp), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movl $0x2501, %ecx           # imm = 0x2501
callq 0x5a83
testl %eax, %eax
jne 0x214a
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x2211
movq %rdi, 0x18(%rsp)
movq %rbx, %rsi
callq 0x55fd
movl %eax, %ebx
movq 0x128(%rsp), %rdi
callq 0x55aa
movq %rax, %r14
movq 0x7712(%rip), %rax      # 0x8ff8
movq (%rax), %r12
movzbl %bl, %r15d
movl %r15d, %edi
callq 0x554d
leaq 0x5128(%rip), %rsi      # 0x6a24
xorl %ebp, %ebp
movq %r12, %rdi
movq %rax, %rdx
movl %r15d, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x1130
leaq 0x60(%rsp), %r12
leaq 0x78(%rsp), %r13
leaq 0xb8(%rsp), %rbx
movq %r12, %rdi
movq %r13, %rsi
movq 0x68(%rsp), %rdx
callq 0x1240
testl %eax, %eax
jle 0x1619
cmpl $0x29, %eax
jb 0x1923
movq 0x60(%rsp), %rdi
movq %rbx, %rsi
callq 0x2444
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
movl %r15d, %edx
movq %r14, %rcx
callq 0x247c
testl %eax, %eax
je 0x1923
movq 0x60(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x10e0
jmp 0x1923
testq %r12, %r12
movq 0x28(%rsp), %r14
je 0x2090
testq %rbp, %rbp
je 0x20bb
testq %r14, %r14
je 0x20ce
cmpq $0x0, 0x30(%rsp)
jne 0x20e4
leaq 0xf8(%rsp), %rsi
movq %rbp, %rdi
callq 0x1140
testl %eax, %eax
jne 0x20fc
movl $0xf000, %eax           # imm = 0xF000
andl 0x110(%rsp), %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x211e
movq 0x128(%rsp), %rbx
movq %rbx, %rdi
callq 0x55d5
testl %eax, %eax
je 0x2134
leaq 0x80(%rsp), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movl $0x2201, %ecx           # imm = 0x2201
callq 0x5a83
testl %eax, %eax
jne 0x214a
cmpq $0x0, 0x80(%rsp)
je 0x2227
leaq 0xf8(%rsp), %rsi
movq %r12, %rdi
callq 0x1140
testl %eax, %eax
jne 0x224d
movl $0xf000, %eax           # imm = 0xF000
andl 0x110(%rsp), %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x2291
movq 0x128(%rsp), %rbx
movq %rbx, %rdi
callq 0x55d5
testl %eax, %eax
je 0x22bc
leaq 0xb8(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
movl $0x2201, %ecx           # imm = 0x2201
callq 0x5a83
testl %eax, %eax
jne 0x2309
cmpq $0x0, 0xb8(%rsp)
je 0x232c
movq 0x90(%rsp), %rdx
cmpq 0xc8(%rsp), %rdx
jne 0x233f
leaq 0xd8(%rsp), %rdi
movq %r14, %rsi
movl $0x20e, %ecx            # imm = 0x20E
callq 0x5a83
testl %eax, %eax
jne 0x2357
cmpq $0x0, 0xd8(%rsp)
movq 0x7528(%rip), %r14      # 0x8ff8
movq (%r14), %rdi
je 0x2377
leaq 0x5130(%rip), %rsi      # 0x6c10
xorl %r15d, %r15d
movq %r12, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x1130
leaq 0x4d76(%rip), %rbx      # 0x686d
cmpq %r15, 0x90(%rsp)
jbe 0x1b7f
movq 0xb8(%rsp), %rax
movq 0x80(%rsp), %rcx
movb (%rcx,%r15), %cl
xorb (%rax,%r15), %cl
movq 0xd8(%rsp), %rax
movb %cl, (%rax,%r15)
testl $0x7ffff, %r15d         # imm = 0x7FFFF
je 0x1b33
incq %r15
jmp 0x1af7
cvtsi2sd %r15d, %xmm0
mulsd 0x44d8(%rip), %xmm0     # 0x6018
movsd 0x90(%rsp), %xmm1
unpcklps 0x44e0(%rip), %xmm1     # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x44e8(%rip), %xmm1     # 0x6040
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movq (%r14), %rdi
movq %rbx, %rsi
movb $0x1, %al
callq 0x1130
movq (%r14), %rdi
callq 0x1170
jmp 0x1b2e
movq (%r14), %rdi
leaq 0x4cf1(%rip), %rsi      # 0x687a
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1130
jmp 0x1619
testq %rcx, %rcx
pushq $0x42
popq %rax
pushq $0x48
popq %r13
cmovel %eax, %r13d
movq 0x744c(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x495b(%rip), %rsi      # 0x6511
movl %r13d, %edx
xorl %eax, %eax
callq 0x1130
pushq $0x29
popq %rdi
movl %r13d, 0x18(%rsp)
cmpb $0x48, %r13b
cmoveq %rdi, %r12
movq %r14, %rax
cqto
idivq %r12
movq %rax, %r14
movq 0x7416(%rip), %rax      # 0x8ff8
movq %rax, %r12
movq (%rax), %rdi
movzbl %r15b, %edx
leaq 0x49df(%rip), %rsi      # 0x65d2
movl %ebx, %ecx
xorl %eax, %eax
callq 0x1130
cmpq $0x1, %r14
je 0x1c5b
testq %r14, %r14
je 0x23fa
cmpb $-0x2, %r15b
jb 0x1c70
xorpd %xmm0, %xmm0
movsd 0x20(%rsp), %xmm1
ucomisd %xmm1, %xmm0
movq (%r12), %rdi
jbe 0x1fc2
leaq 0x49cd(%rip), %rsi      # 0x65fd
movl %ebx, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1130
leaq 0x3(%rsp), %rdx
movl %ebx, %edi
movq %r14, %rsi
callq 0x56d4
movl %eax, %r15d
cmpb $-0x2, %al
movl 0x4(%rsp), %eax
jb 0x1c74
jmp 0x2429
pushq $0x1
popq %rdi
callq 0x555c
movb $0x1, %r15b
movq %rax, 0x8(%rsp)
testq %rax, %rax
jne 0x1c8a
movl 0x4(%rsp), %eax
movzbl %al, %edi
callq 0x555c
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x23b4
leaq 0xf8(%rsp), %rsi
movq %rbp, %rdi
callq 0x1140
testl %eax, %eax
je 0x223a
movq %rbp, %rdi
movl $0xc2, %esi
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x11d0
testl %eax, %eax
js 0x226f
leaq 0x4a1a(%rip), %rsi      # 0x66df
movl %eax, %edi
callq 0x11a0
movq (%r12), %r9
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x22a7
movq %r12, %rbp
movzbl %r15b, %r15d
movzbl 0x2(%rsp), %ecx
movzbl 0x3(%rsp), %r8d
leaq 0x4a1e(%rip), %rsi      # 0x6715
movq %r9, %rdi
movl %r15d, %edx
movq %r14, %r9
xorl %eax, %eax
callq 0x1130
movzbl 0x2(%rsp), %edi
callq 0x558a
movq %r14, %rbx
movq %rax, %r14
movzbl 0x3(%rsp), %edi
movb 0x2(%rsp), %cl
pushq $0x1
popq %rsi
shlq %cl, %rsi
movq %rbx, %rdx
callq 0x54d4
movsd %xmm0, 0x40(%rsp)
movzbl 0x3(%rsp), %eax
cvtsi2sd %eax, %xmm1
callq 0x1090
movsd %xmm0, 0x28(%rsp)
movq (%r12), %r12
movl %r15d, %edi
callq 0x554d
leaq 0x49db(%rip), %rsi      # 0x6736
movq %r12, %rdi
movq %rax, %rdx
movl %r15d, 0x4(%rsp)
movl %r15d, %ecx
movq %r14, %r13
movq %r14, %r8
xorl %eax, %eax
callq 0x1130
movq (%rbp), %rdi
movq 0x8(%rsp), %r15
leaq -0x48(,%r15,8), %rcx
leaq 0x49d7(%rip), %rsi      # 0x6765
movq %rbx, 0x48(%rsp)
movq %rbx, %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0x1130
movq (%rbp), %rdi
leaq 0x49f7(%rip), %rsi      # 0x67a2
movsd 0x40(%rsp), %xmm0
movb $0x1, %al
callq 0x1130
movq (%rbp), %rdi
movsd 0x425c(%rip), %xmm1     # 0x6020
movsd 0x28(%rsp), %xmm0
divsd %xmm0, %xmm1
leaq 0x49e4(%rip), %rsi      # 0x67b9
movb $0x2, %al
callq 0x1130
pushq $0x1
popq %rdi
movq %r15, %rsi
callq 0x1120
movq (%rbp), %r12
testq %rax, %rax
je 0x22d2
movq %rax, %rbx
leaq 0x49f2(%rip), %rdi      # 0x67f0
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
movq %r12, %rcx
callq 0x1260
movq (%rbp), %rdi
leaq 0x49f0(%rip), %rsi      # 0x6807
xorl %ebp, %ebp
movq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x1130
movq 0x48(%rsp), %rax
movq %rax, %r15
movq %rax, %xmm0
punpckldq 0x41f6(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x41fe(%rip), %xmm0     # 0x6040
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
leaq 0x80(%rsp), %r14
leaq 0xb8(%rsp), %r12
cmpq %rbp, %r15
movl 0x18(%rsp), %eax
je 0x1f33
cmpb $0x48, %al
jne 0x1e9e
movq %r14, %rdi
pushq $0x29
popq %rsi
pushq $0x1
popq %rdx
movq 0x10(%rsp), %rcx
callq 0x1060
cmpl $0x1, %eax
jne 0x2078
movq %r14, %rdi
movq %r12, %rsi
callq 0x2444
jmp 0x1eba
movq %r12, %rdi
pushq $0x14
popq %rsi
pushq $0x1
popq %rdx
movq 0x10(%rsp), %rcx
callq 0x1060
cmpl $0x1, %eax
jne 0x2060
movq %rbx, %rdi
movq %r12, %rsi
movl 0x4(%rsp), %edx
movq %r13, %rcx
callq 0x50ac
movq %rbp, %rax
shlq $0x2d, %rax
je 0x1ee2
incq %rbp
leaq 0x80(%rsp), %r14
jmp 0x1e64
movq %rbp, %xmm1
punpckldq 0x4141(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x4149(%rip), %xmm1     # 0x6040
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x410d(%rip), %xmm0     # 0x6018
divsd 0x30(%rsp), %xmm0
movq 0x70e0(%rip), %r14      # 0x8ff8
movq (%r14), %rdi
leaq 0x494b(%rip), %rsi      # 0x686d
movb $0x1, %al
callq 0x1130
movq (%r14), %rdi
callq 0x1170
jmp 0x1ed5
movq 0x70be(%rip), %r13      # 0x8ff8
movq (%r13), %rdi
leaq 0x4935(%rip), %rsi      # 0x687a
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1130
movq %rbx, %rdi
movq 0x8(%rsp), %r12
movq %r12, %rsi
movl 0x4(%rsp), %edx
callq 0x560e
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x5625
movq (%r13), %rdi
leaq 0x490d(%rip), %rsi      # 0x6888
movq 0x50(%rsp), %r14
movq %r14, %rdx
xorl %eax, %eax
callq 0x1130
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
movq 0x20(%rsp), %rcx
callq 0x1260
movq (%r13), %rcx
cmpq $0x1, %rax
jne 0x23a5
leaq 0x4927(%rip), %rdi      # 0x68d9
pushq $0xd
popq %rsi
pushq $0x1
popq %rdx
callq 0x1260
jmp 0x1619
movapd %xmm1, %xmm0
leaq 0x464f(%rip), %rsi      # 0x661c
movsd %xmm1, 0x20(%rsp)
movsd 0x58(%rsp), %xmm1
movq %r14, %rdx
movl %ebx, %ecx
movl 0x8(%rsp), %r8d
movb $0x2, %al
callq 0x1130
leaq 0x2(%rsp), %rsi
leaq 0x3(%rsp), %rdx
movsd 0x20(%rsp), %xmm0
movsd 0x58(%rsp), %xmm1
movq %r14, %rdi
callq 0x57d6
cmpb $-0x3, %al
ja 0x2429
movl %eax, %r15d
movb 0x2(%rsp), %al
jmp 0x1c74
movq 0x6fd5(%rip), %rcx      # 0x8ff8
movq (%rcx), %rdi
movsbl %r14b, %edx
leaq 0x42f7(%rip), %rsi      # 0x6328
jmp 0x2047
movq 0x6fbe(%rip), %rcx      # 0x8ff8
movq (%rcx), %rdi
movsbl %dl, %edx
leaq 0x431a(%rip), %rsi      # 0x6361
movl %eax, %ecx
xorl %eax, %eax
callq 0x1130
pushq $0x1
popq %rdi
callq 0x1250
movq (%r15), %rdi
callq 0x13c8
movq 0x6f91(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x47db(%rip), %rdi      # 0x684c
pushq $0x20
jmp 0x2436
movq 0x6f79(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x47a5(%rip), %rdi      # 0x682e
pushq $0x1d
jmp 0x2436
movq 0x6f61(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x49b3(%rip), %rdi      # 0x6a54
jmp 0x20f5
movq 0x6f4e(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x42fe(%rip), %rdi      # 0x63b2
pushq $0x32
jmp 0x2436
movq 0x6f36(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x49bf(%rip), %rdi      # 0x6a8b
jmp 0x20f5
movq 0x6f23(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x49e3(%rip), %rdi      # 0x6ac2
jmp 0x2190
movq 0x6f0d(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x4a05(%rip), %rdi      # 0x6afa
pushq $0x36
jmp 0x2436
movq 0x6ef5(%rip), %rax      # 0x8ff8
movq (%rax), %rbx
callq 0x1040
movl (%rax), %edi
callq 0x1270
leaq 0x4890(%rip), %rsi      # 0x69a9
jmp 0x2286
movq 0x6ed3(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x4818(%rip), %rsi      # 0x6947
jmp 0x2245
movq 0x6ebd(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x4834(%rip), %rsi      # 0x6979
jmp 0x2245
movq 0x6ea7(%rip), %rcx      # 0x8ff8
movq (%rcx), %rbx
movl %eax, %edi
callq 0x5a04
leaq 0x4864(%rip), %rsi      # 0x69c6
jmp 0x2286
movq 0x6e8a(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x426d(%rip), %rdi      # 0x63e5
pushq $0x2a
jmp 0x2436
movq 0x6e72(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x4757(%rip), %rdi      # 0x68e7
pushq $0x37
jmp 0x2436
movq 0x6e5a(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x4268(%rip), %rdi      # 0x6410
jmp 0x2350
movq 0x6e44(%rip), %rax      # 0x8ff8
movq (%rax), %rbx
callq 0x1040
movl (%rax), %edi
callq 0x1270
leaq 0x42d1(%rip), %rsi      # 0x649b
jmp 0x21e9
movq 0x6e25(%rip), %rax      # 0x8ff8
movq (%rax), %rbx
callq 0x1040
movl (%rax), %edi
callq 0x1270
leaq 0x42d9(%rip), %rsi      # 0x64c2
movq %rbx, %rdi
movq 0x30(%rsp), %rdx
jmp 0x23e6
movq 0x6dfb(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x42e2(%rip), %rsi      # 0x64e9
movq 0x30(%rsp), %rdx
jmp 0x2381
movq 0x6de0(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x47ce(%rip), %rdi      # 0x69f0
jmp 0x2434
movq 0x6dca(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x48f9(%rip), %rsi      # 0x6b31
jmp 0x2245
movq (%r12), %rdi
leaq 0x443e(%rip), %rsi      # 0x6683
movq %rbp, %rdx
jmp 0x2381
movq 0x6da4(%rip), %rax      # 0x8ff8
movq (%rax), %rbx
callq 0x1040
movl (%rax), %edi
callq 0x1270
leaq 0x473f(%rip), %rsi      # 0x69a9
jmp 0x2321
movq (%r12), %rbx
callq 0x1040
movl (%rax), %edi
callq 0x1270
leaq 0x4428(%rip), %rsi      # 0x66ae
movq %rbx, %rdi
movq %rbp, %rdx
jmp 0x23e6
movq 0x6d60(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x46a5(%rip), %rsi      # 0x6947
jmp 0x237e
leaq 0x4434(%rip), %rdi      # 0x66e2
pushq $0x32
popq %rsi
pushq $0x1
popq %rdx
movq %r9, %rcx
jmp 0x243a
movq 0x6d35(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x46ac(%rip), %rsi      # 0x6979
jmp 0x237e
callq 0x1040
movl (%rax), %edi
callq 0x1270
leaq 0x4979(%rip), %rsi      # 0x6c5e
leaq 0x44fa(%rip), %rcx      # 0x67e6
movq %r12, %rdi
movq 0x8(%rsp), %rdx
movl $0x110, %r8d            # imm = 0x110
movq %rax, %r9
xorl %eax, %eax
callq 0x1130
jmp 0x2050
movq 0x6ce8(%rip), %rcx      # 0x8ff8
movq (%rcx), %rbx
movl %eax, %edi
callq 0x5a04
leaq 0x46a5(%rip), %rsi      # 0x69c6
movq %rbx, %rdi
movq %r12, %rdx
jmp 0x23e6
movq 0x6cc5(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
leaq 0x47f4(%rip), %rsi      # 0x6b31
jmp 0x237e
movq 0x6cb2(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x481a(%rip), %rdi      # 0x6b6a
pushq $0x38
jmp 0x2436
movq 0x6c9a(%rip), %rcx      # 0x8ff8
movq (%rcx), %rbx
movl %eax, %edi
callq 0x5a04
leaq 0x4834(%rip), %rsi      # 0x6ba3
movq %rbx, %rdi
movq %r14, %rdx
jmp 0x23e6
leaq 0x4854(%rip), %rsi      # 0x6bd2
movq %r12, %rdx
xorl %eax, %eax
callq 0x1130
jmp 0x2050
movq 0x6c64(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x48a4(%rip), %rdi      # 0x6c42
pushq $0x1b
jmp 0x2436
leaq 0x4501(%rip), %rsi      # 0x68ad
movq %rcx, %rdi
movq %r14, %rdx
jmp 0x2381
movq (%r12), %rcx
leaq 0x428f(%rip), %rdi      # 0x664e
pushq $0x34
jmp 0x2436
movq 0x6c2e(%rip), %rax      # 0x8ff8
movq (%rax), %r14
callq 0x1040
movl (%rax), %edi
callq 0x1270
leaq 0x453f(%rip), %rsi      # 0x691f
movq %r14, %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1130
jmp 0x2050
movq (%r14), %rcx
jmp 0x242d
movq (%r12), %rcx
leaq 0x41e1(%rip), %rdi      # 0x65e6
pushq $0x16
jmp 0x2436
movq 0x6be8(%rip), %rax      # 0x8ff8
movq (%rax), %rcx
leaq 0x4121(%rip), %rdi      # 0x653b
pushq $0x25
jmp 0x2436
leaq 0x413c(%rip), %rdi      # 0x6561
pushq $0x43
jmp 0x2436
movq (%r12), %rcx
leaq 0x4033(%rip), %rdi      # 0x6467
pushq $0x33
popq %rsi
pushq $0x1
popq %rdx
callq 0x1260
jmp 0x2050