user: 请从给定的汇编指令推导出C源代码：

```asm
<SplitChannels>:
  endbr64
  mov    %rdi,%r10
  mov    %r9d,%edi
  push   %r15
  mov    %rsi,%r11
  push   %r14
  mov    %edi,%eax
  push   %r13
  push   %r12
  push   %rbp
  mov    %rcx,%rbp
  movslq %r8d,%rcx
  push   %rbx
  cmp    %edi,0x38(%rsp)
  mov    %rdx,%rbx
  cmovle 0x38(%rsp),%eax
  cmp    0x40(%rsp),%eax
  mov    0x50(%rsp),%r12
  mov    0x58(%rsp),%r13
  mov    %eax,%edx
  cmovg  0x40(%rsp),%edx
  mov    %edi,%eax
  mov    %r9d,-0x2c(%rsp)
  mov    0x48(%rsp),%r9
  add    %r10,%rcx
  mov    %edx,%edi
  mov    %edx,-0x28(%rsp)
  cltd
  idiv   %edi
  movl   $0x0,(%r9)
  movl   $0x0,(%r12)
  movl   $0x0,0x0(%r13)
  mov    %edi,%edx
  mov    %edx,%esi
  imul   %eax,%edi
  mov    %eax,-0x18(%rsp)
  mov    %eax,%r14d
  mov    0x38(%rsp),%eax
  add    %edi,%esi
  mov    %edi,-0x24(%rsp)
  mov    %edx,%edi
  cltd
  idiv   %edi
  mov    %esi,-0x38(%rsp)
  mov    %edi,%edx
  mov    %edx,%esi
  imul   %eax,%edi
  mov    %eax,-0x14(%rsp)
  mov    %eax,%r8d
  mov    0x40(%rsp),%eax
  add    %edi,%esi
  mov    %edi,-0x20(%rsp)
  mov    %edx,%edi
  cltd
  idiv   %edi
  mov    %esi,-0x34(%rsp)
  mov    %edi,%edx
  mov    %edx,%esi
  imul   %eax,%edi
  mov    %eax,-0x10(%rsp)
  add    %edi,%esi
  mov    %edi,-0x1c(%rsp)
  mov    %esi,-0x30(%rsp)
  test   %edx,%edx
  jle    L136
  lea    0x1(%r14),%edx
  add    $0x1,%eax
  xor    %edi,%edi
  mov    %r10,%rsi
  mov    %edx,-0xc(%rsp)
  lea    0x1(%r8),%edx
  xor    %r15d,%r15d
  mov    %edi,%r10d
  movl   $0x0,-0x3c(%rsp)
  movl   $0x0,-0x40(%rsp)
  mov    %edx,-0x8(%rsp)
  mov    %eax,-0x4(%rsp)
L140:
  mov    -0x38(%rsp),%edx
  mov    -0x40(%rsp),%eax
  add    -0x2c(%rsp),%eax
  cmp    %eax,%edx
  jg     L69
  sub    %edx,%eax
  mov    -0x34(%rsp),%edi
  mov    -0xc(%rsp),%r8d
  mov    %eax,-0x40(%rsp)
  mov    -0x3c(%rsp),%eax
  add    0x38(%rsp),%eax
  cmp    %eax,%edi
  jg     L185
L11:
  sub    %edi,%eax
  mov    -0x8(%rsp),%edx
  mov    %eax,-0x3c(%rsp)
L152:
  mov    -0x30(%rsp),%eax
  add    0x40(%rsp),%r10d
  cmp    %r10d,%eax
  jg     L41
  mov    -0x4(%rsp),%r14d
  sub    %eax,%r10d
L104:
  cmp    %rsi,%rcx
  seta   %al
  mov    %eax,%edi
  test   %r8d,%r8d
  jle    L44
  test   %al,%al
  je     L44
  xor    %eax,%eax
  mov    %r11,%rdi
  nopl   (%rax)
L201:
  movsb  %ds:(%rsi),%es:(%rdi)
  add    $0x1,%eax
  addl   $0x1,(%r9)
  cmp    %rsi,%rcx
  seta   %r11b
  cmp    %eax,%r8d
  jle    L6
  test   %r11b,%r11b
  jne    L201
L6:
  mov    %rdi,%rax
  mov    %r11d,%edi
  mov    %rax,%r11
L44:
  test   %edx,%edx
  jle    L129
  test   %dil,%dil
  je     L129
  xor    %eax,%eax
  mov    %rbx,%rdi
L39:
  movsb  %ds:(%rsi),%es:(%rdi)
  add    $0x1,%eax
  addl   $0x1,(%r12)
  cmp    %rsi,%rcx
  seta   %r8b
  cmp    %eax,%edx
  jle    L58
  test   %r8b,%r8b
  jne    L39
L58:
  mov    %rdi,%rbx
  mov    %r8d,%edi
L129:
  test   %r14d,%r14d
  jle    L52
  test   %dil,%dil
  je     L52
  xor    %eax,%eax
  mov    %rbp,%rdi
  xchg   %ax,%ax
L63:
  movsb  %ds:(%rsi),%es:(%rdi)
  add    $0x1,%eax
  addl   $0x1,0x0(%r13)
  cmp    %rsi,%rcx
  jbe    L136
  cmp    %eax,%r14d
  jg     L63
  mov    %rdi,%rbp
L52:
  cmp    %rsi,%rcx
  jbe    L136
  add    $0x1,%r15d
  cmp    %r15d,-0x28(%rsp)
  jne    L140
L136:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L41:
  mov    -0x10(%rsp),%r14d
  sub    -0x1c(%rsp),%r10d
  jmp    L104
  nopw   0x0(%rax,%rax,1)
L69:
  sub    -0x24(%rsp),%eax
  mov    -0x34(%rsp),%edi
  mov    %eax,-0x40(%rsp)
  mov    -0x3c(%rsp),%eax
  add    0x38(%rsp),%eax
  mov    -0x18(%rsp),%r8d
  cmp    %eax,%edi
  jle    L11
L185:
  sub    -0x20(%rsp),%eax
  mov    -0x14(%rsp),%edx
  mov    %eax,-0x3c(%rsp)
  jmp    L152
```

