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

```asm
<tour>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x38,%rsp
  mov    %esi,%eax
  mov    %rdx,%r12
  mov    %rcx,%r14
  mov    %r8d,%ebx
  mov    %fs:0x28,%rdx
  mov    %rdx,-0x38(%rbp)
  xor    %edx,%edx
  movslq %esi,%rdx
  lea    0xf(,%rdx,8),%rdx
  mov    %rdx,%rsi
  and    $0xfffffffffffffff0,%rsi
  and    $0xfffffffffffff000,%rdx
  mov    %rsp,%rcx
  sub    %rdx,%rcx
L82:
  cmp    %rcx,%rsp
  je     L96
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L82
L96:
  mov    %rsi,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  je     L18
  orq    $0x0,-0x8(%rsp,%rdx,1)
L18:
  lea    0x7(%rsp),%rdx
  mov    %rdx,%rcx
  shr    $0x3,%rcx
  mov    %rcx,-0x50(%rbp)
  and    $0xfffffffffffffff8,%rdx
  mov    %rdx,-0x58(%rbp)
  test   %eax,%eax
  jle    L30
  mov    %rdi,%r13
  lea    -0x1(%rax),%eax
  lea    0x8(%rdi,%rax,8),%rax
  mov    %rax,-0x48(%rbp)
  mov    $0x0,%r15d
  jmp    L2
L5:
  add    $0x8,%r13
  cmp    -0x48(%rbp),%r13
  je     L8
L2:
  mov    0x0(%r13),%rdx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <arr_idx@plt>
  cmp    $0xffffffff,%eax
  je     L5
  movslq %r15d,%rax
  mov    0x0(%r13),%rdx
  mov    -0x58(%rbp),%rcx
  mov    %rdx,(%rcx,%rax,8)
  lea    0x1(%r15),%r15d
  jmp    L5
L8:
  mov    -0x50(%rbp),%rax
  mov    0x0(,%rax,8),%rdx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <arr_idx@plt>
  cltq
  mov    0x8(%r12,%rax,8),%rdx
  mov    %ebx,%esi
  mov    %r14,%rdi
  call   <arr_idx@plt>
  cltq
  mov    0x8(%r14,%rax,8),%rdi
  call   <atof@plt>
  movsd  %xmm0,-0x48(%rbp)
  lea    -0x1(%r15),%eax
  mov    %eax,-0x5c(%rbp)
  test   %eax,%eax
  jle    L107
  mov    -0x58(%rbp),%rcx
  mov    %rcx,%r13
  lea    -0x2(%r15),%eax
  lea    0x8(%rcx,%rax,8),%r15
L10:
  mov    0x8(%r13),%rdx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <arr_idx@plt>
  cltq
  mov    0x8(%r12,%rax,8),%rdx
  mov    %ebx,%esi
  mov    %r14,%rdi
  call   <arr_idx@plt>
  cltq
  mov    0x8(%r14,%rax,8),%rdi
  call   <atof@plt>
  movsd  %xmm0,-0x50(%rbp)
  mov    0x0(%r13),%rdx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <arr_idx@plt>
  cltq
  mov    0x8(%r12,%rax,8),%rdx
  mov    %ebx,%esi
  mov    %r14,%rdi
  call   <arr_idx@plt>
  cltq
  mov    0x8(%r14,%rax,8),%rdi
  call   <atof@plt>
  movapd %xmm0,%xmm1
  movsd  -0x50(%rbp),%xmm0
  mulsd  %xmm0,%xmm0
  mulsd  %xmm1,%xmm1
  subsd  %xmm1,%xmm0
  call   <sqrt@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  addsd  -0x48(%rbp),%xmm0
  movsd  %xmm0,-0x48(%rbp)
  add    $0x8,%r13
  cmp    %r15,%r13
  jne    L10
L107:
  movslq -0x5c(%rbp),%rax
  mov    -0x58(%rbp),%rcx
  mov    (%rcx,%rax,8),%rdx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <arr_idx@plt>
  cltq
  mov    0x8(%r12,%rax,8),%rdx
  mov    %ebx,%esi
  mov    %r14,%rdi
  call   <arr_idx@plt>
  cltq
  mov    0x8(%r14,%rax,8),%rdi
  call   <atof@plt>
  addsd  -0x48(%rbp),%xmm0
  call   <floor@plt>
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L108
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L30:
  mov    -0x50(%rbp),%rax
  mov    0x0(,%rax,8),%rdx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <arr_idx@plt>
  cltq
  mov    0x8(%r12,%rax,8),%rdx
  mov    %ebx,%esi
  mov    %r14,%rdi
  call   <arr_idx@plt>
  cltq
  mov    0x8(%r14,%rax,8),%rdi
  call   <atof@plt>
  movsd  %xmm0,-0x48(%rbp)
  movl   $0xffffffff,-0x5c(%rbp)
  jmp    L107
L108:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int tour(char **arrFriends, int szArrFriends, char **ftwns, char **townsDist, int szFTwns) {
  char *f_arr[szArrFriends];
  int temp_idx = 0;
  for (int i = 0; i < szArrFriends; ++i) {
    if (arr_idx(ftwns, szFTwns, arrFriends[i]) != -1)
      f_arr[temp_idx++] = arrFriends[i];
  }
  szArrFriends = temp_idx;
  double sum = atof(townsDist[arr_idx(townsDist, szFTwns, ftwns[arr_idx(ftwns, szFTwns, f_arr[0]) + 1]) + 1]);
  for (int i = 0; i < szArrFriends - 1; ++i) {
    double d1 = atof(townsDist[arr_idx(townsDist, szFTwns, ftwns[arr_idx(ftwns, szFTwns, f_arr[i + 1]) + 1]) + 1]);
    double d2 = atof(townsDist[arr_idx(townsDist, szFTwns, ftwns[arr_idx(ftwns, szFTwns, f_arr[i]) + 1]) + 1]);
    sum += sqrt(d1 * d1 - d2 * d2);
  }
  sum += atof(townsDist[arr_idx(townsDist, szFTwns, ftwns[arr_idx(ftwns, szFTwns, f_arr[szArrFriends - 1]) + 1]) + 1]);
  return floor(sum);
}
```