// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0xc6a0
movl %eax, %esi
leaq 0x457f(%rip), %rdi      # 0x10264
movb $0x0, %al
callq 0x20a0
movq 0x82cd(%rip), %rax      # 0x13fc0
movq (%rax), %rdi
callq 0x2130
leaq -0x18(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x20b0
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x24c(%rbp)
movq -0x10(%rbp), %rdi
callq 0xc6a0
movl %eax, %ecx
movl -0x24c(%rbp), %eax
cmpl %ecx, %eax
jge 0xbf6c
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0xc870
movb (%rax), %al
movb %al, -0x25(%rbp)
movb $0x1, -0x26(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x32(%rbp)
movl $0x8, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x1c(%rbp)
cmpl $0x0, %eax
jle 0xbf1e
movb -0x26(%rbp), %al
movb %al, -0x34(%rbp)
movzbl -0x25(%rbp), %eax
movl -0x1c(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x20(%rbp)
cmpl $0x100, -0x20(%rbp)     # imm = 0x100
jge 0xbef0
movl -0x20(%rbp), %eax
movb %al, -0x33(%rbp)
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
leaq -0x38(%rbp), %rsi
callq 0xd4b0
movq %rax, -0x248(%rbp)
cmpq $0x0, -0x248(%rbp)
jne 0xbdfe
leaq -0x38(%rbp), %rdi
addq $0xe, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x20b0
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
leaq -0x38(%rbp), %rsi
callq 0xd580
movq %rax, -0x248(%rbp)
jmp 0xbe00
cmpq $0x0, -0x248(%rbp)
jne 0xbe22
leaq 0x4474(%rip), %rdi      # 0x10285
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0xbe24
movq -0x248(%rbp), %rax
movb 0xe(%rax), %cl
movslq -0x20(%rbp), %rax
movb %cl, -0x240(%rbp,%rax,2)
movq -0x248(%rbp), %rax
movb 0xf(%rax), %cl
movslq -0x20(%rbp), %rax
movb %cl, -0x23f(%rbp,%rax,2)
movq -0x248(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movzbl 0xe(%rax,%rcx), %ecx
addl $0x1, %ecx
movl $0xff, %eax
cmpl %ecx, %eax
jg 0xbe77
movl $0xff, %eax
movl %eax, -0x250(%rbp)
jmp 0xbe90
movq -0x248(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movzbl 0xe(%rax,%rcx), %eax
addl $0x1, %eax
movl %eax, -0x250(%rbp)
movl -0x250(%rbp), %eax
movb %al, %dl
movq -0x248(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movb %dl, 0xe(%rax,%rcx)
movq -0x248(%rbp), %rax
movl $0x1, %ecx
subl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movzbl 0xe(%rax,%rcx), %eax
cmpl $0x1, %eax
jle 0xbee0
movq -0x248(%rbp), %rax
movl $0x1, %ecx
subl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movzbl 0xe(%rax,%rcx), %edx
sarl %edx
movb %dl, 0xe(%rax,%rcx)
jmp 0xbee2
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xbd9d
movq -0x8(%rbp), %rdi
addq $0x18, %rdi
leaq -0x240(%rbp), %rsi
callq 0xc950
movzbl -0x26(%rbp), %eax
shll %eax
movb %al, -0x26(%rbp)
movl -0x3c(%rbp), %ecx
movzbl -0x26(%rbp), %eax
orl %ecx, %eax
movb %al, -0x26(%rbp)
jmp 0xbd58
movl $0x8, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x1c(%rbp)
cmpl $0x1, %eax
jle 0xbf4b
movl -0x1c(%rbp), %eax
subl $0x1, %eax
cltq
movb -0x18(%rbp,%rax), %cl
movslq -0x1c(%rbp), %rax
movb %cl, -0x18(%rbp,%rax)
jmp 0xbf25
movb -0x25(%rbp), %al
movb %al, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x25(%rbp), %rsi
callq 0xc950
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xbd12
leaq 0x4350(%rip), %rdi      # 0x102c3
movb $0x0, %al
callq 0x20a0
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
nopw %cs:(%rax,%rax)