// File: /workspace/github_c_makefile_star2_O0/negge[P]xlink/src/xlink.c
// Function: xlink_binary_link
void xlink_binary_link(xlink_binary *bin, unsigned int flags) {
  int bss_idx;
  xlink_segment *start;
  xlink_segment *main;
  xlink_segment *prog;
  int s;
  /* Stage -1: Load all modules */
  xlink_binary_load_modules(bin);
  /* Stage 0: Find the entry point segment */
  main = xlink_binary_find_segment_by_public(bin, bin->entry, OMF_SEGMENT_CODE);
  bin->is_32bit = main->attrib.proc == OMF_SEGMENT_USE32;
  /* Stage 0a: Set the 16-bit starting segment */
  if (!bin->is_32bit) {
    start = main;
    XLINK_ERROR(bin->init != NULL,
     ("Cannot set 16-bit initializer function when linking 16-bit COM file"));
    /* TODO: Support packing 16-bit programs */
    XLINK_ERROR(flags & MOD_PACK,
     ("Only 32-bit programs can be packed, %s is 16-bit", bin->entry));
  }
  else {
    char *stub;
    if (flags & MOD_PACK) {
      if (flags & MOD_CLAMP) {
        if (flags & MOD_LOW) {
          if (flags & MOD_BASE) {
            /* Load the 32-bit unpacking stub */
            stub = bin->init ? "stub32pcfbi" : "stub32pcfb";
          }
          else {
            /* Load the 32-bit unpacking stub */
            stub = bin->init ? "stub32pcfi" : "stub32pcf";
          }
        }
        else {
          if (flags & MOD_BASE) {
            /* Load the 32-bit unpacking stub */
            stub = bin->init ? "stub32pcbi" : "stub32pcb";
          }
          else {
            /* Load the 32-bit unpacking stub */
            stub = bin->init ? "stub32pci" : "stub32pc";
          }
        }
      }
      else {
        if (flags & MOD_LOW) {
          if (flags & MOD_BASE) {
            /* Load the 32-bit unpacking stub */
            stub = bin->init ? "stub32pfbi" : "stub32pfb";
          }
          else {
            /* Load the 32-bit unpacking stub */
            stub = bin->init ? "stub32pfi" : "stub32pf";
          }
        }
        else {
          if (flags & MOD_BASE) {
            /* Load the 32-bit unpacking stub */
            stub = bin->init ? "stub32pbi" : "stub32pb";
          }
          else {
            /* Load the 32-bit unpacking stub */
            stub = bin->init ? "stub32pi" : "stub32p";
          }
        }
      }
    }
    else {
      if (flags & MOD_EXIT) {
        if (flags & MOD_BASE) {
          stub = bin->init ? "stub32ebi" : "stub32eb";
        }
        else {
          stub = bin->init ? "stub32ei" : "stub32e";
        }
      }
      else {
        if (flags & MOD_BASE) {
          stub = bin->init ? "stub32bi" : "stub32b";
        }
        else {
          /* If there is a 16-bit initialization function, use STUB32I */
          stub = bin->init ? "stub32i" : "stub32";
        }
      }
    }
    printf("Using %s\n", stub);
    /* Load the stub segment */
    xlink_binary_load_stub(bin, stub);
    /* Find the stub segment */
    start = xlink_binary_find_segment_by_public(bin, stub, OMF_SEGMENT_CODE);
    /* If there is an external init_ function, find and rewrite it */
    if (bin->init) {
      strcpy(xlink_module_find_extern(start->module, "init_")->name, bin->init);
    }
    if (flags & MOD_PACK) {
      prog =
       xlink_binary_find_segment_by_public(bin, "ec_bits", OMF_SEGMENT_BSS);
    }
    else {
      /* The stub code calls an external main_ function, find and rewrite it */
      strcpy(xlink_module_find_extern(start->module, "main_")->name, bin->entry);
    }
  }
  /* Stage 1: Resolve all symbol references, starting from start */
  xlink_binary_link_root_segment(bin, start);
  /* Stage 1a: Link main segment when MOD_EXIT, as start missing main_ extern */
  if (flags & MOD_EXIT) {
    xlink_binary_link_root_segment(bin, main);
  }
  /* Stage 2: Sort segments by class (CODE, DATA, BSS) */
  xlink_sort_segments(bin->segments, bin->nsegments, NULL, &bss_idx);
  /* Stage 2a: Set _MAIN as the first CODE segment */
  xlink_set_first_segment(&bin->segments[0], start);
  /* Stage 2b: Set main as the second CODE segment when MOD_EXIT */
  if (flags & MOD_EXIT) {
    xlink_set_first_segment(&bin->segments[1], main);
  }
  if (flags & MOD_PACK) {
    XLINK_ERROR(bss_idx == bin->nsegments,
     ("Error no BSS segment contained in stub32p"));
    /* Stage 2b: Set _PROG as the first BSS segment */
    xlink_set_first_segment(&bin->segments[bss_idx], prog);
  }
  /* Stage 3: Lay segments in memory with proper alignment starting at 100h */
  xlink_binary_layout_segments(bin, 0, 0x100);
  s = bin->nsegments;
  /* Stage 4: Apply relocations to the program segments */
  xlink_apply_relocations(bin->segments, s);
  if (flags & MOD_PACK) {
    int data_idx;
    int offset;
    xlink_ec_segment code;
    xlink_ec_segment data;
    unsigned char byte;
    xlink_bitstream bs;
    int size;
    if (flags & MOD_BASE) {
      xlink_segment *base;
      base =
       xlink_binary_find_segment_by_public(bin, "_XLINK_base", OMF_SEGMENT_BSS);
      XLINK_ERROR(xlink_binary_has_segment(bin, base),
       ("Error, XLINK_base in 16-bit BSS, but set by 32-bit packing stub"));
    }
    /* Stage 4: Resolve all symbol references, starting from 32-bit entry */
    xlink_binary_link_root_segment(bin, main);
    /* Stage 5: Sort segments by class (CODE, DATA, BSS) */
    xlink_sort_segments(bin->segments + s, bin->nsegments - s, &data_idx, NULL);
    /* Stage 5a: Set main as the first CODE segment */
    xlink_set_first_segment(&bin->segments[s], main);
    if (flags & MOD_BASE) {
      xlink_segment *base;
      base =
       xlink_binary_find_segment_by_public(bin, "_XLINK_base", OMF_SEGMENT_BSS);
      xlink_binary_link_root_segment(bin, base);
      xlink_set_first_segment(&bin->segments[s], base);
      base->start = 0x10000;
      s++;
    }
    /* Stage 6: Lay segments in memory with alignment starting at 10010h */
    xlink_binary_layout_segments(bin, s, 0x10010);
    /* Stage 7: Apply relocations to the payload program segments */
    xlink_apply_relocations(bin->segments + s, bin->nsegments - s);
    /* Stage 8: Extract the CODE and DATA segments */
    xlink_ec_segment_init(&code);
    xlink_ec_segment_init(&data);
    offset = xlink_binary_extract_class(bin, s + 0, 0x10010, OMF_SEGMENT_CODE,
     &code.bytes);
    offset = xlink_binary_extract_class(bin, s + data_idx, offset,
     OMF_SEGMENT_DATA, &data.bytes);
    if (flags & MOD_ONE) {
      /* If only one EC segment, append the data.bytes to code.bytes */
      xlink_list_append(&code.bytes, &data.bytes);
      xlink_list_empty(&data.bytes);
    }
    printf("code bytes = %i\n", xlink_list_length(&code.bytes));
    printf("data bytes = %i\n", xlink_list_length(&data.bytes));
    /* Stage 9: Search for the best context to use for CODE segment bytes */
    xlink_model_search(&code.models, &code.bytes);
    code.header_size = xlink_header_length(&code.models);
    code.state = xlink_model_compute_packed_weights(&code.models);
    if (xlink_list_length(&data.bytes) > 0) {
      /* State 9a: Search for the best context to use for DATA segment bytes */
      xlink_model_search(&data.models, &data.bytes);
      data.header_size = xlink_header_length(&data.models);
      data.state = xlink_model_compute_packed_weights(&data.models);
    }
    byte = xlink_binary_get_relative_byte(bin, prog, -code.header_size);
    /* Set the parity of the CODE and DATA state based on byte */
    if (xlink_list_length(&data.bytes) == 0) {
      if (xlink_parity(byte) == xlink_parity(code.state & 0xff)) {
        code.state ^= 1;
      }
    }
    else {
      if (xlink_parity(byte) != xlink_parity(code.state & 0xff)) {
        code.state ^= 1;
      }
      if (xlink_parity(byte) == xlink_parity(data.state & 0xff)) {
        data.state ^= 1;
      }
    }
    /* Update the model states based on the segment states */
    xlink_model_set_state(&code.models, code.state);
    xlink_model_set_state(&data.models, data.state);
    /* Stage 10: Compress the CODE and DATA segments with perfect hashing */
    xlink_bitstream_from_segments(&bs, &code, &data, 0, flags & MOD_LOW,
     flags & MOD_CLAMP);
    size = code.header_size + data.header_size + (bs.bits + 7)/8;
    printf("Perfect hashing: %i bits, %i bytes\n", bs.bits, (bs.bits + 7)/8);
    printf("Compressed size: %i bytes -> %2.3lf%% smaller\n", size,
     XLINK_RATIO(size, code.bytes.length + data.bytes.length));
    xlink_bitstream_clear(&bs);
    /* Stage 10: Compress the CODE and DATA segments with replacement hashing */
    xlink_bitstream_from_segments(&bs, &code, &data, bin->hash_table_memory/2,
     flags & MOD_LOW, flags & MOD_CLAMP);
    size = code.header_size + data.header_size + (bs.bits + 7)/8;
    printf("Replacement hashing: %i bits, %i bytes\n", bs.bits, (bs.bits + 7)/8);
    printf("Compressed size: %i bytes -> %2.3lf%% smaller\n", size,
     XLINK_RATIO(size, code.bytes.length + data.bytes.length));
    /* Write payload into the prog segment data */
    {
      int i;
      xlink_binary_set_public_offset(bin, "ec_bits",
       code.header_size + data.header_size);
      /* Need to allocate space for the ec_segs header and ec_bits data */
      XLINK_ERROR(size > prog->length,
       ("Compressed binary data %i larger than reserved PROG space %i", size,
       prog->length));
      prog->length = code.header_size + data.header_size + (bs.bits + 7)/8;
      printf("prog->length = %i\n", prog->length);
      prog->data = xlink_malloc(prog->length);
      prog->info |= SEG_HAS_DATA;
      ((unsigned int *)prog->data)[0] =
       0xFFFEFFF0 - code.bytes.length;
      ((unsigned int *)prog->data)[1] = code.state;
      for (i = 0; i < xlink_list_length(&code.models); i++) {
        xlink_model *model;
        model = xlink_list_get(&code.models, i);
        prog->data[8 + i] = model->mask;
      }
      if (xlink_list_length(&data.bytes) > 0) {
        ((unsigned int *)&prog->data[code.header_size])[0] =
         0xFFFEFFF0 - code.bytes.length - data.bytes.length;
        ((unsigned int *)&prog->data[code.header_size])[1] = data.state;
        for (i = 0; i < xlink_list_length(&data.models); i++) {
          xlink_model *model;
          model = xlink_list_get(&data.models, i);
          prog->data[code.header_size + 8 + i] = model->mask;
        }
      }
      xlink_bitstream_copy_bits(&bs, prog->data,
       (code.header_size + data.header_size)*8);
      printf("ec_bits->offset = %i\n", code.header_size + data.header_size);
    }
    xlink_bitstream_clear(&bs);
    /* Fix up the compressing stub */
    {
      xlink_reloc *ec_segs;
      xlink_public *header;
      xlink_binary_set_public_offset(bin, "hash_table_segs",
       (bin->hash_table_memory + 65535)/65536);
      xlink_binary_set_public_offset(bin, "hash_table_words",
       bin->hash_table_memory/2);
      ec_segs = xlink_segment_find_reloc(start, "ec_segs");
      ec_segs->addend.offset = -code.header_size;
      /* Apply relocations again to put the fixups into effect */
      xlink_apply_relocations(bin->segments, s);
      if (!bin->init) {
        xlink_public *heap;
        heap = xlink_binary_find_public(bin, "XLINK_heap_offset");
        start->data[heap->offset] += code.header_size;
      }
      header = xlink_binary_find_public(bin, "XLINK_header_size");
      start->data[header->offset] = code.header_size;
      XLINK_ERROR(
       byte != xlink_binary_get_relative_byte(bin, prog, -code.header_size),
       ("Parity byte %i modified after relocation, %02X != %02X",
       code.header_size, byte,
       xlink_binary_get_relative_byte(bin, prog, -code.header_size)));
      if (!xlink_parity(byte)) {
        /* Flip the direction of branch after segment done */
        start->data[header->offset + 1] ^= 1;
      }
    }
    xlink_ec_segment_clear(&code);
    xlink_ec_segment_clear(&data);
  }
  /* Optionally write the map file. */
  if (bin->map != NULL) {
    xlink_binary_write_map(bin);
  }
  /* Stage 5: Write the COM file to disk a segment at a time */
  xlink_binary_write_com(bin, s);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8320
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
xorl %edx, %edx
callq 0x8510
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movb 0x10(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
sete %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x64(%rax)
jne 0x8b0b
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x8ad5
leaq 0x6812(%rip), %rdi      # 0xf2d6
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x8ad7
jmp 0x8ad9
movl -0xc(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x8b04
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x6827(%rip), %rdi      # 0xf31a
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x8b06
jmp 0x8e0f
movl -0xc(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x8ca1
movl -0xc(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x8be5
movl -0xc(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x8b8b
movl -0xc(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x8b67
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x6805(%rip), %rax      # 0xf357
leaq 0x67f2(%rip), %rcx      # 0xf34b
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x8b89
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x67f7(%rip), %rax      # 0xf36d
leaq 0x67e5(%rip), %rcx      # 0xf362
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x8be0
movl -0xc(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x8bbc
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x67db(%rip), %rax      # 0xf382
leaq 0x67c9(%rip), %rcx      # 0xf377
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x8bde
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x67cb(%rip), %rax      # 0xf396
leaq 0x67ba(%rip), %rcx      # 0xf38c
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x8be0
jmp 0x8c9c
movl -0xc(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x8c45
movl -0xc(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x8c21
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x679e(%rip), %rax      # 0xf3aa
leaq 0x678c(%rip), %rcx      # 0xf39f
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x8c43
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x678e(%rip), %rax      # 0xf3be
leaq 0x677d(%rip), %rcx      # 0xf3b4
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x8c9a
movl -0xc(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x8c76
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x6770(%rip), %rax      # 0xf3d1
leaq 0x675f(%rip), %rcx      # 0xf3c7
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x8c98
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x67d5(%rip), %rax      # 0xf45a
leaq 0x674e(%rip), %rcx      # 0xf3da
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x8c9a
jmp 0x8c9c
jmp 0x8d5a
movl -0xc(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x8d03
movl -0xc(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x8cdf
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x6723(%rip), %rax      # 0xf3ed
leaq 0x6712(%rip), %rcx      # 0xf3e3
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x8d01
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x6711(%rip), %rax      # 0xf3ff
leaq 0x6701(%rip), %rcx      # 0xf3f6
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x8d58
movl -0xc(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x8d34
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x66f1(%rip), %rax      # 0xf410
leaq 0x66e1(%rip), %rcx      # 0xf407
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x8d56
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x640f(%rip), %rax      # 0xf152
leaq 0x66ce(%rip), %rcx      # 0xf418
cmpq $0x0, %rdx
cmovneq %rcx, %rax
movq %rax, -0x38(%rbp)
jmp 0x8d58
jmp 0x8d5a
movq -0x38(%rbp), %rsi
leaq 0x66bb(%rip), %rdi      # 0xf420
movb $0x0, %al
callq 0x20a0
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x83d0
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x8510
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x8dbf
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x6684(%rip), %rsi      # 0xf42a
callq 0x3da0
movq %rax, %rdi
addq $0x10, %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x2040
movl -0xc(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x8de5
movq -0x8(%rbp), %rdi
leaq 0x665b(%rip), %rsi      # 0xf430
movl $0x2, %edx
callq 0x8510
movq %rax, -0x28(%rbp)
jmp 0x8e0d
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x5a38(%rip), %rsi      # 0xe82c
callq 0x3da0
movq %rax, %rdi
addq $0x10, %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x2040
jmp 0x8e0f
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x7af0
movl -0xc(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x8e36
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x7af0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x50(%rax), %esi
xorl %eax, %eax
movl %eax, %edx
leaq -0x10(%rbp), %rcx
callq 0x7bd0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x7c90
movl -0xc(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x8e85
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
addq $0x8, %rdi
movq -0x20(%rbp), %rsi
callq 0x7c90
movl -0xc(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x8ed4
jmp 0x8e92
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jne 0x8eb6
leaq 0x6593(%rip), %rdi      # 0xf438
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x8eb8
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movslq -0x10(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x7c90
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x7cf0
movq -0x8(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movl -0x2c(%rbp), %esi
callq 0x7e10
movl -0xc(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x9828
movl -0xc(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x8f67
movq -0x8(%rbp), %rdi
leaq 0x653d(%rip), %rsi      # 0xf462
movl $0x2, %edx
callq 0x8510
movq %rax, -0xe8(%rbp)
movq -0x8(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x4510
cmpl $0x0, %eax
je 0x8f63
leaq 0x651c(%rip), %rdi      # 0xf46e
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x8f65
jmp 0x8f67
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x7af0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movslq -0x2c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movl 0x50(%rax), %esi
subl -0x2c(%rbp), %esi
leaq -0x3c(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x7bd0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movslq -0x2c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x7c90
movl -0xc(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x9029
movq -0x8(%rbp), %rdi
leaq 0x6490(%rip), %rsi      # 0xf462
movl $0x2, %edx
callq 0x8510
movq %rax, -0xf0(%rbp)
movq -0x8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
callq 0x7af0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movslq -0x2c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0xf0(%rbp), %rsi
callq 0x7c90
movq -0xf0(%rbp), %rax
movl $0x10000, 0x7c(%rax)    # imm = 0x10000
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl $0x10010, %edx          # imm = 0x10010
callq 0x7cf0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movslq -0x2c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movl 0x50(%rax), %esi
subl -0x2c(%rbp), %esi
callq 0x7e10
leaq -0x78(%rbp), %rdi
callq 0x8000
leaq -0xb0(%rbp), %rdi
callq 0x8000
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
addl $0x0, %esi
leaq -0x78(%rbp), %r8
movl $0x10010, %edx          # imm = 0x10010
xorl %ecx, %ecx
callq 0x7e50
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
addl -0x3c(%rbp), %esi
movl -0x40(%rbp), %edx
leaq -0xb0(%rbp), %r8
movl $0x1, %ecx
callq 0x7e50
movl %eax, -0x40(%rbp)
movl -0xc(%rbp), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x90d6
leaq -0x78(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xca30
leaq -0xb0(%rbp), %rdi
callq 0xc6c0
leaq -0x78(%rbp), %rdi
callq 0xc6a0
movl %eax, %esi
leaq 0x63c6(%rip), %rdi      # 0xf4ae
movb $0x0, %al
callq 0x20a0
leaq -0xb0(%rbp), %rdi
callq 0xc6a0
movl %eax, %esi
leaq 0x63bb(%rip), %rdi      # 0xf4bf
movb $0x0, %al
callq 0x20a0
leaq -0x78(%rbp), %rdi
addq $0x18, %rdi
leaq -0x78(%rbp), %rsi
callq 0x7f70
leaq -0x78(%rbp), %rdi
addq $0x18, %rdi
callq 0x89c0
movl %eax, -0x44(%rbp)
leaq -0x78(%rbp), %rdi
addq $0x18, %rdi
callq 0xb0c0
movl %eax, -0x48(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0xc6a0
cmpl $0x0, %eax
jle 0x918a
leaq -0xb0(%rbp), %rdi
addq $0x18, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x7f70
leaq -0xb0(%rbp), %rdi
addq $0x18, %rdi
callq 0x89c0
movl %eax, -0x7c(%rbp)
leaq -0xb0(%rbp), %rdi
addq $0x18, %rdi
callq 0xb0c0
movl %eax, -0x80(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorl %edx, %edx
subl -0x44(%rbp), %edx
callq 0x8820
movb %al, -0xb1(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0xc6a0
cmpl $0x0, %eax
jne 0x91ec
movzbl -0xb1(%rbp), %edi
callq 0x8980
movl %eax, -0x124(%rbp)
movl -0x48(%rbp), %eax
andl $0xff, %eax
movzbl %al, %edi
callq 0x8980
movl %eax, %ecx
movl -0x124(%rbp), %eax
cmpl %ecx, %eax
jne 0x91ea
movl -0x48(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x925c
movzbl -0xb1(%rbp), %edi
callq 0x8980
movl %eax, -0x128(%rbp)
movl -0x48(%rbp), %eax
andl $0xff, %eax
movzbl %al, %edi
callq 0x8980
movl %eax, %ecx
movl -0x128(%rbp), %eax
cmpl %ecx, %eax
je 0x9223
movl -0x48(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x48(%rbp)
movzbl -0xb1(%rbp), %edi
callq 0x8980
movl %eax, -0x12c(%rbp)
movl -0x80(%rbp), %eax
andl $0xff, %eax
movzbl %al, %edi
callq 0x8980
movl %eax, %ecx
movl -0x12c(%rbp), %eax
cmpl %ecx, %eax
jne 0x925a
movl -0x80(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x925c
leaq -0x78(%rbp), %rdi
addq $0x18, %rdi
movl -0x48(%rbp), %esi
callq 0xb190
leaq -0xb0(%rbp), %rdi
addq $0x18, %rdi
movl -0x80(%rbp), %esi
callq 0xb190
movl -0xc(%rbp), %r8d
andl $0x40, %r8d
movl -0xc(%rbp), %r9d
andl $0x80, %r9d
leaq -0xd8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
xorl %ecx, %ecx
callq 0x81b0
movl -0x44(%rbp), %eax
addl -0x7c(%rbp), %eax
movl %eax, -0x134(%rbp)
movl -0xc0(%rbp), %eax
addl $0x7, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x134(%rbp), %eax
addl %ecx, %eax
movl %eax, -0xdc(%rbp)
movl -0xc0(%rbp), %esi
movl -0xc0(%rbp), %eax
addl $0x7, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %edx
leaq 0x61d8(%rip), %rdi      # 0xf4d0
movb $0x0, %al
callq 0x20a0
movl -0xdc(%rbp), %esi
cvtsi2sdl -0xdc(%rbp), %xmm0
movl -0x68(%rbp), %eax
addl -0xa0(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd 0x524a(%rip), %xmm1     # 0xe570
subsd %xmm0, %xmm1
movsd 0x5236(%rip), %xmm0     # 0xe568
mulsd %xmm1, %xmm0
leaq 0x61b7(%rip), %rdi      # 0xf4f4
movb $0x1, %al
callq 0x20a0
leaq -0xd8(%rbp), %rdi
callq 0xa1c0
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xc(%rbp), %r8d
andl $0x40, %r8d
movl -0xc(%rbp), %r9d
andl $0x80, %r9d
leaq -0xd8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x81b0
movl -0x44(%rbp), %eax
addl -0x7c(%rbp), %eax
movl %eax, -0x130(%rbp)
movl -0xc0(%rbp), %eax
addl $0x7, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x130(%rbp), %eax
addl %ecx, %eax
movl %eax, -0xdc(%rbp)
movl -0xc0(%rbp), %esi
movl -0xc0(%rbp), %eax
addl $0x7, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %edx
leaq 0x614b(%rip), %rdi      # 0xf523
movb $0x0, %al
callq 0x20a0
movl -0xdc(%rbp), %esi
cvtsi2sdl -0xdc(%rbp), %xmm0
movl -0x68(%rbp), %eax
addl -0xa0(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd 0x516a(%rip), %xmm1     # 0xe570
subsd %xmm0, %xmm1
movsd 0x5156(%rip), %xmm0     # 0xe568
mulsd %xmm1, %xmm0
leaq 0x60d7(%rip), %rdi      # 0xf4f4
movb $0x1, %al
callq 0x20a0
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %edx
addl -0x7c(%rbp), %edx
leaq 0x5ffb(%rip), %rsi      # 0xf430
callq 0x8a10
movl -0xdc(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x1c(%rcx), %eax
jle 0x946e
movl -0xdc(%rbp), %esi
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %edx
leaq 0x60ee(%rip), %rdi      # 0xf54b
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x9470
movl -0x44(%rbp), %ecx
addl -0x7c(%rbp), %ecx
movl -0xc0(%rbp), %eax
addl $0x7, %eax
movl $0x8, %esi
cltd
idivl %esi
addl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %esi
leaq 0x60ea(%rip), %rdi      # 0xf588
movb $0x0, %al
callq 0x20a0
movq -0x28(%rbp), %rax
movslq 0x1c(%rax), %rdi
callq 0xae70
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rax
movl 0x30(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x30(%rax)
movl $0xfffefff0, %ecx       # imm = 0xFFFEFFF0
subl -0x68(%rbp), %ecx
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movl %ecx, (%rax)
movl -0x48(%rbp), %ecx
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movl %ecx, 0x4(%rax)
movl $0x0, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
movl %eax, -0x138(%rbp)
leaq -0x78(%rbp), %rdi
addq $0x18, %rdi
callq 0xc6a0
movl %eax, %ecx
movl -0x138(%rbp), %eax
cmpl %ecx, %eax
jge 0x9564
leaq -0x78(%rbp), %rdi
addq $0x18, %rdi
movl -0xf4(%rbp), %esi
callq 0xc870
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rax
movb (%rax), %dl
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movl -0xf4(%rbp), %ecx
addl $0x8, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x94f4
leaq -0xb0(%rbp), %rdi
callq 0xc6a0
cmpl $0x0, %eax
jle 0x962b
movl $0xfffefff0, %edx       # imm = 0xFFFEFFF0
subl -0x68(%rbp), %edx
subl -0xa0(%rbp), %edx
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movl -0x44(%rbp), %ecx
movl %edx, (%rax,%rcx)
movl -0x80(%rbp), %edx
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movl -0x44(%rbp), %ecx
movl %edx, 0x4(%rax,%rcx)
movl $0x0, -0xf4(%rbp)
movl -0xf4(%rbp), %eax
movl %eax, -0x13c(%rbp)
leaq -0xb0(%rbp), %rdi
addq $0x18, %rdi
callq 0xc6a0
movl %eax, %ecx
movl -0x13c(%rbp), %eax
cmpl %ecx, %eax
jge 0x9629
leaq -0xb0(%rbp), %rdi
addq $0x18, %rdi
movl -0xf4(%rbp), %esi
callq 0xc870
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
movb (%rax), %dl
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movl -0x44(%rbp), %ecx
addl $0x8, %ecx
addl -0xf4(%rbp), %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0x95b1
jmp 0x962b
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
movl -0x44(%rbp), %edx
addl -0x7c(%rbp), %edx
shll $0x3, %edx
leaq -0xd8(%rbp), %rdi
callq 0xa210
movl -0x44(%rbp), %esi
addl -0x7c(%rbp), %esi
leaq 0x5f46(%rip), %rdi      # 0xf59b
movb $0x0, %al
callq 0x20a0
leaq -0xd8(%rbp), %rdi
callq 0xa1c0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
addl $0xffff, %eax           # imm = 0xFFFF
movl $0x10000, %ecx          # imm = 0x10000
cltd
idivl %ecx
movl %eax, %edx
leaq 0x5f28(%rip), %rsi      # 0xf5b1
callq 0x8a10
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %edx
leaq 0x5f17(%rip), %rsi      # 0xf5c1
callq 0x8a10
movq -0x18(%rbp), %rdi
leaq 0x5f18(%rip), %rsi      # 0xf5d2
callq 0x8720
movq %rax, -0x110(%rbp)
xorl %ecx, %ecx
subl -0x44(%rbp), %ecx
movq -0x110(%rbp), %rax
movl %ecx, 0x3c(%rax)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movl -0x2c(%rbp), %esi
callq 0x7e10
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x9729
movq -0x8(%rbp), %rdi
leaq 0x5edf(%rip), %rsi      # 0xf5da
callq 0x4210
movq %rax, -0x120(%rbp)
movl -0x44(%rbp), %esi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x120(%rbp), %rcx
movslq 0x124(%rcx), %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
movq -0x8(%rbp), %rdi
leaq 0x5eb8(%rip), %rsi      # 0xf5ec
callq 0x4210
movq %rax, -0x118(%rbp)
movl -0x44(%rbp), %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x118(%rbp), %rcx
movslq 0x124(%rcx), %rcx
movb %dl, (%rax,%rcx)
movzbl -0xb1(%rbp), %eax
movl %eax, -0x140(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorl %edx, %edx
subl -0x44(%rbp), %edx
callq 0x8820
movb %al, %cl
movl -0x140(%rbp), %eax
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x97db
movl -0x44(%rbp), %eax
movl %eax, -0x148(%rbp)
movzbl -0xb1(%rbp), %eax
movl %eax, -0x144(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorl %edx, %edx
subl -0x44(%rbp), %edx
callq 0x8820
movl -0x148(%rbp), %esi
movl -0x144(%rbp), %edx
movzbl %al, %ecx
leaq 0x5e34(%rip), %rdi      # 0xf5fe
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x97dd
movzbl -0xb1(%rbp), %edi
callq 0x8980
cmpl $0x0, %eax
jne 0x9813
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x118(%rbp), %rcx
movl 0x124(%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edx
xorl $0x1, %edx
movb %dl, (%rax,%rcx)
leaq -0x78(%rbp), %rdi
callq 0x8050
leaq -0xb0(%rbp), %rdi
callq 0x8050
movq -0x8(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x983c
movq -0x8(%rbp), %rdi
callq 0x85b0
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x85f0
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopw %cs:(%rax,%rax)