user: What is the c source code of the assembly code below?

```asm
<jam_jtag_irscan>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rcx,%r13
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  sub    $0x18,%rsp
  cmp    $0x1,%edi
  je     L58
  cmp    $0x2,%edi
  je     L30
  xor    %eax,%eax
  test   %edi,%edi
  je     L77
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L58:
  xor    %edx,%edx
  xor    %esi,%esi
  mov    $0x1,%edi
  call   <jam_jtag_io@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  mov    $0x1,%edi
  call   <jam_jtag_io@plt>
L77:
  xor    %edx,%edx
  xor    %esi,%esi
  mov    $0x1,%edi
  call   <jam_jtag_io@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  mov    $0x1,%edi
  call   <jam_jtag_io@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  xor    %edi,%edi
L76:
  call   <jam_jtag_io@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  xor    %edi,%edi
  call   <jam_jtag_io@plt>
  test   %ebp,%ebp
  jle    L87
  lea    -0x1(%rbp),%eax
  xor    %r15d,%r15d
  mov    %eax,0xc(%rsp)
  test   %r13,%r13
  je     L2
  nopl   (%rax)
L1:
  mov    %r15d,%ebx
  mov    %r15d,%ecx
  mov    $0x1,%r14d
  xor    %edi,%edi
  sar    $0x3,%ebx
  and    $0x7,%ecx
  mov    $0x1,%edx
  movslq %ebx,%rbx
  shl    %cl,%r14d
  movzbl (%r12,%rbx,1),%esi
  and    %r14d,%esi
  cmp    0xc(%rsp),%r15d
  sete   %dil
  movsbl %sil,%esi
  add    %r13,%rbx
  call   <jam_jtag_io@plt>
  mov    %r14d,%edx
  mov    %eax,%r9d
  movzbl (%rbx),%eax
  not    %edx
  and    (%rbx),%dl
  or     %r14d,%eax
  test   %r9d,%r9d
  cmove  %edx,%eax
  add    $0x1,%r15d
  mov    %al,(%rbx)
  cmp    %r15d,%ebp
  jne    L1
L87:
  xor    %edx,%edx
  xor    %esi,%esi
  xor    %edi,%edi
  call   <jam_jtag_io@plt>
  mov    $0x1,%eax
L84:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L2:
  xor    %ebx,%ebx
  mov    $0x1,%r13d
L61:
  mov    %ebx,%eax
  mov    %ebx,%ecx
  mov    %r13d,%esi
  xor    %edi,%edi
  sar    $0x3,%eax
  and    $0x7,%ecx
  cltq
  shl    %cl,%esi
  and    (%r12,%rax,1),%sil
  cmp    0xc(%rsp),%ebx
  sete   %dil
  movsbl %sil,%esi
  xor    %edx,%edx
  add    $0x1,%ebx
  call   <jam_jtag_io@plt>
  cmp    %ebp,%ebx
  jne    L61
  xor    %edx,%edx
  xor    %esi,%esi
  xor    %edi,%edi
  call   <jam_jtag_io@plt>
  mov    $0x1,%eax
  jmp    L84
  nopl   0x0(%rax,%rax,1)
L30:
  xor    %edx,%edx
  xor    %esi,%esi
  mov    $0x1,%edi
  jmp    L76
```

assistant: ```c
int jam_jtag_irscan(int start_state, int count, char *tdi, char *tdo) {
  int i = 0;
  int tdo_bit = 0;
  int status = 1;
  switch (start_state) {
  case 0:
    jam_jtag_io(1, 0, 0);
    jam_jtag_io(1, 0, 0);
    jam_jtag_io(0, 0, 0);
    jam_jtag_io(0, 0, 0);
    break;
  case 1:
    jam_jtag_io(1, 0, 0);
    jam_jtag_io(1, 0, 0);
    jam_jtag_io(1, 0, 0);
    jam_jtag_io(1, 0, 0);
    jam_jtag_io(0, 0, 0);
    jam_jtag_io(0, 0, 0);
    break;
  case 2:
    jam_jtag_io(1, 0, 0);
    jam_jtag_io(0, 0, 0);
    break;
  default:
    status = 0;
  }
  if (status) {
    for (i = 0; i < count; i++) {
      tdo_bit = jam_jtag_io((i == count - 1), tdi[i >> 3] & (1 << (i & 7)), (tdo != (0)));
      if (tdo != (0)) {
        if (tdo_bit) {
          tdo[i >> 3] |= (1 << (i & 7));
        } else {
          tdo[i >> 3] &= ~(unsigned int)(1 << (i & 7));
        }
      }
    }
    jam_jtag_io(0, 0, 0);
  }
  return (status);
}
```