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

```asm
<scan_env>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %rcx,-0x30(%rbp)
  mov    %r8,-0x38(%rbp)
  mov    %r9,-0x40(%rbp)
  movq   $0x0,-0x8(%rbp)
  mov    -0x40(%rbp),%rax
  movq   $0xffffffffffffffff,(%rax)
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,(%rax)
  jmp    L148
L56:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  cmp    $0xffffffffffffffff,%rax
  je     L87
  mov    -0x8(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    $0xc,%edx
  lea    D12(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L87
  mov    -0x20(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  jmp    L53
L87:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  cmp    $0xffffffffffffffff,%rax
  je     L10
  mov    -0x8(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    $0x12,%edx
  lea    D47(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L10
  mov    -0x38(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  jmp    L53
L10:
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  cmp    $0xffffffffffffffff,%rax
  je     L55
  mov    -0x8(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    $0x11,%edx
  lea    D3(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L55
  mov    -0x40(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  jmp    L53
L55:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  cmp    $0xffffffffffffffff,%rax
  je     L11
  mov    -0x8(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    $0x17,%edx
  lea    D37(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L11
  mov    -0x28(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  jmp    L53
L11:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  cmp    $0xffffffffffffffff,%rax
  je     L53
  mov    -0x8(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    $0x1b,%edx
  lea    D30(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L53
  mov    -0x30(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
L53:
  addq   $0x1,-0x8(%rbp)
L148:
  mov    -0x8(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L56
  mov    -0x8(%rbp),%rax
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D12
type: string
name: parse_data
arguments: data_tag: D47
type: string
name: parse_data
arguments: data_tag: D3
type: string
name: parse_data
arguments: data_tag: D37
type: string
name: parse_data
arguments: data_tag: D30
type: string

tool: D12: LD_PRELOAD=

tool: D47: BUILDSH_TEMPFILE=

tool: D3: BUILDSH_PRELOAD=

tool: D37: DYLD_INSERT_LIBRARIES=

tool: D30: DYLD_FORCE_FLAT_NAMESPACE=

assistant: ```c
size_t scan_env(char *const *env, size_t *ldp_pos, size_t *dil_pos, size_t *dffns_pos, size_t *lmtf_pos, size_t *lmpl_pos) {
  size_t n = 0;
  *ldp_pos = *dil_pos = *dffns_pos = *lmtf_pos = *lmpl_pos = -1;
  while (env[n] != NULL) {
    if (*ldp_pos != (size_t)-1 && !strncmp(env[n], "LD_PRELOAD=", sizeof("LD_PRELOAD=")))
      *ldp_pos = n;
    else if (*lmtf_pos != (size_t)-1 && !strncmp(env[n], "BUILDSH_TEMPFILE=", sizeof("BUILDSH_TEMPFILE=")))
      *lmtf_pos = n;
    else if (*lmpl_pos != (size_t)-1 && !strncmp(env[n], "BUILDSH_PRELOAD=", sizeof("BUILDSH_PRELOAD=")))
      *lmpl_pos = n;
    else if (*dil_pos != (size_t)-1 && !strncmp(env[n], "DYLD_INSERT_LIBRARIES=", sizeof("DYLD_INSERT_LIBRARIES=")))
      *dil_pos = n;
    else if (*dffns_pos != (size_t)-1 && !strncmp(env[n], "DYLD_FORCE_FLAT_NAMESPACE=", sizeof("DYLD_FORCE_FLAT_NAMESPACE=")))
      *dffns_pos = n;
    ++n;
  }
  return n;
}
```