LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_module_dump_segments
void xlink_module_dump_segments(xlink_module *mod) {
  int i, j;
  printf("Segment records:\n");
  for (i = 1; i <= mod->nsegments; i++) {
    xlink_segment *seg;
    seg = xlink_module_get_segment(mod, i);
    printf("%2i : %6s segment %s %s %s %6s 0x%04x bytes%s\n", i, seg->name->str,
     OMF_SEGDEF_ALIGN[seg->attrib.align], OMF_SEGDEF_USE[seg->attrib.proc],
     OMF_SEGDEF_COMBINE[seg->attrib.combine], xlink_segment_get_class_name(seg),
     seg->length, seg->attrib.big ? ", big" : "");
  }
  for (i = 1; i <= mod->ngroups; i++) {
    xlink_group *grp;
    grp = xlink_module_get_group(mod, i);
    printf("Group: %s\n", xlink_group_get_name(grp));
    for (j = 1; j <= grp->nsegments; j++) {
      printf("%2i : segment %8s\n", j,
       xlink_segment_get_name(xlink_group_get_segment(grp, j)));
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x6ec4(%rip), %rdi      # 0xacfa
callq 0x2060
pushq $0x1
popq %rbp
movq %r14, (%rsp)
cmpl 0x130(%r14), %ebp
jg 0x3ef6
movq %r14, %rdi
movl %ebp, %esi
callq 0x2bf6
movq %rax, %r15
movq 0x20(%rax), %r12
addq $0x10, %r12
movzbl 0x10(%rax), %eax
movl %eax, %ecx
shrl $0x5, %ecx
leaq 0xbc4c(%rip), %rdx      # 0xfac0
movq (%rdx,%rcx,8), %r13
movl %eax, %ecx
andl $0x1, %ecx
leaq 0xbc7c(%rip), %rdx      # 0xfb00
movq (%rdx,%rcx,8), %r14
andl $0x1c, %eax
leaq 0xbc7e(%rip), %rcx      # 0xfb10
movq (%rcx,%rax,2), %rbx
movq %r15, %rdi
callq 0x2584
testb $0x2, 0x10(%r15)
movl 0x1c(%r15), %r10d
leaq 0x59a7(%rip), %r11      # 0x9855
leaq 0x6604(%rip), %rax      # 0xa4b9
cmoveq %rax, %r11
subq $0x8, %rsp
leaq 0x5ac1(%rip), %rdi      # 0x9985
movl %ebp, %esi
movq %r12, %rdx
movq %r13, %rcx
movq %r14, %r8
movq 0x8(%rsp), %r14
movq %rbx, %r9
xorl %eax, %eax
pushq %r11
pushq %r10
leaq 0xf24c(%rip), %r10      # 0x13130
pushq %r10
callq 0x20c0
addq $0x20, %rsp
incl %ebp
jmp 0x3e42
pushq $0x1
popq %rbx
leaq 0x5abf(%rip), %r12      # 0x99bf
leaq 0xf129(%rip), %r13      # 0x13030
movl %ebx, %ebp
cmpl 0x140(%r14), %ebp
jg 0x3f75
movq %r14, %rdi
movl %ebp, %esi
callq 0x2ca5
movq %rax, %r14
movq %rax, %rdi
callq 0x26cf
leaq 0x5a86(%rip), %rdi      # 0x99b4
leaq 0xf2fb(%rip), %rsi      # 0x13230
xorl %eax, %eax
callq 0x20c0
movl %ebx, %r15d
cmpl 0x20(%r14), %r15d
jg 0x3f6d
movq %r14, %rdi
movl %r15d, %esi
callq 0x265a
movq %rax, %rdi
callq 0x255c
movq %r12, %rdi
movl %r15d, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0x20c0
incl %r15d
jmp 0x3f3f
incl %ebp
movq (%rsp), %r14
jmp 0x3f09
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_module_dump_relocations
void xlink_module_dump_relocations(xlink_module *mod) {
  int i;
  for (i = 1; i <= mod->nrelocs; i++) {
    xlink_reloc *rel;
    xlink_segment *seg;
    rel = xlink_module_get_reloc(mod, i);
    seg = rel->segment;
    switch (rel->target) {
      case OMF_TARGET_EXT : {
        xlink_extern *ext;
        ext = xlink_module_get_extern(seg->module, rel->target_idx);
        printf("  FIXUPP: %6s %c seg %s off 0x%03x -> ext %13s addend %s\n",
         OMF_FIXUP_LOCATION[rel->location], rel->mode ? 'E' : 'R',
         xlink_segment_get_name(seg), rel->offset, xlink_extern_get_name(ext),
         xlink_reloc_get_addend(rel));
        break;
      }
      case OMF_TARGET_SEG : {
        xlink_segment *target;
        target = xlink_module_get_segment(seg->module, rel->target_idx);
        printf(
         "  FIXUPP: %6s %c seg %s off 0x%03x -> ",
         OMF_FIXUP_LOCATION[rel->location], rel->mode ? 'E' : 'R',
         xlink_segment_get_name(seg), rel->offset);
        printf("seg %8s off 0x0 addend %s\n",
         xlink_segment_get_name(target), xlink_reloc_get_addend(rel));
        break;
      }
      default : {
        XLINK_ERROR(1, ("Unsupported target T%i", rel->target));
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
pushq $0x1
popq %rbp
movq %rdi, 0x10(%rsp)
cmpl 0x180(%rdi), %ebp
jg 0x40d5
movl %ebp, %esi
callq 0x2f61
movq %rax, %r14
movq 0x10(%rax), %r12
movl 0x28(%rax), %esi
cmpl $0x4, %esi
je 0x4047
cmpl $0x6, %esi
jne 0x40e4
movq 0x8(%r12), %rdi
movl 0x30(%r14), %esi
callq 0x2eb2
movq %rax, %r13
movl 0x20(%r14), %eax
cmpl $0x0, 0x1c(%r14)
leaq 0xbb66(%rip), %rcx      # 0xfb50
movq (%rcx,%rax,8), %r15
pushq $0x45
popq %rbx
pushq $0x52
popq %rax
cmovel %eax, %ebx
movq %r12, %rdi
callq 0x255c
movl 0x18(%r14), %r12d
movq %r13, %rdi
callq 0x26f7
movq %r14, %rdi
callq 0x274c
leaq 0xf416(%rip), %rax      # 0x13430
movq %rax, (%rsp)
leaq 0x59ad(%rip), %rdi      # 0x99d2
movq %r15, %rsi
movl %ebx, %edx
leaq 0xefff(%rip), %rcx      # 0x13030
movl %r12d, %r8d
leaq 0xf2f5(%rip), %r9       # 0x13330
xorl %eax, %eax
callq 0x20c0
jmp 0x40c9
movq 0x8(%r12), %rdi
movl 0x30(%r14), %esi
callq 0x2bf6
movq %rax, %rbx
movl 0x20(%r14), %eax
cmpl $0x0, 0x1c(%r14)
leaq 0xbae8(%rip), %rcx      # 0xfb50
movq (%rcx,%rax,8), %r15
pushq $0x45
popq %r13
pushq $0x52
popq %rax
cmovel %eax, %r13d
movq %r12, %rdi
callq 0x255c
movl 0x18(%r14), %r8d
leaq 0x5982(%rip), %rdi      # 0x9a0c
movq %r15, %rsi
movl %r13d, %edx
leaq 0xef99(%rip), %r15      # 0x13030
movq %r15, %rcx
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x255c
movq %r14, %rdi
callq 0x274c
leaq 0x597b(%rip), %rdi      # 0x9a33
movq %r15, %rsi
leaq 0xf36e(%rip), %rdx      # 0x13430
xorl %eax, %eax
callq 0x20c0
incl %ebp
movq 0x10(%rsp), %rdi
jmp 0x3f9a
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5716(%rip), %rdi      # 0x9801
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_omf_record_load_iterated
int xlink_omf_record_load_iterated(xlink_omf_record *rec, unsigned char *data,
 int length) {
  unsigned char *block;
  unsigned int repeat_count;
  unsigned int block_count;
  unsigned int size;
  int i;
  block = data;
  repeat_count = xlink_omf_record_read_numeric(rec);
  block_count = xlink_omf_record_read_word(rec);
  if (block_count) {
    size = 0;
    for (i = 0; i < block_count; i++) {
      int block_size;
      block_size = xlink_omf_record_load_iterated(rec, block, length);
      block += block_size;
      length -= block_size;
      size += block_size;
    }
  }
  else {
    size = xlink_omf_record_read_byte(rec);
    XLINK_ERROR(size > length,
     ("LIDATA wrote past end of segment, size = %i but length = %i", size,
     length));
    memcpy(block, &rec->buf[rec->idx], size);
    block += size;
    rec->idx += size;
  }
  for (i = 1; i < repeat_count; i++) {
    memcpy(block, data, size);
    block += size;
  }
  return repeat_count*size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r12d
movq %rsi, %r14
movq %rdi, %r15
callq 0x38b1
movl %eax, %ebp
movq (%r15), %rsi
movslq 0x8(%r15), %rax
movzwl (%rsi,%rax), %ebx
leaq 0x2(%rax), %rcx
movl %ecx, 0x8(%r15)
testl %ebx, %ebx
je 0x45d0
xorl %r13d, %r13d
movq %r14, (%rsp)
subl $0x1, %ebx
jb 0x45ca
movq %r15, %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x4571
cltq
addq %rax, %r14
subl %eax, %r12d
addl %eax, %r13d
jmp 0x45aa
movq (%rsp), %r12
jmp 0x4600
addq $0x3, %rax
movl %eax, 0x8(%r15)
movzbl (%rsi,%rcx), %r13d
cmpl %r12d, %r13d
ja 0x4635
movq %r14, %rdx
addq %rax, %rsi
movl %r13d, %r14d
movq %rdx, %r12
movq %rdx, %rdi
movq %r14, %rdx
callq 0x2140
addq %r12, %r14
addl %r13d, 0x8(%r15)
movl %r13d, %r15d
pushq $0x1
popq %rbx
cmpl %ebp, %ebx
jae 0x461f
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x2140
addq %r15, %r14
incl %ebx
jmp 0x4606
imull %ebp, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5461(%rip), %rdi      # 0x9a9d
movl %r13d, %esi
movl %r12d, %edx
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_file_load_omf_record
static void xlink_file_load_omf_record(xlink_file *file,
 xlink_omf_record *rec) {
  unsigned char checksum;
  XLINK_ERROR(file->size < 3,
   ("Need 3 bytes for a record but only have %i", file->size));
  rec->buf = &file->buf[file->pos];
  rec->idx = 0;
  rec->type = xlink_omf_record_read_byte(rec);
  rec->size = xlink_omf_record_read_word(rec);
  XLINK_ERROR(file->size - 3 < rec->size,
   ("Record extends %i bytes past the end of file %s",
   rec->size - file->size + 3, file->name));
  file->pos += 3 + rec->size;
  file->size -= 3 + rec->size;
  checksum = rec->buf[3 + rec->size - 1];
  if (checksum != 0) {
    int i;
    for (i = 0; i < 3 + rec->size - 1; i++) {
      checksum += rec->buf[i];
    }
  }
  XLINK_ERROR(checksum != 0, ("Invalid checksum, expected 0 got %i", checksum));
}

// Assembly:
pushq %rax
movl 0x8(%rdi), %eax
cmpl $0x2, %eax
jbe 0x52f0
movq %rsi, %rcx
movq 0x10(%rdi), %rsi
movl 0xc(%rdi), %r8d
leaq (%rsi,%r8), %rdx
movq %rdx, (%rcx)
movl $0x1, 0x8(%rcx)
movb (%rsi,%r8), %r9b
movb %r9b, 0xc(%rcx)
movzwl 0x1(%rsi,%r8), %esi
movl $0x3, 0x8(%rcx)
movw %si, 0xe(%rcx)
leal -0x3(%rax), %ecx
cmpl %esi, %ecx
jb 0x52fb
leal 0x3(%rsi), %ecx
addl %esi, %r8d
addl $0x3, %r8d
movl %r8d, 0xc(%rdi)
subl %ecx, %eax
movl %eax, 0x8(%rdi)
movl %esi, %eax
movb 0x2(%rdx,%rax), %al
testb %al, %al
je 0x52ee
addq $0x2, %rsi
xorl %ecx, %ecx
cmpq %rcx, %rsi
je 0x52ea
addb (%rdx,%rcx), %al
incq %rcx
jmp 0x52dd
testb %al, %al
jne 0x5313
popq %rax
retq
leaq 0x54dd(%rip), %rdi      # 0xa7d4
movl %eax, %esi
jmp 0x531d
subl %eax, %esi
addl $0x3, %esi
movq (%rdi), %rdx
leaq 0x54f5(%rip), %rdi      # 0xa7ff
xorl %eax, %eax
callq 0x7514
jmp 0x5324
movzbl %al, %esi
leaq 0x5512(%rip), %rdi      # 0xa82f
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_file_load_omf_library
xlink_library *xlink_file_load_omf_library(xlink_file *file,
 unsigned int flags) {
  xlink_library *lib;
  int done;
  lib = xlink_malloc(sizeof(xlink_library));
  done = 0;
  while (file->size > 0 && !done) {
    switch (file->buf[file->pos]) {
      case OMF_LIBHDR : {
        xlink_omf_record rec;
        xlink_file_load_omf_record(file, &rec);
        lib->page_size = rec.size + 3;
        break;
      }
      case OMF_LIBEND : {
        done = 1;
        break;
      }
      case OMF_THEADR :
      case OMF_LHEADR : {
        int mask;
        int skip;
        xlink_module *mod;
        /* TODO: Find embedded module name in dictionary, set file->name here */
        mod = xlink_file_load_omf_module(file, flags);
        XLINK_LIST_ADD(library, module, lib, mod);
        /* Page size is always a power of two */
        mask = lib->page_size - 1;
        /* Compute the number of bytes to skip to reach the next page */
        skip = ((file->pos + mask) & ~mask) - file->pos;
        file->pos += skip;
        file->size -= skip;
        break;
      }
      default : {
        XLINK_ERROR(1, ("Unknown record type %02X", file->buf[file->pos]));
      }
    }
  }
  XLINK_ERROR(!done, ("Got EOF before reading LIBEND in %s", file->name));
  return lib;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebp
movq %rdi, %rbx
pushq $0x30
popq %rdi
callq 0x75d9
movq %rax, %r14
movb $0x1, %al
leaq 0x8(%rsp), %r15
testb $0x1, %al
je 0x53e8
cmpl $0x0, 0x8(%rbx)
je 0x53e8
movq 0x10(%rbx), %rax
movl 0xc(%rbx), %ecx
movzbl (%rax,%rcx), %esi
cmpl $0x80, %esi
je 0x53a7
cmpl $0x82, %esi
je 0x53a7
xorl %eax, %eax
cmpl $0xf1, %esi
je 0x534d
cmpl $0xf0, %esi
jne 0x53fa
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5278
movzwl 0x16(%rsp), %eax
addl $0x3, %eax
movl %eax, 0x18(%r14)
movb $0x1, %al
jmp 0x534d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4651
movl 0x28(%r14), %ecx
incl %ecx
movl %ecx, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x314e
movl 0x18(%r14), %eax
movl 0xc(%rbx), %ecx
leal (%rax,%rcx), %edx
decl %edx
negl %eax
andl %edx, %eax
subl %eax, %ecx
movl %eax, 0xc(%rbx)
addl %ecx, 0x8(%rbx)
movb $0x1, %al
jmp 0x534d
testb $0x1, %al
jne 0x5410
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x492a(%rip), %rdi      # 0x9d2b
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
movq (%rbx), %rsi
leaq 0x492a(%rip), %rdi      # 0x9d44
xorl %eax, %eax
callq 0x7514
jmp 0x5408
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: seg_comp
int seg_comp(const void *a, const void *b) {
  const xlink_segment *seg_a;
  const xlink_segment *seg_b;
  seg_a = *(xlink_segment **)a;
  seg_b = *(xlink_segment **)b;
  if (xlink_segment_get_class(seg_a) == xlink_segment_get_class(seg_b)) {
    if (seg_a->attrib.proc == seg_b->attrib.proc) {
      if (seg_a->module == seg_b->module) {
        return seg_a->index - seg_b->index;
      }
      return seg_a->module->index - seg_b->module->index;
    }
    return seg_a->attrib.proc - seg_b->attrib.proc;
  }
  return xlink_segment_get_class(seg_a) - xlink_segment_get_class(seg_b);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq (%rdi), %r15
movq (%rsi), %r14
movq %r15, %rdi
callq 0x5423
movl %eax, %ebx
movq %r14, %rdi
callq 0x5423
subl %eax, %ebx
jne 0x54a4
movzbl 0x10(%r15), %ebx
andl $0x1, %ebx
movzbl 0x10(%r14), %eax
andl $0x1, %eax
cmpb %al, %bl
jne 0x549a
movq 0x8(%r15), %rcx
movq 0x8(%r14), %rax
cmpq %rax, %rcx
je 0x549e
movl 0x8(%rcx), %ebx
subl 0x8(%rax), %ebx
jmp 0x54a4
subl %eax, %ebx
jmp 0x54a4
movl (%r15), %ebx
subl (%r14), %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_binary_link_root_segment
void xlink_binary_link_root_segment(xlink_binary *bin, xlink_segment *root) {
  int i;
  xlink_binary_process_segment(bin, root);
  for (i = 1; i <= bin->nexterns; i++) {
    xlink_extern *ext;
    ext = xlink_binary_get_extern(bin, i);
    if (ext->is_local) {
      ext->public = xlink_module_find_public(ext->module, ext->name);
    }
    else {
      ext->public = xlink_binary_find_public(bin, ext->name);
    }
    if (ext->public->segment != NULL) {
      xlink_binary_process_segment(bin, ext->public->segment);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x3599
pushq $0x1
popq %rbp
cmpl 0x60(%rbx), %ebp
jg 0x5513
movq %rbx, %rdi
movl %ebp, %esi
callq 0x3542
movq %rax, %r14
cmpl $0x0, 0x114(%rax)
je 0x54e8
movq 0x8(%r14), %rdi
movq %r14, %rsi
addq $0x10, %rsi
callq 0x3047
jmp 0x54f7
movq %r14, %rsi
addq $0x10, %rsi
movq %rbx, %rdi
callq 0x330a
movq %rax, 0x118(%r14)
movq 0x18(%rax), %rsi
testq %rsi, %rsi
je 0x550f
movq %rbx, %rdi
callq 0x3599
incl %ebp
jmp 0x54bb
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_sort_segments
void xlink_sort_segments(xlink_segment **segments, int nsegments, int *data_idx,
 int *bss_idx) {
  int i;
  qsort(segments, nsegments, sizeof(xlink_segment *), seg_comp);
  if (data_idx != NULL) {
    for (i = 0; i < nsegments; i++) {
      if (xlink_segment_get_class(segments[i]) == OMF_SEGMENT_DATA) break;
    }
    *data_idx = i;
  }
  if (bss_idx != NULL) {
    for (i = 0; i < nsegments; i++) {
      if (xlink_segment_get_class(segments[i]) == OMF_SEGMENT_BSS) break;
    }
    *bss_idx = i;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r12
movl %esi, %r14d
movq %rdi, %r15
movslq %esi, %rsi
leaq -0xe9(%rip), %rcx       # 0x5450
pushq $0x8
popq %rdx
callq 0x2070
testq %r12, %r12
je 0x5574
xorl %ebp, %ebp
testl %r14d, %r14d
movl $0x0, %r13d
cmovgl %r14d, %r13d
cmpq %rbp, %r13
je 0x5570
movq (%r15,%rbp,8), %rdi
callq 0x5423
cmpl $0x1, %eax
je 0x556d
incq %rbp
jmp 0x5555
movl %ebp, %r13d
movl %r13d, (%r12)
testq %rbx, %rbx
je 0x55a1
xorl %r12d, %r12d
testl %r14d, %r14d
cmovlel %r12d, %r14d
cmpq %r12, %r14
je 0x559e
movq (%r15,%r12,8), %rdi
callq 0x5423
cmpl $0x2, %eax
je 0x559b
incq %r12
jmp 0x5583
movl %r12d, %r14d
movl %r14d, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_set_first_segment
void xlink_set_first_segment(xlink_segment **segments, xlink_segment *first) {
  int i;
  for (i = 0; segments[i] != first; i++);
  memmove(&segments[1], &segments[0], sizeof(*segments)*i);
  segments[0] = first;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
pushq $-0x8
popq %rdx
movq %rdx, %rax
addq $0x8, %rdx
cmpq %rbx, 0x8(%r14,%rax)
jne 0x55bd
leaq 0x8(%r14), %rdi
movq %r14, %rsi
callq 0x21a0
movq %rbx, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_binary_layout_segments
void xlink_binary_layout_segments(xlink_binary *bin, int index, int offset) {
  int i;
  for (i = index + 1; i <= bin->nsegments; i++) {
    xlink_segment *seg;
    seg = xlink_binary_get_segment(bin, i);
    /* If this is a 32-bit program, move all 32-bit BSS above the first 64k */
    if (bin->is_32bit && seg->attrib.proc == OMF_SEGMENT_USE32 &&
     xlink_segment_get_class(seg) == OMF_SEGMENT_BSS && offset < 0x10000) {
      offset = 0x10000;
    }
    offset = ALIGN2(offset, xlink_segment_get_alignment(seg));
    seg->start = offset;
    offset += seg->length;
  }
  XLINK_ERROR(!bin->is_32bit && offset > 65536,
   ("Address space exceeds 65536 bytes, %i", offset));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %rbx
pushq $-0x1
popq %r12
cmpl 0x50(%rbx), %ebp
jge 0x566c
incl %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x34ae
movq %rax, %r15
cmpl $0x0, 0x64(%rbx)
je 0x5639
testb $0x1, 0x10(%r15)
je 0x5639
movq %r15, %rdi
callq 0x5423
cmpl $0x10001, %r14d         # imm = 0x10001
movl $0x10000, %ecx          # imm = 0x10000
cmovgel %r14d, %ecx
cmpl $0x2, %eax
cmovel %ecx, %r14d
movq %r15, %rdi
callq 0x25aa
movl %r12d, %r13d
movl %eax, %ecx
shll %cl, %r13d
notl %r13d
addl %r14d, %r13d
movq %r15, %rdi
callq 0x25aa
movl %eax, %ecx
shrl %cl, %r13d
shll %cl, %r13d
movl %r13d, 0x7c(%r15)
addl 0x1c(%r15), %r13d
movl %r13d, %r14d
jmp 0x55f9
cmpl $0x0, 0x64(%rbx)
jne 0x567b
cmpl $0x10001, %r14d         # imm = 0x10001
jge 0x568a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x46dc(%rip), %rdi      # 0x9d6d
movl %r14d, %esi
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_binary_extract_class
int xlink_binary_extract_class(xlink_binary *bin, int index, int offset,
 xlink_segment_class class, xlink_list *bytes) {
  int i;
  for (i = index + 1; i <= bin->nsegments; i++) {
    xlink_segment *seg;
    seg = xlink_binary_get_segment(bin, i);
    if (xlink_segment_get_class(seg) != class) break;
    XLINK_ERROR(seg->info & SEG_HAS_DATA == 0,
     ("Error segment %s has no data", xlink_segment_get_name(seg)));
    if (offset != seg->start) {
      unsigned char buf[4096];
      memset(buf, 0, 4096);
      xlink_list_add_all(bytes, buf, seg->start - offset);
      offset = seg->start;
    }
    xlink_list_add_all(bytes, seg->data, seg->length);
    offset += seg->length;
  }
  return offset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1018, %rsp           # imm = 0x1018
movq %r8, %rbx
movl %ecx, %ebp
movl %edx, %r13d
movl %esi, %r14d
movq %rdi, %r15
movq %rdi, 0x8(%rsp)
cmpl 0x50(%r15), %r14d
jge 0x576d
incl %r14d
movq %r15, %rdi
movl %r14d, %esi
callq 0x34ae
movq %rax, %r12
movq %rax, %rdi
callq 0x5423
cmpl %ebp, %eax
jne 0x576d
cmpl 0x7c(%r12), %r13d
je 0x5754
movl $0x1000, %edx           # imm = 0x1000
movl %ebp, %r15d
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
xorl %esi, %esi
callq 0x20d0
movl 0x7c(%r12), %edx
subl %r13d, %edx
movq %rbx, %rdi
movq %rbp, %rsi
movl %r15d, %ebp
movq 0x8(%rsp), %r15
callq 0x83c4
movl 0x7c(%r12), %r13d
movq 0x38(%r12), %rsi
movl 0x1c(%r12), %edx
movq %rbx, %rdi
callq 0x83c4
addl 0x1c(%r12), %r13d
jmp 0x56f3
movl %r13d, %eax
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_model_search
void xlink_model_search(xlink_list *models, xlink_list *bytes) {
  xlink_modeler mod;
  /* Build a context modeler for bytes */
  xlink_modeler_init(&mod, xlink_list_length(bytes));
  xlink_modeler_load_binary(&mod, bytes);
  /* Search for the best context to use for bytes */
  xlink_list_empty(models);
  xlink_modeler_search(&mod, models);
  XLINK_ERROR(xlink_list_length(models) == 0,
   ("Error no context models found for bytes"));
  xlink_modeler_clear(&mod);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x82d7
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movl %eax, %esi
callq 0x7bec
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7c65
movq %r14, %rdi
callq 0x82db
movq %r15, %rdi
movq %r14, %rsi
callq 0x80df
movq %r14, %rdi
callq 0x82d7
testl %eax, %eax
je 0x57ec
leaq 0x8(%rsp), %rdi
callq 0x7c46
addq $0x90, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x45a0(%rip), %rdi      # 0x9d93
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_decoder_test_bytes
void xlink_decoder_test_bytes(xlink_decoder *dec, xlink_list *bytes) {
  int i;
  for (i = 0; i < xlink_list_length(bytes); i++) {
    unsigned char orig;
    unsigned char byte;
    orig = *xlink_list_get_byte(bytes, i);
    byte = xlink_decoder_read_byte(dec);
    XLINK_ERROR(byte != orig,
     ("Decoder mismatch %02x != %02x at pos = %i", byte, orig, i));
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x82d7
cmpl %eax, %ebx
jge 0x5884
movq %r14, %rdi
movl %ebx, %esi
callq 0x831b
movzbl (%rax), %ebp
movq %r15, %rdi
callq 0x748a
cmpb %bpl, %al
jne 0x588f
incl %ebx
jmp 0x585a
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movzbl %al, %esi
leaq 0x4522(%rip), %rdi      # 0x9dbb
movl %ebp, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_bitstream_from_context
void xlink_bitstream_from_context(xlink_bitstream *bs, xlink_context *ctx,
 xlink_list *bytes) {
  xlink_encoder enc;
  xlink_decoder dec;
  bs->bytes.length = 0;
  /* Reset the context */
  xlink_context_reset(ctx);
  /* Encode bytes with the context */
  xlink_encoder_init(&enc, ctx);
  xlink_encoder_write_bytes(&enc, bytes);
  /* Finalize the bitstream */
  xlink_encoder_finalize(&enc, bs);
  xlink_encoder_clear(&enc);
  /* Reset the context */
  xlink_context_reset(ctx);
  /* Initialize the decoder with the context and bitstream */
  xlink_decoder_init(&dec, ctx, bs);
  /* Test that decoded bytes match original input */
  xlink_decoder_test_bytes(&dec, bytes);
  xlink_decoder_clear(&dec);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
andl $0x0, 0x10(%rdi)
movq %rsi, %rdi
callq 0x7a7b
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x6f5d
movq %r12, %rdi
movq %rbx, %rsi
callq 0x7058
movq %r12, %rdi
movq %r14, %rsi
callq 0x7151
movq %r12, %rdi
callq 0x704f
movq %r15, %rdi
callq 0x7a7b
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x7367
movq %r12, %rdi
movq %rbx, %rsi
callq 0x584b
movq %r12, %rdi
callq 0x7489
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_binary_load_modules
void xlink_binary_load_modules(xlink_binary *bin) {
  int i;
  for (i = 0; i < sizeof(XLINK_STUB_MODULES)/sizeof(xlink_file); i++) {
    xlink_file file;
    file = XLINK_STUB_MODULES[i];
    if (strstr(file.name, "stub32") == NULL) {
      xlink_module *mod;
      mod = xlink_file_load_omf_module(&file, 0);
      XLINK_LIST_ADD(binary, module, bin, mod);
    }
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
xorl %r12d, %r12d
leaq 0x9da4(%rip), %r13      # 0xf850
leaq 0x4332(%rip), %r14      # 0x9de5
movq %rsp, %r15
cmpq $0x270, %r12            # imm = 0x270
je 0x5b0a
movups (%r12,%r13), %xmm0
movaps %xmm0, (%rsp)
movq 0x10(%r12,%r13), %rax
movq %rax, 0x10(%rsp)
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x2230
testq %rax, %rax
jne 0x5b04
movq %r15, %rdi
xorl %esi, %esi
callq 0x4651
movl 0x30(%rbx), %ecx
incl %ecx
movl %ecx, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x31e2
addq $0x18, %r12
jmp 0x5ab6
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_binary_load_stub
void xlink_binary_load_stub(xlink_binary *bin, const char *stub) {
  char buf[1024];
  xlink_module *mod;
  int i;
  sprintf(buf, "stubs/%s.o", stub);
  mod = NULL;
  for (i = 0; i < sizeof(XLINK_STUB_MODULES)/sizeof(xlink_file); i++) {
    xlink_file file;
    file = XLINK_STUB_MODULES[i];
    if (strcmp(file.name, buf) == 0) {
      mod = xlink_file_load_omf_module(&file, 0);
      XLINK_LIST_ADD(binary, module, bin, mod);
      break;
    }
  }
  XLINK_ERROR(mod == NULL, ("Stub %s not found", stub));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x420, %rsp            # imm = 0x420
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x42b7(%rip), %rsi      # 0x9dec
xorl %r12d, %r12d
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x21e0
leaq 0x9cff(%rip), %r13      # 0xf850
cmpq $0x270, %r12            # imm = 0x270
je 0x5bb4
movups (%r12,%r13), %xmm0
movaps %xmm0, (%rsp)
movq 0x10(%r12,%r13), %rax
movq %rax, 0x10(%rsp)
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x2110
testl %eax, %eax
je 0x5b83
addq $0x18, %r12
jmp 0x5b51
movq %rsp, %rdi
xorl %esi, %esi
callq 0x4651
movl 0x30(%rbx), %ecx
incl %ecx
movl %ecx, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq %rbx, %rdi
movq %rax, %rsi
addq $0x420, %rsp            # imm = 0x420
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x31e2
leaq 0x423c(%rip), %rdi      # 0x9df7
movq %r14, %rsi
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_binary_find_segment_by_public
xlink_segment *xlink_binary_find_segment_by_public(xlink_binary *bin,
 const char *public, xlink_segment_class class) {
  xlink_segment *seg;
  seg = xlink_binary_find_public(bin, public)->segment;
  XLINK_ERROR(xlink_segment_get_class(seg) != class,
   ("Public %s found in segment %s, but class %s not '%s'", public,
   xlink_segment_get_name(seg), xlink_segment_get_class_name(seg),
   XLINK_SEGMENT_CLASS_NAME[class]));
  return seg;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rsi, %rbx
callq 0x330a
movq 0x18(%rax), %r14
movq %r14, %rdi
callq 0x5423
cmpl %ebp, %eax
jne 0x5bf3
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
movq %r14, %rdi
callq 0x255c
movq %r14, %rdi
callq 0x2584
movl %ebp, %eax
leaq 0x355c(%rip), %rcx      # 0x9168
movslq (%rcx,%rax,4), %r8
addq %rcx, %r8
leaq 0x41ef(%rip), %rdi      # 0x9e09
leaq 0xd40f(%rip), %rdx      # 0x13030
leaq 0xd508(%rip), %rcx      # 0x13130
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_binary_write_map
void xlink_binary_write_map(xlink_binary *bin) {
  FILE *out;
  out = fopen(bin->map, "w");
  xlink_binary_print_map(bin, out);
  fclose(out);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
leaq 0x466b(%rip), %rsi      # 0xa2b7
callq 0x21b0
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3640
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2090
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_binary_write_com
void xlink_binary_write_com(xlink_binary *bin, int nsegments) {
  FILE *out;
  int i;
  int offset;
  out = fopen(bin->output, "wb");
  XLINK_ERROR(out == NULL, ("Unable to open output file '%s'", bin->output));
  for (offset = 0x100, i = 1; i <= nsegments; i++) {
    xlink_segment *seg;
    seg = xlink_binary_get_segment(bin, i);
    if (seg->info & SEG_HAS_DATA) {
      if (offset != seg->start) {
        unsigned char buf[4096];
        memset(buf, 0, 4096);
        fwrite(buf, 1, seg->start - offset, out);
        offset = seg->start;
      }
      fwrite(seg->data, 1, seg->length, out);
      offset += seg->length;
    }
  }
  fclose(out);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1018, %rsp           # imm = 0x1018
movl %esi, %r14d
movq %rdi, %rbx
movq (%rdi), %rdi
leaq 0x41af(%rip), %rsi      # 0x9e3e
callq 0x21b0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x5d42
xorl %eax, %eax
testl %r14d, %r14d
cmovlel %eax, %r14d
negl %r14d
pushq $0x1
popq %r12
movl $0x100, %r13d           # imm = 0x100
leal (%r14,%r12), %eax
cmpl $0x1, %eax
je 0x5d27
movq %rbx, %rdi
movl %r12d, %esi
callq 0x34ae
testb $0x1, 0x30(%rax)
je 0x5d22
movq %rax, %rbp
movl 0x7c(%rax), %r15d
subl %r13d, %r15d
je 0x5d09
movl $0x1000, %edx           # imm = 0x1000
leaq 0x10(%rsp), %r13
movq %r13, %rdi
xorl %esi, %esi
callq 0x20d0
movslq %r15d, %rdx
movq %r13, %rdi
pushq $0x1
popq %rsi
movq 0x8(%rsp), %rcx
callq 0x2200
movl 0x7c(%rbp), %r13d
movq 0x38(%rbp), %rdi
movslq 0x1c(%rbp), %rdx
pushq $0x1
popq %rsi
movq 0x8(%rsp), %rcx
callq 0x2200
addl 0x1c(%rbp), %r13d
incl %r12d
jmp 0x5cb8
movq 0x8(%rsp), %rdi
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2090
movq (%rbx), %rsi
leaq 0x40f5(%rip), %rdi      # 0x9e41
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_segment_find_reloc
xlink_reloc *xlink_segment_find_reloc(xlink_segment *seg, const char *name) {
  xlink_reloc *ret;
  int i;
  ret = NULL;
  for (i = 1; i <= seg->nrelocs; i++) {
    xlink_reloc *rel;
    rel = xlink_segment_get_reloc(seg, i);
    if (rel->target == OMF_TARGET_EXT) {
      xlink_extern *ext;
      ext = xlink_module_get_extern(seg->module, rel->target_idx);
      if (strcmp(ext->name, name) == 0) {
        XLINK_ERROR(ret != NULL,
         ("Duplicate relocation definition found for name %s in %s", name,
         seg->module->filename));
        ret = rel;
        break;
      }
    }
  }
  XLINK_ERROR(ret == NULL, ("No relocation found for extern name %s", name));
  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x1
popq %rbp
cmpl 0x78(%r14), %ebp
jg 0x5db2
movq %r14, %rdi
movl %ebp, %esi
callq 0x24b0
cmpl $0x6, 0x28(%rax)
jne 0x5da0
movq %rax, %r15
movq 0x8(%r14), %rdi
movl 0x30(%rax), %esi
callq 0x2eb2
leaq 0x10(%rax), %rdi
movq %rbx, %rsi
callq 0x2110
testl %eax, %eax
je 0x5da4
incl %ebp
jmp 0x5d6b
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40a8(%rip), %rdi      # 0x9e61
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_binary_get_relative_byte
unsigned char xlink_binary_get_relative_byte(xlink_binary *bin,
 xlink_segment *prog, int relative) {
  int prog_idx;
  int i;
  unsigned char byte;
  XLINK_ERROR(relative >= 0,
   ("Relative byte index should be negative, %i", relative));
  for (prog_idx = bin->nsegments; prog_idx-- > 0; ) {
    if (bin->segments[prog_idx] == prog) {
      break;
    }
  }
  XLINK_ERROR(prog_idx < 0, ("PROG segment index not found"));
  for (i = prog_idx; relative < 0 && i-- > 0; ) {
    relative += bin->segments[i + 1]->start - bin->segments[i]->start;
  }
  XLINK_ERROR(i < 0, ("Relative byte %i bytes before program start", relative));
  byte = 0;
  if (relative <= bin->segments[i]->length) {
    byte = bin->segments[i]->data[relative];
  }
  return byte;
}

// Assembly:
pushq %rax
testl %edx, %edx
jns 0x5e54
movl 0x50(%rdi), %ecx
movq %rcx, %r8
decq %r8
testl %ecx, %ecx
jle 0x5e2c
decl %ecx
movq 0x48(%rdi), %rax
leaq -0x1(%r8), %r9
cmpq %rsi, (%rax,%r8,8)
movq %r9, %r8
jne 0x5ddd
movl %ecx, %ecx
testl %edx, %edx
jns 0x5e12
testl %ecx, %ecx
jle 0x5e3c
movq -0x8(%rax,%rcx,8), %rsi
movq (%rax,%rcx,8), %rdi
addl 0x7c(%rdi), %edx
decq %rcx
subl 0x7c(%rsi), %edx
jmp 0x5df6
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
cmpl 0x1c(%rax), %edx
jle 0x5e21
xorl %eax, %eax
jmp 0x5e2a
movq 0x38(%rax), %rax
movl %edx, %ecx
movb (%rax,%rcx), %al
popq %rcx
retq
leaq 0x4080(%rip), %rdi      # 0x9eb3
xorl %eax, %eax
callq 0x7514
jmp 0x5e4c
leaq 0x408d(%rip), %rdi      # 0x9ed0
movl %edx, %esi
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
leaq 0x402d(%rip), %rdi      # 0x9e88
jmp 0x5e43
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/xlink.c
// Function: xlink_parity
int xlink_parity(unsigned char byte) {
  int bits;
  bits = 0;
  while (byte > 0) {
    bits += byte & 1;
    byte >>= 1;
  }
  return bits & 1;
}

// Assembly:
xorl %eax, %eax
testb %dil, %dil
je 0x5e6f
movzbl %dil, %ecx
addl %ecx, %eax
shrb %dil
jmp 0x5e5f
andl $0x1, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/ec.c
// Function: xlink_bitstream_copy_bits
void xlink_bitstream_copy_bits(xlink_bitstream *bs, unsigned char *dst,
 int pos) {
  int i;
  /* Intentionally skip the first bit */
  for (i = 1; i < bs->bits; i++, pos++) {
    XLINK_SET_BIT(dst, pos, XLINK_GET_BIT(bs->bytes.data, i));
  }
}

// Assembly:
pushq %rbx
movl $0x1, %eax
cmpl 0x18(%rdi), %eax
jge 0x6f5b
movl %edx, %ecx
sarl $0x3, %ecx
movslq %ecx, %r8
movzbl (%rsi,%r8), %r9d
movl %edx, %ecx
andb $0x7, %cl
btrl %ecx, %r9d
movq (%rdi), %r10
movl %eax, %r11d
shrl $0x3, %r11d
movzbl (%r10,%r11), %r10d
movl %eax, %r11d
andl $0x7, %r11d
xorl %ebx, %ebx
btl %r11d, %r10d
setb %bl
shll %cl, %ebx
orl %r9d, %ebx
movb %bl, (%rsi,%r8)
incl %eax
incl %edx
jmp 0x6f12
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/ec.c
// Function: xlink_encoder_init
void xlink_encoder_init(xlink_encoder *enc, xlink_context *ctx) {
  enc->ctx = ctx;
  xlink_list_init(&enc->bytes, sizeof(unsigned char), 0);
  enc->bits = 0;
  enc->low = 0;
  enc->range = EC_BASE;
  enc->zero = 0;
  enc->ones = 0;
  /* Start by writing a 1 bit, this is necessary for decoder implementation */
  xlink_encoder_write_bit(enc, 1, 1, 1);
  /* Update the context with 1 bit */
  xlink_context_update_bit(enc->ctx, 0, 1);
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq %rsi, (%rdi)
addq $0x8, %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x82a8
movaps 0x3d95(%rip), %xmm0     # 0xad10
movups %xmm0, 0x20(%rbx)
andl $0x0, 0x30(%rbx)
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
movl %ebp, %edx
movl %ebp, %ecx
callq 0x6fa6
movq (%rbx), %rdi
xorl %esi, %esi
movl %ebp, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x7b2d
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/ec.c
// Function: xlink_encoder_write_bit
static void xlink_encoder_write_bit(xlink_encoder *enc, xlink_word c0,
 xlink_word c1, int bit) {
  xlink_word s;
  XLINK_ERROR(c0 == 0 || c1 == 0 || (c0 > EC_MASK - c1),
   ("Error invalid counts, c0 = %i and c1 = %i", c0, c1));
  s = ((xlink_dword)enc->range)*c1/(c0 + c1);
  enc->range = bit ? s : enc->range - s;
  if (!bit) {
    /* Handle carry */
    if (s > EC_MASK - enc->low) {
      xlink_encoder_emit(enc, 1);
    }
    enc->low += s;
  }
  /* Normalize */
  while (enc->range < EC_BASE) {
    if (enc->low & EC_BASE) {
      enc->ones++;
    }
    else {
      xlink_encoder_emit(enc, 0);
    }
    enc->low <<= 1;
    enc->range <<= 1;
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %eax
negl %eax
cmpl %edx, %eax
jbe 0x7039
testl %edx, %edx
je 0x7039
movq %rdi, %rbx
movl 0x28(%rdi), %edi
movl %edx, %eax
imulq %rdi, %rax
addl %edx, %esi
xorl %edx, %edx
divq %rsi
movq %rax, %r14
subl %r14d, %edi
testl %ecx, %ecx
cmovel %edi, %eax
movl %eax, 0x28(%rbx)
jne 0x702c
movl 0x24(%rbx), %eax
movl %eax, %ecx
addl %r14d, %ecx
jae 0x6ff8
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x7209
movl 0x24(%rbx), %eax
movl 0x28(%rbx), %edi
addl %r14d, %eax
movl %eax, 0x24(%rbx)
movl %edi, %r14d
jmp 0x702c
movl 0x24(%rbx), %eax
testl %eax, %eax
js 0x701d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x7209
movl 0x24(%rbx), %eax
movl 0x28(%rbx), %r14d
jmp 0x7020
incl 0x30(%rbx)
addl %eax, %eax
movl %eax, 0x24(%rbx)
addl %r14d, %r14d
movl %r14d, 0x28(%rbx)
testl %r14d, %r14d
jns 0x7003
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x3d7b(%rip), %rdi      # 0xadbb
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/ec.c
// Function: xlink_encoder_write_bytes
void xlink_encoder_write_bytes(xlink_encoder *enc, xlink_list *bytes) {
  int i, j;
  for (j = 0; j < xlink_list_length(bytes); j++) {
    unsigned char byte;
    unsigned char partial;
    byte = *xlink_list_get_byte(bytes, j);
    partial = 1;
    /* Build partially seen byte from high bit to low bit to match decoder. */
    for (i = 8; i-- > 0; ) {
      unsigned int counts[2];
      int bit;
      xlink_context_get_counts(enc->ctx, partial, counts);
      bit = !!(byte & (1 << i));
      xlink_encoder_write_bit(enc, counts[0], counts[1], bit);
      xlink_context_update_bit(enc->ctx, partial, bit);
      partial <<= 1;
      partial |= bit;
    }
    XLINK_ERROR(partial != byte,
     ("Mismatch between partial %02x and byte %02x", partial, byte));
    for (i = 8; i-- > 1; ) {
      enc->ctx->buf[i] = enc->ctx->buf[i - 1];
    }
    enc->ctx->buf[0] = byte;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
xorl %ebp, %ebp
leaq 0x8(%rsp), %r15
movq %rsi, 0x10(%rsp)
movq %rbx, %rdi
callq 0x82d7
cmpl %eax, %ebp
jge 0x7126
movq %rbx, %rdi
movl %ebp, 0x4(%rsp)
movl %ebp, %esi
callq 0x831b
movb (%rax), %al
movb %al, 0x3(%rsp)
movzbl %al, %r12d
movb $0x1, %bl
pushq $0x7
popq %rbp
movzbl %bl, %r13d
cmpl $-0x1, %ebp
je 0x70ee
movq (%r14), %rdi
movl %r13d, %esi
movq %r15, %rdx
callq 0x7a91
xorl %ebx, %ebx
btl %ebp, %r12d
setb %bl
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movq %r14, %rdi
movl %ebx, %ecx
callq 0x6fa6
movq (%r14), %rdi
movl %r13d, %esi
movl %ebx, %edx
callq 0x7b2d
addb %r13b, %r13b
orb %r13b, %bl
decl %ebp
jmp 0x70a5
cmpb 0x3(%rsp), %bl
jne 0x7135
pushq $0x8
popq %rax
movq 0x10(%rsp), %rbx
movl 0x4(%rsp), %ebp
cmpq $0x2, %rax
jb 0x7116
movq (%r14), %rcx
movb -0x2(%rcx,%rax), %dl
movb %dl, -0x1(%rcx,%rax)
decq %rax
jmp 0x7100
movq (%r14), %rax
movb 0x3(%rsp), %cl
movb %cl, (%rax)
incl %ebp
jmp 0x7078
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3bf4(%rip), %rdi      # 0xad30
movl %r13d, %esi
movl %r12d, %edx
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/ec.c
// Function: xlink_encoder_finalize
void xlink_encoder_finalize(xlink_encoder *enc, xlink_bitstream *bs) {
  xlink_word m;
  int s;
  int i;
  m = EC_BASE - 1;
  /* Count how many bits must be output to ensure that the symbols encoded thus
      far will decode correctly regardless of the bits that follow. */
  for (s = 1; ((enc->low + m) | m) - enc->low >= enc->range; s++, m >>= 1);
  XLINK_ERROR(s > 2,
   ("At most two bits need to be written to finalize range coder"));
  if (m > EC_MASK - enc->low) {
    /* Handle carry */
    xlink_encoder_emit(enc, 1);
  }
  for (i = 0; i < s; i++) {
    if ((enc->low + m) & (EC_BASE >> i)) {
      enc->ones++;
    }
    else {
      xlink_encoder_emit(enc, 0);
    }
  }
  /* Flush any pending bits */
  xlink_encoder_emit(enc, 0);
  /* Copy finalized bits to bitstream */
  bs->bits = enc->bits;
  bs->bytes.length = 0;
  xlink_list_append(&bs->bytes, &enc->bytes);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl 0x24(%rdi), %eax
movl 0x28(%rdi), %ecx
pushq $0x1
popq %r15
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
leal (%rax,%r12), %edx
orl %r12d, %edx
subl %eax, %edx
cmpl %ecx, %edx
jb 0x7184
incl %r15d
shrl %r12d
jmp 0x716f
cmpl $0x3, %r15d
jae 0x71f3
addl %r12d, %eax
jae 0x719a
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x7209
xorl %ebp, %ebp
cmpl %ebp, %r15d
je 0x71c7
movl 0x24(%r14), %eax
addl %r12d, %eax
movl %ebp, %ecx
shll %cl, %eax
testl $0x80000000, %eax       # imm = 0x80000000
je 0x71b9
incl 0x30(%r14)
jmp 0x71c3
movq %r14, %rdi
xorl %esi, %esi
callq 0x7209
incl %ebp
jmp 0x719c
movq %r14, %rdi
xorl %esi, %esi
callq 0x7209
movl 0x20(%r14), %eax
movl %eax, 0x18(%rbx)
andl $0x0, 0x10(%rbx)
addq $0x8, %r14
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x8409
leaq 0x3b62(%rip), %rdi      # 0xad5c
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/ec.c
// Function: xlink_encoder_emit
static void xlink_encoder_emit(xlink_encoder *enc, int bit) {
  XLINK_ERROR(bit == 1 && enc->zero == 0,
   ("Got a carry, but have not seen a zero to propogate it into yet"));
  if (bit == 0) {
    if (enc->zero) {
      xlink_encoder_store(enc, 0);
    }
    while (enc->ones > 0) {
      xlink_encoder_store(enc, 1);
      enc->ones--;
    }
    enc->zero = 1;
  }
  else {
    xlink_encoder_store(enc, 1);
    enc->zero = enc->ones > 0;
    while (enc->ones > 1) {
      xlink_encoder_store(enc, 0);
      enc->ones--;
    }
    enc->ones = 0;
  }
  enc->bytes.length = (enc->bits + 7)/8;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
testl %esi, %esi
je 0x72b7
cmpl $0x1, %esi
jne 0x7227
cmpl $0x0, 0x2c(%rbx)
je 0x7351
leaq 0x8(%rbx), %r14
movl 0x20(%rbx), %esi
andl $-0x8, %esi
incl %esi
movq %r14, %rdi
callq 0x82e0
movq 0x8(%rbx), %rax
movl 0x20(%rbx), %ecx
movl %ecx, %edx
sarl $0x3, %edx
andb $0x7, %cl
pushq $0x1
popq %rbp
movl %ebp, %esi
shll %cl, %esi
movslq %edx, %rcx
orb %sil, (%rax,%rcx)
movl 0x20(%rbx), %esi
movl 0x30(%rbx), %eax
incl %esi
movl %esi, 0x20(%rbx)
xorl %ecx, %ecx
testl %eax, %eax
setg %cl
movl %ecx, 0x2c(%rbx)
cmpl $0x2, %eax
jl 0x72ae
andl $-0x8, %esi
incl %esi
movq %r14, %rdi
callq 0x82e0
movq 0x8(%rbx), %rax
movl 0x20(%rbx), %ecx
movl %ecx, %edx
sarl $0x3, %edx
movslq %edx, %rdx
andb $0x7, %cl
movl %ebp, %esi
shll %cl, %esi
notb %sil
andb %sil, (%rax,%rdx)
movl 0x20(%rbx), %esi
movl 0x30(%rbx), %eax
incl %esi
movl %esi, 0x20(%rbx)
decl %eax
movl %eax, 0x30(%rbx)
jmp 0x726d
andl $0x0, 0x30(%rbx)
jmp 0x733e
cmpl $0x0, 0x2c(%rbx)
je 0x72ef
leaq 0x8(%rbx), %rdi
movl 0x20(%rbx), %esi
andl $-0x8, %esi
incl %esi
callq 0x82e0
movq 0x8(%rbx), %rax
movl 0x20(%rbx), %ecx
movl %ecx, %edx
sarl $0x3, %edx
movslq %edx, %rdx
andb $0x7, %cl
pushq $0x1
popq %rsi
shll %cl, %esi
notb %sil
andb %sil, (%rax,%rdx)
incl 0x20(%rbx)
leaq 0x8(%rbx), %r14
movl 0x30(%rbx), %eax
pushq $0x1
popq %rbp
testl %eax, %eax
jle 0x7334
movl 0x20(%rbx), %esi
andl $-0x8, %esi
incl %esi
movq %r14, %rdi
callq 0x82e0
movq 0x8(%rbx), %rax
movl 0x20(%rbx), %ecx
movl %ecx, %edx
sarl $0x3, %edx
andb $0x7, %cl
movl %ebp, %esi
shll %cl, %esi
movslq %edx, %rcx
orb %sil, (%rax,%rcx)
incl 0x20(%rbx)
movl 0x30(%rbx), %eax
decl %eax
movl %eax, 0x30(%rbx)
jmp 0x72f9
movl $0x1, 0x2c(%rbx)
movl 0x20(%rbx), %esi
addl $0x7, %esi
pushq $0x8
popq %rcx
movl %esi, %eax
cltd
idivl %ecx
movl %eax, 0x18(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x3a8d(%rip), %rdi      # 0xade5
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/ec.c
// Function: xlink_decoder_init
void xlink_decoder_init(xlink_decoder *dec, xlink_context *ctx,
 xlink_bitstream *bs) {
  dec->ctx = ctx;
  dec->bytes = &bs->bytes;
  dec->bits = bs->bits;
  dec->pos = 1;
  dec->low = 0;
  dec->range = 1;
  dec->value = 0;
  /* Discard first bit */
  XLINK_ERROR(xlink_decoder_read_bit(dec, 1, 1) == 0,
   ("Expected first decoded bit to be 1"));
  /* Update the context with 1 bit */
  xlink_context_update_bit(dec->ctx, 0, 1);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq %rsi, (%rdi)
movq %rdx, 0x8(%rdi)
movl 0x18(%rdx), %eax
movl %eax, 0x10(%rdi)
movaps 0x39a1(%rip), %xmm0     # 0xad20
movups %xmm0, 0x14(%rdi)
pushq $0x1
popq %rdx
movl %edx, %esi
callq 0x73b5
testl %eax, %eax
je 0x739f
movq (%rbx), %rdi
pushq $0x1
popq %rdx
xorl %esi, %esi
popq %rbx
jmp 0x7b2d
leaq 0x39f2(%rip), %rdi      # 0xad98
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/ec.c
// Function: xlink_decoder_read_bit
static int xlink_decoder_read_bit(xlink_decoder *dec, xlink_word c0,
 xlink_word c1) {
  int bit;
  xlink_word s;
  XLINK_ERROR(c0 == 0 || c1 == 0 || (c0 > EC_MASK - c1),
   ("Error invalid counts, c0 = %i and c1 = %i", c0, c1));
  /* Fill value with bits until EC_BASE <= range < 2*EC_BASE */
  while (dec->range < EC_BASE) {
    dec->low <<= 1;
    dec->range <<= 1;
    dec->value <<= 1;
    dec->value |=
     dec->pos >= dec->bits ? 0 : XLINK_GET_BIT(dec->bytes->data, dec->pos);
    dec->pos++;
  }
  s = ((xlink_dword)dec->range)*c1/(c0 + c1);
  XLINK_ERROR(s == 0 || s >= dec->range, ("Invalid scale value s = %02x", s));
  bit = dec->value < s;
  if (!bit) {
    dec->low += s;
    dec->range -= s;
    dec->value -= s;
  }
  else {
    dec->range = s;
  }
  return bit;
}

// Assembly:
pushq %rax
movl %esi, %eax
negl %eax
cmpl %edx, %eax
jbe 0x7461
testl %edx, %edx
je 0x7461
movl 0x1c(%rdi), %ecx
testl %ecx, %ecx
js 0x7425
shll 0x18(%rdi)
addl %ecx, %ecx
movl %ecx, 0x1c(%rdi)
movl 0x14(%rdi), %eax
movl 0x20(%rdi), %r8d
addl %r8d, %r8d
movl %r8d, 0x20(%rdi)
xorl %r9d, %r9d
cmpl 0x10(%rdi), %eax
jge 0x7417
movq 0x8(%rdi), %r9
movq (%r9), %r9
movl %eax, %r10d
sarl $0x3, %r10d
movslq %r10d, %r10
movzbl (%r9,%r10), %r10d
movl %eax, %r11d
andl $0x7, %r11d
xorl %r9d, %r9d
btl %r11d, %r10d
setb %r9b
orl %r8d, %r9d
movl %r9d, 0x20(%rdi)
incl %eax
movl %eax, 0x14(%rdi)
jmp 0x73cd
movl %ecx, %r8d
movl %edx, %eax
imulq %r8, %rax
addl %edx, %esi
xorl %edx, %edx
divq %rsi
testl %eax, %eax
je 0x7471
subl %eax, %ecx
jbe 0x7471
movl 0x20(%rdi), %edx
movl %edx, %r8d
movl %eax, %esi
subl %eax, %r8d
jb 0x7453
addl %eax, 0x18(%rdi)
movl %r8d, 0x20(%rdi)
movl %ecx, %esi
xorl %ecx, %ecx
cmpl %eax, %edx
setb %cl
movl %esi, 0x1c(%rdi)
movl %ecx, %eax
popq %rcx
retq
leaq 0x3953(%rip), %rdi      # 0xadbb
xorl %eax, %eax
callq 0x7514
jmp 0x7481
leaq 0x39ac(%rip), %rdi      # 0xae24
movl %eax, %esi
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0
// File: /workspace/github_c_makefile_star2_O2/negge[P]xlink/src/ec.c
// Function: xlink_decoder_read_byte
unsigned char xlink_decoder_read_byte(xlink_decoder *dec) {
  unsigned char byte;
  int i;
  byte = 1;
  for (i = 8; i-- > 0; ) {
    unsigned int counts[2];
    int bit;
    xlink_context_get_counts(dec->ctx, byte, counts);
    bit = xlink_decoder_read_bit(dec, counts[0], counts[1]);
    xlink_context_update_bit(dec->ctx, byte, bit);
    byte <<= 1;
    byte |= bit;
  }
  for (i = 8; i-- > 1; ) {
    dec->ctx->buf[i] = dec->ctx->buf[i - 1];
  }
  dec->ctx->buf[0] = byte;
  return byte;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movb $0x1, %bpl
pushq $-0x8
popq %r12
leaq 0x8(%rsp), %r14
testl %r12d, %r12d
je 0x74e6
movq (%rbx), %rdi
movzbl %bpl, %r15d
movl %r15d, %esi
movq %r14, %rdx
callq 0x7a91
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movq %rbx, %rdi
callq 0x73b5
movl %eax, %ebp
movq (%rbx), %rdi
movl %r15d, %esi
movl %eax, %edx
callq 0x7b2d
addb %r15b, %r15b
orb %r15b, %bpl
incl %r12d
jmp 0x74a5
pushq $0x8
popq %rax
cmpq $0x2, %rax
jb 0x74ff
movq (%rbx), %rcx
movb -0x2(%rcx,%rax), %dl
movb %dl, -0x1(%rcx,%rax)
decq %rax
jmp 0x74e9
movq (%rbx), %rax
movb %bpl, (%rax)
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq