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

```asm
<c_phansalkar>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  mov    %rcx,%rdi
  push   %rbx
  mov    %edx,%ebx
  mov    $0x8,%edx
  sub    $0x78,%rsp
  mov    %esi,0x4c(%rsp)
  xor    %esi,%esi
  mov    %rcx,0x38(%rsp)
  call   <memset@plt>
  test   %ebx,%ebx
  jle    L82
  movslq %ebx,%rax
  mov    0x38(%rsp),%rdi
  mov    $0xfffffffffffffff8,%rdx
  movl   $0x0,0x18(%rsp)
  mov    %rax,0x40(%rsp)
  shl    $0x3,%rax
  movsd  D20(%rip),%xmm3
  mov    %rax,0x30(%rsp)
  lea    -0x1(%rbx),%eax
  movsd  D28(%rip),%xmm2
  shl    $0x3,%rax
  mov    %rdi,0x28(%rsp)
  sub    %rax,%rdx
  lea    0x8(%rbp,%rax,1),%r14
  mov    %rdx,0x20(%rsp)
  mov    %r14,%r15
L76:
  mov    0x20(%rsp),%rax
  mov    0x28(%rsp),%r13
  lea    (%rax,%r15,1),%r12
  cs nopw 0x0(%rax,%rax,1)
L118:
  movsd  (%r12),%xmm1
  movapd %xmm3,%xmm0
  add    $0x8,%r12
  add    $0x1,%r13
  movsd  %xmm2,0x10(%rsp)
  call   <min@plt>
  movsd  0x10(%rsp),%xmm2
  movsd  -0x8(%r12),%xmm1
  movsd  %xmm0,0x8(%rsp)
  movapd %xmm2,%xmm0
  call   <max@plt>
  movb   $0x0,-0x1(%r13)
  cmp    %r15,%r12
  movsd  0x8(%rsp),%xmm3
  movapd %xmm0,%xmm2
  jne    L118
  mov    0x18(%rsp),%eax
  mov    0x40(%rsp),%rdi
  add    %rdi,0x28(%rsp)
  lea    0x1(%rax),%edx
  mov    0x30(%rsp),%rax
  lea    (%r12,%rax,1),%r15
  cmp    %edx,%ebx
  je     L149
  mov    %edx,0x18(%rsp)
  jmp    L76
L82:
  mov    0x4c(%rsp),%r9d
  mov    %ebx,%edx
  sub    %r9d,%edx
  mov    %r9d,%edi
  cmp    %r9d,%edx
  jle    L78
  imul   %ebx,%edi
  lea    (%r9,%r9,1),%eax
  pxor   %xmm6,%xmm6
  movslq %ebx,%r10
  lea    0x1(%rax),%r15d
  mov    %eax,0x68(%rsp)
  movslq %r9d,%rax
  lea    0x8(%rbp),%r12
  mov    %r15d,%ecx
  mov    %r10,0x60(%rsp)
  mov    %r15d,%r14d
  pxor   %xmm3,%xmm3
  movslq %edi,%rsi
  imul   %r15d,%ecx
  mov    %edi,0x5c(%rsp)
  mov    %ebx,%r15d
  add    %rsi,%rax
  mov    %rsi,%rdi
  mov    0x38(%rsp),%rsi
  mov    %rbp,%rbx
  mov    %edi,0x58(%rsp)
  mov    %r12,%r13
  add    %rax,%rsi
  cvtsi2sd %ecx,%xmm6
  lea    0x0(%rbp,%rax,8),%rax
  mov    %rsi,0x28(%rsp)
  lea    0x0(,%r10,8),%rsi
  mov    %rax,0x20(%rsp)
  lea    0x1(%rdx,%r9,1),%eax
  mov    %rsi,0x50(%rsp)
  mov    %eax,0x6c(%rsp)
  movsd  %xmm6,0x38(%rsp)
L19:
  mov    0x68(%rsp),%r12d
  mov    %r14d,%eax
  xor    %ebp,%ebp
  sub    %r12d,%eax
  sub    $0x1,%eax
  mov    %eax,0x30(%rsp)
  mov    0x58(%rsp),%eax
  sub    0x5c(%rsp),%eax
  mov    %eax,0x4c(%rsp)
  lea    -0x1(%r14),%eax
  mov    %eax,0x40(%rsp)
  mov    %r13,%rax
  mov    %rbp,%r13
  mov    %r14d,%ebp
  mov    %r12d,%r14d
  mov    %rbx,%r12
  mov    %rax,%rbx
  nopl   0x0(%rax)
L105:
  mov    0x20(%rsp),%rax
  mov    0x30(%rsp),%ecx
  movsd  (%rax,%r13,8),%xmm6
  movsd  %xmm6,0x8(%rsp)
  cmp    %ecx,0x40(%rsp)
  jl     L54
  movslq %r13d,%r8
  mov    %r14d,%edi
  mov    0x4c(%rsp),%esi
  movapd %xmm3,%xmm1
  sub    %r8d,%edi
  movapd %xmm3,%xmm2
  add    %r8,%rdi
  nopw   0x0(%rax,%rax,1)
L124:
  cmp    %r13d,%r14d
  jl     L90
  movslq %esi,%rdx
  lea    (%r8,%rdx,1),%rax
  add    %rdi,%rdx
  lea    (%r12,%rax,8),%rax
  lea    (%rbx,%rdx,8),%rdx
  nopw   0x0(%rax,%rax,1)
L157:
  movsd  (%rax),%xmm0
  add    $0x8,%rax
  addsd  %xmm0,%xmm2
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  cmp    %rax,%rdx
  jne    L157
L90:
  add    $0x1,%ecx
  add    %r15d,%esi
  cmp    %ebp,%ecx
  jne    L124
L25:
  movsd  0x38(%rsp),%xmm5
  movapd %xmm2,%xmm4
  divsd  %xmm5,%xmm4
  mulsd  %xmm4,%xmm2
  subsd  %xmm2,%xmm1
  divsd  %xmm5,%xmm1
  ucomisd %xmm1,%xmm3
  ja     L158
  sqrtsd %xmm1,%xmm1
L9:
  movsd  D40(%rip),%xmm0
  movsd  %xmm1,0x18(%rsp)
  movsd  %xmm4,0x10(%rsp)
  mulsd  %xmm4,%xmm0
  call   <exp@plt>
  movsd  0x18(%rsp),%xmm1
  movsd  0x10(%rsp),%xmm4
  pxor   %xmm3,%xmm3
  movapd %xmm0,%xmm2
  movsd  0x8(%rsp),%xmm7
  mov    0x28(%rsp),%rax
  addsd  %xmm1,%xmm1
  movsd  D47(%rip),%xmm0
  subsd  D12(%rip),%xmm1
  addsd  %xmm2,%xmm2
  addsd  D12(%rip),%xmm2
  mulsd  %xmm1,%xmm0
  addsd  %xmm2,%xmm0
  mulsd  %xmm4,%xmm0
  comisd %xmm0,%xmm7
  seta   (%rax,%r13,1)
  add    $0x1,%r14d
  add    $0x1,%r13
  cmp    %r14d,%r15d
  jne    L105
  mov    %ebp,%r14d
  mov    0x60(%rsp),%rdi
  mov    %rbx,%r13
  add    %rdi,0x28(%rsp)
  add    %r15d,0x58(%rsp)
  mov    0x50(%rsp),%rdi
  mov    %r12,%rbx
  add    $0x1,%r14d
  add    %rdi,0x20(%rsp)
  cmp    0x6c(%rsp),%r14d
  jne    L19
L78:
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L54:
  movapd %xmm3,%xmm1
  movapd %xmm3,%xmm2
  jmp    L25
L149:
  subsd  %xmm3,%xmm2
  xor    %edx,%edx
L169:
  mov    0x20(%rsp),%rax
  add    %r14,%rax
  nopl   0x0(%rax,%rax,1)
L103:
  movsd  (%rax),%xmm0
  add    $0x8,%rax
  subsd  %xmm3,%xmm0
  divsd  %xmm2,%xmm0
  movsd  %xmm0,-0x8(%rax)
  cmp    %r14,%rax
  jne    L103
  lea    0x1(%rdx),%eax
  add    0x30(%rsp),%r14
  cmp    %edx,0x18(%rsp)
  je     L82
  mov    %eax,%edx
  jmp    L169
L158:
  movapd %xmm1,%xmm0
  movsd  %xmm4,0x10(%rsp)
  call   <sqrt@plt>
  movsd  0x10(%rsp),%xmm4
  movapd %xmm0,%xmm1
  jmp    L9
```

tool_calls: name: retrieve_data
arguments: data_label: D20
datatype: byte[8]
name: retrieve_data
arguments: data_label: D28
datatype: f64
name: retrieve_data
arguments: data_label: D40
datatype: byte[8]
name: retrieve_data
arguments: data_label: D47
datatype: f64
name: retrieve_data
arguments: data_label: D12
datatype: f64

tool: {"D20": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xbf]}

tool: D28: 65537

tool: {"D40": [0x00,0x00,0x00,0x00,0x00,0x00,0x24,0xc0]}

tool: D47: 0.25

tool: D12: 1

assistant: ```c
void c_phansalkar(double *frame, int wsize, int size, unsigned char *ret) {
  int i, j, m, n;
  double mean, sdv;
  double k = 0.25, r = 0.5, p = 2, q = 10;
  double pixel, th, sum, sum2, num;
  double Max = 65537, Min = -1;
  memset(ret, 0, sizeof(ret));
  for (i = 0; i < size; i++)
    for (j = 0; j < size; j++) {
      Min = min(Min, frame[i * size + j]);
      Max = max(Max, frame[i * size + j]);
      ret[i * size + j] = 0;
    }
  for (i = 0; i < size; i++)
    for (j = 0; j < size; j++)
      frame[i * size + j] = (frame[i * size + j] - Min) / (Max - Min);
  for (i = wsize; i < size - wsize; i++)
    for (j = wsize; j < size - wsize; j++) {
      pixel = frame[i * size + j];
      th = 0;
      sum = 0;
      sum2 = 0;
      for (m = i - wsize; m <= i + wsize; m++)
        for (n = j - wsize; n <= j + wsize; n++) {
          sum += frame[m * size + n];
          sum2 += frame[m * size + n] * frame[m * size + n];
        }
      num = (2 * wsize + 1) * (2 * wsize + 1);
      mean = sum / num;
      sdv = sqrt((sum2 - sum * mean) / num);
      th = mean * (1 + p * exp(-q * mean) + k * (sdv / r - 1));
      if (pixel > th)
        ret[i * size + j] = 1;
      else
        ret[i * size + j] = 0;
    }
}
```