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

```asm
<apply_mask>:
  endbr64
  push   %r14
  cmp    $0x3,%edi
  mov    %edi,%r14d
  push   %r13
  setbe  %dil
  mov    %r8d,%r13d
  push   %r12
  movzbl %dil,%edi
  mov    %rdx,%r12
  push   %rbp
  mov    %rcx,%rbp
  push   %rbx
  mov    %esi,%ebx
  call   <assert@plt>
  cmp    $0x2,%r14d
  je     L80
  jg     L61
  test   %r14d,%r14d
  je     L96
  cmp    $0x1,%r14d
  jne    L152
  movb   $0x1,(%r12)
  test   %ebx,%ebx
  jle    L152
  movslq %ebx,%rdi
  xor    %ecx,%ecx
  nopl   0x0(%rax,%rax,1)
L55:
  movzbl 0x0(%rbp,%rcx,1),%edx
  lea    (%rcx,%rcx,2),%eax
  add    %eax,%edx
  movslq %edx,%rax
  mov    %edx,%esi
  imul   $0x487ede05,%rax,%rax
  sar    $0x1f,%esi
  sar    $0x25,%rax
  sub    %esi,%eax
  imul   $0x71,%eax,%eax
  sub    %eax,%edx
  mov    %dl,0x1(%r12,%rcx,1)
  add    $0x1,%rcx
  cmp    %rcx,%rdi
  jne    L55
L152:
  lea    0x1(%rbx),%edi
  mov    %r12,%rdx
  pop    %rbx
  mov    %r13d,%esi
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  jmp    1070 <rsencode@plt>
L61:
  cmp    $0x3,%r14d
  jne    L152
  movb   $0x3,(%r12)
  test   %ebx,%ebx
  jle    L152
  mov    %ebx,%edi
  xor    %esi,%esi
  xor    %ecx,%ecx
  shl    $0x4,%edi
  add    %ebx,%edi
  nopw   0x0(%rax,%rax,1)
L76:
  movzbl 0x0(%rbp,%rsi,1),%edx
  add    %ecx,%edx
  add    $0x11,%ecx
  movslq %edx,%rax
  mov    %edx,%r8d
  imul   $0x487ede05,%rax,%rax
  sar    $0x1f,%r8d
  sar    $0x25,%rax
  sub    %r8d,%eax
  imul   $0x71,%eax,%eax
  sub    %eax,%edx
  mov    %dl,0x1(%r12,%rsi,1)
  add    $0x1,%rsi
  cmp    %ecx,%edi
  jne    L76
  jmp    L152
  cs nopw 0x0(%rax,%rax,1)
L96:
  movb   $0x0,(%r12)
  movslq %ebx,%rcx
  xor    %eax,%eax
  test   %ebx,%ebx
  jle    L152
  nopw   0x0(%rax,%rax,1)
L110:
  movzbl 0x0(%rbp,%rax,1),%edx
  mov    %dl,0x1(%r12,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rcx
  jne    L110
  jmp    L152
L80:
  movb   $0x2,(%r12)
  test   %ebx,%ebx
  jle    L152
  lea    0x0(,%rbx,8),%edi
  xor    %esi,%esi
  xor    %ecx,%ecx
  sub    %ebx,%edi
  nopw   0x0(%rax,%rax,1)
L1:
  movzbl 0x0(%rbp,%rsi,1),%edx
  add    %ecx,%edx
  add    $0x7,%ecx
  movslq %edx,%rax
  mov    %edx,%r8d
  imul   $0x487ede05,%rax,%rax
  sar    $0x1f,%r8d
  sar    $0x25,%rax
  sub    %r8d,%eax
  imul   $0x71,%eax,%eax
  sub    %eax,%edx
  mov    %dl,0x1(%r12,%rsi,1)
  add    $0x1,%rsi
  cmp    %edi,%ecx
  jne    L1
  jmp    L152
```

assistant: ```c
void apply_mask(const int mask, const int data_length, unsigned char *masked_codeword_array, const unsigned char *codeword_array, const int ecc_length) {
  int weight = 0;
  int j;
  assert(mask >= 0 && mask <= 3);
  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);
}
```