user: 请将以下的汇编代码转换成C语言代码:

```asm
<PDJHUFF_BalanceTree_r>:
  endbr64
  mov    $0x0,%eax
  test   %edx,%edx
  js     L11
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r12
  mov    %ecx,0xc(%rsp)
  lea    0x1(%rcx),%eax
  add    %edx,%edx
  movslq %edx,%rbx
  lea    (%rdi,%rbx,2),%r15
  movswl (%r15),%edx
  mov    %r8d,0x4(%rsp)
  mov    %eax,0x8(%rsp)
  mov    %eax,%ecx
  call   <PDJHUFF_BalanceTree_r>
  mov    %eax,%r13d
  lea    0x2(%rbp,%rbx,2),%r14
  movswl (%r14),%edx
  mov    0x4(%rsp),%r8d
  mov    0x8(%rsp),%ecx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <PDJHUFF_BalanceTree_r>
  mov    %eax,%ecx
  cmp    %eax,%r13d
  mov    %eax,%edx
  cmovge %r13d,%edx
  lea    0x1(%rdx),%eax
  add    %r12,%rbx
  mov    %ax,(%rbx)
  mov    0xc(%rsp),%edi
  lea    (%rdi,%rax,1),%edx
  cmp    0x4(%rsp),%edx
  jle    L67
  lea    0x1(%r13),%edx
  cmp    %ecx,%edx
  jge    L8
  movzwl (%r14),%ecx
  movswl %cx,%eax
  lea    (%rax,%rax,1),%edx
  movslq %edx,%rdx
  lea    0x2(%rbp,%rdx,2),%rdi
  movzwl (%rdi),%esi
  lea    0x0(%rbp,%rdx,2),%rdx
  movzwl (%rdx),%r8d
  mov    %r8w,(%rdi)
  movzwl (%r15),%edi
  mov    %di,(%rdx)
L63:
  mov    %cx,(%r15)
  mov    %si,(%r14)
  add    %eax,%eax
  cltq
  movzwl 0x0(%rbp,%rax,2),%esi
  movzwl 0x2(%rbp,%rax,2),%ecx
  mov    $0x0,%edx
  test   %si,%si
  js     L55
  movswq %si,%rsi
  movswl (%r12,%rsi,2),%edx
L55:
  mov    $0x0,%esi
  test   %cx,%cx
  js     L86
  movswq %cx,%rcx
  movswl (%r12,%rcx,2),%esi
L86:
  cmp    %esi,%edx
  cmovl  %esi,%edx
  add    $0x1,%edx
  mov    %dx,(%r12,%rax,1)
  movzwl (%r15),%ecx
  movzwl (%r14),%edx
  mov    $0x0,%eax
  test   %cx,%cx
  js     L23
  movswq %cx,%rcx
  movswl (%r12,%rcx,2),%eax
L23:
  mov    $0x0,%ecx
  test   %dx,%dx
  js     L34
  movswq %dx,%rdx
  movswl (%r12,%rdx,2),%ecx
L34:
  cmp    %ecx,%eax
  cmovl  %ecx,%eax
  add    $0x1,%eax
  mov    %ax,(%rbx)
L67:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L8:
  add    $0x1,%ecx
  cmp    %r13d,%ecx
  jge    L67
  movzwl (%r15),%esi
  movswl %si,%eax
  lea    (%rax,%rax,1),%edx
  movslq %edx,%rdx
  lea    0x0(%rbp,%rdx,2),%rdi
  movzwl (%rdi),%ecx
  lea    0x2(%rbp,%rdx,2),%rdx
  movzwl (%rdx),%r8d
  mov    %r8w,(%rdi)
  movzwl (%r14),%edi
  mov    %di,(%rdx)
  jmp    L63
L11:
  ret
```

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);
}
```