// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_file_load_omf_module
xlink_module *xlink_file_load_omf_module(xlink_file *file, unsigned int flags) {
  xlink_module *mod;
  xlink_omf omf;
  xlink_data *dat;
  int done;
  int i, j;
  mod = xlink_malloc(sizeof(xlink_module));
  mod->filename = file->name;
  xlink_omf_init(&omf);
  dat = NULL;
  done = 0;
  while (file->size > 0 && !done) {
    xlink_omf_record rec;
    int i;
    xlink_file_load_omf_record(file, &rec);
    xlink_omf_add_record(&omf, &rec);
    switch (rec.type & ~1) {
      case OMF_THEADR :
      case OMF_LHEADR : {
        strcpy(mod->source, xlink_omf_record_read_string(&rec));
        break;
      }
      case OMF_MODEND : {
        done = 1;
        break;
      }
      case OMF_LNAMES :
      case OMF_LLNAMES : {
        while (xlink_omf_record_has_data(&rec)) {
          xlink_name *name;
          name = xlink_malloc(sizeof(xlink_name));
          strcpy(name->str, xlink_omf_record_read_string(&rec));
          XLINK_LIST_ADD(module, name, mod, name);
        }
        break;
      }
      case OMF_SEGDEF : {
        xlink_segment *seg;
        seg = xlink_malloc(sizeof(xlink_segment));
        seg->attrib.b = xlink_omf_record_read_byte(&rec);
        if (seg->attrib.align == 0) {
          seg->frame = xlink_omf_record_read_word(&rec);
          seg->offset = xlink_omf_record_read_byte(&rec);
        }
        else {
          seg->frame = seg->offset = 0;
        }
        seg->length = xlink_omf_record_read_numeric(&rec);
        XLINK_ERROR(seg->attrib.big && seg->length != 0,
         ("Invalid length for 'big' segment, expected 0 got %i", seg->length));
        seg->name =
         xlink_module_get_name(mod, xlink_omf_record_read_index(&rec));
        seg->class =
         xlink_module_get_name(mod, xlink_omf_record_read_index(&rec));
        /* Read and ignore Overlay Name Index */
        xlink_omf_record_read_index(&rec);
        seg->info = 0;
        seg->data = xlink_malloc(seg->length);
        seg->mask = xlink_malloc(CEIL2(seg->length, 3));
        xlink_segment_reset_mask(seg);
        XLINK_LIST_ADD(module, segment, mod, seg);
        break;
      }
      case OMF_GRPDEF : {
        xlink_group *grp;
        grp = xlink_malloc(sizeof(xlink_group));
        grp->name =
         xlink_module_get_name(mod, xlink_omf_record_read_index(&rec));
        grp->nsegments = 0;
        while (xlink_omf_record_has_data(&rec)) {
          unsigned char index;
          xlink_segment *s;
          index = xlink_omf_record_read_byte(&rec);
          XLINK_ERROR(index != 0xFF, ("Invalid segment index %i", index));
          s = xlink_module_get_segment(mod, xlink_omf_record_read_index(&rec));
          XLINK_ERROR(s->group != NULL,
           ("Cannot add segment %s to group %s, already added to group %s:%i",
           xlink_segment_get_name(s), xlink_group_get_name(grp), s->group->name,
           s->group->index));
          s->group = grp;
          xlink_group_add_segment(grp, s);
        }
        XLINK_LIST_ADD(module, group, mod, grp);
        break;
      }
      case OMF_PUBDEF :
      case OMF_LPUBDEF : {
        int group_idx;
        int segment_idx;
        xlink_public base;
        group_idx = xlink_omf_record_read_index(&rec);
        segment_idx = xlink_omf_record_read_index(&rec);
        base.group = group_idx ? xlink_module_get_group(mod, group_idx) : NULL;
        base.segment =
         segment_idx ? xlink_module_get_segment(mod, segment_idx) : NULL;
        base.base_frame =
         base.segment == NULL ? xlink_omf_record_read_word(&rec) : 0;
        base.is_local = ((rec.type & ~1) == OMF_LPUBDEF);
        while (xlink_omf_record_has_data(&rec)) {
          xlink_public *pub;
          pub = xlink_malloc(sizeof(xlink_public));
          *pub = base;
          strcpy(pub->name, xlink_omf_record_read_string(&rec));
          pub->offset = xlink_omf_record_read_numeric(&rec);
          pub->type_idx = xlink_omf_record_read_index(&rec);
          XLINK_LIST_ADD(module, public, mod, pub);
          if (pub->segment) {
            xlink_segment_add_public(pub->segment, pub);
          }
        }
        break;
      }
      case OMF_EXTDEF :
      case OMF_LEXTDEF : {
        xlink_extern base;
        base.is_local = (rec.type == OMF_LEXTDEF);
        while (xlink_omf_record_has_data(&rec)) {
          xlink_extern *ext;
          ext = xlink_malloc(sizeof(xlink_extern));
          *ext = base;
          strcpy(ext->name, xlink_omf_record_read_string(&rec));
          ext->type_idx = xlink_omf_record_read_index(&rec);
          XLINK_LIST_ADD(module, extern, mod, ext);
        }
        break;
      }
      case OMF_LEDATA :
      case OMF_LIDATA : {
        xlink_segment *seg;
        seg = xlink_module_get_segment(mod, xlink_omf_record_read_index(&rec));
        seg->info |= SEG_HAS_DATA;
        dat = xlink_malloc(sizeof(xlink_data));
        dat->segment = seg;
        dat->offset = xlink_omf_record_read_numeric(&rec);
        dat->is_iterated = rec.type & 0x2;
        dat->length = xlink_omf_record_data_left(&rec);
        dat->data = xlink_malloc(dat->length);
        dat->mask = xlink_malloc(CEIL2(dat->length, 3));
        memcpy(dat->data, &rec.buf[rec.idx], dat->length);
        xlink_data_reset_mask(dat);
        if (!dat->is_iterated) {
          XLINK_ERROR(dat->offset + dat->length > seg->length,
           ("LEDATA wrote past end of segment %s, offset = %i but length = %i",
           xlink_segment_get_name(seg), dat->offset + dat->length,
           seg->length));
          memcpy(&seg->data[dat->offset], &rec.buf[rec.idx], dat->length);
          for (i = 0; i < dat->length; i++) {
            XLINK_ERROR(XLINK_GET_BIT(seg->mask, dat->offset + i),
             ("LEDATA overwrote existing data in segment %s, offset = %i",
             xlink_segment_get_name(seg), dat->offset + i));
            XLINK_SET_BIT(seg->mask, dat->offset + i, 1);
          }
        }
        else {
          int size;
          size = xlink_omf_record_load_iterated(&rec, &seg->data[dat->offset],
           seg->length - dat->offset);
          for (i = 0; i < size; i++) {
            XLINK_ERROR(XLINK_GET_BIT(seg->mask, dat->offset + i),
             ("LIDATA overwrote existing data in segment %s, offset = %i",
             xlink_segment_get_name(seg), dat->offset + i));
            XLINK_SET_BIT(seg->mask, dat->offset + i, 1);
          }
        }
        XLINK_LIST_ADD(module, data, mod, dat);
        xlink_segment_add_data(dat->segment, dat);
        break;
      }
      case OMF_FIXUPP : {
        while (xlink_omf_record_has_data(&rec)) {
          unsigned char byte;
          byte = xlink_omf_record_read_byte(&rec);
          if (byte & 0x80) {
            xlink_segment *seg;
            xlink_reloc *rel;
            xlink_omf_fixup_locat locat;
            xlink_omf_fixup_fixdata fixdata;
            const unsigned char *data;
            XLINK_ERROR(dat == NULL, ("Got FIXUP before LxDATA record"));
            XLINK_ERROR(dat->is_iterated,
             ("FIXUP records for LIDATA not yet supported"));
            seg = dat->segment;
            rel = xlink_malloc(sizeof(xlink_reloc));
            rel->segment = seg;
            locat.b0 = byte;
            locat.b1 = xlink_omf_record_read_byte(&rec);
            XLINK_ERROR(locat.high != 1, ("Expecting FIXUP subrecord"));
            rel->offset = dat->offset + locat.offset;
            rel->mode = locat.mode;
            rel->location = locat.location;
            XLINK_ERROR(
             seg->length < rel->offset + OMF_FIXUP_SIZE[rel->location],
             ("FIXUP offset %i past segment end %i", rel->offset, seg->length));
            for (i = 0; i < OMF_FIXUP_SIZE[rel->location]; i++) {
              XLINK_ERROR(XLINK_GET_BIT(seg->mask, rel->offset + i) == 0,
               ("FIXUP modifies uninitialized data, location %i",
               rel->offset + i));
            }
            fixdata.b = xlink_omf_record_read_byte(&rec);
            if (!fixdata.th_frame) {
              rel->frame = fixdata.frame;
              rel->frame_idx = 0;
              if (fixdata.frame < OMF_FRAME_LOC) {
                rel->frame_idx = xlink_omf_record_read_index(&rec);
                switch (rel->frame) {
                  case OMF_FRAME_SEG : {
                    xlink_module_get_segment(mod, rel->frame_idx);
                    break;
                  }
                  case OMF_FRAME_GRP : {
                    xlink_module_get_group(mod, rel->frame_idx);
                    break;
                  }
                  case OMF_FRAME_EXT : {
                    xlink_module_get_extern(mod, rel->frame_idx);
                    break;
                  }
                }
              }
            }
            else {
              // TODO: Get frame info from thread in xlink_omf struct
            }
            if (!fixdata.th_target) {
              rel->target = (fixdata.no_disp << 2) + fixdata.target;
              rel->target_idx = xlink_omf_record_read_index(&rec);
              switch (rel->target) {
                case OMF_TARGET_SEG :
                case OMF_TARGET_SEG_DISP : {
                  xlink_module_get_segment(mod, rel->target_idx);
                  break;
                }
                case OMF_TARGET_GRP :
                case OMF_TARGET_GRP_DISP : {
                  xlink_module_get_group(mod, rel->target_idx);
                  break;
                }
                case OMF_TARGET_EXT :
                case OMF_TARGET_EXT_DISP : {
                  xlink_module_get_extern(mod, rel->target_idx);
                  break;
                }
              }
            }
            else {
              // TODO: Get target info from thread in xlink_omf struct
            }
            if (!fixdata.no_disp) {
              rel->disp = xlink_omf_record_read_numeric(&rec);
            }
            data = seg->data + rel->offset;
            switch (rel->location) {
              case OMF_LOCATION_8BIT :
              case OMF_LOCATION_8BIT_HIGH : {
                rel->addend.offset = *(int8_t *)data;
                break;
              }
              case OMF_LOCATION_16BIT :
              case OMF_LOCATION_SEGMENT :
              case OMF_LOCATION_16BIT_LOADER : {
                rel->addend.offset = *(int16_t *)data;
                break;
              }
              case OMF_LOCATION_FAR : {
                rel->addend.segment = *(uint16_t *)(data + 2),
                rel->addend.offset = *(int16_t *)data;
                break;
              }
              case OMF_LOCATION_32BIT :
              case OMF_LOCATION_32BIT_LOADER : {
                rel->addend.offset = *(int32_t *)data;
                break;
              }
              case OMF_LOCATION_48BIT :
              case OMF_LOCATION_48BIT_PHARLAP : {
                rel->addend.segment = *(uint16_t *)(data + 4),
                rel->addend.offset = *(int32_t *)data;
                break;
              }
              default : {
                XLINK_ERROR(1, ("Unsupported location %i", rel->location));
              }
            }
            XLINK_LIST_ADD(module, reloc, mod, rel);
            xlink_segment_add_reloc(rel->segment, rel);
          }
          else {
            xlink_omf_fixup_thread th;
            int index;
            XLINK_ERROR(th.high != 0, ("Expecting THREAD subrecord"));
            index = 0;
            if (th.method < OMF_FRAME_LOC) {
              index = xlink_omf_record_read_index(&rec);
            }
          }
        }
      }
    }
  }
  XLINK_ERROR(!done, ("Got EOF before reading MODEND in %s", file->name));
  for (i = 1; i <= mod->nsegments; i++) {
    xlink_segment *seg;
    seg = xlink_module_get_segment(mod, i);
    /* Check that all segments are either fully populated or uninitialized */
    if (seg->info & SEG_HAS_DATA) {
      for (j = 0; j < seg->length; j++) {
        XLINK_ERROR(XLINK_GET_BIT(seg->mask, j) == 0,
         ("Missing data for segment %s, offset = %i",
         xlink_segment_get_name(seg), j));
      }
    }
    else {
      free(seg->data);
      free(seg->mask);
      seg->data = seg->mask = NULL;
    }
    /* Sort the PUBDEF and FIXUPP records by their offset into segment */
    qsort(seg->publics, seg->npublics, sizeof(xlink_public *), pub_comp);
    qsort(seg->relocs, seg->nrelocs, sizeof(xlink_reloc *), rel_comp);
    if ((seg->info & SEG_HAS_DATA) == 0) {
      XLINK_ERROR(seg->nrelocs != 0,
       ("Uninitialized segment %s has %i relocations, should have none",
       xlink_segment_get_name(seg), seg->nrelocs));
    }
  }
  if (flags & MOD_SPLIT) {
    xlink_module_split_segments(mod);
  }
  if (flags & MOD_DUMP) {
    printf("Module: %s\n", mod->filename);
    xlink_omf_dump_records(&omf);
    xlink_module_dump_names(mod);
    xlink_module_dump_symbols(mod);
    xlink_module_dump_segments(mod);
    xlink_omf_dump_lxdata(&omf, mod);
    xlink_module_dump_relocations(mod);
  }
  xlink_omf_clear(&omf);
  return mod;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %esi, 0x34(%rsp)
movq %rdi, %rbp
movl $0x188, %edi            # imm = 0x188
callq 0x75d9
movq %rax, %rbx
movq (%rbp), %rax
movq %rax, (%rbx)
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rax
movaps %xmm0, (%rax)
movq %rbx, %rax
addq $0x18, %rax
movq %rax, 0x50(%rsp)
xorl %r12d, %r12d
leaq 0x8(%rsp), %r13
xorl %r14d, %r14d
movq %rbp, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
cmpl $0x0, 0x8(%rbp)
je 0x4fd6
testl %r12d, %r12d
jne 0x4fd6
movq %rbp, %rdi
movq %r13, %rsi
callq 0x5278
leaq 0x40(%rsp), %rdi
movq %r13, %rsi
callq 0x2a67
movzbl 0x14(%rsp), %ebp
movl %ebp, %eax
andl $-0x2, %eax
xorl %r12d, %r12d
leal -0x96(%rax), %ecx
cmpl $0xc, %ecx
movq %r14, 0x28(%rsp)
jbe 0x4752
cmpl $0x80, %eax
je 0x4a33
cmpl $0x82, %eax
je 0x4a33
cmpl $0x8a, %eax
je 0x4d3e
cmpl $0x8c, %eax
je 0x4a51
cmpl $0x90, %eax
je 0x4ad3
cmpl $0xb4, %eax
je 0x4a51
cmpl $0xb6, %eax
je 0x4ad3
cmpl $0xca, %eax
leaq 0xede9(%rip), %rbp      # 0x13530
je 0x4d05
jmp 0x4dd4
leaq 0x48ef(%rip), %rdx      # 0x9048
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movq %r13, %rdi
callq 0x3c0e
movq %rbx, %rdi
movl %eax, %esi
callq 0x2bf6
movq %rax, %r15
orb $0x1, 0x30(%rax)
pushq $0x38
popq %rdi
callq 0x75d9
movq %rax, 0x28(%rsp)
movq %r15, 0x10(%rax)
movzbl 0x14(%rsp), %eax
movq 0x8(%rsp), %r12
movslq 0x10(%rsp), %rdx
testb $0x1, %al
jne 0x4b06
movzwl (%r12,%rdx), %ecx
leal 0x2(%rdx), %ebp
jmp 0x4b0d
movq 0x8(%rsp), %r15
leaq 0x1(%r12), %rbx
movl %ebx, 0x10(%rsp)
movzbl (%r15,%r12), %eax
testb %al, %al
js 0x47de
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x3c0e
movq 0x20(%rsp), %rbx
jmp 0x4a0e
testq %r14, %r14
je 0x51d3
cmpl $0x0, 0x1c(%r14)
jne 0x51dc
movzwl %ax, %ebp
movq %r14, %r13
movq 0x10(%r14), %r14
pushq $0x40
popq %rdi
callq 0x75d9
movq %r14, 0x10(%rax)
movq %r15, %r11
movq %rax, %r15
movzbl (%r11,%rbx), %r8d
movl 0x18(%r13), %ecx
movl %ebp, %edi
andl $0x3, %edi
shll $0x8, %edi
leal (%rdi,%r8), %esi
addl %ecx, %esi
movl %esi, 0x18(%rax)
movl %ebp, %eax
shrl $0x6, %eax
andl $0x1, %eax
movl %eax, 0x1c(%r15)
shrl $0x2, %ebp
andl $0xf, %ebp
movl %ebp, 0x20(%r15)
movl 0x1c(%r14), %edx
leaq 0x48e7(%rip), %rax      # 0x9130
movl (%rax,%rbp,4), %r9d
leal (%r9,%rsi), %eax
cmpl %eax, %edx
jb 0x51ec
xorl %eax, %eax
testl %r9d, %r9d
cmovlel %eax, %r9d
negl %r9d
cmpl %eax, %r9d
je 0x4890
movq 0x40(%r14), %rdx
movl %esi, %r10d
shrl $0x3, %r10d
movzbl (%rdx,%r10), %edx
movl %esi, %r10d
andl $0x7, %r10d
decl %eax
incl %esi
btl %r10d, %edx
jb 0x4865
jmp 0x5115
movl %r12d, %eax
addl $0x3, %eax
movl %eax, 0x10(%rsp)
movzbl 0x2(%r11,%r12), %ebp
testb %bpl, %bpl
leaq 0x8(%rsp), %r13
js 0x4903
movl %ebp, %ebx
shrl $0x4, %ebx
movl %ebx, 0x24(%r15)
andl $0x0, 0x2c(%r15)
cmpb $0x3f, %bpl
ja 0x4903
movq %r13, %rdi
callq 0x3c0e
movl %eax, 0x2c(%r15)
cmpb $0x2, %bl
je 0x48f7
movzbl %bl, %ecx
cmpl $0x1, %ecx
je 0x48e9
testl %ecx, %ecx
jne 0x4903
movq 0x20(%rsp), %rdi
movl %eax, %esi
callq 0x2bf6
jmp 0x4903
movq 0x20(%rsp), %rdi
movl %eax, %esi
callq 0x2ca5
jmp 0x4903
movq 0x20(%rsp), %rdi
movl %eax, %esi
callq 0x2eb2
testb $0x8, %bpl
jne 0x4963
movl %ebp, %ebx
andl $0x7, %ebx
movl %ebx, 0x28(%r15)
movq %r13, %rdi
callq 0x3c0e
movl %eax, 0x30(%r15)
cmpb $0x6, %bl
ja 0x4963
pushq $0x11
popq %rcx
btl %ebx, %ecx
jb 0x4957
pushq $0x22
popq %rcx
btl %ebx, %ecx
jb 0x4949
pushq $0x44
popq %rcx
btl %ebx, %ecx
jae 0x4963
movq 0x20(%rsp), %rdi
movl %eax, %esi
callq 0x2eb2
jmp 0x4963
movq 0x20(%rsp), %rdi
movl %eax, %esi
callq 0x2ca5
jmp 0x4963
movq 0x20(%rsp), %rdi
movl %eax, %esi
callq 0x2bf6
testb $0x4, %bpl
jne 0x4991
testb $0x1, 0x14(%rsp)
movq 0x8(%rsp), %rax
movslq 0x10(%rsp), %rcx
jne 0x4983
movzwl (%rax,%rcx), %eax
addl $0x2, %ecx
jmp 0x4989
movl (%rax,%rcx), %eax
addl $0x4, %ecx
movl %ecx, 0x10(%rsp)
movl %eax, 0x34(%r15)
movl 0x20(%r15), %esi
cmpq $0xd, %rsi
ja 0x5218
movq 0x38(%r14), %rax
movl 0x18(%r15), %ecx
leaq 0x46ce(%rip), %rdi      # 0x907c
movslq (%rdi,%rsi,4), %rdx
addq %rdi, %rdx
jmpq *%rdx
movsbl (%rax,%rcx), %eax
jmp 0x49da
movzwl 0x4(%rax,%rcx), %edx
movw %dx, 0x38(%r15)
movl (%rax,%rcx), %eax
jmp 0x49da
movzwl 0x2(%rax,%rcx), %edx
movw %dx, 0x38(%r15)
movswl (%rax,%rcx), %eax
movq 0x20(%rsp), %rbx
movl %eax, 0x3c(%r15)
movl 0x180(%rbx), %eax
incl %eax
movl %eax, (%r15)
movq %rbx, 0x8(%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2f15
movq 0x10(%r15), %rdi
movq %r15, %rsi
callq 0x2473
movq 0x28(%rsp), %r14
movzwl 0x16(%rsp), %eax
movslq 0x10(%rsp), %r12
subl %r12d, %eax
addl $0x2, %eax
testl %eax, %eax
jg 0x47b0
movq 0x18(%rsp), %rbp
xorl %r12d, %r12d
jmp 0x46a6
movq %r13, %rdi
callq 0x393e
movq 0x50(%rsp), %rdi
leaq 0xeae9(%rip), %rsi      # 0x13530
callq 0x2050
jmp 0x4dd4
xorl %r12d, %r12d
cmpb $-0x4c, %bpl
sete %r12b
leaq 0xeacd(%rip), %rbp      # 0x13530
movzwl 0x16(%rsp), %eax
subl 0x10(%rsp), %eax
addl $0x2, %eax
testl %eax, %eax
jle 0x4ac9
movl $0x120, %edi            # imm = 0x120
callq 0x75d9
movq %rax, %r14
movl %r12d, 0x114(%rax)
leaq 0x10(%rax), %r15
movq %r13, %rdi
callq 0x393e
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2050
movq %r13, %rdi
callq 0x3c0e
movl %eax, 0x110(%r14)
movl 0x160(%rbx), %eax
incl %eax
movl %eax, (%r14)
movq %rbx, 0x8(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2e66
jmp 0x4a63
movq 0x18(%rsp), %rbp
jmp 0x4ef8
movq %r13, %rdi
callq 0x3c0e
movl %eax, %r14d
movq %r13, %rdi
callq 0x3c0e
movl %eax, %ebp
testl %r14d, %r14d
je 0x4dde
movq %rbx, %rdi
movl %r14d, %esi
callq 0x2ca5
movq %rax, 0x38(%rsp)
jmp 0x4de7
movl (%r12,%rdx), %ecx
leal 0x4(%rdx), %ebp
movl %ebp, 0x10(%rsp)
movq 0x28(%rsp), %r14
movl %ecx, 0x18(%r14)
andl $0x2, %eax
movl %eax, 0x1c(%r14)
movzwl 0x16(%rsp), %eax
subl %ebp, %eax
addl $0x2, %eax
movl %eax, 0x20(%r14)
movslq %eax, %rdi
callq 0x75d9
movq %rax, 0x28(%r14)
movl 0x20(%r14), %eax
addl $0x7, %eax
sarl $0x3, %eax
movslq %eax, %rdi
callq 0x75d9
movq %rax, 0x30(%r14)
movq 0x28(%r14), %rdi
movslq %ebp, %rax
addq %rax, %r12
movslq 0x20(%r14), %rdx
movq %r12, %rsi
callq 0x2140
movq 0x30(%r14), %rdi
movl 0x20(%r14), %eax
addl $0x7, %eax
sarl $0x3, %eax
movslq %eax, %rdx
xorl %esi, %esi
callq 0x20d0
cmpl $0x0, 0x1c(%r14)
je 0x4d49
movl 0x18(%r14), %esi
movl 0x1c(%r15), %edx
subl %esi, %edx
addq 0x38(%r15), %rsi
movq %r13, %rdi
callq 0x4571
xorl %ebp, %ebp
testl %eax, %eax
cmovlel %ebp, %eax
xorl %r12d, %r12d
cmpl %ebp, %eax
je 0x4dae
movq 0x40(%r15), %rdx
movl 0x18(%r14), %r8d
addl %ebp, %r8d
movl %r8d, %esi
movl %r8d, %ecx
andb $0x7, %cl
pushq $0x1
popq %rdi
shll %cl, %edi
shrl $0x3, %esi
movzbl (%rdx,%rsi), %ecx
andl $0x7, %r8d
btl %r8d, %ecx
jb 0x5151
orb %cl, %dil
movb %dil, (%rdx,%rsi)
incl %ebp
jmp 0x4baa
pushq $0x28
popq %rdi
callq 0x75d9
movq %rax, %r14
movq %r13, %rdi
callq 0x3c0e
movq %rbx, %rdi
movl %eax, %esi
callq 0x2b47
movq %rax, 0x10(%r14)
andl $0x0, 0x20(%r14)
movq 0x18(%rsp), %rbp
movzwl 0x16(%rsp), %ecx
movslq 0x10(%rsp), %rax
subl %eax, %ecx
addl $0x2, %ecx
testl %ecx, %ecx
jle 0x4d1a
movq 0x8(%rsp), %rcx
leal 0x1(%rax), %edx
movl %edx, 0x10(%rsp)
movzbl (%rcx,%rax), %esi
cmpl $0xff, %esi
jne 0x5166
movq %r13, %rdi
callq 0x3c0e
movq %rbx, %rdi
movl %eax, %esi
callq 0x2bf6
movq %rax, %r15
cmpq $0x0, 0x48(%rax)
jne 0x516f
movq %r14, 0x48(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x261d
jmp 0x4c16
movl $0x80, %edi
callq 0x75d9
movq %rax, %r15
movq 0x8(%rsp), %rcx
movslq 0x10(%rsp), %rsi
leaq 0x1(%rsi), %rdx
movb (%rcx,%rsi), %al
movb %al, 0x10(%r15)
cmpb $0x1f, %al
ja 0x4f05
movzwl (%rcx,%rdx), %edx
movl %edx, 0x14(%r15)
leal 0x4(%rsi), %edx
movzbl 0x3(%rcx,%rsi), %esi
jmp 0x4f0c
leaq 0xe870(%rip), %rbp      # 0x13530
jmp 0x4d05
movl $0x110, %edi            # imm = 0x110
callq 0x75d9
movq %rax, %r14
leaq 0x10(%rax), %r15
movq %r13, %rdi
callq 0x393e
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2050
movl 0x120(%rbx), %eax
incl %eax
movl %eax, (%r14)
movq %rbx, 0x8(%r14)
movq %rbx, %rdi
movq %r14, %rsi
movq 0x28(%rsp), %r14
callq 0x2afb
movzwl 0x16(%rsp), %eax
subl 0x10(%rsp), %eax
addl $0x2, %eax
testl %eax, %eax
jg 0x4cc2
jmp 0x4dd4
movl 0x140(%rbx), %eax
incl %eax
movl %eax, (%r14)
movq %rbx, 0x8(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2c59
movq 0x28(%rsp), %r14
jmp 0x46a6
pushq $0x1
popq %rax
movl %eax, %r12d
jmp 0x4dd4
movl 0x18(%r14), %edi
movslq 0x20(%r14), %rdx
leal (%rdx,%rdi), %eax
cmpl 0x1c(%r15), %eax
ja 0x5230
addq 0x38(%r15), %rdi
movq %r12, %rsi
callq 0x2140
xorl %ebp, %ebp
movq 0x28(%rsp), %r14
xorl %r12d, %r12d
cmpl 0x20(%r14), %ebp
jge 0x4dae
movq 0x40(%r15), %rax
movl 0x18(%r14), %edi
addl %ebp, %edi
movl %edi, %edx
movl %edi, %ecx
andb $0x7, %cl
pushq $0x1
popq %rsi
shll %cl, %esi
shrl $0x3, %edx
movzbl (%rax,%rdx), %ecx
andl $0x7, %edi
btl %edi, %ecx
jb 0x51a8
orb %cl, %sil
movb %sil, (%rax,%rdx)
incl %ebp
jmp 0x4d74
movl 0x170(%rbx), %eax
incl %eax
movl %eax, (%r14)
movq %rbx, 0x8(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2db7
movq 0x10(%r14), %rdi
movq %r14, %rsi
callq 0x23df
movq 0x18(%rsp), %rbp
jmp 0x46a6
movq $0x0, 0x38(%rsp)
testl %ebp, %ebp
je 0x4e02
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2bf6
testq %rax, %rax
je 0x4e02
movq %rax, %r14
xorl %r13d, %r13d
jmp 0x4e1b
movq 0x8(%rsp), %rax
movslq 0x10(%rsp), %rcx
movzwl (%rax,%rcx), %r13d
leal 0x2(%rcx), %eax
movl %eax, 0x10(%rsp)
xorl %r14d, %r14d
movb 0x14(%rsp), %al
andb $-0x2, %al
xorl %r15d, %r15d
cmpb $-0x4a, %al
sete %r15b
movzwl 0x16(%rsp), %eax
subl 0x10(%rsp), %eax
addl $0x2, %eax
testl %eax, %eax
jle 0x4eee
movl $0x130, %edi            # imm = 0x130
callq 0x75d9
movq %rax, %rbp
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rbp)
movq %r14, 0x18(%rbp)
movl %r13d, 0x20(%rbp)
leaq 0x24(%rbp), %r12
movl %r15d, 0x12c(%rbp)
leaq 0x8(%rsp), %rdi
callq 0x393e
movq %r12, %rdi
leaq 0xe6b5(%rip), %rsi      # 0x13530
callq 0x2050
testb $0x1, 0x14(%rsp)
movq 0x8(%rsp), %rax
movslq 0x10(%rsp), %rcx
jne 0x4e9a
movzwl (%rax,%rcx), %eax
addl $0x2, %ecx
jmp 0x4ea0
movl (%rax,%rcx), %eax
addl $0x4, %ecx
movl %ecx, 0x10(%rsp)
movl %eax, 0x124(%rbp)
leaq 0x8(%rsp), %rdi
callq 0x3c0e
movl %eax, 0x128(%rbp)
movl 0x150(%rbx), %eax
incl %eax
movl %eax, (%rbp)
movq %rbx, 0x8(%rbp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2d08
movq 0x18(%rbp), %rdi
testq %rdi, %rdi
je 0x4e2a
movq %rbp, %rsi
callq 0x234b
jmp 0x4e2a
movq 0x18(%rsp), %rbp
leaq 0x8(%rsp), %r13
movq 0x28(%rsp), %r14
xorl %r12d, %r12d
jmp 0x46a6
andl $0x0, 0x14(%r15)
xorl %esi, %esi
movl %esi, 0x18(%r15)
movslq %edx, %rdx
testb $0x1, %bpl
jne 0x4f22
movzwl (%rcx,%rdx), %esi
addl $0x2, %edx
jmp 0x4f28
movl (%rcx,%rdx), %esi
addl $0x4, %edx
movq 0x18(%rsp), %rbp
movl %edx, 0x10(%rsp)
movl %esi, 0x1c(%r15)
testb $0x2, %al
je 0x4f41
testl %esi, %esi
jne 0x5224
movq %r13, %rdi
callq 0x3c0e
movq %rbx, %rdi
movl %eax, %esi
callq 0x2b47
movq %rax, 0x20(%r15)
movq %r13, %rdi
callq 0x3c0e
movq %rbx, %rdi
movl %eax, %esi
callq 0x2b47
movq %rax, 0x28(%r15)
movq %r13, %rdi
callq 0x3c0e
andl $0x0, 0x30(%r15)
movslq 0x1c(%r15), %rdi
callq 0x75d9
movq %rax, 0x38(%r15)
movl 0x1c(%r15), %eax
addl $0x7, %eax
sarl $0x3, %eax
movslq %eax, %rdi
callq 0x75d9
movq %rax, 0x40(%r15)
movl 0x1c(%r15), %ecx
addl $0x7, %ecx
sarl $0x3, %ecx
movslq %ecx, %rdx
xorl %r12d, %r12d
movq %rax, %rdi
xorl %esi, %esi
callq 0x20d0
movl 0x130(%rbx), %eax
incl %eax
movl %eax, (%r15)
movq %rbx, 0x8(%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2baa
jmp 0x46a6
testl %r12d, %r12d
je 0x5261
pushq $0x1
popq %rbp
pushq $0x8
popq %r15
leaq -0xa89(%rip), %r12      # 0x4564
cmpl 0x130(%rbx), %ebp
jg 0x509a
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2bf6
movq %rax, %r13
testb $0x1, 0x30(%rax)
jne 0x5066
movq 0x38(%r13), %rdi
callq 0x2030
movq 0x40(%r13), %rdi
callq 0x2030
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%r13)
movq 0x50(%r13), %rdi
movslq 0x58(%r13), %rsi
movq %r15, %rdx
leaq -0xae7(%rip), %rcx      # 0x4551
callq 0x2070
movq 0x70(%r13), %rdi
movslq 0x78(%r13), %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x2070
testb $0x1, 0x30(%r13)
jne 0x5062
cmpl $0x0, 0x78(%r13)
jne 0x51fc
incl %ebp
jmp 0x4fed
movl 0x1c(%r13), %eax
xorl %r14d, %r14d
testl %eax, %eax
cmovlel %r14d, %eax
cmpl %r14d, %eax
je 0x5026
movq 0x40(%r13), %rcx
movl %r14d, %edx
shrl $0x3, %edx
movzbl (%rcx,%rdx), %ecx
movl %r14d, %edx
andl $0x7, %edx
btl %edx, %ecx
jae 0x5136
incl %r14d
jmp 0x5073
testb $0x4, 0x34(%rsp)
je 0x50a9
movq %rbx, %rdi
callq 0x40fa
testb $0x1, 0x34(%rsp)
je 0x50f9
movq (%rbx), %rsi
leaq 0x4c65(%rip), %rdi      # 0x9d1f
xorl %eax, %eax
callq 0x20c0
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x3a57
movq %rbx, %rdi
callq 0x3c38
movq %rbx, %rdi
callq 0x3cb9
movq %rbx, %rdi
callq 0x3e21
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3b00
movq %rbx, %rdi
callq 0x3f84
movq 0x40(%rsp), %rdi
callq 0x2030
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzwl %r8w, %edx
orl %edx, %edi
addl %edi, %ecx
notl %eax
addl %ecx, %eax
leaq 0x4b3d(%rip), %rdi      # 0x9c65
movl %eax, %esi
xorl %eax, %eax
callq 0x7514
jmp 0x51cb
movq %r13, %rdi
callq 0x255c
leaq 0x4b73(%rip), %rdi      # 0x9cb8
leaq 0xdee4(%rip), %rsi      # 0x13030
movl %r14d, %edx
jmp 0x51c4
movq %r15, %rdi
callq 0x255c
addl 0x18(%r14), %ebp
leaq 0x4a7d(%rip), %rdi      # 0x9be1
jmp 0x51bb
leaq 0x49a0(%rip), %rdi      # 0x9b0d
jmp 0x512a
movq %r15, %rdi
callq 0x255c
movq %r14, %rdi
callq 0x26cf
movq 0x48(%r15), %rax
movq 0x10(%rax), %rcx
movl (%rax), %r8d
leaq 0x4995(%rip), %rdi      # 0x9b26
leaq 0xde98(%rip), %rsi      # 0x13030
leaq 0xe091(%rip), %rdx      # 0x13230
xorl %eax, %eax
callq 0x7514
jmp 0x51cb
movq %r15, %rdi
callq 0x255c
addl 0x18(%r14), %ebp
leaq 0x49ec(%rip), %rdi      # 0x9ba7
leaq 0xde6e(%rip), %rsi      # 0x13030
movl %ebp, %edx
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
leaq 0x4a41(%rip), %rdi      # 0x9c1b
jmp 0x51e3
leaq 0x4a57(%rip), %rdi      # 0x9c3a
xorl %eax, %eax
callq 0x7514
jmp 0x51cb
leaq 0x485b(%rip), %rdi      # 0x9a4e
xorl %eax, %eax
callq 0x7514
jmp 0x51cb
movq %r13, %rdi
callq 0x255c
movl 0x78(%r13), %edx
leaq 0x4ad2(%rip), %rdi      # 0x9ce1
leaq 0xde1a(%rip), %rsi      # 0x13030
jmp 0x51c4
leaq 0x435d(%rip), %rdi      # 0x957c
jmp 0x512a
leaq 0x48ae(%rip), %rdi      # 0x9ad9
jmp 0x512a
movq %r15, %rdi
callq 0x255c
movq 0x28(%rsp), %rax
movl 0x20(%rax), %edx
addl 0x18(%rax), %edx
movl 0x1c(%r15), %ecx
leaq 0x4918(%rip), %rdi      # 0x9b66
leaq 0xdddb(%rip), %rsi      # 0x13030
xorl %eax, %eax
callq 0x7514
jmp 0x51cb
movq (%rbp), %rsi
leaq 0x4a28(%rip), %rdi      # 0x9c94
xorl %eax, %eax
callq 0x7514
jmp 0x51cb