user: 请从给定的汇编指令推导出C源代码：

```asm
<PDJHUFF_BalanceTree_r>:
  endbr64
  xor    %eax,%eax
  test   %edx,%edx
  js     L10
  push   %r15
  add    %edx,%edx
  push   %r14
  push   %r13
  mov    %ecx,%r13d
  lea    0x1(%rcx),%ecx
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  movslq %edx,%rbx
  lea    (%rdi,%rbx,2),%r9
  lea    0x2(%rbp,%rbx,2),%r15
  sub    $0x18,%rsp
  movswl (%r9),%edx
  mov    %r9,0x8(%rsp)
  mov    %r8d,(%rsp)
  mov    %ecx,0x4(%rsp)
  call   <PDJHUFF_BalanceTree_r>
  movswl (%r15),%edx
  mov    (%rsp),%r8d
  mov    %r12,%rsi
  mov    0x4(%rsp),%ecx
  mov    %rbp,%rdi
  mov    %eax,%r14d
  call   <PDJHUFF_BalanceTree_r>
  mov    (%rsp),%r8d
  cmp    %eax,%r14d
  mov    %eax,%edx
  mov    %eax,%ecx
  cmovge %r14d,%edx
  add    %r12,%rbx
  lea    0x1(%rdx),%eax
  add    %eax,%r13d
  mov    %ax,(%rbx)
  cmp    %r8d,%r13d
  jle    L74
  lea    0x1(%r14),%edx
  mov    0x8(%rsp),%r9
  cmp    %ecx,%edx
  jl     L56
  add    $0x1,%ecx
  cmp    %r14d,%ecx
  jge    L74
  movswl (%r9),%edx
  lea    (%rdx,%rdx,1),%eax
  mov    %edx,%edi
  cltq
  lea    0x0(%rbp,%rax,2),%rcx
  lea    0x2(%rbp,%rax,2),%rax
  movzwl (%rax),%r8d
  movzwl (%rcx),%esi
  mov    %r8w,(%rcx)
  movzwl (%r15),%r8d
  mov    %r8w,(%rax)
L62:
  mov    %si,(%r9)
  mov    %di,(%r15)
  movswq (%rcx),%rsi
  movswq (%rax),%rcx
  xor    %eax,%eax
  test   %si,%si
  js     L5
  movswl (%r12,%rsi,2),%eax
L5:
  xor    %esi,%esi
  test   %cx,%cx
  js     L19
  movswl (%r12,%rcx,2),%esi
L19:
  cmp    %esi,%eax
  movslq %edx,%rdx
  cmovl  %esi,%eax
  add    $0x1,%eax
  mov    %ax,(%r12,%rdx,2)
  movswq (%r9),%rcx
  xor    %eax,%eax
  movswq (%r15),%rdx
  test   %cx,%cx
  js     L50
  movswl (%r12,%rcx,2),%eax
L50:
  xor    %ecx,%ecx
  test   %dx,%dx
  js     L29
  movswl (%r12,%rdx,2),%ecx
L29:
  cmp    %ecx,%eax
  cmovl  %ecx,%eax
  add    $0x1,%eax
  mov    %ax,(%rbx)
L74:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L10:
  ret
  nopl   0x0(%rax)
L56:
  movswl (%r15),%edx
  lea    (%rdx,%rdx,1),%ecx
  mov    %edx,%esi
  movslq %ecx,%rcx
  lea    0x2(%rbp,%rcx,2),%rax
  lea    0x0(%rbp,%rcx,2),%rcx
  movzwl (%rcx),%r8d
  movzwl (%rax),%edi
  mov    %r8w,(%rax)
  movzwl (%r9),%r8d
  mov    %r8w,(%rcx)
  jmp    L62
```

assistant: ```c
int PDJHUFF_BalanceTree_r(short *nodes, short *nlen, int root, int h, int ml) {
  int h0, h1, h2, h3;
  int l0, l1, l2;
  if (root < 0)
    return (0);
  h1 = PDJHUFF_BalanceTree_r(nodes, nlen, nodes[root * 2 + 0], h + 1, ml);
  h2 = PDJHUFF_BalanceTree_r(nodes, nlen, nodes[root * 2 + 1], h + 1, ml);
  h0 = ((h1 > h2) ? h1 : h2) + 1;
  nlen[root] = h0;
  if ((h + h0) <= ml)
    return (h0);
  if ((h1 + 1) < h2) {
    l0 = nodes[root * 2 + 1];
    l1 = nodes[l0 * 2 + 1];
    nodes[l0 * 2 + 1] = nodes[l0 * 2 + 0];
    nodes[l0 * 2 + 0] = nodes[root * 2 + 0];
    nodes[root * 2 + 0] = l0;
    nodes[root * 2 + 1] = l1;
  } else if ((h2 + 1) < h1) {
    l0 = nodes[root * 2 + 0];
    l1 = nodes[l0 * 2 + 0];
    nodes[l0 * 2 + 0] = nodes[l0 * 2 + 1];
    nodes[l0 * 2 + 1] = nodes[root * 2 + 1];
    nodes[root * 2 + 0] = l1;
    nodes[root * 2 + 1] = l0;
  } else {
    return (h0);
  }
  l1 = nodes[l0 * 2 + 0];
  l2 = nodes[l0 * 2 + 1];
  h1 = (l1 < 0) ? 0 : nlen[l1];
  h2 = (l2 < 0) ? 0 : nlen[l2];
  h3 = ((h1 > h2) ? h1 : h2) + 1;
  nlen[l0] = h3;
  l1 = nodes[root * 2 + 0];
  l2 = nodes[root * 2 + 1];
  h1 = (l1 < 0) ? 0 : nlen[l1];
  h2 = (l2 < 0) ? 0 : nlen[l2];
  h0 = ((h1 > h2) ? h1 : h2) + 1;
  nlen[root] = h0;
  return (h0);
}
```