// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %esi, %ebp
movq %rdi, %r12
callq 0x6680
movq 0x8(%r12), %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0x6823
movq %rax, %r13
movzbl 0x10(%rax), %eax
andl $0x1, %eax
movl %eax, 0x64(%r12)
je 0x6c22
testb $0x10, %bpl
jne 0x6c53
btl $0x8, %ebp
movq 0x10(%r12), %rax
jb 0x6c83
btl $0x9, %ebp
jb 0x6cc5
testq %rax, %rax
leaq 0x41cf(%rip), %rax      # 0xade5
leaq 0x448e(%rip), %r14      # 0xb0ab
jmp 0x6d6a
cmpq $0x0, 0x10(%r12)
jne 0x77d3
movq %r13, %r14
testb $0x10, %bpl
je 0x6dfd
movq 0x8(%r12), %rsi
leaq 0x4366(%rip), %rdi      # 0xafad
xorl %eax, %eax
callq 0x22ef
jmp 0x777f
movq 0x10(%r12), %rax
testb %bpl, %bpl
js 0x6c9f
testb $0x40, %bpl
jne 0x6cdb
btl $0x9, %ebp
jb 0x6d20
testq %rax, %rax
leaq 0x4476(%rip), %rax      # 0xb0ed
leaq 0x43ef(%rip), %r14      # 0xb06d
jmp 0x6d6a
btl $0x9, %ebp
jb 0x6cf4
testq %rax, %rax
leaq 0x43ff(%rip), %rax      # 0xb092
leaq 0x43ef(%rip), %r14      # 0xb089
jmp 0x6d6a
testb $0x40, %bpl
jne 0x6d07
btl $0x9, %ebp
jb 0x6d33
testq %rax, %rax
leaq 0x4370(%rip), %rax      # 0xb029
leaq 0x435f(%rip), %r14      # 0xb01f
jmp 0x6d6a
testq %rax, %rax
leaq 0x43d4(%rip), %rax      # 0xb0a3
leaq 0x43c4(%rip), %r14      # 0xb09a
jmp 0x6d6a
btl $0x9, %ebp
jb 0x6d46
testq %rax, %rax
leaq 0x4366(%rip), %rax      # 0xb051
leaq 0x4355(%rip), %r14      # 0xb047
jmp 0x6d6a
testq %rax, %rax
leaq 0x4382(%rip), %rax      # 0xb080
leaq 0x4371(%rip), %r14      # 0xb076
jmp 0x6d6a
btl $0x9, %ebp
jb 0x6d59
testq %rax, %rax
leaq 0x42e9(%rip), %rax      # 0xb000
leaq 0x42d7(%rip), %r14      # 0xaff5
jmp 0x6d6a
testq %rax, %rax
leaq 0x433a(%rip), %rax      # 0xb064
leaq 0x4329(%rip), %r14      # 0xb05a
jmp 0x6d6a
testq %rax, %rax
leaq 0x42d8(%rip), %rax      # 0xb015
leaq 0x42c6(%rip), %r14      # 0xb00a
jmp 0x6d6a
testq %rax, %rax
leaq 0x42ed(%rip), %rax      # 0xb03d
leaq 0x42db(%rip), %r14      # 0xb032
jmp 0x6d6a
testq %rax, %rax
leaq 0x4287(%rip), %rax      # 0xafea
leaq 0x4274(%rip), %r14      # 0xafde
cmoveq %rax, %r14
leaq 0x433e(%rip), %rdi      # 0xb0b3
movq %r14, %rsi
xorl %eax, %eax
callq 0x20c0
movq %r12, %rdi
movq %r14, %rsi
callq 0x672b
movq %r12, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x6823
movq %rax, %r14
cmpq $0x0, 0x10(%r12)
je 0x6dc0
movq 0x8(%r14), %rdi
leaq 0x4310(%rip), %rsi      # 0xb0bd
callq 0x3344
leaq 0x10(%rax), %rdi
movq 0x10(%r12), %rsi
callq 0x2050
testb $0x10, %bpl
jne 0x6de6
movq 0x8(%r14), %rdi
leaq 0x37c3(%rip), %rsi      # 0xa594
callq 0x3344
leaq 0x10(%rax), %rdi
movq 0x8(%r12), %rsi
callq 0x2050
jmp 0x6dfd
leaq 0x42d6(%rip), %rsi      # 0xb0c3
movq %r12, %rdi
movl $0x2, %edx
callq 0x6823
movq %rax, %r15
movq %r12, %rdi
movq %r14, %rsi
callq 0x5fbf
btl $0x8, %ebp
jae 0x6e19
movq %r12, %rdi
movq %r13, %rsi
callq 0x5fbf
movq 0x48(%r12), %rdi
movl 0x50(%r12), %esi
leaq 0x5c(%rsp), %rcx
xorl %edx, %edx
callq 0x602e
movq 0x48(%r12), %rbx
movq $-0x8, %rdx
movq %rdx, %rax
addq $0x8, %rdx
cmpq %r14, 0x8(%rbx,%rax)
jne 0x6e3b
leaq 0x8(%rbx), %rdi
movq %rbx, %rsi
callq 0x21a0
btl $0x8, %ebp
movq %r14, (%rbx)
jae 0x6e89
movq 0x48(%r12), %rbx
leaq 0x8(%rbx), %rsi
movq $-0x8, %rdx
movq %rdx, %rax
addq $0x8, %rdx
cmpq %r13, 0x8(%rsi,%rax)
jne 0x6e6e
leaq 0x10(%rbx), %rdi
callq 0x21a0
movq %r13, 0x8(%rbx)
testb $0x10, %bpl
je 0x6ecc
movslq 0x5c(%rsp), %rbx
cmpl 0x50(%r12), %ebx
je 0x7789
shlq $0x3, %rbx
addq 0x48(%r12), %rbx
movq $-0x8, %rdx
movq %rdx, %rax
addq $0x8, %rdx
cmpq %r15, 0x8(%rbx,%rax)
jne 0x6eaf
leaq 0x8(%rbx), %rdi
movq %rbx, %rsi
callq 0x21a0
movq %r15, (%rbx)
movl %ebp, 0x14(%rsp)
movq %r14, 0xa0(%rsp)
movq %r12, %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x614a
movslq 0x50(%r12), %r14
testq %r14, %r14
jle 0x6f09
movq 0x48(%r12), %rbx
xorl %ebp, %ebp
movq (%rbx,%rbp,8), %rdi
callq 0x3b44
incq %rbp
cmpq %rbp, %r14
jne 0x6ef8
movq %r14, 0x8(%rsp)
movl 0x14(%rsp), %eax
testb $0x10, %al
jne 0x6f20
movq 0x8(%rsp), %rbx
jmp 0x7745
btl $0x9, %eax
movq 0x8(%rsp), %rbx
jae 0x6f62
leaq 0x41c3(%rip), %rsi      # 0xb0f5
movq %r12, %rdi
movl $0x2, %edx
callq 0x6823
movslq 0x50(%r12), %rcx
testq %rcx, %rcx
jle 0x6f62
movq 0x48(%r12), %rdx
xorl %esi, %esi
cmpq %rax, (%rdx,%rsi,8)
je 0x7771
incq %rsi
cmpq %rsi, %rcx
jne 0x6f50
movq %r12, %rdi
movq %r13, %rsi
callq 0x5fbf
movq %rbx, %rbp
shlq $0x3, %rbp
movq 0x48(%r12), %rdi
addq %rbp, %rdi
movl 0x50(%r12), %esi
subl %ebx, %esi
leaq 0x58(%rsp), %rdx
xorl %ecx, %ecx
callq 0x602e
movq 0x48(%r12), %rbx
addq %rbp, %rbx
movq $-0x8, %rdx
movq %rdx, %rax
addq $0x8, %rdx
cmpq %r13, 0x8(%rbx,%rax)
jne 0x6f9e
leaq 0x8(%rbx), %rdi
movq %rbx, %rsi
callq 0x21a0
btl $0x9, 0x14(%rsp)
movq %r13, (%rbx)
jb 0x6fca
movq 0x8(%rsp), %rbx
jmp 0x7024
leaq 0x4124(%rip), %rsi      # 0xb0f5
movq %r12, %rdi
movl $0x2, %edx
callq 0x6823
movq %rax, %rbx
movq %r12, %rdi
movq %rax, %rsi
callq 0x5fbf
addq 0x48(%r12), %rbp
movq $-0x8, %rdx
movq %rdx, %rax
addq $0x8, %rdx
cmpq %rbx, 0x8(%rbp,%rax)
jne 0x6ff8
leaq 0x8(%rbp), %rdi
movq %rbp, %rsi
callq 0x21a0
movq %rbx, (%rbp)
movl $0x10000, 0x7c(%rbx)    # imm = 0x10000
movq 0x8(%rsp), %rbx
incl %ebx
movq %r12, %rdi
movl %ebx, %esi
movl $0x10010, %edx          # imm = 0x10010
callq 0x614a
movl 0x50(%r12), %eax
movq %rbx, 0x8(%rsp)
subl %ebx, %eax
jle 0x7065
movslq 0x8(%rsp), %rbx
shlq $0x3, %rbx
addq 0x48(%r12), %rbx
movl %eax, %r13d
xorl %ebp, %ebp
movq (%rbx,%rbp,8), %rdi
callq 0x3b44
incq %rbp
cmpq %rbp, %r13
jne 0x7054
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %r13
movaps %xmm0, 0x20(%r13)
movaps %xmm0, 0x10(%r13)
movaps %xmm0, (%r13)
movq %r12, 0x18(%rsp)
xorl %r12d, %r12d
movq %r12, 0x30(%r13)
movl $0x1, %esi
movq %r13, %rdi
xorl %edx, %edx
callq 0x92e8
leaq 0x38(%rsp), %rdi
movl $0xc, %esi
xorl %edx, %edx
callq 0x92e8
leaq 0x60(%rsp), %rbx
movq %r12, 0x30(%rbx)
movq 0x18(%rsp), %r12
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rbx)
movaps %xmm0, 0x10(%rbx)
movaps %xmm0, (%rbx)
movl $0x1, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x92e8
leaq 0x78(%rsp), %rdi
movl $0xc, %esi
xorl %edx, %edx
callq 0x92e8
movq %r12, %rdi
movq 0x8(%rsp), %rbp
movl %ebp, %esi
movl $0x10010, %edx          # imm = 0x10010
xorl %ecx, %ecx
movq %r13, %r8
callq 0x6268
movl 0x58(%rsp), %esi
addl %ebp, %esi
movq %r12, %rdi
movl %eax, %edx
movl $0x1, %ecx
movq %rbx, %r8
callq 0x6268
testb $0x20, 0x14(%rsp)
je 0x7136
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rbx
movq %rbx, %rsi
callq 0x945f
movq %rbx, %rdi
callq 0x931e
leaq 0x20(%rsp), %r13
movq %r13, %rdi
callq 0x931a
leaq 0x3ff7(%rip), %rdi      # 0xb141
xorl %ebp, %ebp
movl %eax, %esi
xorl %eax, %eax
callq 0x20c0
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
callq 0x931a
leaq 0x3fe9(%rip), %rdi      # 0xb152
movl %eax, %esi
xorl %eax, %eax
callq 0x20c0
leaq 0x38(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x6356
movq %r12, %rdi
callq 0x6b70
movl %eax, 0x34(%r13)
movq %r12, %rdi
callq 0x8627
movl %eax, 0x30(%r13)
movq %rbx, %rdi
callq 0x931a
testl %eax, %eax
leaq 0x78(%rsp), %r13
jle 0x71d1
leaq 0x60(%rsp), %rbx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x6356
movq %r13, %rdi
callq 0x6b70
movl %eax, 0x34(%rbx)
movq %r13, %rdi
callq 0x8627
movl %eax, 0x30(%rbx)
subl 0x54(%rsp), %ebp
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x6a95
movl %eax, %ebp
leaq 0x60(%rsp), %rdi
callq 0x931a
testl %eax, %eax
je 0x72a1
xorl %eax, %eax
movl $0x0, %ecx
testb %bpl, %bpl
leaq 0x38(%rsp), %rdi
je 0x721f
xorl %ecx, %ecx
movl %ebp, %edx
movzbl %dl, %esi
addl %esi, %ecx
movl %esi, %edx
shrb %dl
cmpb $0x1, %sil
ja 0x720d
andl $0x1, %ecx
movl 0x50(%rsp), %edx
testb %dl, %dl
je 0x7241
xorl %eax, %eax
movl %edx, %esi
movzbl %sil, %r8d
addl %r8d, %eax
movl %r8d, %esi
shrb %sil
cmpb $0x1, %r8b
ja 0x722b
andl $0x1, %eax
cmpl %eax, %ecx
je 0x724c
xorl $0x1, %edx
movl %edx, 0x50(%rsp)
xorl %ecx, %ecx
movl $0x0, %edx
testb %bpl, %bpl
je 0x726e
xorl %edx, %edx
movl %ebp, %eax
movzbl %al, %esi
addl %esi, %edx
movl %esi, %eax
shrb %al
cmpb $0x1, %sil
ja 0x725c
andl $0x1, %edx
movl 0x90(%rsp), %eax
testb %al, %al
je 0x7293
xorl %ecx, %ecx
movl %eax, %esi
movzbl %sil, %r8d
addl %r8d, %ecx
movl %r8d, %esi
shrb %sil
cmpb $0x1, %r8b
ja 0x727d
andl $0x1, %ecx
cmpl %ecx, %edx
jne 0x72f8
leaq 0x90(%rsp), %rcx
jmp 0x72f3
xorl %ecx, %ecx
movl $0x0, %edx
testb %bpl, %bpl
leaq 0x38(%rsp), %rdi
je 0x72c8
xorl %edx, %edx
movl %ebp, %eax
movzbl %al, %esi
addl %esi, %edx
movl %esi, %eax
shrb %al
cmpb $0x1, %sil
ja 0x72b6
andl $0x1, %edx
movl 0x50(%rsp), %eax
testb %al, %al
je 0x72ea
xorl %ecx, %ecx
movl %eax, %esi
movzbl %sil, %r8d
addl %r8d, %ecx
movl %r8d, %esi
shrb %sil
cmpb $0x1, %r8b
ja 0x72d4
andl $0x1, %ecx
cmpl %ecx, %edx
jne 0x72f8
leaq 0x50(%rsp), %rcx
xorl $0x1, %eax
movl %eax, (%rcx)
leaq 0x20(%rsp), %r12
movl 0x30(%r12), %esi
callq 0x86c8
leaq 0x60(%rsp), %rbx
movl 0x30(%rbx), %esi
movq %r13, %rdi
callq 0x86c8
movl 0x14(%rsp), %r13d
movl %r13d, %r14d
andl $0x40, %r14d
andl $0x80, %r13d
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
movl %r14d, %r8d
movl %r13d, %r9d
callq 0x6522
movl 0x34(%rbx), %ebx
addl 0x34(%r12), %ebx
leaq 0xa8(%rsp), %rax
movl 0x18(%rax), %esi
leal 0x7(%rsi), %eax
leal 0xe(%rsi), %edx
testl %eax, %eax
cmovnsl %eax, %edx
sarl $0x3, %edx
addl %edx, %ebx
leaq 0x3df4(%rip), %rdi      # 0xb163
xorl %eax, %eax
callq 0x20c0
cvtsi2sd %ebx, %xmm1
leaq 0x60(%rsp), %rax
movl 0x10(%rax), %eax
addl 0x10(%r12), %eax
cvtsi2sd %eax, %xmm0
divsd %xmm0, %xmm1
movsd 0x2f39(%rip), %xmm0     # 0xa2d0
subsd %xmm1, %xmm0
mulsd 0x2f35(%rip), %xmm0     # 0xa2d8
leaq 0x3ddd(%rip), %rdi      # 0xb187
movl %ebx, %esi
movb $0x1, %al
callq 0x20c0
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
callq 0x7e86
movq 0x18(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movq %rbx, %rdi
movq %r12, %rbx
movq %r12, %rsi
leaq 0x60(%rsp), %r12
movq %r12, %rdx
movl %r14d, %r8d
movl %r13d, %r9d
callq 0x6522
movl 0x34(%r12), %r13d
addl 0x34(%rbx), %r13d
movq %rbx, %r14
leaq 0xa8(%rsp), %rax
movl 0x18(%rax), %esi
leal 0x7(%rsi), %eax
leal 0xe(%rsi), %edx
testl %eax, %eax
cmovnsl %eax, %edx
sarl $0x3, %edx
addl %edx, %r13d
leaq 0x3d97(%rip), %rdi      # 0xb1b6
xorl %eax, %eax
callq 0x20c0
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movl 0x10(%r12), %eax
addl 0x10(%rbx), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd 0x2e87(%rip), %xmm1     # 0xa2d0
subsd %xmm0, %xmm1
mulsd 0x2e83(%rip), %xmm1     # 0xa2d8
movapd %xmm1, %xmm0
leaq 0x3d27(%rip), %rdi      # 0xb187
movl %r13d, %esi
movb $0x1, %al
callq 0x20c0
movl 0x34(%r12), %ebx
addl 0x34(%r14), %ebx
leaq 0x3c49(%rip), %rsi      # 0xb0c3
movq 0x18(%rsp), %rdi
callq 0x359a
movl %ebx, 0x124(%rax)
movl 0x1c(%r15), %edx
cmpl %edx, %r13d
jg 0x7792
movl 0x94(%rsp), %eax
addl 0x54(%rsp), %eax
movl 0xc0(%rsp), %esi
leal 0x7(%rsi), %ecx
addl $0xe, %esi
testl %ecx, %ecx
cmovnsl %ecx, %esi
sarl $0x3, %esi
addl %eax, %esi
movl %esi, 0x1c(%r15)
leaq 0x3d57(%rip), %rdi      # 0xb21b
xorl %eax, %eax
callq 0x20c0
movslq 0x1c(%r15), %rdi
callq 0x8508
movq %rax, 0x38(%r15)
orb $0x1, 0x30(%r15)
movl $0xfffefff0, %ecx       # imm = 0xFFFEFFF0
subl 0x30(%rsp), %ecx
movl %ecx, (%rax)
movl 0x50(%rsp), %ecx
movl %ecx, 0x4(%rax)
leaq 0x38(%rsp), %r12
movq %r12, %rdi
callq 0x931a
testl %eax, %eax
movq 0xa0(%rsp), %r14
jle 0x7530
xorl %ebx, %ebx
movq %r12, %rdi
movl %ebx, %esi
callq 0x9366
movb (%rax), %al
movq 0x38(%r15), %rcx
movb %al, 0x8(%rcx,%rbx)
incq %rbx
movq %r12, %rdi
callq 0x931a
cltq
cmpq %rax, %rbx
jl 0x750a
leaq 0x60(%rsp), %rdi
callq 0x931a
testl %eax, %eax
leaq 0x78(%rsp), %r12
jle 0x75a4
movl 0x30(%rsp), %eax
addl 0x70(%rsp), %eax
movl 0x54(%rsp), %ecx
movl $0xfffefff0, %edx       # imm = 0xFFFEFFF0
subl %eax, %edx
movq 0x38(%r15), %rax
movl %edx, (%rax,%rcx)
movl 0x90(%rsp), %ecx
movl 0x54(%rsp), %edx
movl %ecx, 0x4(%rax,%rdx)
movq %r12, %rdi
callq 0x931a
testl %eax, %eax
jle 0x75a4
xorl %ebx, %ebx
movq %r12, %rdi
movl %ebx, %esi
callq 0x9366
movb (%rax), %al
movq 0x38(%r15), %rcx
movl 0x54(%rsp), %edx
addl %ebx, %edx
addl $0x8, %edx
movb %al, (%rcx,%rdx)
incl %ebx
movq %r12, %rdi
callq 0x931a
cmpl %eax, %ebx
jl 0x757a
movq 0x38(%r15), %rsi
movl 0x94(%rsp), %edx
addl 0x54(%rsp), %edx
shll $0x3, %edx
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
callq 0x7e9e
movl 0x94(%rsp), %esi
addl 0x54(%rsp), %esi
leaq 0x3c56(%rip), %rdi      # 0xb22e
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x7e86
movq 0x18(%rsp), %r12
movl 0x18(%r12), %ebx
leal 0xffff(%rbx), %eax
addl $0x1fffe, %ebx          # imm = 0x1FFFE
testl %eax, %eax
cmovnsl %eax, %ebx
sarl $0x10, %ebx
leaq 0x3c35(%rip), %rsi      # 0xb244
movq %r12, %rdi
callq 0x359a
movl %ebx, 0x124(%rax)
movl 0x18(%r12), %eax
movl %eax, %ebx
shrl $0x1f, %ebx
addl %eax, %ebx
sarl %ebx
leaq 0x3c22(%rip), %rsi      # 0xb254
movq %r12, %rdi
callq 0x359a
movl %ebx, 0x124(%rax)
leaq 0x3c1e(%rip), %rsi      # 0xb265
movq %r14, %rdi
callq 0x69e2
subl 0x54(%rsp), %r13d
movl %r13d, 0x3c(%rax)
cmpl $0x0, 0x8(%rsp)
jle 0x7681
movq 0x18(%rsp), %rax
movq 0x48(%rax), %rbx
movl 0x8(%rsp), %r13d
xorl %r12d, %r12d
movq (%rbx,%r12,8), %rdi
callq 0x3b44
incq %r12
cmpq %r12, %r13
jne 0x7670
movq 0x18(%rsp), %r12
cmpq $0x0, 0x10(%r12)
jne 0x76af
leaq 0x3bd8(%rip), %rsi      # 0xb26d
movq %r12, %rdi
callq 0x359a
movb 0x54(%rsp), %cl
movq 0x38(%r14), %rdx
movslq 0x124(%rax), %rax
addb %cl, (%rdx,%rax)
leaq 0x3bc9(%rip), %rsi      # 0xb27f
movq %r12, %rdi
callq 0x359a
movq %rax, %r13
movb 0x54(%rsp), %al
movq 0x38(%r14), %rcx
movslq 0x124(%r13), %rdx
movb %al, (%rcx,%rdx)
xorl %edx, %edx
subl 0x54(%rsp), %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x6a95
cmpb %al, %bpl
movq 0x8(%rsp), %rbx
jne 0x77a5
testb %bpl, %bpl
je 0x770d
xorl %eax, %eax
movzbl %bpl, %ecx
addl %ecx, %eax
movl %ecx, %ebp
shrb %bpl
cmpb $0x1, %cl
ja 0x76f9
testb $0x1, %al
jne 0x771d
movq 0x38(%r14), %rax
movslq 0x124(%r13), %rcx
xorb $0x1, 0x1(%rax,%rcx)
leaq 0x20(%rsp), %rdi
callq 0x9312
leaq 0x38(%rsp), %rdi
callq 0x9312
leaq 0x60(%rsp), %rdi
callq 0x9312
leaq 0x78(%rsp), %rdi
callq 0x9312
cmpq $0x0, 0x20(%r12)
je 0x7755
movq %r12, %rdi
callq 0x68b4
movq %r12, %rdi
movl %ebx, %esi
callq 0x68e8
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3989(%rip), %rdi      # 0xb101
xorl %eax, %eax
callq 0x22ef
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21f0
leaq 0x393b(%rip), %rdi      # 0xb0cb
jmp 0x7778
leaq 0x3a45(%rip), %rdi      # 0xb1de
movl %r13d, %esi
xorl %eax, %eax
callq 0x22ef
jmp 0x777f
movzbl %bpl, %ebx
movl 0x54(%rsp), %ebp
movl %ebp, %edx
negl %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x6a95
movzbl %al, %ecx
leaq 0x3acb(%rip), %rdi      # 0xb291
movl %ebp, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x22ef
jmp 0x777f
leaq 0x378f(%rip), %rdi      # 0xaf69
jmp 0x7778