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

```asm
<check_the_check>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %edx,-0x30(%rbp)
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <islower@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L88
  mov    $0x4b,%eax
  jmp    L464
L88:
  mov    $0x6b,%eax
L464:
  mov    %al,-0x12(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L510
  mov    $0x51,%eax
  jmp    L16
L510:
  mov    $0x71,%eax
L16:
  mov    %al,-0x11(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L97
  mov    $0x4e,%eax
  jmp    L702
L97:
  mov    $0x6e,%eax
L702:
  mov    %al,-0x10(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L114
  mov    $0x52,%eax
  jmp    L79
L114:
  mov    $0x72,%eax
L79:
  mov    %al,-0xf(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L775
  mov    $0x42,%eax
  jmp    L454
L775:
  mov    $0x62,%eax
L454:
  mov    %al,-0xe(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L38
  mov    $0x50,%eax
  jmp    L83
L38:
  mov    $0x70,%eax
L83:
  mov    %al,-0xd(%rbp)
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  lea    -0x18(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  sub    $0x1,%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x10(%rbp)
  je     L820
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  lea    -0xc(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  sub    $0x2,%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x10(%rbp)
  je     L820
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  lea    0x18(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  sub    $0x1,%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x10(%rbp)
  je     L820
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  sub    $0x2,%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x10(%rbp)
  je     L820
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  lea    -0x18(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  add    $0x1,%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x10(%rbp)
  je     L820
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  lea    -0xc(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  add    $0x2,%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x10(%rbp)
  je     L820
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  lea    0x18(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  add    $0x1,%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x10(%rbp)
  je     L820
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  add    $0x2,%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x10(%rbp)
  jne    L574
L820:
  mov    $0x1,%eax
  jmp    L713
L574:
  cmpl   $0x0,-0x4(%rbp)
  je     L740
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  sub    $0x1,%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0xd(%rbp)
  je     L838
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  add    $0x1,%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0xd(%rbp)
  jne    L221
L838:
  mov    $0x1,%eax
  jmp    L713
L740:
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  lea    -0xc(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  sub    $0x1,%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0xd(%rbp)
  je     L150
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  lea    -0xc(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  add    $0x1,%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0xd(%rbp)
  jne    L221
L150:
  mov    $0x1,%eax
  jmp    L713
L221:
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x30(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x8(%rbp)
  jmp    L385
L425:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    $0x2e,%al
  jne    L166
  subl   $0x1,-0x8(%rbp)
L385:
  cmpl   $0x2,-0x8(%rbp)
  jg     L425
  jmp    L50
L166:
  nop
L50:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0xf(%rbp)
  je     L352
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x11(%rbp)
  jne    L424
L352:
  mov    $0x1,%eax
  jmp    L713
L424:
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x30(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x8(%rbp)
  jmp    L550
L742:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    $0x2e,%al
  jne    L18
  addl   $0x1,-0x8(%rbp)
L550:
  cmpl   $0x8,-0x8(%rbp)
  jle    L742
  jmp    L446
L18:
  nop
L446:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0xf(%rbp)
  je     L152
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x11(%rbp)
  jne    L673
L152:
  mov    $0x1,%eax
  jmp    L713
L673:
  mov    -0x2c(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L10
L543:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    $0x2e,%al
  jne    L47
  subl   $0x1,-0xc(%rbp)
L10:
  cmpl   $0x2,-0xc(%rbp)
  jg     L543
  jmp    L733
L47:
  nop
L733:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0xf(%rbp)
  je     L799
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x11(%rbp)
  jne    L752
L799:
  mov    $0x1,%eax
  jmp    L713
L752:
  mov    -0x2c(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L191
L354:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    $0x2e,%al
  jne    L542
  addl   $0x1,-0xc(%rbp)
L191:
  cmpl   $0x8,-0xc(%rbp)
  jle    L354
  jmp    L405
L542:
  nop
L405:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0xf(%rbp)
  je     L776
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x11(%rbp)
  jne    L862
L776:
  mov    $0x1,%eax
  jmp    L713
L862:
  mov    -0x2c(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x30(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x8(%rbp)
  jmp    L513
L840:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    $0x2e,%al
  jne    L331
  subl   $0x1,-0xc(%rbp)
  subl   $0x1,-0x8(%rbp)
L513:
  cmpl   $0x2,-0xc(%rbp)
  jle    L195
  cmpl   $0x2,-0x8(%rbp)
  jg     L840
  jmp    L195
L331:
  nop
L195:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0xe(%rbp)
  je     L72
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x11(%rbp)
  jne    L101
L72:
  mov    $0x1,%eax
  jmp    L713
L101:
  mov    -0x2c(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x30(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x8(%rbp)
  jmp    L75
L86:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    $0x2e,%al
  jne    L640
  subl   $0x1,-0xc(%rbp)
  addl   $0x1,-0x8(%rbp)
L75:
  cmpl   $0x2,-0xc(%rbp)
  jle    L609
  cmpl   $0x8,-0x8(%rbp)
  jle    L86
  jmp    L609
L640:
  nop
L609:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0xe(%rbp)
  je     L412
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x11(%rbp)
  jne    L350
L412:
  mov    $0x1,%eax
  jmp    L713
L350:
  mov    -0x2c(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x30(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x8(%rbp)
  jmp    L432
L499:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    $0x2e,%al
  jne    L498
  addl   $0x1,-0xc(%rbp)
  subl   $0x1,-0x8(%rbp)
L432:
  cmpl   $0x8,-0xc(%rbp)
  jg     L184
  cmpl   $0x2,-0x8(%rbp)
  jg     L499
  jmp    L184
L498:
  nop
L184:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0xe(%rbp)
  je     L272
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x11(%rbp)
  jne    L532
L272:
  mov    $0x1,%eax
  jmp    L713
L532:
  mov    -0x2c(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x30(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x8(%rbp)
  jmp    L17
L24:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    $0x2e,%al
  jne    L5
  addl   $0x1,-0xc(%rbp)
  addl   $0x1,-0x8(%rbp)
L17:
  cmpl   $0x8,-0xc(%rbp)
  jg     L792
  cmpl   $0x8,-0x8(%rbp)
  jle    L24
  jmp    L792
L5:
  nop
L792:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0xe(%rbp)
  je     L482
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  movzbl (%rdx,%rax,1),%eax
  cmp    %al,-0x11(%rbp)
  jne    L153
L482:
  mov    $0x1,%eax
  jmp    L713
L153:
  mov    $0x0,%eax
L713:
  leave
  ret
```

assistant: ```c
int check_the_check(char chess_board[12][12], int i, int j) {
  int is_black_king;
  char king;
  char opp_king, opp_queen, opp_knight, opp_rook, opp_bishop, opp_pawn;
  int next_i, next_j;
  is_black_king = islower(chess_board[i][j]);
  opp_king = is_black_king ? 'K' : 'k';
  opp_queen = is_black_king ? 'Q' : 'q';
  opp_knight = is_black_king ? 'N' : 'n';
  opp_rook = is_black_king ? 'R' : 'r';
  opp_bishop = is_black_king ? 'B' : 'b';
  opp_pawn = is_black_king ? 'P' : 'p';
  if (chess_board[i - 2][j - 1] == opp_knight || chess_board[i - 1][j - 2] == opp_knight || chess_board[i + 2][j - 1] == opp_knight || chess_board[i + 1][j - 2] == opp_knight || chess_board[i - 2][j + 1] == opp_knight || chess_board[i - 1][j + 2] == opp_knight || chess_board[i + 2][j + 1] == opp_knight || chess_board[i + 1][j + 2] == opp_knight) {
    return 1;
  }
  if (is_black_king) {
    if (chess_board[i + 1][j - 1] == opp_pawn || chess_board[i + 1][j + 1] == opp_pawn)
      return 1;
  } else {
    if (chess_board[i - 1][j - 1] == opp_pawn || chess_board[i - 1][j + 1] == opp_pawn)
      return 1;
  }
  for (next_i = i, next_j = j - 1; next_j > 2; --next_j) {
    if (chess_board[next_i][next_j] != '.')
      break;
  }
  if (chess_board[next_i][next_j] == opp_rook || chess_board[next_i][next_j] == opp_queen) {
    return 1;
  };
  for (next_i = i, next_j = j + 1; next_j < 9; ++next_j) {
    if (chess_board[next_i][next_j] != '.')
      break;
  }
  if (chess_board[next_i][next_j] == opp_rook || chess_board[next_i][next_j] == opp_queen) {
    return 1;
  };
  for (next_i = i - 1, next_j = j; next_i > 2; --next_i) {
    if (chess_board[next_i][next_j] != '.')
      break;
  }
  if (chess_board[next_i][next_j] == opp_rook || chess_board[next_i][next_j] == opp_queen) {
    return 1;
  };
  for (next_i = i + 1, next_j = j; next_i < 9; ++next_i) {
    if (chess_board[next_i][next_j] != '.')
      break;
  }
  if (chess_board[next_i][next_j] == opp_rook || chess_board[next_i][next_j] == opp_queen) {
    return 1;
  };
  for (next_i = i - 1, next_j = j - 1; next_i > 2 && next_j > 2; --next_i, --next_j) {
    if (chess_board[next_i][next_j] != '.')
      break;
  }
  if (chess_board[next_i][next_j] == opp_bishop || chess_board[next_i][next_j] == opp_queen) {
    return 1;
  };
  for (next_i = i - 1, next_j = j + 1; next_i > 2 && next_j < 9; --next_i, ++next_j) {
    if (chess_board[next_i][next_j] != '.')
      break;
  }
  if (chess_board[next_i][next_j] == opp_bishop || chess_board[next_i][next_j] == opp_queen) {
    return 1;
  };
  for (next_i = i + 1, next_j = j - 1; next_i < 9 && next_j > 2; ++next_i, --next_j) {
    if (chess_board[next_i][next_j] != '.')
      break;
  }
  if (chess_board[next_i][next_j] == opp_bishop || chess_board[next_i][next_j] == opp_queen) {
    return 1;
  };
  for (next_i = i + 1, next_j = j + 1; next_i < 9 && next_j < 9; ++next_i, ++next_j) {
    if (chess_board[next_i][next_j] != '.')
      break;
  }
  if (chess_board[next_i][next_j] == opp_bishop || chess_board[next_i][next_j] == opp_queen) {
    return 1;
  };
  return 0;
}
```