user: What would the C source look like for the assembly code provided here:

```asm
<encode>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %edx,-0x54(%rbp)
  mov    %ecx,-0x58(%rbp)
  mov    -0x58(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x34(%rbp)
  movl   $0x20,-0x30(%rbp)
  mov    -0x30(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x30(%rbp),%eax
  sub    $0x2,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x30(%rbp),%eax
  sub    $0x3,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x28(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x24(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x18(%rbp)
  movl   $0x0,-0x3c(%rbp)
  jmp    L16
L105:
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  and    -0x18(%rbp),%eax
  test   %eax,%eax
  jne    L123
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  and    -0x34(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <put_rle@plt>
  mov    %eax,-0x8(%rbp)
  cmpl   $0x0,-0x8(%rbp)
  je     L132
  mov    -0x8(%rbp),%eax
  jmp    L100
L132:
  cmpl   $0x0,-0xc(%rbp)
  je     L123
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  and    -0x20(%rbp),%eax
  mov    %eax,%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <rle_put_bit@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L61
  mov    -0x4(%rbp),%eax
  jmp    L100
L61:
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x3c(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x50(%rbp),%rdx
  add    %rcx,%rdx
  or     -0x1c(%rbp),%eax
  mov    %eax,(%rdx)
L123:
  addl   $0x1,-0x3c(%rbp)
L16:
  mov    -0x3c(%rbp),%eax
  cmp    -0x54(%rbp),%eax
  jl     L105
  movl   $0x0,-0x38(%rbp)
  jmp    L130
L24:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  and    -0x18(%rbp),%eax
  test   %eax,%eax
  je     L113
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  and    -0x34(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <rle_put_bit@plt>
  mov    %eax,-0x10(%rbp)
  cmpl   $0x0,-0x10(%rbp)
  je     L0
  mov    -0x10(%rbp),%eax
  jmp    L100
L113:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  and    -0x1c(%rbp),%eax
  test   %eax,%eax
  je     L0
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x1c(%rbp),%eax
  or     -0x18(%rbp),%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rsi
  mov    -0x50(%rbp),%rax
  add    %rsi,%rax
  xor    %ecx,%edx
  mov    %edx,(%rax)
L0:
  addl   $0x1,-0x38(%rbp)
L130:
  mov    -0x38(%rbp),%eax
  cmp    -0x54(%rbp),%eax
  jl     L24
  mov    $0x0,%eax
L100:
  leave
  ret
```

assistant: ```c
int encode(struct rle_writer *rle, int *val, int num, int plane) {
  int bit_mask = 1 << plane;
  int int_bits = sizeof(int) * 8;
  int sgn_pos = int_bits - 1;
  int sig_pos = int_bits - 2;
  int ref_pos = int_bits - 3;
  int sgn_mask = 1 << sgn_pos;
  int sig_mask = 1 << sig_pos;
  int ref_mask = 1 << ref_pos;
  for (int i = 0; i < num; ++i) {
    if (!(val[i] & ref_mask)) {
      int bit = val[i] & bit_mask;
      int ret = put_rle(rle, bit);
      if (ret)
        return ret;
      if (bit) {
        int ret = rle_put_bit(rle, val[i] & sgn_mask);
        if (ret)
          return ret;
        val[i] |= sig_mask;
      }
    }
  }
  for (int i = 0; i < num; ++i) {
    if (val[i] & ref_mask) {
      int bit = val[i] & bit_mask;
      int ret = rle_put_bit(rle, bit);
      if (ret)
        return ret;
    } else if (val[i] & sig_mask) {
      val[i] ^= sig_mask | ref_mask;
    }
  }
  return 0;
}
```