user: Converte this assembly snippet into its equivalent C code:

```asm
<funcUpdateInvalidPort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  mov    %rdx,%r15
  push   %r14
  push   %r13
  mov    %rcx,%r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    (%r8),%ecx
  mov    (%rdi),%edx
  mov    %rdi,-0x70(%rbp)
  mov    %r8,-0x78(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  cmp    %edx,%ecx
  jl     L65
  xor    %eax,%eax
  cmp    (%rsi),%ecx
  jle    L48
L65:
  mov    (%rsi),%eax
  lea    -0x44(%rbp),%rdi
  mov    %rsp,-0x80(%rbp)
  sub    %edx,%eax
  mov    %eax,-0x44(%rbp)
  call   <funcLenInt@plt>
  mov    %rsp,%rcx
  mov    %eax,%r8d
  cltq
  lea    0xf(,%rax,4),%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L22
L102:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L102
L22:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  je     L81
  orq    $0x0,-0x8(%rsp,%rdx,1)
L81:
  mov    %r8d,%edi
  mov    %rsp,%rcx
  sub    $0x1,%edi
  js     L92
  mov    -0x44(%rbp),%edx
  movslq %edi,%rsi
  nopl   0x0(%rax,%rax,1)
L90:
  movslq %edx,%rax
  mov    %edx,%r9d
  imul   $0x66666667,%rax,%rax
  sar    $0x1f,%r9d
  sar    $0x22,%rax
  sub    %r9d,%eax
  lea    (%rax,%rax,4),%r9d
  add    %r9d,%r9d
  sub    %r9d,%edx
  mov    %edx,(%rcx,%rsi,4)
  sub    $0x1,%rsi
  mov    %eax,%edx
  test   %esi,%esi
  jns    L90
  mov    %eax,-0x44(%rbp)
L92:
  test   %r8d,%r8d
  jle    L94
  mov    %edi,%edi
  mov    %rcx,%rbx
  lea    -0x3a(%rbp),%r12
  xor    %r14d,%r14d
  lea    0x4(%rcx,%rdi,4),%rax
  mov    %rax,-0x68(%rbp)
  lea    -0x40(%rbp),%rax
  mov    %rax,-0x60(%rbp)
  jmp    L64
  nopw   0x0(%rax,%rax,1)
L67:
  mov    $0x2,%esi
  mov    %r12,%rdi
  add    $0x4,%rbx
  call   <bzero@plt>
  mov    -0x40(%rbp),%eax
  lea    (%r14,%r14,4),%esi
  subl   $0x1,0x0(%r13)
  cltd
  idivl  -0x54(%rbp)
  lea    (%rdx,%rsi,2),%r14d
  cmp    -0x68(%rbp),%rbx
  je     L5
L64:
  mov    (%rbx),%eax
  mov    $0x2,%esi
  mov    %r12,%rdi
  add    $0x1,%eax
  mov    %eax,-0x54(%rbp)
  call   <bzero@plt>
  mov    %r15,%rdi
  call   <strlen@plt>
  add    0x0(%r13),%eax
  mov    $0x1,%edx
  mov    %r12,%rdi
  movslq %eax,%rsi
  add    %r15,%rsi
  call   <strncpy@plt>
  mov    -0x60(%rbp),%rsi
  mov    %r12,%rdi
  movb   $0x0,-0x39(%rbp)
  movl   $0x0,-0x40(%rbp)
  call   <funcHex2Int@plt>
  mov    -0x40(%rbp),%eax
  test   %eax,%eax
  jns    L67
  mov    -0x80(%rbp),%rsp
L48:
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L109
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L94:
  xor    %r14d,%r14d
  nopw   0x0(%rax,%rax,1)
L5:
  mov    -0x70(%rbp),%rax
  add    (%rax),%r14d
  mov    -0x78(%rbp),%rax
  mov    %r14d,(%rax)
  xor    %eax,%eax
  mov    -0x80(%rbp),%rsp
  jmp    L48
L109:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int funcUpdateInvalidPort(const int *piPortMin, const int *piPortMax, const char *pcHashOOR, int *piInitHashPos, int *piPort) {
  if ((*piPort < *piPortMin) || (*piPort > *piPortMax)) {
    int iPortDiff = *piPortMax - *piPortMin;
    int iLenPortDiff = funcLenInt(&iPortDiff);
    int iI;
    int iaPortDiff[iLenPortDiff];
    for (iI = (iLenPortDiff - 1); iI >= 0; iI--, iPortDiff /= 10) {
      iaPortDiff[iI] = iPortDiff % 10;
    }
    int iPort = 0;
    for (iI = 0; iI < iLenPortDiff; iI++) {
      int iDiffVal = iaPortDiff[iI] + 1;
      int iLenOffset = 1;
      char cOffset[iLenOffset + 1];
      bzero(cOffset, iLenOffset + 1);
      strncpy(cOffset, pcHashOOR + (strlen(pcHashOOR) + *piInitHashPos), 1);
      cOffset[iLenOffset] = '\0';
      int iOffset = 0;
      funcHex2Int(cOffset, &iOffset);
      if (iOffset < 0)
        return iOffset;
      bzero(cOffset, iLenOffset + 1);
      int iMod = iOffset % iDiffVal;
      iPort = (10 * iPort) + iMod;
      *piInitHashPos -= iLenOffset;
    }
    iPort += *piPortMin;
    *piPort = iPort;
  }
  return 0;
}
```