user: 请从给定的汇编指令推导出C源代码:

```asm
<ars_d_firstfield_off>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,%r14
  mov    %rdx,%r15
  mov    %rdx,-0x60(%rbp)
  mov    %rcx,-0x68(%rbp)
  mov    %r8,-0x70(%rbp)
  mov    %r9,-0x78(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    %rsi,-0x58(%rbp)
  mov    %rsi,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  mov    %r15,%rdi
  call   <strlen@plt>
  mov    %eax,%r13d
  mov    %r14,-0x50(%rbp)
  mov    %r14,%rdi
  call   <strlen@plt>
  mov    %eax,-0x44(%rbp)
  lea    0x3(%rbx),%edi
  call   <alloca@plt>
  mov    %rax,%r12
  lea    0x3(%r13),%edi
  call   <alloca@plt>
  mov    %rax,%r14
  movb   $0x2b,(%r12)
  lea    0x1(%r12),%r15
  mov    %ebx,%edx
  mov    -0x58(%rbp),%rsi
  mov    %r15,%rdi
  call   <memcpy@plt>
  movslq %ebx,%rax
  lea    0x1(%rax),%rcx
  mov    %rcx,-0x58(%rbp)
  movb   $0x28,0x1(%r12,%rax,1)
  movb   $0x0,0x2(%r12,%rax,1)
  lea    0x1(%rbx),%edx
  mov    $0x0,%ecx
  cmp    -0x44(%rbp),%edx
  jl     L55
L131:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L36
  mov    %ecx,%eax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L55:
  mov    %r15,%rsi
  mov    -0x50(%rbp),%rbx
  mov    %rbx,%rdi
  call   <memcmp@plt>
  test   %rax,%rax
  je     L77
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L95
  lea    0x1(%rax),%rbx
L0:
  movb   $0x2c,(%r14)
  lea    0x1(%r14),%r12
  mov    %r13d,%edx
  mov    -0x60(%rbp),%rsi
  mov    %r12,%rdi
  call   <memcpy@plt>
  movslq %r13d,%rax
  lea    0x1(%rax),%rsi
  mov    %rsi,-0x60(%rbp)
  movb   $0x3d,0x1(%r14,%rax,1)
  movb   $0x0,0x2(%r14,%rax,1)
  add    -0x58(%rbp),%rbx
  mov    %rbx,%rdx
  sub    -0x50(%rbp),%rdx
  mov    -0x44(%rbp),%eax
  sub    %edx,%eax
  add    $0x1,%r13d
  mov    $0x0,%ecx
  cmp    %eax,%r13d
  jge    L131
  mov    $0x29,%esi
  mov    %rbx,%rdi
  call   <strchr@plt>
  mov    %rax,%r15
  mov    $0x0,%ecx
  test   %rax,%rax
  je     L131
  mov    %r13d,%edx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <memcmp@plt>
  test   %rax,%rax
  je     L119
  mov    %r14,%rsi
  mov    %rbx,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L72
  cmp    %rax,%r15
  jbe    L72
  lea    0x1(%rax),%rbx
L119:
  mov    -0x68(%rbp),%rcx
  test   %rcx,%rcx
  je     L103
  mov    %rbx,%rax
  sub    -0x50(%rbp),%rax
  mov    %eax,(%rcx)
L103:
  mov    -0x60(%rbp),%rdi
  add    %rbx,%rdi
  mov    -0x70(%rbp),%rsi
  test   %rsi,%rsi
  je     L114
  mov    %rdi,%rax
  sub    -0x50(%rbp),%rax
  mov    %eax,(%rsi)
L114:
  mov    $0x2c,%esi
  call   <strchr@plt>
  mov    %r15,%rdx
  cmp    %rax,%r15
  mov    %r15,%rcx
  cmova  %rax,%rcx
  test   %rax,%rax
  cmovne %rcx,%rdx
  mov    %rdx,%r15
  mov    $0x1,%ecx
  mov    -0x78(%rbp),%rax
  test   %rax,%rax
  je     L131
  sub    -0x50(%rbp),%r15
  sub    $0x1,%r15d
  mov    %r15d,(%rax)
  jmp    L131
L77:
  mov    -0x50(%rbp),%rbx
  jmp    L0
L95:
  mov    $0x0,%ecx
  jmp    L131
L72:
  mov    $0x0,%ecx
  jmp    L131
L36:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int ars_d_firstfield_off(char *packet, char *layer, char *field, int *field_start, int *value_start, int *value_end) {
  int layerlen = strlen(layer);
  int fieldlen = strlen(field);
  int pktlen = strlen(packet);
  char *x = alloca(layerlen + 3);
  char *y = alloca(fieldlen + 3);
  char *p, *j, *w;
  x[0] = '+';
  memcpy(x + 1, layer, layerlen);
  x[layerlen + 1] = '(';
  x[layerlen + 2] = '\0';
  if (pktlen <= layerlen + 1)
    return 0;
  if (memcmp(packet, x + 1, layerlen + 1) == 0) {
    p = packet;
  } else {
    p = strstr(packet, x);
    if (p == NULL)
      return 0;
    p++;
  }
  y[0] = ',';
  memcpy(y + 1, field, fieldlen);
  y[fieldlen + 1] = '=';
  y[fieldlen + 2] = '\0';
  p += layerlen + 1;
  pktlen -= p - packet;
  if (pktlen <= fieldlen + 1)
    return 0;
  if ((j = strchr(p, ')')) == NULL)
    return 0;
  if (memcmp(p, y + 1, fieldlen + 1)) {
    p = strstr(p, y);
    if (p == NULL || p >= j)
      return 0;
    p++;
  }
  if (field_start)
    *field_start = p - packet;
  p += fieldlen + 1;
  if (value_start)
    *value_start = p - packet;
  w = strchr(p, ',');
  if (w && w < j)
    j = w;
  if (value_end)
    *value_end = (j - packet) - 1;
  return 1;
}
```