// File: /workspace/github_c_makefile_star2_O2/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, %rbx
callq 0x5a92
movq 0x8(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x5bcd
movq %rax, %r12
movzbl 0x10(%rax), %eax
andl $0x1, %eax
movl %eax, 0x64(%rbx)
je 0x5f1b
testb $0x10, %bpl
jne 0x5f4a
btl $0x8, %ebp
movq 0x10(%rbx), %rax
jb 0x5f79
btl $0x9, %ebp
jb 0x5fbb
testq %rax, %rax
leaq 0x3ed6(%rip), %rax      # 0x9de5
leaq 0x415d(%rip), %r14      # 0xa073
jmp 0x6060
cmpq $0x0, 0x10(%rbx)
jne 0x686a
movq %r12, %r14
testb $0x10, %bpl
je 0x60ee
movq 0x8(%rbx), %rsi
leaq 0x4037(%rip), %rdi      # 0x9f75
xorl %eax, %eax
callq 0x7514
jmp 0x6881
movq 0x10(%rbx), %rax
testb %bpl, %bpl
js 0x5f95
testb $0x40, %bpl
jne 0x5fd1
btl $0x9, %ebp
jb 0x6016
testq %rax, %rax
leaq 0x4148(%rip), %rax      # 0xa0b5
leaq 0x40c1(%rip), %r14      # 0xa035
jmp 0x6060
btl $0x9, %ebp
jb 0x5fea
testq %rax, %rax
leaq 0x40d1(%rip), %rax      # 0xa05a
leaq 0x40c1(%rip), %r14      # 0xa051
jmp 0x6060
testb $0x40, %bpl
jne 0x5ffd
btl $0x9, %ebp
jb 0x6029
testq %rax, %rax
leaq 0x4042(%rip), %rax      # 0x9ff1
leaq 0x4031(%rip), %r14      # 0x9fe7
jmp 0x6060
testq %rax, %rax
leaq 0x40a6(%rip), %rax      # 0xa06b
leaq 0x4096(%rip), %r14      # 0xa062
jmp 0x6060
btl $0x9, %ebp
jb 0x603c
testq %rax, %rax
leaq 0x4038(%rip), %rax      # 0xa019
leaq 0x4027(%rip), %r14      # 0xa00f
jmp 0x6060
testq %rax, %rax
leaq 0x4054(%rip), %rax      # 0xa048
leaq 0x4043(%rip), %r14      # 0xa03e
jmp 0x6060
btl $0x9, %ebp
jb 0x604f
testq %rax, %rax
leaq 0x3fbb(%rip), %rax      # 0x9fc8
leaq 0x3fa9(%rip), %r14      # 0x9fbd
jmp 0x6060
testq %rax, %rax
leaq 0x400c(%rip), %rax      # 0xa02c
leaq 0x3ffb(%rip), %r14      # 0xa022
jmp 0x6060
testq %rax, %rax
leaq 0x3faa(%rip), %rax      # 0x9fdd
leaq 0x3f98(%rip), %r14      # 0x9fd2
jmp 0x6060
testq %rax, %rax
leaq 0x3fbf(%rip), %rax      # 0xa005
leaq 0x3fad(%rip), %r14      # 0x9ffa
jmp 0x6060
testq %rax, %rax
leaq 0x3f59(%rip), %rax      # 0x9fb2
leaq 0x3f46(%rip), %r14      # 0x9fa6
cmoveq %rax, %r14
leaq 0x4010(%rip), %rdi      # 0xa07b
movq %r14, %rsi
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5b18
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x5bcd
movq %rax, %r14
cmpq $0x0, 0x10(%rbx)
je 0x60b4
movq 0x8(%r14), %rdi
leaq 0x3fe3(%rip), %rsi      # 0xa085
callq 0x30c6
leaq 0x10(%rax), %rdi
movq 0x10(%rbx), %rsi
callq 0x2050
testb $0x10, %bpl
jne 0x60d9
movq 0x8(%r14), %rdi
leaq 0x34cf(%rip), %rsi      # 0x9594
callq 0x30c6
leaq 0x10(%rax), %rdi
movq 0x8(%rbx), %rsi
callq 0x2050
jmp 0x60ee
leaq 0x3fab(%rip), %rsi      # 0xa08b
pushq $0x2
popq %rdx
movq %rbx, %rdi
callq 0x5bcd
movq %rax, %r15
movq %rbx, %rdi
movq %r14, %rsi
callq 0x54ac
btl $0x8, %ebp
jae 0x610a
movq %rbx, %rdi
movq %r12, %rsi
callq 0x54ac
movq 0x48(%rbx), %rdi
movl 0x50(%rbx), %esi
leaq 0x64(%rsp), %rcx
xorl %edx, %edx
callq 0x5518
movq 0x48(%rbx), %rdi
movq %r14, %rsi
callq 0x55b0
btl $0x8, %ebp
jae 0x613f
movq 0x48(%rbx), %rdi
addq $0x8, %rdi
movq %r12, %rsi
callq 0x55b0
testb $0x10, %bpl
je 0x6163
movslq 0x64(%rsp), %rdi
cmpl 0x50(%rbx), %edi
je 0x6823
shlq $0x3, %rdi
addq 0x48(%rbx), %rdi
movq %r15, %rsi
callq 0x55b0
movq %rbx, %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x55e2
movl 0x50(%rbx), %esi
movq 0x48(%rbx), %rdi
movl %esi, 0xc(%rsp)
callq 0x56a3
testb $0x10, %bpl
jne 0x6192
movl 0xc(%rsp), %r13d
jmp 0x67f7
movq %r14, 0xa0(%rsp)
movl %ebp, 0x10(%rsp)
btl $0x9, %ebp
jae 0x61c9
leaq 0x3f12(%rip), %rsi      # 0xa0bd
pushq $0x2
popq %rdx
movq %rbx, %rdi
callq 0x5bcd
movq %rbx, %rdi
movq %rax, %rsi
callq 0x34dc
testl %eax, %eax
jne 0x6873
movl 0xc(%rsp), %r13d
movslq %r13d, %r14
movq %rbx, %rdi
movq %r12, %rsi
callq 0x54ac
leaq (,%r14,8), %rbp
movq 0x48(%rbx), %rdi
addq %rbp, %rdi
movl 0x50(%rbx), %esi
subl %r13d, %esi
leaq 0x60(%rsp), %rdx
xorl %ecx, %ecx
callq 0x5518
movq 0x48(%rbx), %rdi
addq %rbp, %rdi
movq %r12, %rsi
callq 0x55b0
btl $0x9, 0x10(%rsp)
jb 0x621a
movl 0xc(%rsp), %ebp
jmp 0x6258
leaq 0x3e9c(%rip), %rsi      # 0xa0bd
pushq $0x2
popq %rdx
movq %rbx, %rdi
callq 0x5bcd
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x54ac
addq 0x48(%rbx), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x55b0
movl $0x10000, 0x7c(%r12)    # imm = 0x10000
incq %r14
movl %r14d, %ebp
movq %rbx, %rdi
movl %ebp, %esi
movl $0x10010, %edx          # imm = 0x10010
callq 0x55e2
shlq $0x3, %r14
addq 0x48(%rbx), %r14
movl 0x50(%rbx), %esi
subl %ebp, %esi
movq %r14, %rdi
callq 0x56a3
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x5802
leaq 0x68(%rsp), %r12
movq %r12, %rdi
callq 0x5802
movq %rbx, %rdi
movl %ebp, %esi
movl $0x10010, %edx          # imm = 0x10010
xorl %ecx, %ecx
movq %r14, %r8
callq 0x56cf
movl 0x60(%rsp), %esi
movl %ebp, 0xc(%rsp)
addl %ebp, %esi
pushq $0x1
popq %rcx
movq %rbx, %rdi
movl %eax, %edx
movq %r12, %r8
callq 0x56cf
testb $0x20, 0x10(%rsp)
je 0x62e5
leaq 0x18(%rsp), %rdi
leaq 0x68(%rsp), %r14
movq %r14, %rsi
callq 0x8409
movq %r14, %rdi
callq 0x82db
leaq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0x82d7
leaq 0x3e10(%rip), %rdi      # 0xa109
xorl %ebp, %ebp
movl %eax, %esi
xorl %eax, %eax
callq 0x20c0
leaq 0x68(%rsp), %r14
movq %r14, %rdi
callq 0x82d7
leaq 0x3e02(%rip), %rdi      # 0xa11a
movl %eax, %esi
xorl %eax, %eax
callq 0x20c0
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x5782
movq %r13, %rdi
callq 0x5e73
movl %eax, 0x1c(%r13)
movq %r13, %rdi
callq 0x770a
movl %eax, 0x18(%r13)
movq %r14, %rdi
callq 0x82d7
testl %eax, %eax
jle 0x6387
leaq 0x80(%rsp), %r14
leaq 0x68(%rsp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x5782
movq %r14, %rdi
callq 0x5e73
movl %eax, 0x34(%r12)
movq %r14, %rdi
callq 0x770a
movl %eax, 0x30(%r12)
subl 0x4c(%rsp), %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x5dcb
movl %eax, %ebp
leaq 0x68(%rsp), %rdi
callq 0x82d7
movl %eax, %r12d
movb %bpl, 0xb(%rsp)
movzbl %bpl, %edi
movl %edi, 0x14(%rsp)
callq 0x5e5d
movl %eax, %r14d
movl 0x48(%rsp), %ebp
movzbl %bpl, %edi
callq 0x5e5d
testl %r12d, %r12d
movq %rbx, 0x50(%rsp)
je 0x63ff
cmpl %eax, %r14d
je 0x63df
xorl $0x1, %ebp
movl %ebp, 0x48(%rsp)
movl 0x98(%rsp), %ebx
movzbl %bl, %edi
callq 0x5e5d
cmpl %eax, %r14d
jne 0x640b
xorl $0x1, %ebx
movl %ebx, 0x98(%rsp)
jmp 0x640b
cmpl %eax, %r14d
jne 0x640b
xorl $0x1, %ebp
movl %ebp, 0x48(%rsp)
movq %r13, %rdi
movl %ebp, %esi
callq 0x7780
leaq 0x80(%rsp), %r14
movl 0x18(%r14), %esi
movq %r14, %rdi
callq 0x7780
movl 0x10(%rsp), %ebp
movl %ebp, %eax
andl $0x40, %eax
movl %eax, %r8d
movl %eax, 0x5c(%rsp)
andl $0x80, %ebp
leaq 0xa8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x68(%rsp), %rbx
movq %rbx, %rdx
xorl %ecx, %ecx
movl %ebp, %r9d
callq 0x5934
movl 0x34(%rbx), %r12d
leaq 0x18(%rsp), %rax
addl 0x34(%rax), %r12d
leaq 0xa8(%rsp), %rax
movl 0x18(%rax), %esi
leal 0x7(%rsi), %eax
pushq $0x8
popq %rbx
cltd
idivl %ebx
addl %eax, %r12d
leaq 0x3ca2(%rip), %rdi      # 0xa12b
movl %eax, %edx
xorl %eax, %eax
callq 0x20c0
cvtsi2sd %r12d, %xmm1
leaq 0x68(%rsp), %rax
movl 0x10(%rax), %eax
leaq 0x18(%rsp), %rcx
addl 0x10(%rcx), %eax
cvtsi2sd %eax, %xmm0
divsd %xmm0, %xmm1
movsd 0x2e19(%rip), %xmm0     # 0x92d0
subsd %xmm1, %xmm0
mulsd 0x2e15(%rip), %xmm0     # 0x92d8
leaq 0x3c85(%rip), %rdi      # 0xa14f
movl %r12d, %esi
movb $0x1, %al
callq 0x20c0
leaq 0xa8(%rsp), %r12
movq %r12, %rdi
callq 0x6ef4
movq 0x50(%rsp), %rax
movl 0x18(%rax), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movq %r12, %rdi
leaq 0x18(%rsp), %rsi
leaq 0x68(%rsp), %r12
movq %r12, %rdx
movl %eax, %ecx
movl 0x5c(%rsp), %r8d
movl %ebp, %r9d
callq 0x5934
movl 0x34(%r12), %ebp
leaq 0x18(%rsp), %r12
addl 0x34(%r12), %ebp
leaq 0xa8(%rsp), %rax
movl 0x18(%rax), %esi
leal 0x7(%rsi), %eax
cltd
idivl %ebx
addl %eax, %ebp
leaq 0x3c44(%rip), %rdi      # 0xa17e
movl %eax, %edx
xorl %eax, %eax
callq 0x20c0
cvtsi2sd %ebp, %xmm0
leaq 0x68(%rsp), %rax
movl 0x10(%rax), %eax
addl 0x10(%r12), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd 0x2d6c(%rip), %xmm1     # 0x92d0
subsd %xmm0, %xmm1
mulsd 0x2d68(%rip), %xmm1     # 0x92d8
movapd %xmm1, %xmm0
leaq 0x3bd4(%rip), %rdi      # 0xa14f
movl %ebp, %esi
movb $0x1, %al
callq 0x20c0
leaq 0x68(%rsp), %rax
movl 0x34(%rax), %r12d
leaq 0x18(%rsp), %rax
addl 0x34(%rax), %r12d
leaq 0x3aee(%rip), %rsi      # 0xa08b
movq 0x50(%rsp), %rdi
callq 0x330a
movl %r12d, 0x124(%rax)
movl 0x1c(%r15), %edx
cmpl %edx, %ebp
jg 0x682c
movl 0x9c(%rsp), %esi
addl 0x4c(%rsp), %esi
movl 0xc0(%rsp), %eax
addl $0x7, %eax
cltd
idivl %ebx
addl %eax, %esi
movl %esi, 0x1c(%r15)
leaq 0x3c04(%rip), %rdi      # 0xa1e3
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x20c0
movslq 0x1c(%r15), %rdi
callq 0x75d9
movq %rax, 0x38(%r15)
orb $0x1, 0x30(%r15)
movl $0xfffefff0, %ecx       # imm = 0xFFFEFFF0
subl 0x28(%rsp), %ecx
movl %ecx, (%rax)
movl 0x48(%rsp), %ecx
movl %ecx, 0x4(%rax)
movq %r13, %rdi
callq 0x82d7
cltq
cmpq %rax, %r12
jge 0x6637
movq %r13, %rdi
movl %r12d, %esi
callq 0x831b
movb (%rax), %al
movq 0x38(%r15), %rcx
movb %al, 0x8(%rcx,%r12)
incq %r12
jmp 0x660d
leaq 0x68(%rsp), %rdi
callq 0x82d7
testl %eax, %eax
movq 0xa0(%rsp), %r12
movl 0xc(%rsp), %r13d
jle 0x66a7
movl 0x28(%rsp), %eax
addl 0x78(%rsp), %eax
movl 0x4c(%rsp), %ecx
movl $0xfffefff0, %edx       # imm = 0xFFFEFFF0
subl %eax, %edx
movq 0x38(%r15), %rax
movl %edx, (%rax,%rcx)
movl 0x98(%rsp), %ecx
movl 0x4c(%rsp), %edx
movl %ecx, 0x4(%rax,%rdx)
leal -0x8(%rbx), %ebp
movq %r14, %rdi
callq 0x82d7
cmpl %eax, %ebp
jge 0x66a7
movq %r14, %rdi
movl %ebp, %esi
callq 0x831b
movb (%rax), %al
movq 0x38(%r15), %rcx
movl 0x4c(%rsp), %edx
addl %ebx, %edx
movb %al, (%rcx,%rdx)
incl %ebx
jmp 0x667b
movq 0x38(%r15), %rsi
movl 0x9c(%rsp), %edx
addl 0x4c(%rsp), %edx
shll $0x3, %edx
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
callq 0x6f0c
movl 0x9c(%rsp), %esi
addl 0x4c(%rsp), %esi
leaq 0x3b1b(%rip), %rdi      # 0xa1f6
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x20c0
movq %r14, %rdi
callq 0x6ef4
movl $0xffff, %eax           # imm = 0xFFFF
movq 0x50(%rsp), %rbx
addl 0x18(%rbx), %eax
movl $0x10000, %ecx          # imm = 0x10000
cltd
idivl %ecx
movl %eax, %r14d
leaq 0x3b01(%rip), %rsi      # 0xa20c
movq %rbx, %rdi
callq 0x330a
movl %r14d, 0x124(%rax)
movl 0x18(%rbx), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %eax, %r14d
leaq 0x3aef(%rip), %rsi      # 0xa21c
movq %rbx, %rdi
callq 0x330a
movl %r14d, 0x124(%rax)
leaq 0x3aea(%rip), %rsi      # 0xa22d
movq %r12, %rdi
callq 0x5d5b
xorl %ecx, %ecx
subl 0x4c(%rsp), %ecx
movl %ecx, 0x3c(%rax)
movq 0x48(%rbx), %rdi
movl %r13d, %esi
callq 0x56a3
cmpq $0x0, 0x10(%rbx)
jne 0x6789
leaq 0x3ac7(%rip), %rsi      # 0xa235
movq %rbx, %rdi
callq 0x330a
movb 0x4c(%rsp), %cl
movq 0x38(%r12), %rdx
movslq 0x124(%rax), %rax
addb %cl, (%rdx,%rax)
leaq 0x3ab7(%rip), %rsi      # 0xa247
movq %rbx, %rdi
callq 0x330a
movq %rax, %r14
movb 0x4c(%rsp), %al
movq 0x38(%r12), %rcx
movslq 0x124(%r14), %rdx
movb %al, (%rcx,%rdx)
subl 0x4c(%rsp), %ebp
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x5dcb
cmpb %al, 0xb(%rsp)
jne 0x683e
movl 0x14(%rsp), %edi
callq 0x5e5d
testl %eax, %eax
jne 0x67e3
movq 0x38(%r12), %rax
movslq 0x124(%r14), %rcx
xorb $0x1, 0x1(%rax,%rcx)
leaq 0x18(%rsp), %rdi
callq 0x5835
leaq 0x68(%rsp), %rdi
callq 0x5835
cmpq $0x0, 0x20(%rbx)
je 0x6806
movq %rbx, %rdi
callq 0x5c3a
movq %rbx, %rdi
movl %r13d, %esi
callq 0x5c6e
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3869(%rip), %rdi      # 0xa093
jmp 0x687a
leaq 0x3973(%rip), %rdi      # 0xa1a6
movl %ebp, %esi
xorl %eax, %eax
callq 0x7514
jmp 0x6881
movl 0x4c(%rsp), %ebp
movl %ebp, %edx
negl %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5dcb
movzbl %al, %ecx
leaq 0x39fe(%rip), %rdi      # 0xa259
movl %ebp, %esi
movl 0x14(%rsp), %edx
xorl %eax, %eax
callq 0x7514
jmp 0x6881
leaq 0x36c0(%rip), %rdi      # 0x9f31
jmp 0x687a
leaq 0x384f(%rip), %rdi      # 0xa0c9
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0