user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<MergeChannels>:
  endbr64
  push   %r15
  cmp    %r8d,%r9d
  mov    %r8d,%eax
  mov    %rdx,%r10
  push   %r14
  mov    %rcx,%r11
  push   %r13
  mov    %r8d,%r13d
  push   %r12
  cmovle %r9d,%r13d
  push   %rbp
  push   %rbx
  cmp    0x38(%rsp),%r13d
  cmovg  0x38(%rsp),%r13d
  cltd
  idiv   %r13d
  mov    %r8d,-0x38(%rsp)
  mov    %r9d,-0x34(%rsp)
  mov    %eax,-0x20(%rsp)
  mov    %eax,%ebx
  imul   %r13d,%eax
  mov    %eax,-0x2c(%rsp)
  add    %r13d,%eax
  mov    %eax,-0x44(%rsp)
  mov    %r9d,%eax
  cltd
  idiv   %r13d
  mov    %eax,-0x1c(%rsp)
  mov    %eax,%ecx
  imul   %r13d,%eax
  mov    %eax,-0x28(%rsp)
  add    %r13d,%eax
  mov    %eax,-0x40(%rsp)
  mov    0x38(%rsp),%eax
  cltd
  idiv   %r13d
  mov    %eax,%edx
  mov    %eax,-0x18(%rsp)
  imul   %r13d,%edx
  mov    %edx,-0x24(%rsp)
  add    %r13d,%edx
  mov    %edx,-0x3c(%rsp)
  test   %r13d,%r13d
  jle    L267
  add    $0x1,%ebx
  add    $0x1,%eax
  mov    %r13d,-0x30(%rsp)
  xor    %r15d,%r15d
  mov    %ebx,-0x14(%rsp)
  lea    0x1(%rcx),%ebx
  xor    %r12d,%r12d
  movl   $0x0,-0x48(%rsp)
  movl   $0x0,-0x4c(%rsp)
  mov    %ebx,-0x10(%rsp)
  mov    %eax,-0xc(%rsp)
  nopl   0x0(%rax)
L89:
  mov    -0x44(%rsp),%ebx
  mov    -0x4c(%rsp),%eax
  add    -0x38(%rsp),%eax
  cmp    %eax,%ebx
  jg     L403
  sub    %ebx,%eax
  mov    -0x40(%rsp),%ebx
  mov    -0x14(%rsp),%ecx
  mov    %eax,-0x4c(%rsp)
  mov    -0x48(%rsp),%eax
  add    -0x34(%rsp),%eax
  cmp    %eax,%ebx
  jg     L151
L552:
  sub    %ebx,%eax
  mov    -0x10(%rsp),%edx
  mov    %eax,-0x48(%rsp)
L165:
  mov    -0x3c(%rsp),%ebx
  add    0x38(%rsp),%r12d
  cmp    %r12d,%ebx
  jg     L226
  mov    -0xc(%rsp),%eax
  sub    %ebx,%r12d
L203:
  test   %ecx,%ecx
  jle    L264
  lea    0x1(%rsi),%rbx
  mov    %rdi,%r9
  lea    -0x1(%rcx),%r8d
  sub    %rbx,%r9
  cmp    $0xe,%r9
  jbe    L490
  cmp    $0x6,%r8d
  jbe    L490
  cmp    $0xe,%r8d
  jbe    L202
  mov    %ecx,%r9d
  xor    %r8d,%r8d
  shr    $0x4,%r9d
  shl    $0x4,%r9
  nop
L583:
  movdqu (%rsi,%r8,1),%xmm0
  movups %xmm0,(%rdi,%r8,1)
  add    $0x10,%r8
  cmp    %r9,%r8
  jne    L583
  mov    %ecx,%r8d
  mov    %ecx,%ebp
  and    $0xfffffff0,%r8d
  mov    %r8d,%r13d
  lea    (%rdi,%r13,1),%r9
  lea    (%rsi,%r13,1),%rbx
  cmp    %r8d,%ecx
  je     L454
  mov    %ecx,%r14d
  sub    %r8d,%r14d
  lea    -0x1(%r14),%ebp
  cmp    $0x6,%ebp
  jbe    L496
L230:
  mov    (%rsi,%r13,1),%rbp
  mov    %rbp,(%rdi,%r13,1)
  mov    %r14d,%r13d
  and    $0xfffffff8,%r13d
  mov    %r13d,%ebp
  add    %r13d,%r8d
  add    %rbp,%r9
  add    %rbp,%rbx
  mov    %ecx,%ebp
  cmp    %r13d,%r14d
  je     L454
