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

```asm
<NV21Transform>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rsi,0x8(%rsp)
  mov    %edx,%esi
  mov    %ecx,%r10d
  mov    %r8d,%eax
  and    $0x50,%eax
  sete   %cl
  movzbl %cl,%ecx
  test   $0x30,%r8b
  je     L415
  mov    %r8d,%r15d
  and    $0x1,%r15d
  sar    %r8d
  mov    %r8d,%r11d
  and    $0x1,%r11d
L489:
  mov    %r10d,%r9d
  imul   %esi,%r9d
  lea    (%r9,%r9,2),%r8d
  mov    %r8d,%edx
  shr    $0x1f,%edx
  add    %r8d,%edx
  sar    %edx
  mov    %edx,0x28(%rsp)
  mov    %r15d,%r8d
  or     %r11d,%r8d
  or     %ecx,%r8d
  je     L424
L440:
  mov    %r10d,%ebx
  sar    %ebx
  mov    %esi,%ebp
  sar    %ebp
  test   %eax,%eax
  je     L223
  test   %r11d,%r11d
  je     L583
  test   %r15d,%r15d
  jne    L583
  sub    %esi,%r9d
  test   %r10d,%r10d
  jle    L540
  mov    %esi,%r13d
  neg    %r13d
  movslq %r13d,%r13
  movslq %r9d,%r9
  mov    $0xffffffff,%r8d
  mov    $0x0,%r11d
  lea    0x1(%rsi),%r14d
L524:
  test   %esi,%esi
  jle    L343
  lea    0x1(%r8),%eax
  cltq
  movslq %r8d,%rdx
  lea    (%r14,%rdx,1),%r12
  mov    %r9,%rcx
  sub    %rdx,%rcx
  add    0x8(%rsp),%rcx
L2:
  movzbl (%rdi,%rax,1),%edx
  mov    %dl,-0x1(%rcx,%rax,1)
  add    $0x1,%rax
  cmp    %r12,%rax
  jne    L2
  add    %esi,%r8d
L343:
  add    $0x1,%r11d
  add    %r13,%r9
  cmp    %r11d,%r10d
  jne    L524
L460:
  mov    0x28(%rsp),%r10d
  sub    %esi,%r10d
  test   %ebx,%ebx
  jle    L206
  sub    $0x1,%r10d
  lea    -0x1(%rbp),%r12d
  mov    %r12d,%eax
  add    %r12d,%r12d
  mov    $0x0,%r11d
  lea    0x4(%rdi,%rax,2),%r13
  mov    0x8(%rsp),%r14
L554:
  test   %ebp,%ebp
  jle    L561
  movslq %r10d,%rdx
  add    %r14,%rdx
  movslq %r8d,%r9
  lea    0x2(%rdi,%r9,1),%rax
  add    %r13,%r9
L493:
  movzbl -0x1(%rax),%ecx
  mov    %cl,0x1(%rdx)
  movzbl (%rax),%ecx
  mov    %cl,0x2(%rdx)
  add    $0x2,%rdx
  add    $0x2,%rax
  cmp    %r9,%rax
  jne    L493
  lea    0x2(%r12,%r8,1),%r8d
L561:
  add    $0x1,%r11d
  sub    %esi,%r10d
  cmp    %r11d,%ebx
  jne    L554
L206:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L415:
  test   $0x2,%r8b
  je     L17
  test   $0x1,%r8b
  sete   %r15b
  movzbl %r15b,%r15d
  mov    $0x0,%r11d
  jmp    L489
L17:
  test   $0x1,%r8b
  sete   %r15b
  movzbl %r15b,%r15d
  mov    %r10d,%r9d
  imul   %edx,%r9d
  lea    (%r9,%r9,2),%ecx
  mov    %ecx,%edx
  shr    $0x1f,%edx
  add    %ecx,%edx
  sar    %edx
  mov    %edx,0x28(%rsp)
  mov    $0x1,%r11d
  jmp    L440
L424:
  mov    %rdi,%rsi
  mov    0x8(%rsp),%rdi
  call   <memcpy@plt>
  jmp    L206
L223:
  cmp    $0x1,%r15d
  je     L149
  cmp    $0x1,%r11d
  je     L355
  lea    -0x1(%r10),%edx
  test   %r10d,%r10d
  jle    L47
  mov    %r10d,0x2c(%rsp)
  mov    $0xffffffff,%eax
L193:
  cltq
  mov    %rax,0x18(%rsp)
  movslq %edx,%rdx
  mov    0x8(%rsp),%rax
  lea    (%rax,%rdx,1),%r12
  mov    $0xffffffff,%r14d
  mov    $0x0,%r13d
  movslq 0x2c(%rsp),%r8
  lea    0x1(%rsi),%eax
  add    %rdi,%rax
  mov    %rax,0x20(%rsp)
  jmp    L49
L149:
  cmp    $0x1,%r11d
  je     L295
  lea    -0x1(%r9),%edx
  mov    %r10d,%eax
  neg    %eax
  mov    %eax,0x2c(%rsp)
  mov    $0xffffffff,%eax
  test   %r10d,%r10d
  jg     L193
  jmp    L37
L295:
  mov    %r9d,%edx
  sub    %r10d,%edx
  mov    %r10d,%eax
  neg    %eax
  mov    %eax,0x2c(%rsp)
  mov    %r11d,%eax
  test   %r10d,%r10d
  jg     L193
L253:
  mov    0x28(%rsp),%eax
  sub    %r10d,%eax
  mov    $0x2,%r12d
  jmp    L264
L294:
  movslq %r14d,%rcx
  lea    0x1(%rdi,%rcx,1),%rax
  add    0x20(%rsp),%rcx
  mov    %r12,%rdx
  mov    %esi,0x14(%rsp)
L40:
  movzbl (%rax),%esi
  mov    %sil,(%rdx)
  add    $0x1,%rax
  add    %r8,%rdx
  cmp    %rcx,%rax
  jne    L40
  mov    0x14(%rsp),%esi
  add    %esi,%r14d
L531:
  add    $0x1,%r13d
  add    0x18(%rsp),%r12
  cmp    %r13d,%r10d
  jle    L446
L49:
  test   %esi,%esi
  jg     L294
  jmp    L531
L446:
  cmp    $0x1,%r15d
  je     L354
  cmp    $0x1,%r11d
  je     L526
L89:
  lea    -0x2(%r9,%r10,1),%eax
  mov    $0xfffffffe,%r12d
L264:
  sub    $0x1,%r9d
  test   %ebx,%ebx
  jle    L206
  movslq %r12d,%r12
  cltq
  mov    0x8(%rsp),%r10
  add    %rax,%r10
  lea    -0x1(%rbp),%r13d
  mov    %r13d,%eax
  add    %r13d,%r13d
  mov    $0x0,%r11d
  movslq 0x2c(%rsp),%r8
  lea    0x3(%rdi,%rax,2),%r14
  jmp    L256
L354:
  cmp    $0x1,%r11d
  je     L253
L37:
  mov    0x28(%rsp),%eax
  sub    $0x2,%eax
  mov    $0xfffffffe,%r12d
  jmp    L264
L47:
  mov    %r10d,0x2c(%rsp)
  jmp    L89
L526:
  mov    %r9d,%eax
  mov    $0x2,%r12d
  jmp    L264
L302:
  movslq %r9d,%rsi
  lea    0x1(%rdi,%rsi,1),%rax
  add    %r14,%rsi
  mov    %r10,%rdx
L254:
  movzbl (%rax),%ecx
  mov    %cl,(%rdx)
  movzbl 0x1(%rax),%ecx
  mov    %cl,0x1(%rdx)
  add    $0x2,%rax
  add    %r8,%rdx
  cmp    %rax,%rsi
  jne    L254
  lea    0x2(%r13,%r9,1),%r9d
L482:
  add    $0x1,%r11d
  add    %r12,%r10
  cmp    %r11d,%ebx
  je     L206
L256:
  test   %ebp,%ebp
  jg     L302
  jmp    L482
L540:
  mov    $0xffffffff,%r8d
  jmp    L460
L583:
  cmp    $0x1,%r11d
  je     L452
  lea    -0x1(%rsi),%eax
  mov    %esi,%r14d
  mov    $0xffffffff,%r8d
  test   %r10d,%r10d
  jle    L288
L521:
  mov    %r14d,0x18(%rsp)
  lea    0x1(%rax),%r13d
  movslq %r14d,%r15
  lea    -0x1(%rsi),%edx
  mov    0x8(%rsp),%rcx
  sub    %rdx,%rcx
  cltq
  add    %rax,%rcx
  mov    $0xffffffff,%r8d
  mov    $0x0,%r12d
L93:
  test   %esi,%esi
  jle    L281
  movslq %r8d,%rax
  lea    0x1(%rdi,%rax,1),%rdx
  movslq %r13d,%rax
  add    0x8(%rsp),%rax
  mov    %esi,0x14(%rsp)
L42:
  movzbl (%rdx),%esi
  mov    %sil,-0x1(%rax)
  add    $0x1,%rdx
  sub    $0x1,%rax
  cmp    %rcx,%rax
  jne    L42
  mov    0x14(%rsp),%esi
  add    %esi,%r8d
L281:
  add    $0x1,%r12d
  add    0x18(%rsp),%r13d
  add    %r15,%rcx
  cmp    %r12d,%r10d
  jg     L93
  cmp    $0x1,%r11d
  je     L387
L288:
  lea    -0x1(%r9,%rsi,1),%eax
L84:
  test   %ebx,%ebx
  jle    L206
  movslq %r14d,%r14
  cltq
  mov    0x8(%rsp),%r9
  add    %rax,%r9
  lea    -0x1(%rbp),%r11d
  mov    %r11d,%eax
  add    %r11d,%r11d
  mov    $0x0,%r10d
  lea    0x4(%rdi,%rax,2),%r12
  jmp    L436
L452:
  mov    %esi,%r14d
  neg    %r14d
  lea    -0x1(%r9),%eax
  test   %r10d,%r10d
  jg     L521
  mov    $0xffffffff,%r8d
L387:
  mov    0x28(%rsp),%eax
  sub    $0x1,%eax
  jmp    L84
L423:
  movslq %r8d,%rsi
  lea    0x2(%rdi,%rsi,1),%rax
  add    %r12,%rsi
  mov    %r9,%rdx
L586:
  movzbl -0x1(%rax),%ecx
  mov    %cl,-0x1(%rdx)
  movzbl (%rax),%ecx
  mov    %cl,(%rdx)
  sub    $0x2,%rdx
  add    $0x2,%rax
  cmp    %rsi,%rax
  jne    L586
  lea    0x2(%r11,%r8,1),%r8d
L39:
  add    $0x1,%r10d
  add    %r14,%r9
  cmp    %r10d,%ebx
  je     L206
L436:
  test   %ebp,%ebp
  jg     L423
  jmp    L39
L355:
  mov    %r10d,0x2c(%rsp)
  mov    %r11d,%eax
  mov    %r15d,%edx
  test   %r10d,%r10d
  jg     L193
  mov    %r9d,%eax
  mov    $0x2,%r12d
  jmp    L264
```

