// File: /workspace/github_c_makefile_star2_O3/negge[P]xlink/src/paq.c
// Function: xlink_modeler_load_binary
void xlink_modeler_load_binary(xlink_modeler *mod, xlink_list *bytes) {
  unsigned char buf[8];
  int i, j, k;
  printf("Scanning %i bytes for counts... ", xlink_list_length(bytes));
  fflush(stdout);
  memset(buf, 0, sizeof(buf));
  for (k = 0; k < xlink_list_length(bytes); k++) {
    unsigned char byte;
    unsigned char partial;
    xlink_match key;
    byte = *xlink_list_get_byte(bytes, k);
    partial = 1;
    memcpy(key.buf, buf, sizeof(buf));
    for (i = 8; i-- > 0; ) {
      int bit;
      xlink_counts counts;
      key.partial = partial;
      bit = !!(byte & (1 << i));
      for (j = 0; j < 256; j++) {
        xlink_match *match;
        key.mask = j;
        match = xlink_set_get(&mod->matches, &key);
        if (match == NULL) {
          memset(key.counts, 0, sizeof(key.counts));
          match = xlink_set_put(&mod->matches, &key);
        }
        XLINK_ERROR(match == NULL,
         ("Null pointer for match, should point to allocated xlink_match"));
        counts[j][0] = match->counts[0];
        counts[j][1] = match->counts[1];
        match->counts[bit] = XLINK_MIN(255, match->counts[bit] + 1);
        if (match->counts[1 - bit] > 1) {
          match->counts[1 - bit] >>= 1;
        }
      }
      xlink_list_add(&mod->counts, &counts);
      partial <<= 1;
      partial |= bit;
    }
    for (i = 8; i-- > 1; ) {
      buf[i] = buf[i - 1];
    }
    buf[0] = byte;
    xlink_list_add(&mod->bytes, &byte);
  }
  printf("done\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rsi, %r14
movq %rdi, 0x20(%rsp)
movq %rsi, %rdi
callq 0x94be
leaq 0x32db(%rip), %rdi      # 0xbf8c
xorl %r15d, %r15d
movl %eax, %esi
xorl %eax, %eax
callq 0x20c0
movq 0x72fc(%rip), %rax      # 0xffc0
movq (%rax), %rdi
callq 0x2160
movq $0x0, 0x10(%rsp)
movq %r14, %rdi
callq 0x94be
testl %eax, %eax
jle 0x8e3d
movq 0x20(%rsp), %rax
leaq 0x30(%rax), %r12
addq $0x18, %rax
movq %rax, 0x48(%rsp)
leaq 0x28(%rsp), %rbp
movl $0xff, %ebx
movq %r14, 0x38(%rsp)
movq %r14, %rdi
movq %r15, 0x40(%rsp)
movl %r15d, %esi
callq 0x9507
movb (%rax), %al
movb %al, 0xe(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x2e(%rsp)
movb $0x1, %al
movl $0x7, %ecx
movb %al, 0xf(%rsp)
movb %al, 0x2c(%rsp)
movzbl 0xe(%rsp), %eax
xorl %r13d, %r13d
movl %ecx, 0x1c(%rsp)
btl %ecx, %eax
setb %r13b
movq %r13, %r15
xorq $0x1, %r15
xorl %r14d, %r14d
movb %r14b, 0x2d(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
callq 0x9c8e
testq %rax, %rax
jne 0x8d82
movw $0x0, 0x36(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
callq 0x9d24
testq %rax, %rax
je 0x8e5b
movb 0xe(%rax), %cl
movb %cl, 0x50(%rsp,%r14,2)
movb 0xf(%rax), %cl
movb %cl, 0x51(%rsp,%r14,2)
movb 0xe(%rax,%r13), %cl
leal 0x1(%rcx), %edx
cmpb $-0x2, %cl
movzbl %dl, %ecx
cmovael %ebx, %ecx
movb %cl, 0xe(%rax,%r13)
movb 0xe(%rax,%r15), %cl
cmpb $0x2, %cl
jb 0x8db9
shrb %cl
movb %cl, 0xe(%rax,%r15)
incq %r14
cmpq $0x100, %r14            # imm = 0x100
jne 0x8d52
movq 0x48(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x957e
movb 0xf(%rsp), %al
addb %al, %al
orb %al, %r13b
movl %r13d, %eax
movl 0x1c(%rsp), %ecx
subl $0x1, %ecx
jae 0x8d2d
movl 0x10(%rsp), %eax
movzwl 0x14(%rsp), %ecx
movb 0x16(%rsp), %dl
leaq 0x11(%rsp), %rsi
movb %dl, 0x6(%rsi)
movw %cx, 0x4(%rsi)
movl %eax, (%rsi)
movb 0xe(%rsp), %al
movb %al, 0x10(%rsp)
movq 0x20(%rsp), %rdi
leaq 0xe(%rsp), %rsi
callq 0x957e
movq 0x40(%rsp), %r15
incl %r15d
movq 0x38(%rsp), %r14
movq %r14, %rdi
callq 0x94be
cmpl %eax, %r15d
jl 0x8d06
leaq 0x3272(%rip), %rdi      # 0xc0b6
callq 0x2060
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x314b(%rip), %rdi      # 0xbfad
xorl %eax, %eax
callq 0x22ef
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21f0