L496:
  movzbl (%rbx),%ebp
  lea    0x1(%r8),%r13d
  mov    %bpl,(%r9)
  mov    %ecx,%ebp
  cmp    %r13d,%ecx
  jle    L454
  movzbl 0x1(%rbx),%r13d
  mov    %r13b,0x1(%r9)
  lea    0x2(%r8),%r13d
  cmp    %r13d,%ecx
  jle    L454
  movzbl 0x2(%rbx),%r13d
  mov    %r13b,0x2(%r9)
  lea    0x3(%r8),%r13d
  cmp    %r13d,%ecx
  jle    L454
  movzbl 0x3(%rbx),%r13d
  mov    %r13b,0x3(%r9)
  lea    0x4(%r8),%r13d
  cmp    %r13d,%ecx
  jle    L454
  movzbl 0x4(%rbx),%r13d
  mov    %r13b,0x4(%r9)
  lea    0x5(%r8),%r13d
  cmp    %r13d,%ecx
  jle    L454
  movzbl 0x5(%rbx),%r13d
  add    $0x6,%r8d
  mov    %r13b,0x5(%r9)
  cmp    %r8d,%ecx
  jle    L454
  movzbl 0x6(%rbx),%ecx
  mov    %cl,0x6(%r9)
L454:
  add    %rbp,%rdi
  add    %rbp,%rsi
L264:
  test   %edx,%edx
  jle    L113
  lea    0x1(%r10),%r9
  mov    %rdi,%r8
  lea    -0x1(%rdx),%ecx
  sub    %r9,%r8
  cmp    $0xe,%r8
  jbe    L459
  cmp    $0x6,%ecx
  jbe    L459
  cmp    $0xe,%ecx
  jbe    L574
  mov    %edx,%r8d
  xor    %ecx,%ecx
  shr    $0x4,%r8d
  shl    $0x4,%r8
  nopl   0x0(%rax)
L68:
  movdqu (%r10,%rcx,1),%xmm1
  movups %xmm1,(%rdi,%rcx,1)
  add    $0x10,%rcx
  cmp    %r8,%rcx
  jne    L68
  mov    %edx,%ecx
  mov    %edx,%ebx
  and    $0xfffffff0,%ecx
  mov    %ecx,%ebp
  lea    (%rdi,%rbp,1),%r8
  lea    (%r10,%rbp,1),%r9
  cmp    %ecx,%edx
  je     L150
  mov    %edx,%r13d
  sub    %ecx,%r13d
  lea    -0x1(%r13),%ebx
  cmp    $0x6,%ebx
  jbe    L429
L547:
  mov    (%r10,%rbp,1),%rbx
  mov    %rbx,(%rdi,%rbp,1)
  mov    %r13d,%ebp
  and    $0xfffffff8,%ebp
  mov    %ebp,%ebx
  add    %ebp,%ecx
  add    %rbx,%r8
  add    %rbx,%r9
  mov    %edx,%ebx
  cmp    %r13d,%ebp
  je     L150
L429:
  movzbl (%r9),%ebx
  lea    0x1(%rcx),%ebp
  mov    %bl,(%r8)
  mov    %edx,%ebx
  cmp    %ebp,%edx
  jle    L150
  movzbl 0x1(%r9),%ebp
  mov    %bpl,0x1(%r8)
  lea    0x2(%rcx),%ebp
  cmp    %ebp,%edx
  jle    L150
  movzbl 0x2(%r9),%ebp
  mov    %bpl,0x2(%r8)
  lea    0x3(%rcx),%ebp
  cmp    %ebp,%edx
  jle    L150
  movzbl 0x3(%r9),%ebp
  mov    %bpl,0x3(%r8)
  lea    0x4(%rcx),%ebp
  cmp    %ebp,%edx
  jle    L150
  movzbl 0x4(%r9),%ebp
  mov    %bpl,0x4(%r8)
  lea    0x5(%rcx),%ebp
  cmp    %ebp,%edx
  jle    L150
  movzbl 0x5(%r9),%ebp
  add    $0x6,%ecx
  mov    %bpl,0x5(%r8)
  cmp    %ecx,%edx
  jle    L150
  movzbl 0x6(%r9),%edx
  mov    %dl,0x6(%r8)
L150:
  add    %rbx,%rdi
  add    %rbx,%r10
L113:
  test   %eax,%eax
  jle    L50
  lea    0x1(%r11),%r8
  mov    %rdi,%rcx
  lea    -0x1(%rax),%edx
  sub    %r8,%rcx
  cmp    $0xe,%rcx
  jbe    L564
  cmp    $0x6,%edx
  jbe    L564
  cmp    $0xe,%edx
  jbe    L128
  mov    %eax,%ecx
  xor    %edx,%edx
  shr    $0x4,%ecx
  shl    $0x4,%rcx
  nopl   (%rax)
L171:
  movdqu (%r11,%rdx,1),%xmm2
  movups %xmm2,(%rdi,%rdx,1)
  add    $0x10,%rdx
  cmp    %rcx,%rdx
  jne    L171
  mov    %eax,%edx
  mov    %eax,%r9d
  and    $0xfffffff0,%edx
  mov    %edx,%ebx
  lea    (%rdi,%rbx,1),%rcx
  lea    (%r11,%rbx,1),%r8
  cmp    %edx,%eax
  je     L406
  mov    %eax,%ebp
  sub    %edx,%ebp
  lea    -0x1(%rbp),%r9d
  cmp    $0x6,%r9d
  jbe    L211
