user: Translate the below assembly code into C programming language:

```asm
<needed_unusual_el_valence>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %esi,-0x38(%rbp)
  mov    %edx,-0x3c(%rbp)
  mov    %ecx,-0x40(%rbp)
  mov    %r8d,-0x44(%rbp)
  mov    %r9d,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x0,0x10(%rbp)
  je     L78
  lea    -0xc(%rbp),%rdx
  mov    -0x34(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <GetElementFormulaFromAtNum@plt>
  test   %eax,%eax
  jne    L78
  mov    -0x44(%rbp),%esi
  mov    -0x3c(%rbp),%ecx
  mov    -0x38(%rbp),%edx
  lea    -0xc(%rbp),%rax
  push   $0x0
  push   $0x0
  push   $0x0
  push   $0x0
  mov    %esi,%r9d
  mov    %ecx,%r8d
  mov    %edx,%ecx
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <get_num_H@plt>
  add    $0x20,%rsp
  mov    %eax,-0x18(%rbp)
  jmp    L36
L78:
  mov    -0x48(%rbp),%eax
  mov    %eax,-0x18(%rbp)
L36:
  mov    -0x40(%rbp),%edx
  mov    -0x48(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x14(%rbp)
  cmpl   $0xfffffffe,-0x38(%rbp)
  jl     L107
  cmpl   $0x2,-0x38(%rbp)
  jg     L107
  mov    -0x38(%rbp),%ecx
  mov    -0x34(%rbp),%eax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <get_el_valence@plt>
  test   %eax,%eax
  je     L107
  mov    -0x34(%rbp),%eax
  mov    %eax,%edi
  call   <do_not_add_H@plt>
  test   %rax,%rax
  jne    L107
  mov    -0x40(%rbp),%eax
  cmp    -0x44(%rbp),%eax
  jne    L107
  mov    -0x18(%rbp),%eax
  cmp    -0x48(%rbp),%eax
  je     L113
L107:
  cmpl   $0x0,-0x48(%rbp)
  jne    L100
  cmpl   $0x0,-0x18(%rbp)
  jne    L100
  mov    -0x40(%rbp),%eax
  cmp    -0x44(%rbp),%eax
  jne    L100
  mov    $0x0,%eax
  jmp    L299
L100:
  mov    -0x14(%rbp),%eax
  jmp    L299
L113:
  cmpl   $0x2,-0x3c(%rbp)
  jne    L231
  movl   $0x1,-0x20(%rbp)
  jmp    L35
L231:
  cmpl   $0x3,-0x3c(%rbp)
  jne    L274
  movl   $0x2,-0x20(%rbp)
  jmp    L35
L274:
  movl   $0x0,-0x20(%rbp)
L35:
  movl   $0x0,-0x24(%rbp)
  movl   $0x0,-0x28(%rbp)
  movl   $0x0,-0x1c(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L77
L147:
  mov    -0x2c(%rbp),%edx
  mov    -0x38(%rbp),%ecx
  mov    -0x34(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <get_el_valence@plt>
  mov    %eax,-0x10(%rbp)
  cmpl   $0x0,-0x10(%rbp)
  jle    L219
  mov    -0x20(%rbp),%eax
  sub    %eax,-0x10(%rbp)
  mov    -0x10(%rbp),%eax
  cmp    -0x40(%rbp),%eax
  jl     L219
  addl   $0x1,-0x24(%rbp)
  mov    -0x10(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jg     L7
  addl   $0x1,-0x28(%rbp)
L7:
  mov    -0x10(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jne    L219
  movl   $0x1,-0x1c(%rbp)
  jmp    L311
L219:
  addl   $0x1,-0x2c(%rbp)
L77:
  cmpl   $0x4,-0x2c(%rbp)
  jle    L147
L311:
  cmpl   $0x0,-0x1c(%rbp)
  je     L91
  cmpl   $0x1,-0x28(%rbp)
  jne    L91
  cmpl   $0x1,-0x24(%rbp)
  je     L227
L91:
  cmpl   $0x0,-0x14(%rbp)
  je     L284
  mov    -0x14(%rbp),%eax
  jmp    L299
L284:
  mov    $0xffffffff,%eax
  jmp    L299
L227:
  mov    $0x0,%eax
L299:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L76
  call   <__stack_chk_fail@plt>
L76:
  leave
  ret
```

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;
}
```