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

```asm
<hpp_simulation>:
  endbr64
  push   %r15
  mov    %esi,%r15d
  push   %r14
  push   %r13
  push   %r12
  movslq %edi,%r12
  xor    %edi,%edi
  push   %rbp
  mov    %r12,%r14
  push   %rbx
  mov    %r12d,%ebx
  sub    $0x48,%rsp
  test   %r12d,%r12d
  setg   %dil
  movsd  %xmm0,0x18(%rsp)
  imul   %r12d,%ebx
  movsd  %xmm1,0x28(%rsp)
  call   <assert@plt>
  mov    %r15d,%edi
  not    %edi
  shr    $0x1f,%edi
  call   <assert@plt>
  mov    %ebx,%edi
  call   <malloc@plt>
  mov    %ebx,%edi
  mov    %rax,%rbp
  call   <malloc@plt>
  mov    %rax,%r13
  test   %rbp,%rbp
  je     L77
  test   %rax,%rax
  je     L77
L61:
  xor    %esi,%esi
  mov    %ebx,%edx
  mov    %rbp,%rdi
  call   <memset@plt>
  xor    %esi,%esi
  mov    %ebx,%edx
  mov    %r13,%rdi
  call   <memset@plt>
  movsd  0x28(%rsp),%xmm7
  comisd 0x18(%rsp),%xmm7
  jbe    L73
  mov    %r14d,%eax
  pxor   %xmm7,%xmm7
  shr    $0x1f,%eax
  add    %r14d,%eax
  sar    %eax
  cvtsi2sd %eax,%xmm7
  movsd  %xmm7,0x20(%rsp)
  nopw   0x0(%rax,%rax,1)
L37:
  mov    D27(%rip),%rax
  pxor   %xmm1,%xmm1
  mov    $0x1,%ebx
  movapd %xmm1,%xmm0
  movq   %rax,%xmm2
  jmp    L10
  nopl   0x0(%rax,%rax,1)
L23:
  lea    0x38(%rsp),%rdi
  lea    0x30(%rsp),%rsi
  movsd  %xmm0,(%rsp)
  call   <sincos@plt>
  movsd  0x30(%rsp),%xmm2
  movsd  0x38(%rsp),%xmm1
  movsd  (%rsp),%xmm0
L10:
  movsd  %xmm1,0x10(%rsp)
  movsd  %xmm2,0x8(%rsp)
  movsd  %xmm0,(%rsp)
  call   <conv_angle_to_direc@plt>
  movsd  0x18(%rsp),%xmm3
  movsd  (%rsp),%xmm0
  mov    %ebx,%edi
  movsd  0x10(%rsp),%xmm1
  movsd  0x20(%rsp),%xmm4
  mov    %eax,%ecx
  movsd  0x8(%rsp),%xmm2
  movsd  D39(%rip),%xmm5
  shl    %cl,%edi
  mulsd  %xmm3,%xmm1
  mulsd  %xmm3,%xmm2
  addsd  %xmm4,%xmm1
  addsd  %xmm4,%xmm2
  cvttsd2si %xmm1,%edx
  movsd  D6(%rip),%xmm1
  cvttsd2si %xmm2,%esi
  divsd  %xmm3,%xmm1
  movslq %edx,%rdx
  imul   %r12,%rdx
  movslq %esi,%rsi
  add    %rbp,%rdx
  or     %dil,(%rdx,%rsi,1)
  addsd  %xmm1,%xmm0
  comisd %xmm0,%xmm5
  ja     L23
  movsd  D6(%rip),%xmm6
  addsd  0x18(%rsp),%xmm6
  movsd  0x28(%rsp),%xmm7
  comisd %xmm6,%xmm7
  movsd  %xmm6,0x18(%rsp)
  ja     L37
L73:
  xor    %ebx,%ebx
  test   %r15d,%r15d
  jg     L48
  jmp    L31
  xchg   %ax,%ax
L20:
  mov    %rbp,%rax
  mov    %r13,%rbp
  mov    %rax,%r13
L48:
  mov    %r14d,%edx
  mov    %r13,%rsi
  mov    %rbp,%rdi
  add    $0x1,%ebx
  call   <take_next_step@plt>
  cmp    %ebx,%r15d
  jne    L20
L106:
  mov    %rbp,%rdi
  call   <free@plt>
  add    $0x48,%rsp
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L77:
  lea    D0(%rip),%rdi
  call   <perror@plt>
  xor    %eax,%eax
  call   <abort@plt>
  jmp    L61
L31:
  mov    %r13,%rax
  mov    %rbp,%r13
  mov    %rax,%rbp
  jmp    L106
```

tool_calls: name: disassemble_data
arguments: data_tag: D27
type_infered: f64
name: disassemble_data
arguments: data_tag: D39
type_infered: byte[8]
name: disassemble_data
arguments: data_tag: D6
type_infered: f64
name: disassemble_data
arguments: data_tag: D0
type_infered: string

tool: D27: 1

tool: {"D39": [0x18,0x2d,0x44,0x54,0xfb,0x21,0x19,0x40]}

tool: D6: 0.5

tool: D0: malloc (lattice)

assistant: ```c
char *hpp_simulation(int dim, double r0, double r1, int nsteps) {
  assert(dim > 0);
  assert(nsteps >= 0);
  char(*oldlat)[dim] = (char(*)[dim])malloc(dim * dim * sizeof(char));
  char(*newlat)[dim] = (char(*)[dim])malloc(dim * dim * sizeof(char));
  if (oldlat == NULL || newlat == NULL) {
    perror("malloc (lattice)");
    abort();
  }
  double radius, angle;
  memset(oldlat, 0, dim * dim * sizeof(char));
  memset(newlat, 0, dim * dim * sizeof(char));
  for (radius = r0; radius < r1; radius += 0.5) {
    for (angle = 0; angle < 2 * (atan(1.0) * 4.0); angle += 0.5 / radius) {
      int direc = conv_angle_to_direc(angle);
      int x = radius * cos(angle) + dim / 2;
      int y = radius * sin(angle) + dim / 2;
      ((oldlat[y][x]) |= (1 << (direc)));
    }
  }
  int i;
  char(*tmp)[dim];
  for (i = 0; i < nsteps; i++) {
    take_next_step((char *)oldlat, (char *)newlat, dim);
    tmp = oldlat;
    oldlat = newlat;
    newlat = tmp;
  }
  free(newlat);
  return (char *)oldlat;
}
```