assistant: ```c
void SplitChannels(unsigned char *buf, unsigned char *lum, unsigned char *cb, unsigned char *cr, int n_buf, int n_lum, int n_cb, int n_cr, int *count_lum, int *count_cb, int *count_cr) {
  int lum_pkg, cb_pkg, cr_pkg;
  int lum_div, cb_div, cr_div;
  int lum_cur, cb_cur, cr_cur;
  int lum_rem, cb_rem, cr_rem;
  int lum_tr0, cb_tr0, cr_tr0;
  int lum_tr1, cb_tr1, cr_tr1;
  unsigned char *pn;
  int i, pkg, min;
  min = (n_lum < (n_cb < n_cr ? n_cb : n_cr) ? n_lum : (n_cb < n_cr ? n_cb : n_cr));
  pn = buf + n_buf;
  *count_lum = 0;
  *count_cb = 0;
  *count_cr = 0;
  lum_div = n_lum / min;
  lum_cur = n_lum;
  lum_rem = 0;
  lum_tr0 = lum_div * min;
  lum_tr1 = lum_tr0 + min;
  cb_div = n_cb / min;
  cb_cur = n_cb;
  cb_rem = 0;
  cb_tr0 = cb_div * min;
  cb_tr1 = cb_tr0 + min;
  cr_div = n_cr / min;
  cr_cur = n_cr;
  cr_rem = 0;
  cr_tr0 = cr_div * min;
  cr_tr1 = cr_tr0 + min;
  for (pkg = 0; pkg < min; pkg++) {
    lum_cur = n_lum + lum_rem;
    if (lum_cur >= lum_tr1) {
      lum_pkg = lum_div + 1;
      lum_rem = lum_cur - lum_tr1;
    } else {
      lum_pkg = lum_div;
      lum_rem = lum_cur - lum_tr0;
    }
    cb_cur = n_cb + cb_rem;
    if (cb_cur >= cb_tr1) {
      cb_pkg = cb_div + 1;
      cb_rem = cb_cur - cb_tr1;
    } else {
      cb_pkg = cb_div;
      cb_rem = cb_cur - cb_tr0;
    }
    cr_cur = n_cr + cr_rem;
    if (cr_cur >= cr_tr1) {
      cr_pkg = cr_div + 1;
      cr_rem = cr_cur - cr_tr1;
    } else {
      cr_pkg = cr_div;
      cr_rem = cr_cur - cr_tr0;
    }
    for (i = 0; (buf < pn) && (i < lum_pkg); i++, (*count_lum)++)
      *lum++ = *buf++;
    for (i = 0; (buf < pn) && (i < cb_pkg); i++, (*count_cb)++)
      *cb++ = *buf++;
    for (i = 0; (buf < pn) && (i < cr_pkg); i++, (*count_cr)++)
      *cr++ = *buf++;
    if (buf >= pn)
      return;
  }
}
```