user: What is the c source code of the assembly code below:

```asm
<FS460_encode_alpha_mask_from_bitmap>:
  endbr64
  test   %rsi,%rsi
  je     L172
  push   %rbp
  mov    %rdx,%r9
  mov    %rsi,%r10
  mov    $0x1000,%eax
  push   %rbx
  mov    (%rsi),%ebx
  lea    -0x2(%rbx),%edx
  cmp    $0xfffe,%edx
  ja     L192
  test   %rdi,%rdi
  je     L235
  test   %r9,%r9
  je     L235
  mov    %rcx,%r11
  mov    $0x2d0,%r8d
  mov    %ebx,%ecx
  test   %r11,%r11
  jle    L176
L215:
  movzbl (%r9),%esi
  cmp    $0x1,%r8d
  jle    L127
  cmp    $0x1,%r11
  je     L69
  lea    0x1(%r9),%rax
  lea    (%r9,%r11,1),%rbp
  mov    $0x1,%edx
  jmp    L225
  nopl   0x0(%rax,%rax,1)
L205:
  add    $0x1,%edx
  cmp    %r8d,%edx
  je     L66
  add    $0x1,%rax
  cmp    %rax,%rbp
  je     L29
L225:
  cmp    %sil,(%rax)
  je     L205
L29:
  cmp    $0xff,%edx
  jle    L62
  cmp    $0x1,%ecx
  jle    L120
  mov    %esi,%ebp
  mov    %edx,%eax
  or     $0xff00,%bp
  jmp    L111
  cs nopw 0x0(%rax,%rax,1)
L35:
  cmp    $0x1,%ecx
  jle    L120
L111:
  sub    $0xff,%eax
  add    $0x2,%rdi
  sub    $0x2,%ecx
  mov    %bp,-0x2(%rdi)
  cmp    $0xff,%eax
  jg     L35
L187:
  cmp    $0x1,%ecx
  jle    L120
  shl    $0x8,%eax
  or     %eax,%esi
L198:
  movslq %edx,%rax
  mov    %si,(%rdi)
  sub    $0x2,%ecx
  add    $0x2,%rdi
  sub    %rax,%r11
  add    %rax,%r9
  sub    %edx,%r8d
  je     L28
  test   %r11,%r11
  jg     L215
L240:
  sub    %ecx,%ebx
L242:
  mov    %ebx,(%r10)
  xor    %eax,%eax
L192:
  pop    %rbx
  pop    %rbp
  ret
L127:
  mov    $0x1,%edx
  jne    L55
  nopl   0x0(%rax,%rax,1)
L66:
  cmp    $0x1,%ecx
  jg     L198
L120:
  mov    $0x1002,%eax
  pop    %rbx
  pop    %rbp
  ret
L235:
  mov    $0x1000,%eax
  pop    %rbx
  pop    %rbp
  ret
L172:
  mov    $0x1000,%eax
  ret
L69:
  mov    $0x1,%edx
L55:
  mov    $0x1,%eax
  jmp    L187
L28:
  test   %r11,%r11
  jle    L240
  mov    $0x2d0,%r8d
  jmp    L215
L62:
  mov    %edx,%eax
  jmp    L187
L176:
  xor    %ebx,%ebx
  jmp    L242
```

assistant: ```c
int FS460_encode_alpha_mask_from_bitmap(unsigned short *p_alpha_mask, int *p_mask_size, const unsigned char *p_alpha_values, long alpha_value_count) {
  unsigned short *p_m;
  const unsigned char *p_a;
  int count, c, remainder;
  int mask_size;
  unsigned char to_match;
  if (!p_mask_size || (*p_mask_size > 0x10000) || (*p_mask_size < 2) || !p_alpha_mask || !p_alpha_values)
    return 0x1000;
  p_m = p_alpha_mask;
  p_a = p_alpha_values;
  mask_size = *p_mask_size;
  while (alpha_value_count > 0) {
    remainder = 720;
    while (remainder && (alpha_value_count > 0)) {
      to_match = *p_a;
      for (count = 1; 1; count++) {
        if (count >= remainder)
          break;
        if (alpha_value_count - count <= 0)
          break;
        if (to_match != p_a[count])
          break;
      }
      {}
      if (count == remainder) {
        if (mask_size < 2)
          return 0x1002;
        *(p_m++) = to_match;
        mask_size -= 2;
      } else {
        c = count;
        while (c > 255) {
          if (mask_size < 2)
            return 0x1002;
          *(p_m++) = (0xFF00 | to_match);
          mask_size -= 2;
          c -= 255;
        }
        {
          if (mask_size < 2)
            return 0x1002;
          *(p_m++) = ((0xFF00 & (c << 8)) | to_match);
          mask_size -= 2;
        }
      }
      remainder -= count;
      alpha_value_count -= count;
      p_a += count;
    }
  }
  *p_mask_size -= mask_size;
  return 0;
}
```