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

```asm
<SplitChannels>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdx,%r10
  mov    %rcx,%r11
  mov    %r9d,%eax
  mov    %r9d,-0x2c(%rsp)
  mov    0x48(%rsp),%r9
  mov    0x50(%rsp),%rbx
  mov    0x58(%rsp),%rbp
  cmp    %eax,0x38(%rsp)
  mov    %eax,%r13d
  cmovle 0x38(%rsp),%r13d
  cmp    0x40(%rsp),%r13d
  cmovg  0x40(%rsp),%r13d
  movslq %r8d,%rcx
  add    %rdi,%rcx
  movl   $0x0,(%r9)
  movl   $0x0,(%rbx)
  movl   $0x0,0x0(%rbp)
  cltd
  idiv   %r13d
  mov    %eax,-0x18(%rsp)
  mov    %eax,%r8d
  imul   %r13d,%eax
  mov    %eax,-0x24(%rsp)
  add    %r13d,%eax
  mov    %eax,-0x38(%rsp)
  mov    0x38(%rsp),%eax
  cltd
  idiv   %r13d
  mov    %eax,-0x14(%rsp)
  mov    %eax,%r12d
  imul   %r13d,%eax
  mov    %eax,-0x20(%rsp)
  add    %r13d,%eax
  mov    %eax,-0x34(%rsp)
  mov    0x40(%rsp),%eax
  cltd
  idiv   %r13d
  mov    %eax,-0x10(%rsp)
  mov    %eax,%edx
  imul   %r13d,%edx
  mov    %edx,-0x1c(%rsp)
  add    %r13d,%edx
  mov    %edx,-0x30(%rsp)
  test   %r13d,%r13d
  jle    L217
  mov    $0x0,%r15d
  mov    $0x0,%r14d
  movl   $0x0,-0x3c(%rsp)
  movl   $0x0,-0x40(%rsp)
  lea    0x1(%r8),%edx
  mov    %edx,-0xc(%rsp)
  lea    0x1(%r12),%edx
  mov    %edx,-0x8(%rsp)
  add    $0x1,%eax
  mov    %eax,-0x4(%rsp)
  mov    %r13d,-0x28(%rsp)
  mov    $0x0,%r13d
  jmp    L182
L135:
  sub    -0x24(%rsp),%eax
  mov    %eax,-0x40(%rsp)
  mov    -0x18(%rsp),%r12d
  jmp    L138
L141:
  sub    -0x20(%rsp),%r13d
  mov    -0x14(%rsp),%r8d
  jmp    L146
L226:
  sub    -0x1c(%rsp),%r14d
  mov    -0x10(%rsp),%edx
  jmp    L163
L176:
  mov    -0x3c(%rsp),%edx
  jmp    L124
L200:
  cmp    %rdi,%rcx
  jbe    L217
  add    $0x1,%r15d
  cmp    %r15d,-0x28(%rsp)
  je     L217
L182:
  mov    -0x40(%rsp),%eax
  add    -0x2c(%rsp),%eax
  mov    -0x38(%rsp),%edx
  cmp    %eax,%edx
  jg     L135
  mov    -0xc(%rsp),%r12d
  sub    %edx,%eax
  mov    %eax,-0x40(%rsp)
L138:
  add    0x38(%rsp),%r13d
  mov    -0x34(%rsp),%eax
  cmp    %r13d,%eax
  jg     L141
  mov    -0x8(%rsp),%r8d
  sub    %eax,%r13d
L146:
  add    0x40(%rsp),%r14d
  mov    -0x30(%rsp),%eax
  cmp    %r14d,%eax
  jg     L226
  mov    -0x4(%rsp),%edx
  sub    %eax,%r14d
L163:
  cmp    %rdi,%rcx
  jbe    L124
  test   %r12d,%r12d
  jle    L124
  mov    $0x0,%eax
  mov    %edx,-0x3c(%rsp)
L111:
  add    $0x1,%rdi
  add    $0x1,%rsi
  movzbl -0x1(%rdi),%edx
  mov    %dl,-0x1(%rsi)
  add    $0x1,%eax
  addl   $0x1,(%r9)
  cmp    %rdi,%rcx
  jbe    L176
  cmp    %eax,%r12d
  jg     L111
  mov    -0x3c(%rsp),%edx
L124:
  cmp    %rdi,%rcx
  jbe    L82
  test   %r8d,%r8d
  jle    L82
  mov    $0x0,%eax
L219:
  add    $0x1,%rdi
  add    $0x1,%r10
  movzbl -0x1(%rdi),%r12d
  mov    %r12b,-0x1(%r10)
  add    $0x1,%eax
  addl   $0x1,(%rbx)
  cmp    %rdi,%rcx
  jbe    L82
  cmp    %eax,%r8d
  jg     L219
L82:
  cmp    %rdi,%rcx
  jbe    L200
  test   %edx,%edx
  jle    L200
  mov    $0x0,%eax
L228:
  add    $0x1,%rdi
  add    $0x1,%r11
  movzbl -0x1(%rdi),%r8d
  mov    %r8b,-0x1(%r11)
  add    $0x1,%eax
  addl   $0x1,0x0(%rbp)
  cmp    %rdi,%rcx
  jbe    L200
  cmp    %eax,%edx
  jg     L228
  jmp    L200
L217:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

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;
  }
}
```