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

```asm
<needed_unusual_el_valence>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,0x8(%rsp)
  mov    %esi,%r12d
  mov    %edx,0xc(%rsp)
  mov    %ecx,%ebp
  mov    %r8d,%r13d
  mov    %r9d,%ebx
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    %r9d,%r14d
  cmpl   $0x0,0x60(%rsp)
  jne    L122
L54:
  lea    (%rbx,%rbp,1),%r15d
  lea    0x2(%r12),%eax
  cmp    $0x4,%eax
  jbe    L132
L2:
  or     %ebx,%r14d
  jne    L214
  cmp    %ebp,%r13d
  mov    $0x0,%eax
  cmove  %eax,%r15d
L214:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L107
  mov    %r15d,%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L122:
  lea    0x14(%rsp),%rsi
  call   <GetElementFormulaFromAtNum@plt>
  test   %eax,%eax
  jne    L54
  lea    0x14(%rsp),%rdi
  push   $0x0
  push   $0x0
  push   $0x0
  push   $0x0
  mov    %r13d,%r9d
  mov    0x2c(%rsp),%r8d
  mov    %r12d,%ecx
  mov    $0x0,%edx
  mov    $0x0,%esi
  call   <get_num_H@plt>
  mov    %eax,%r14d
  add    $0x20,%rsp
  jmp    L54
L132:
  mov    $0x0,%edx
  mov    %r12d,%esi
  mov    0x8(%rsp),%edi
  call   <get_el_valence@plt>
  test   %eax,%eax
  je     L2
  mov    0x8(%rsp),%edi
  call   <do_not_add_H@plt>
  test   %rax,%rax
  jne    L2
  cmp    %ebp,%r13d
  jne    L2
  cmp    %ebx,%r14d
  jne    L2
  mov    $0x1,%r14d
  mov    0xc(%rsp),%eax
  cmp    $0x2,%eax
  je     L155
  cmp    $0x3,%eax
  sete   %al
  movzbl %al,%eax
  lea    (%rax,%rax,1),%r14d
L155:
  mov    $0x0,%r13d
  movl   $0x0,0xc(%rsp)
  mov    $0x0,%ebx
  jmp    L115
L26:
  mov    %edx,%r13d
L74:
  add    $0x1,%ebx
  cmp    $0x5,%ebx
  je     L73
L115:
  mov    %ebx,%edx
  mov    %r12d,%esi
  mov    0x8(%rsp),%edi
  call   <get_el_valence@plt>
  test   %eax,%eax
  jle    L74
  sub    %r14d,%eax
  cmp    %eax,%ebp
  jg     L74
  lea    0x1(%r13),%edx
  cmp    %eax,%r15d
  jl     L26
  mov    0xc(%rsp),%ecx
  add    $0x1,%ecx
  cmp    %eax,%r15d
  je     L59
  mov    %edx,%r13d
  mov    %ecx,0xc(%rsp)
  jmp    L74
L59:
  mov    0xc(%rsp),%eax
  or     %r13d,%eax
  jne    L73
  mov    %eax,%r15d
  jmp    L214
L73:
  test   %r15d,%r15d
  jne    L214
  mov    $0xffffffff,%r15d
  jmp    L214
L107:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int needed_unusual_el_valence(int nPeriodicNum, int charge, int radical, int bonds_valence, int actual_bonds_valence, int num_H, int num_bonds) {
  int i, num_found, num_found_known, chem_valence, rad_adj, known_chem_valence, exact_found;
  int num_H_expected;
  char szElement[4];
  if (num_bonds && !GetElementFormulaFromAtNum(nPeriodicNum, szElement)) {
    num_H_expected = get_num_H(szElement, 0, NULL, charge, radical, actual_bonds_valence, 0, 0, 0, 0);
  } else {
    num_H_expected = num_H;
  }
  chem_valence = bonds_valence + num_H;
  if (charge < (-2) || charge > 2 || !get_el_valence(nPeriodicNum, charge, 0) || do_not_add_H(nPeriodicNum) || bonds_valence != actual_bonds_valence || num_H_expected != num_H) {
    if (!num_H && !num_H_expected && bonds_valence == actual_bonds_valence)
      return 0;
    return chem_valence;
  }
  if (radical == 2)
    rad_adj = 1;
  else if (radical == 3)
    rad_adj = 2;
  else
    rad_adj = 0;
  num_found_known = 0;
  num_found = 0;
  exact_found = 0;
  for (i = 0; i < 5; i++) {
    if (0 < (known_chem_valence = get_el_valence(nPeriodicNum, charge, i)) && bonds_valence <= (known_chem_valence -= rad_adj)) {
      num_found_known++;
      if (known_chem_valence <= chem_valence) {
        num_found++;
      }
      if (known_chem_valence == chem_valence) {
        exact_found = 1;
        break;
      }
    }
  }
  return (exact_found && 1 == num_found && 1 == num_found_known) ? 0 : chem_valence ? chem_valence : -1;
}
```