L7:
  mov    (%r11,%rbx,1),%r9
  mov    %r9,(%rdi,%rbx,1)
  mov    %ebp,%ebx
  and    $0xfffffff8,%ebx
  mov    %ebx,%r9d
  add    %ebx,%edx
  add    %r9,%rcx
  add    %r9,%r8
  mov    %eax,%r9d
  cmp    %ebp,%ebx
  je     L406
L211:
  movzbl (%r8),%r9d
  lea    0x1(%rdx),%ebx
  mov    %r9b,(%rcx)
  mov    %eax,%r9d
  cmp    %ebx,%eax
  jle    L406
  movzbl 0x1(%r8),%ebx
  mov    %bl,0x1(%rcx)
  lea    0x2(%rdx),%ebx
  cmp    %ebx,%eax
  jle    L406
  movzbl 0x2(%r8),%ebx
  mov    %bl,0x2(%rcx)
  lea    0x3(%rdx),%ebx
  cmp    %ebx,%eax
  jle    L406
  movzbl 0x3(%r8),%ebx
  mov    %bl,0x3(%rcx)
  lea    0x4(%rdx),%ebx
  cmp    %ebx,%eax
  jle    L406
  movzbl 0x4(%r8),%ebx
  mov    %bl,0x4(%rcx)
  lea    0x5(%rdx),%ebx
  cmp    %ebx,%eax
  jle    L406
  movzbl 0x5(%r8),%ebx
  add    $0x6,%edx
  mov    %bl,0x5(%rcx)
  cmp    %edx,%eax
  jle    L406
  movzbl 0x6(%r8),%eax
  mov    %al,0x6(%rcx)
L406:
  add    %r9,%rdi
  add    %r9,%r11
L50:
  add    $0x1,%r15d
  cmp    %r15d,-0x30(%rsp)
  jne    L89
L267:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L226:
  mov    -0x18(%rsp),%eax
  sub    -0x24(%rsp),%r12d
  jmp    L203
  xchg   %ax,%ax
L403:
  sub    -0x2c(%rsp),%eax
  mov    -0x40(%rsp),%ebx
  mov    %eax,-0x4c(%rsp)
  mov    -0x48(%rsp),%eax
  add    -0x34(%rsp),%eax
  mov    -0x20(%rsp),%ecx
  cmp    %eax,%ebx
  jle    L552
L151:
  sub    -0x28(%rsp),%eax
  mov    -0x1c(%rsp),%edx
  mov    %eax,-0x48(%rsp)
  jmp    L165
  nopl   0x0(%rax)
L564:
  mov    %eax,%r9d
  xor    %eax,%eax
  nopl   (%rax)
L192:
  movzbl (%r11,%rax,1),%edx
  mov    %dl,(%rdi,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%r9
  jne    L192
  jmp    L406
  cs nopw 0x0(%rax,%rax,1)
L459:
  mov    %edx,%ebx
  xor    %edx,%edx
  nopl   0x0(%rax)
L15:
  movzbl (%r10,%rdx,1),%ecx
  mov    %cl,(%rdi,%rdx,1)
  add    $0x1,%rdx
  cmp    %rbx,%rdx
  jne    L15
  jmp    L150
  xchg   %ax,%ax
L490:
  mov    %ecx,%ebp
  xor    %ecx,%ecx
  nopl   0x0(%rax)
L43:
  movzbl (%rsi,%rcx,1),%r8d
  mov    %r8b,(%rdi,%rcx,1)
  add    $0x1,%rcx
  cmp    %rbp,%rcx
  jne    L43
  jmp    L454
L202:
  mov    %ecx,%r14d
  mov    %rsi,%rbx
  mov    %rdi,%r9
  xor    %r8d,%r8d
  xor    %r13d,%r13d
  jmp    L230
L128:
  mov    %eax,%ebp
  mov    %r11,%r8
  mov    %rdi,%rcx
  xor    %edx,%edx
  xor    %ebx,%ebx
  jmp    L7
L574:
  mov    %edx,%r13d
  mov    %r10,%r9
  mov    %rdi,%r8
  xor    %ecx,%ecx
  xor    %ebp,%ebp
  jmp    L547
```

assistant: ```c
void MergeChannels(unsigned char *buf, unsigned char *lum, unsigned char *cb, unsigned char *cr, int n_lum, int n_cb, int n_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;
  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));
  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; i < lum_pkg; i++)
      *buf++ = *lum++;
    for (i = 0; i < cb_pkg; i++)
      *buf++ = *cb++;
    for (i = 0; i < cr_pkg; i++)
      *buf++ = *cr++;
  }
}
```