user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<timediff>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x14(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  jne    L32
  lea    -0x10(%rbp),%rax
  mov    %rax,-0x38(%rbp)
L32:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  sub    %eax,%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    0x4(%rax),%edx
  mov    -0x28(%rbp),%rax
  mov    0x4(%rax),%eax
  sub    %eax,%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,0x4(%rax)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jne    L114
  mov    -0x38(%rbp),%rax
  mov    0x4(%rax),%eax
  test   %eax,%eax
  je     L20
L114:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jg     L111
  mov    -0x38(%rbp),%rax
  mov    0x4(%rax),%eax
  test   %eax,%eax
  jg     L111
  movl   $0xffffffff,-0x14(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  neg    %eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x38(%rbp),%rax
  mov    0x4(%rax),%eax
  neg    %eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,0x4(%rax)
  jmp    L20
L111:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  js     L94
  mov    -0x38(%rbp),%rax
  mov    0x4(%rax),%eax
  test   %eax,%eax
  js     L94
  movl   $0x1,-0x14(%rbp)
  jmp    L20
L94:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jns    L65
  mov    -0x38(%rbp),%rax
  mov    0x4(%rax),%eax
  test   %eax,%eax
  jle    L65
  movl   $0xffffffff,-0x14(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x38(%rbp),%rax
  mov    0x4(%rax),%eax
  mov    $0xf4240,%edx
  sub    %eax,%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,0x4(%rax)
  jmp    L20
L65:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jle    L38
  mov    -0x38(%rbp),%rax
  mov    0x4(%rax),%eax
  test   %eax,%eax
  jns    L38
  movl   $0x1,-0x14(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x1(%rax),%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x38(%rbp),%rax
  mov    0x4(%rax),%eax
  lea    0xf4240(%rax),%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,0x4(%rax)
  jmp    L20
L38:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x38(%rbp),%rax
  mov    0x4(%rax),%eax
  test   %eax,%eax
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
L20:
  mov    -0x14(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L119
  call   <__stack_chk_fail@plt>
L119:
  leave
  ret
```

assistant: ```c
int timediff(struct timeval *t1, struct timeval *t2, struct timeval *diff) {
  int cmp = 0;
  struct timeval result;
  if (diff == NULL)
    diff = &result;
  diff->tv_sec = t2->tv_sec - t1->tv_sec;
  diff->tv_usec = t2->tv_usec - t1->tv_usec;
  if (diff->tv_sec == 0 && diff->tv_usec == 0) {
  } else if (diff->tv_sec <= 0 && diff->tv_usec <= 0) {
    cmp = -1;
    diff->tv_sec *= -1;
    diff->tv_usec *= -1;
  } else if (diff->tv_sec >= 0 && diff->tv_usec >= 0) {
    cmp = 1;
  } else if (diff->tv_sec < 0 && diff->tv_usec > 0) {
    cmp = -1;
    diff->tv_sec += 1;
    diff->tv_usec = 1000000 - diff->tv_usec;
  } else if (diff->tv_sec > 0 && diff->tv_usec < 0) {
    cmp = 1;
    diff->tv_sec -= 1;
    diff->tv_usec += 1000000;
  } else {
    assert(diff->tv_sec == 0);
    assert(diff->tv_usec == 0);
  }
  return cmp;
}
```