user: Please show me the C implementation that matches the assembly code listed below:

```asm
<xsvfGotoTapState>:
  endbr64
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  test   %sil,%sil
  je     L140
  movzbl (%rdi),%eax
  mov    %esi,%ebx
  mov    %esi,%r12d
  cmp    %sil,%al
  je     L251
  cmp    $0x7,%sil
  jne    L107
  mov    $0x5,%r8d
  cmp    $0x6,%al
  jne    L102
L107:
  cmp    $0xe,%bl
  jne    L221
  mov    $0x5,%r8d
  cmp    $0xd,%al
  jne    L102
L221:
  cmp    $0xf,%al
  ja     1080 <xsvfGotoTapState.cold>
  lea    D4(%rip),%rdx
  movslq (%rdx,%rax,4),%rax
  add    %rdx,%rax
  notrack jmp *%rax
  nopl   (%rax)
L335:
  mov    $0x1,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0x9,0x0(%rbp)
  cmp    $0x9,%bl
  je     L145
  xor    %edi,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0xa,0x0(%rbp)
  cmp    $0xa,%bl
  je     L145
  cmp    $0xb,%bl
  je     L300
  mov    $0x1,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0xc,0x0(%rbp)
  cmp    $0xc,%bl
  je     L145
  cmp    $0xd,%bl
  je     L192
L237:
  mov    $0x1,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0xf,0x0(%rbp)
  cmp    $0xf,%bl
  je     L145
  cmp    $0x1,%bl
  je     L192
  nopl   0x0(%rax,%rax,1)
L78:
  mov    $0x1,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0x2,0x0(%rbp)
  cmp    $0x2,%bl
  je     L145
  cmp    $0x8,%bl
  ja     L335
  xor    %edi,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0x3,0x0(%rbp)
  cmp    $0x3,%bl
  je     L145
  cmp    $0x4,%bl
  je     L310
  mov    $0x1,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0x5,0x0(%rbp)
  cmp    $0x5,%bl
  je     L145
  cmp    $0x6,%bl
  je     L192
L90:
  mov    $0x1,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0x8,0x0(%rbp)
  cmp    $0x8,%bl
  je     L145
  cmp    $0x1,%bl
  jne    L78
L192:
  xor    %edi,%edi
  call   <xsvfTmsTransition@plt>
  xor    %r8d,%r8d
L125:
  mov    %r12b,0x0(%rbp)
L102:
  pop    %rbx
  mov    %r8d,%eax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
  mov    $0x1,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0xe,0x0(%rbp)
  cmp    $0xe,%bl
  je     L145
L7:
  cmp    $0xb,%bl
  jne    L237
L300:
  xor    %edi,%edi
  mov    $0xb,%r12d
  call   <xsvfTmsTransition@plt>
  xor    %r8d,%r8d
  jmp    L125
  nopw   0x0(%rax,%rax,1)
  xor    %edi,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0x1,0x0(%rbp)
  cmp    $0x1,%bl
  jne    L78
  jmp    L145
  xchg   %ax,%ax
  mov    $0x1,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0x7,0x0(%rbp)
  cmp    $0x7,%bl
  je     L145
L96:
  cmp    $0x4,%bl
  jne    L90
L310:
  xor    %edi,%edi
  mov    $0x4,%r12d
  call   <xsvfTmsTransition@plt>
  xor    %r8d,%r8d
  jmp    L125
  nopl   0x0(%rax)
L140:
  mov    $0x1,%edi
  mov    $0x5,%ebx
  call   <xsvfTmsTransition@plt>
L243:
  xor    %esi,%esi
  xor    %edi,%edi
  call   <setPort@plt>
  xor    %edi,%edi
  mov    $0x1,%esi
  call   <setPort@plt>
  sub    $0x1,%ebx
  jne    L243
  xor    %r8d,%r8d
  pop    %rbx
  movb   $0x0,0x0(%rbp)
  mov    %r8d,%eax
  pop    %rbp
  pop    %r12
  ret
L251:
  cmp    $0x6,%sil
  je     L232
  cmp    $0xd,%sil
  je     L17
L145:
  xor    %r8d,%r8d
  pop    %rbx
  pop    %rbp
  mov    %r8d,%eax
  pop    %r12
  ret
L232:
  mov    $0x1,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0x7,0x0(%rbp)
  jmp    L96
L17:
  mov    $0x1,%edi
  call   <xsvfTmsTransition@plt>
  movb   $0xe,0x0(%rbp)
  jmp    L7
```