assistant: ```c
void NV21Transform(const unsigned char *src, const unsigned char *dst, int srcWidth, int srcHeight, int directionFlag) {
  unsigned char *cdst = dst;
  unsigned char *csrc = src;
  int rotate = 0;
  int hflip = 0;
  int vflip = 0;
  if ((0x10 & directionFlag) != 0 || (0x40 & directionFlag) != 0) {
    rotate = 0;
  } else {
    rotate = 1;
  }
  if ((0x10 & directionFlag) != 0 || (0x20 & directionFlag) != 0) {
    hflip = ((0x01 & directionFlag) != 0) ? 1 : 0;
    vflip = ((0x02 & directionFlag) != 0) ? 1 : 0;
  } else {
    if (((0x02 & directionFlag) != 0)) {
      hflip = ((0x01 & directionFlag) != 0) ? 0 : 1;
      vflip = ((0x01 & directionFlag) != 0) ? 0 : 0;
    } else {
      hflip = ((0x01 & directionFlag) != 0) ? 0 : 1;
      vflip = ((0x01 & directionFlag) != 0) ? 1 : 1;
    }
  }
  int ySize = srcHeight * srcWidth;
  int totalSize = ySize * 3 / 2;
  int yStart, yStep, xStep;
  if (rotate == 0 && hflip == 0 && vflip == 0) {
    memcpy(cdst, csrc, totalSize);
    return;
  }
  int srcX, srcY, srcCurr;
  int dstX, dstY, dstCurr;
  int halfHeight = srcHeight >> 1, halfWidth = srcWidth >> 1;
  if (rotate == 1) {
    if (hflip == 1) {
      yStart = vflip == 1 ? ySize - srcHeight : ySize - 1;
      yStep = vflip == 1 ? 1 : -1;
      xStep = -srcHeight;
    } else {
      yStart = vflip == 1 ? 0 : srcHeight - 1;
      yStep = vflip == 1 ? 1 : -1;
      xStep = srcHeight;
    }
    srcCurr = -1;
    for (srcY = 0; srcY < srcHeight; ++srcY) {
      dstCurr = yStart;
      for (srcX = 0; srcX < srcWidth; ++srcX) {
        cdst[dstCurr] = csrc[++srcCurr];
        dstCurr += xStep;
      }
      yStart += yStep;
    }
    if (hflip == 1) {
      yStart = vflip == 1 ? totalSize - srcHeight : totalSize - 2;
      yStep = vflip == 1 ? 2 : -2;
      xStep = -srcHeight;
    } else {
      yStart = vflip == 1 ? ySize : ySize + srcHeight - 2;
      yStep = vflip == 1 ? 2 : -2;
      xStep = srcHeight;
    }
    srcCurr = ySize - 1;
    for (srcY = 0; srcY < halfHeight; ++srcY) {
      dstCurr = yStart;
      for (srcX = 0; srcX < halfWidth; ++srcX) {
        cdst[dstCurr] = csrc[++srcCurr];
        cdst[dstCurr + 1] = csrc[++srcCurr];
        dstCurr += xStep;
      }
      yStart += yStep;
    }
  } else {
    if (vflip == 1 && hflip == 0) {
      yStart = ySize - srcWidth;
      srcCurr = -1;
      for (srcY = 0; srcY < srcHeight; ++srcY) {
        dstCurr = yStart - 1;
        for (srcX = 0; srcX < srcWidth; ++srcX) {
          cdst[++dstCurr] = csrc[++srcCurr];
        }
        yStart -= srcWidth;
      }
      yStart = totalSize - srcWidth;
      for (srcY = 0; srcY < halfHeight; ++srcY) {
        dstCurr = yStart - 1;
        for (srcX = 0; srcX < halfWidth; ++srcX) {
          cdst[++dstCurr] = csrc[++srcCurr];
          cdst[++dstCurr] = csrc[++srcCurr];
        }
        yStart -= srcWidth;
      }
    } else {
      yStep = vflip == 1 ? -srcWidth : srcWidth;
      yStart = vflip == 1 ? ySize - 1 : srcWidth - 1;
      srcCurr = -1;
      for (srcY = 0; srcY < srcHeight; ++srcY) {
        dstCurr = yStart + 1;
        for (srcX = 0; srcX < srcWidth; ++srcX) {
          cdst[--dstCurr] = csrc[++srcCurr];
        }
        yStart += yStep;
      }
      yStart = vflip == 1 ? totalSize - 1 : ySize + srcWidth - 1;
      for (srcY = 0; srcY < halfHeight; ++srcY) {
        dstCurr = yStart;
        for (srcX = 0; srcX < halfWidth; ++srcX) {
          cdst[dstCurr - 1] = csrc[++srcCurr];
          cdst[dstCurr] = csrc[++srcCurr];
          dstCurr -= 2;
        }
        yStart += yStep;
      }
    }
  }
}
```