// File: /workspace/github_c_makefile_star2_O2/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, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x82d7
leaq 0x32d1(%rip), %rdi      # 0xaf5c
xorl %r13d, %r13d
movl %eax, %esi
xorl %eax, %eax
callq 0x20c0
movq 0x8322(%rip), %rax      # 0xffc0
movq (%rax), %rdi
callq 0x2160
andq $0x0, 0x10(%rsp)
leaq 0x30(%rbx), %r12
movq %rbx, 0x30(%rsp)
leaq 0x18(%rbx), %rax
movq %rax, 0x40(%rsp)
leaq 0x20(%rsp), %r14
movl $0xff, %ebx
movq %r15, 0x48(%rsp)
movq %r15, %rdi
callq 0x82d7
cmpl %eax, %r13d
jge 0x7e05
movq %r15, %rdi
movq %r13, 0x38(%rsp)
movq %r13, %rsi
callq 0x831b
movb (%rax), %al
movb %al, 0xe(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x26(%rsp)
movb $0x1, %cl
pushq $0x8
popq %rdx
subl $0x1, %edx
jb 0x7dcb
movb %cl, 0xf(%rsp)
movb %cl, 0x24(%rsp)
movzbl 0xe(%rsp), %eax
xorl %r13d, %r13d
movl %edx, 0x1c(%rsp)
btl %edx, %eax
setb %r13b
movq %r13, %r15
xorq $0x1, %r15
xorl %ebp, %ebp
cmpq $0x100, %rbp            # imm = 0x100
je 0x7da2
movb %bpl, 0x25(%rsp)
movq %r12, %rdi
movq %r14, %rsi
callq 0x89e8
testq %rax, %rax
jne 0x7d68
andw $0x0, 0x2e(%rsp)
movq %r12, %rdi
movq %r14, %rsi
callq 0x8a75
testq %rax, %rax
je 0x7e23
movb 0xe(%rax), %cl
movb %cl, 0x50(%rsp,%rbp,2)
movb 0xf(%rax), %cl
movb %cl, 0x51(%rsp,%rbp,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 0x7d9d
shrb %cl
movb %cl, 0xe(%rax,%r15)
incq %rbp
jmp 0x7d30
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x838e
movb 0xf(%rsp), %al
addb %al, %al
orb %al, %r13b
movl %r13d, %ecx
movq 0x48(%rsp), %r15
movl 0x1c(%rsp), %edx
jmp 0x7d03
pushq $0x8
popq %rax
cmpq $0x2, %rax
jb 0x7de1
movb 0xe(%rsp,%rax), %cl
movb %cl, 0xf(%rsp,%rax)
decq %rax
jmp 0x7dce
movb 0xe(%rsp), %al
movb %al, 0x10(%rsp)
movq 0x30(%rsp), %rdi
leaq 0xe(%rsp), %rsi
callq 0x838e
movq 0x38(%rsp), %r13
incl %r13d
jmp 0x7ccd
leaq 0x327a(%rip), %rdi      # 0xb086
callq 0x2060
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3153(%rip), %rdi      # 0xaf7d
xorl %eax, %eax
callq 0x7514
pushq $-0x1
popq %rdi
callq 0x21f0