// File: atsidaev[P]trx2x/DiskImage.cpp
// Function: update(int)
void update(int c)
{
  int i, j, k, l;

  if(freq[R] == MAX_FREQ) reconst();

  c = prnt[c + T];
  do {
    k = ++freq[c];

    /* if the order is disturbed, exchange nodes */
    if (k > freq[l = c + 1])
    {
      while (k > freq[++l]);
      l--;
      freq[c] = freq[l];
      freq[l] = k;

      i = son[c];
      prnt[i] = l;
      if (i < T) prnt[i + 1] = l;

      j = son[l];
      son[l] = i;

      prnt[j] = c;
      if (j < T) prnt[j + 1] = c;
      son[c] = j;

      c = l;
    }
  } while ((c = prnt[c]) != 0);  /* repeat up to root */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movzwl 0x5742(%rip), %eax      # 0x12b34
cmpl $0x8000, %eax           # imm = 0x8000
jne 0xd3fe
callq 0xd190
movl -0x4(%rbp), %eax
addl $0x273, %eax            # imm = 0x273
movl %eax, %eax
movl %eax, %ecx
leaq 0x572f(%rip), %rax      # 0x12b40
movswl (%rax,%rcx,2), %eax
movl %eax, -0x4(%rbp)
movslq -0x4(%rbp), %rdx
leaq 0x522d(%rip), %rax      # 0x12650
movw (%rax,%rdx,2), %ax
addw $0x1, %ax
leaq 0x521e(%rip), %rcx      # 0x12650
movw %ax, (%rcx,%rdx,2)
movzwl %ax, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
movl -0x4(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rdx
leaq 0x51fe(%rip), %rcx      # 0x12650
movzwl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
jle 0xd580
jmp 0xd460
movl -0x10(%rbp), %eax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movslq %ecx, %rdx
leaq 0x51da(%rip), %rcx      # 0x12650
movzwl (%rcx,%rdx,2), %ecx
cmpl %ecx, %eax
jle 0xd480
jmp 0xd460
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0x51bc(%rip), %rax      # 0x12650
movw (%rax,%rcx,2), %dx
movslq -0x4(%rbp), %rcx
leaq 0x51ad(%rip), %rax      # 0x12650
movw %dx, (%rax,%rcx,2)
movl -0x10(%rbp), %eax
movw %ax, %dx
movslq -0x14(%rbp), %rcx
leaq 0x5198(%rip), %rax      # 0x12650
movw %dx, (%rax,%rcx,2)
movslq -0x4(%rbp), %rcx
leaq 0x5dd9(%rip), %rax      # 0x132a0
movswl (%rax,%rcx,2), %eax
movl %eax, -0x8(%rbp)
movl -0x14(%rbp), %eax
movw %ax, %dx
movslq -0x8(%rbp), %rcx
leaq 0x5661(%rip), %rax      # 0x12b40
movw %dx, (%rax,%rcx,2)
cmpl $0x273, -0x8(%rbp)      # imm = 0x273
jae 0xd506
movl -0x14(%rbp), %eax
movw %ax, %dx
movl -0x8(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x563e(%rip), %rax      # 0x12b40
movw %dx, (%rax,%rcx,2)
movslq -0x14(%rbp), %rcx
leaq 0x5d8f(%rip), %rax      # 0x132a0
movswl (%rax,%rcx,2), %eax
movl %eax, -0xc(%rbp)
movl -0x8(%rbp), %eax
movw %ax, %dx
movslq -0x14(%rbp), %rcx
leaq 0x5d77(%rip), %rax      # 0x132a0
movw %dx, (%rax,%rcx,2)
movl -0x4(%rbp), %eax
movw %ax, %dx
movslq -0xc(%rbp), %rcx
leaq 0x5602(%rip), %rax      # 0x12b40
movw %dx, (%rax,%rcx,2)
cmpl $0x273, -0xc(%rbp)      # imm = 0x273
jae 0xd565
movl -0x4(%rbp), %eax
movw %ax, %dx
movl -0xc(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x55df(%rip), %rax      # 0x12b40
movw %dx, (%rax,%rcx,2)
movl -0xc(%rbp), %eax
movw %ax, %dx
movslq -0x4(%rbp), %rcx
leaq 0x5d2a(%rip), %rax      # 0x132a0
movw %dx, (%rax,%rcx,2)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xd582
movslq -0x4(%rbp), %rcx
leaq 0x55b3(%rip), %rax      # 0x12b40
movswl (%rax,%rcx,2), %eax
movl %eax, -0x4(%rbp)
cmpl $0x0, %eax
jne 0xd418
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)