assistant: ```c
int xsvfGotoTapState(unsigned char *pucTapState, unsigned char ucTargetState) {
  int i;
  int iErrorCode;
  iErrorCode = 0;
  if (ucTargetState == 0x00) {
    xsvfTmsTransition(1);
    for (i = 0; i < 5; ++i) {
      setPort((short)0, 0);
      setPort((short)0, 1);
    }
    *pucTapState = 0x00;
    ;

    ;
  } else if ((ucTargetState != *pucTapState) && (((ucTargetState == 0x07) && (*pucTapState != 0x06)) || ((ucTargetState == 0x0E) && (*pucTapState != 0x0D)))) {
    iErrorCode = 5;
  } else {
    if (ucTargetState == *pucTapState) {
      if (ucTargetState == 0x06) {
        xsvfTmsTransition(1);
        *pucTapState = 0x07;

        ;
      } else if (ucTargetState == 0x0D) {
        xsvfTmsTransition(1);
        *pucTapState = 0x0E;

        ;
      }
    }
    while (ucTargetState != *pucTapState) {
      switch (*pucTapState) {
      case 0x00:
        xsvfTmsTransition(0);
        *pucTapState = 0x01;
        break;
      case 0x01:
        xsvfTmsTransition(1);
        *pucTapState = 0x02;
        break;
      case 0x02:
        if (ucTargetState >= 0x09) {
          xsvfTmsTransition(1);
          *pucTapState = 0x09;
        } else {
          xsvfTmsTransition(0);
          *pucTapState = 0x03;
        }
        break;
      case 0x03:
        if (ucTargetState == 0x04) {
          xsvfTmsTransition(0);
          *pucTapState = 0x04;
        } else {
          xsvfTmsTransition(1);
          *pucTapState = 0x05;
        }
        break;
      case 0x04:
        xsvfTmsTransition(1);
        *pucTapState = 0x05;
        break;
      case 0x05:
        if (ucTargetState == 0x06) {
          xsvfTmsTransition(0);
          *pucTapState = 0x06;
        } else {
          xsvfTmsTransition(1);
          *pucTapState = 0x08;
        }
        break;
      case 0x06:
        xsvfTmsTransition(1);
        *pucTapState = 0x07;
        break;
      case 0x07:
        if (ucTargetState == 0x04) {
          xsvfTmsTransition(0);
          *pucTapState = 0x04;
        } else {
          xsvfTmsTransition(1);
          *pucTapState = 0x08;
        }
        break;
      case 0x08:
        if (ucTargetState == 0x01) {
          xsvfTmsTransition(0);
          *pucTapState = 0x01;
        } else {
          xsvfTmsTransition(1);
          *pucTapState = 0x02;
        }
        break;
      case 0x09:
        xsvfTmsTransition(0);
        *pucTapState = 0x0A;
        break;
      case 0x0A:
        if (ucTargetState == 0x0B) {
          xsvfTmsTransition(0);
          *pucTapState = 0x0B;
        } else {
          xsvfTmsTransition(1);
          *pucTapState = 0x0C;
        }
        break;
      case 0x0B:
        xsvfTmsTransition(1);
        *pucTapState = 0x0C;
        break;
      case 0x0C:
        if (ucTargetState == 0x0D) {
          xsvfTmsTransition(0);
          *pucTapState = 0x0D;
        } else {
          xsvfTmsTransition(1);
          *pucTapState = 0x0F;
        }
        break;
      case 0x0D:
        xsvfTmsTransition(1);
        *pucTapState = 0x0E;
        break;
      case 0x0E:
        if (ucTargetState == 0x0B) {
          xsvfTmsTransition(0);
          *pucTapState = 0x0B;
        } else {
          xsvfTmsTransition(1);
          *pucTapState = 0x0F;
        }
        break;
      case 0x0F:
        if (ucTargetState == 0x01) {
          xsvfTmsTransition(0);
          *pucTapState = 0x01;
        } else {
          xsvfTmsTransition(1);
          *pucTapState = 0x02;
        }
        break;
      default:
        iErrorCode = 5;
        *pucTapState = ucTargetState;
        break;
      }

      ;
    }
  }
  return (iErrorCode);
}
```