user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<apply_mask>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    %rdx,-0x20(%rbp)
  mov    %rcx,-0x28(%rbp)
  mov    %r8d,-0x2c(%rbp)
  movl   $0x0,-0x8(%rbp)
  cmpl   $0x3,-0x14(%rbp)
  je     L69
  cmpl   $0x3,-0x14(%rbp)
  jg     L38
  cmpl   $0x2,-0x14(%rbp)
  je     L105
  cmpl   $0x2,-0x14(%rbp)
  jg     L38
  cmpl   $0x0,-0x14(%rbp)
  je     L94
  cmpl   $0x1,-0x14(%rbp)
  je     L9
  jmp    L38
L94:
  mov    -0x20(%rbp),%rax
  movb   $0x0,(%rax)
  movl   $0x0,-0x4(%rbp)
  jmp    L56
L87:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    -0x4(%rbp),%edx
  movslq %edx,%rdx
  lea    0x1(%rdx),%rcx
  mov    -0x20(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x4(%rbp)
L56:
  mov    -0x4(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jl     L87
  jmp    L38
L9:
  mov    -0x20(%rbp),%rax
  movb   $0x1,(%rax)
  movl   $0x0,-0x4(%rbp)
  jmp    L108
L147:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x8(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  imul   $0x487ede05,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x5,%edx
  mov    %eax,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%edx
  imul   $0x71,%edx,%ecx
  sub    %ecx,%eax
  mov    %eax,%edx
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x1(%rax),%rcx
  mov    -0x20(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  addl   $0x3,-0x8(%rbp)
  addl   $0x1,-0x4(%rbp)
L108:
  mov    -0x4(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jl     L147
  jmp    L38
L105:
  mov    -0x20(%rbp),%rax
  movb   $0x2,(%rax)
  movl   $0x0,-0x4(%rbp)
  jmp    L152
L65:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x8(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  imul   $0x487ede05,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x5,%edx
  mov    %eax,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%edx
  imul   $0x71,%edx,%ecx
  sub    %ecx,%eax
  mov    %eax,%edx
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x1(%rax),%rcx
  mov    -0x20(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  addl   $0x7,-0x8(%rbp)
  addl   $0x1,-0x4(%rbp)
L152:
  mov    -0x4(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jl     L65
  jmp    L38
L69:
  mov    -0x20(%rbp),%rax
  movb   $0x3,(%rax)
  movl   $0x0,-0x4(%rbp)
  jmp    L169
L95:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x8(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  imul   $0x487ede05,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x5,%edx
  mov    %eax,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%edx
  imul   $0x71,%edx,%ecx
  sub    %ecx,%eax
  mov    %eax,%edx
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x1(%rax),%rcx
  mov    -0x20(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  addl   $0x11,-0x8(%rbp)
  addl   $0x1,-0x4(%rbp)
L169:
  mov    -0x4(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jl     L95
  nop
L38:
  mov    -0x18(%rbp),%eax
  lea    0x1(%rax),%ecx
  mov    -0x20(%rbp),%rdx
  mov    -0x2c(%rbp),%eax
  mov    %eax,%esi
  mov    %ecx,%edi
  call   <rsencode@plt>
  nop
  leave
  ret
```

assistant: ```c
void apply_mask(int mask, int data_length, unsigned char *masked_codeword_array, unsigned char *codeword_array, int ecc_length) {
  int weight = 0;
  int j;
  switch (mask) {
  case 0:
    masked_codeword_array[0] = 0;
    for (j = 0; j < data_length; j++) {
      masked_codeword_array[j + 1] = codeword_array[j];
    }
    break;
  case 1:
    masked_codeword_array[0] = 1;
    for (j = 0; j < data_length; j++) {
      masked_codeword_array[j + 1] = (weight + codeword_array[j]) % 113;
      weight += 3;
    }
    break;
  case 2:
    masked_codeword_array[0] = 2;
    for (j = 0; j < data_length; j++) {
      masked_codeword_array[j + 1] = (weight + codeword_array[j]) % 113;
      weight += 7;
    }
    break;
  case 3:
    masked_codeword_array[0] = 3;
    for (j = 0; j < data_length; j++) {
      masked_codeword_array[j + 1] = (weight + codeword_array[j]) % 113;
      weight += 17;
    }
    break;
  }
  rsencode(data_length + 1, ecc_length, masked_codeword_array);
}
```