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

```asm
<add_ctr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x28(%rbp)
  movl   $0x0,-0x30(%rbp)
  jmp    L74
L82:
  mov    -0x30(%rbp),%eax
  shl    $0x2,%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  shl    $0x18,%eax
  mov    %eax,%edx
  mov    -0x30(%rbp),%eax
  shl    $0x2,%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  shl    $0x10,%eax
  or     %eax,%edx
  mov    -0x30(%rbp),%eax
  shl    $0x2,%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  shl    $0x8,%eax
  or     %eax,%edx
  mov    -0x30(%rbp),%eax
  shl    $0x2,%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  or     %eax,%edx
  mov    -0x30(%rbp),%eax
  cltq
  mov    %edx,-0x20(%rbp,%rax,4)
  addl   $0x1,-0x30(%rbp)
L74:
  cmpl   $0x3,-0x30(%rbp)
  jle    L82
  movl   $0x3,-0x30(%rbp)
  jmp    L66
L49:
  mov    -0x30(%rbp),%eax
  cltq
  mov    -0x20(%rbp,%rax,4),%edx
  mov    -0x3c(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x30(%rbp),%eax
  cltq
  mov    -0x20(%rbp,%rax,4),%eax
  cmp    %eax,-0x2c(%rbp)
  jge    L61
  movl   $0x1,-0x3c(%rbp)
  jmp    L48
L61:
  movl   $0x0,-0x3c(%rbp)
L48:
  mov    -0x30(%rbp),%eax
  cltq
  mov    -0x2c(%rbp),%edx
  mov    %edx,-0x20(%rbp,%rax,4)
  subl   $0x1,-0x30(%rbp)
L66:
  cmpl   $0x0,-0x30(%rbp)
  jns    L49
  movl   $0x0,-0x30(%rbp)
  jmp    L25
L80:
  mov    -0x30(%rbp),%eax
  cltq
  mov    -0x20(%rbp,%rax,4),%edx
  mov    -0x30(%rbp),%eax
  shl    $0x2,%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  sar    $0x18,%edx
  mov    %edx,(%rax)
  mov    -0x30(%rbp),%eax
  cltq
  mov    -0x20(%rbp,%rax,4),%edx
  mov    -0x30(%rbp),%eax
  shl    $0x2,%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  sar    $0x10,%edx
  mov    %edx,(%rax)
  mov    -0x30(%rbp),%eax
  cltq
  mov    -0x20(%rbp,%rax,4),%edx
  mov    -0x30(%rbp),%eax
  shl    $0x2,%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  sar    $0x8,%edx
  mov    %edx,(%rax)
  mov    -0x30(%rbp),%eax
  shl    $0x2,%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%eax
  cltq
  mov    -0x20(%rbp,%rax,4),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x30(%rbp)
L25:
  cmpl   $0x3,-0x30(%rbp)
  jle    L80
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L11
  call   <__stack_chk_fail@plt>
L11:
  leave
  ret
```

assistant: ```c
void add_ctr(void *ctr, uint32_t carry) {
  uint32_t counter[4];
  uint8_t *outctr = (uint8_t *)ctr;
  uint32_t sum;
  int32_t i;
  for (i = 0; i < 4; i++) {
    counter[i] = (outctr[i * 4 + 0] << 24) | (outctr[i * 4 + 1] << 16) | (outctr[i * 4 + 2] << 8) | (outctr[i * 4 + 3] << 0);
  }
  for (i = 3; i >= 0; i--) {
    sum = counter[i] + carry;
    if (sum < counter[i]) {
      carry = 1;
    } else {
      carry = 0;
    }
    counter[i] = sum;
  }
  for (i = 0; i < 4; i++) {
    outctr[i * 4 + 0] = counter[i] >> 24;
    outctr[i * 4 + 1] = counter[i] >> 16;
    outctr[i * 4 + 2] = counter[i] >> 8;
    outctr[i * 4 + 3] = counter[i] >> 0;
  }
}
```