user: Demonstrate the C code that generates the assembly output below:

```asm
<build_tree>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    -0x34(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x34(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x34(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0xc(%rbp)
  jmp    L29
L69:
  cmpl   $0x0,-0x10(%rbp)
  je     L51
  mov    -0xc(%rbp),%eax
  add    $0x2,%eax
  cmp    %eax,-0x14(%rbp)
  jbe    L41
  mov    -0x14(%rbp),%eax
  sub    $0x2,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jge    L41
L51:
  mov    -0x14(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x14(%rbp),%eax
  sub    $0x2,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x14(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x14(%rbp),%eax
  sub    $0x2,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  subl   $0x2,-0x14(%rbp)
  jmp    L89
L41:
  mov    -0xc(%rbp),%eax
  add    $0x2,%eax
  cmp    %eax,-0x14(%rbp)
  jb     L46
  cmpl   $0x1,-0x10(%rbp)
  jbe    L57
  mov    -0x10(%rbp),%eax
  sub    $0x2,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x14(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jg     L57
L46:
  mov    -0x10(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x10(%rbp),%eax
  sub    $0x2,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  subl   $0x2,-0x10(%rbp)
  jmp    L89
L57:
  mov    -0x14(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x14(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x10(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  subl   $0x1,-0x10(%rbp)
  subl   $0x1,-0x14(%rbp)
L89:
  mov    -0xc(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  movzwl %ax,%edx
  mov    -0x8(%rbp),%ecx
  mov    -0x4(%rbp),%eax
  add    %ecx,%eax
  and    $0xff0000,%eax
  or     %edx,%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%eax
  and    $0xff000000,%eax
  mov    %eax,%edx
  mov    -0x4(%rbp),%eax
  and    $0xff000000,%eax
  cmp    %eax,%edx
  cmovae %edx,%eax
  add    %ecx,%eax
  lea    0x1000000(%rax),%edx
  mov    -0xc(%rbp),%eax
  lea    0x0(,%rax,4),%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  mov    %edx,(%rax)
  subl   $0x1,-0xc(%rbp)
L29:
  cmpl   $0x0,-0xc(%rbp)
  jne    L69
  cmpl   $0x2,-0x14(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  cmpl   $0x0,-0x10(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  cmpl   $0x0,-0xc(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  nop
  leave
  ret
```

assistant: ```c
void build_tree(uint32_t *tree, uint64_t *weight, int32_t as) {
  unsigned r;
  unsigned s;
  unsigned t;
  uint64_t w1, w2;
  r = as;
  s = as;
  for (t = as - 1; t > 0; t--) {
    if (s < 1 || (r > t + 2 && weight[r - 2] < weight[s - 1])) {
      tree[r - 1] = t;
      tree[r - 2] = t;
      w1 = weight[r - 1];
      w2 = weight[r - 2];
      r -= 2;
    } else if (r < t + 2 || (s > 1 && weight[s - 2] <= weight[r - 1])) {
      w1 = weight[s - 1];
      w2 = weight[s - 2];
      s -= 2;
    } else {
      tree[r - 1] = t;
      w1 = weight[r - 1];
      w2 = weight[s - 1];
      s--;
      r--;
    }
    weight[t] = (weight[t] & 0xFFFF) + ((w1 + w2) & ~(uint64_t)0xFF00FFFF) + ((w1 & 0xFF000000) < (w2 & 0xFF000000) ? (w2 & 0xFF000000) : (w1 & 0xFF000000)) + 0x01000000;
  }
  assert(r == 2);
  assert(s == 0);
  assert(t == 0);
}
```