user: Converte this assembly snippet into its equivalent C code:

```asm
<sort_points>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xfa0,%rsp
  mov    %rdi,-0xf68(%rbp)
  movsd  %xmm0,-0xf70(%rbp)
  mov    %rsi,-0xf78(%rbp)
  mov    %edx,-0xf7c(%rbp)
  mov    %rcx,-0xf88(%rbp)
  mov    %r8,-0xf90(%rbp)
  mov    %r9,-0xf98(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0xf7c(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L454
  mov    $0x1,%edx
  mov    $0x7,%esi
  mov    $0x1,%edi
  call   <new_cept@plt>
  mov    %rax,-0xf28(%rbp)
  mov    -0xf28(%rbp),%rax
  lea    D26(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_function@plt>
  mov    -0xf28(%rbp),%rax
  lea    D41(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_message@plt>
  jmp    L189
L454:
  movl   $0x0,-0xf44(%rbp)
  movl   $0x0,-0xf40(%rbp)
  movl   $0x0,-0xf3c(%rbp)
  jmp    L436
L102:
  mov    -0xf3c(%rbp),%eax
  cltq
  lea    (%rax,%rax,1),%rdx
  mov    -0xf90(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  test   %ax,%ax
  je     L247
  addl   $0x1,-0xf40(%rbp)
  jmp    L105
L247:
  addl   $0x1,-0xf44(%rbp)
L105:
  movl   $0x0,-0xf58(%rbp)
  jmp    L85
L313:
  mov    -0xf3c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x3,%rax
  mov    %rax,%rdx
  mov    -0xf88(%rbp),%rax
  add    %rax,%rdx
  mov    -0xf58(%rbp),%eax
  cltq
  movsd  (%rdx,%rax,8),%xmm0
  mov    -0xf58(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0xf68(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  divsd  -0xf70(%rbp),%xmm0
  mov    -0xf58(%rbp),%eax
  movslq %eax,%rcx
  mov    -0xf3c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  add    %rcx,%rax
  movsd  %xmm0,-0xa70(%rbp,%rax,8)
  addl   $0x1,-0xf58(%rbp)
L85:
  cmpl   $0x2,-0xf58(%rbp)
  jle    L313
  addl   $0x1,-0xf3c(%rbp)
L436:
  mov    -0xf3c(%rbp),%eax
  cmp    -0xf7c(%rbp),%eax
  jl     L102
  mov    -0xf44(%rbp),%eax
  cmp    -0xf40(%rbp),%eax
  je     L167
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    $0x1,%edi
  call   <new_cept@plt>
  mov    %rax,-0xf28(%rbp)
  mov    -0xf28(%rbp),%rax
  lea    D26(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_function@plt>
  mov    -0xf44(%rbp),%eax
  movslq %eax,%rdx
  mov    -0xf28(%rbp),%rax
  lea    D186(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <add_long@plt>
  mov    -0xf40(%rbp),%eax
  movslq %eax,%rdx
  mov    -0xf28(%rbp),%rax
  lea    D123(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <add_long@plt>
  jmp    L189
L167:
  movl   $0xffffffff,-0xf4c(%rbp)
  movl   $0x0,-0xf3c(%rbp)
  jmp    L396
L101:
  mov    -0xf3c(%rbp),%eax
  cltq
  lea    (%rax,%rax,1),%rdx
  mov    -0xf90(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  test   %ax,%ax
  jne    L294
  mov    -0xf3c(%rbp),%eax
  mov    %eax,-0xf4c(%rbp)
  jmp    L142
L294:
  addl   $0x1,-0xf3c(%rbp)
L396:
  mov    -0xf3c(%rbp),%eax
  cmp    -0xf7c(%rbp),%eax
  jl     L101
L142:
  cmpl   $0x0,-0xf4c(%rbp)
  jns    L405
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    $0x1,%edi
  call   <new_cept@plt>
  mov    %rax,-0xf28(%rbp)
  mov    -0xf28(%rbp),%rax
  lea    D26(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_function@plt>
  mov    -0xf28(%rbp),%rax
  lea    D184(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_message@plt>
  jmp    L189
L405:
  movl   $0x0,-0xf3c(%rbp)
  jmp    L447
L60:
  lea    -0xa70(%rbp),%rcx
  mov    -0xf3c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x3,%rax
  lea    (%rcx,%rax,1),%rsi
  lea    -0xa70(%rbp),%rcx
  mov    -0xf4c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rdx,%rax
  shl    $0x3,%rax
  add    %rax,%rcx
  mov    -0xf78(%rbp),%rax
  mov    %rax,%rdx
  mov    %rcx,%rdi
  call   <positive_angle@plt>
  movq   %xmm0,%rax
  mov    -0xf3c(%rbp),%edx
  movslq %edx,%rdx
  mov    %rax,-0xd90(%rbp,%rdx,8)
  addl   $0x1,-0xf3c(%rbp)
L447:
  mov    -0xf3c(%rbp),%eax
  cmp    -0xf7c(%rbp),%eax
  jl     L60
  mov    -0xf4c(%rbp),%eax
  cltq
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0xd90(%rbp,%rax,8)
  movl   $0x0,-0xf3c(%rbp)
  jmp    L149
L181:
  mov    -0xf3c(%rbp),%eax
  cltq
  movl   $0x0,-0xf20(%rbp,%rax,4)
  addl   $0x1,-0xf3c(%rbp)
L149:
  mov    -0xf3c(%rbp),%eax
  cmp    -0xf7c(%rbp),%eax
  jl     L181
  mov    -0xf7c(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0xf34(%rbp)
  movl   $0x0,-0xf38(%rbp)
  movl   $0x0,-0xf48(%rbp)
  jmp    L391
L87:
  movl   $0xffffffff,-0xf54(%rbp)
  movl   $0x0,-0xf3c(%rbp)
  jmp    L14
L394:
  mov    -0xf3c(%rbp),%eax
  cltq
  mov    -0xf20(%rbp,%rax,4),%eax
  test   %eax,%eax
  jne    L301
  mov    -0xf3c(%rbp),%eax
  cltq
  lea    (%rax,%rax,1),%rdx
  mov    -0xf90(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cmp    $0x1,%ax
  je     L461
  mov    -0xf3c(%rbp),%eax
  mov    %eax,-0xf54(%rbp)
  jmp    L175
L301:
  nop
  jmp    L191
L461:
  nop
L191:
  addl   $0x1,-0xf3c(%rbp)
L14:
  mov    -0xf3c(%rbp),%eax
  cmp    -0xf7c(%rbp),%eax
  jl     L394
L175:
  cmpl   $0x0,-0xf54(%rbp)
  jns    L468
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    $0x1,%edi
  call   <new_cept@plt>
  mov    %rax,-0xf28(%rbp)
  mov    -0xf28(%rbp),%rax
  lea    D26(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_function@plt>
  mov    -0xf28(%rbp),%rax
  lea    D75(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_message@plt>
  jmp    L189
L468:
  cmpl   $0x0,-0xf48(%rbp)
  jne    L305
  mov    -0xf54(%rbp),%eax
  cmp    -0xf4c(%rbp),%eax
  je     L305
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    $0x1,%edi
  call   <new_cept@plt>
  mov    %rax,-0xf28(%rbp)
  mov    -0xf28(%rbp),%rax
  lea    D26(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_function@plt>
  mov    -0xf28(%rbp),%rax
  lea    D34(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_message@plt>
  jmp    L189
L305:
  mov    -0xf54(%rbp),%eax
  cltq
  movl   $0x1,-0xf20(%rbp,%rax,4)
  movsd  D122(%rip),%xmm0
  movsd  %xmm0,-0xf30(%rbp)
  movl   $0xffffffff,-0xf50(%rbp)
  movl   $0x0,-0xf3c(%rbp)
  jmp    L460
L25:
  mov    -0xf3c(%rbp),%eax
  cltq
  mov    -0xf20(%rbp,%rax,4),%eax
  test   %eax,%eax
  jne    L98
  mov    -0xf3c(%rbp),%eax
  cltq
  lea    (%rax,%rax,1),%rdx
  mov    -0xf90(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  test   %ax,%ax
  je     L15
  mov    -0xf3c(%rbp),%eax
  cltq
  movsd  -0xd90(%rbp,%rax,8),%xmm1
  mov    -0xf54(%rbp),%eax
  cltq
  movsd  -0xd90(%rbp,%rax,8),%xmm0
  comisd %xmm1,%xmm0
  jae    L306
  mov    -0xf3c(%rbp),%eax
  cltq
  movsd  -0xd90(%rbp,%rax,8),%xmm1
  movsd  -0xf30(%rbp),%xmm0
  comisd %xmm1,%xmm0
  jbe    L45
  mov    -0xf3c(%rbp),%eax
  mov    %eax,-0xf50(%rbp)
  mov    -0xf3c(%rbp),%eax
  cltq
  movsd  -0xd90(%rbp,%rax,8),%xmm0
  movsd  %xmm0,-0xf30(%rbp)
  jmp    L45
L98:
  nop
  jmp    L45
L15:
  nop
  jmp    L45
L306:
  nop
L45:
  addl   $0x1,-0xf3c(%rbp)
L460:
  mov    -0xf3c(%rbp),%eax
  cmp    -0xf7c(%rbp),%eax
  jl     L25
  cmpl   $0x0,-0xf50(%rbp)
  jns    L58
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    $0x1,%edi
  call   <new_cept@plt>
  mov    %rax,-0xf28(%rbp)
  mov    -0xf28(%rbp),%rax
  lea    D26(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_function@plt>
  mov    -0xf28(%rbp),%rax
  lea    D188(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_message@plt>
  jmp    L189
L58:
  mov    -0xf50(%rbp),%eax
  cltq
  movl   $0x1,-0xf20(%rbp,%rax,4)
  mov    -0xf7c(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0xf38(%rbp)
  jl     L164
  mov    $0x1,%edx
  mov    $0xc,%esi
  mov    $0x7,%edi
  call   <new_cept@plt>
  mov    %rax,-0xf28(%rbp)
  mov    -0xf28(%rbp),%rax
  lea    D26(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_function@plt>
  mov    -0xf7c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0xf28(%rbp),%rax
  lea    D197(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <add_long@plt>
  mov    -0xf38(%rbp),%eax
  movslq %eax,%rdx
  mov    -0xf28(%rbp),%rax
  lea    D52(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <add_long@plt>
  jmp    L189
L164:
  mov    -0xf38(%rbp),%eax
  cltq
  lea    (%rax,%rax,1),%rdx
  mov    -0xf98(%rbp),%rax
  add    %rdx,%rax
  mov    -0xf54(%rbp),%edx
  mov    %dx,(%rax)
  addl   $0x1,-0xf38(%rbp)
  mov    -0xf38(%rbp),%eax
  cltq
  lea    (%rax,%rax,1),%rdx
  mov    -0xf98(%rbp),%rax
  add    %rdx,%rax
  mov    -0xf50(%rbp),%edx
  mov    %dx,(%rax)
  addl   $0x1,-0xf38(%rbp)
  addl   $0x1,-0xf48(%rbp)
L391:
  mov    -0xf48(%rbp),%eax
  cmp    -0xf34(%rbp),%eax
  jl     L87
  mov    -0xf38(%rbp),%eax
  cmp    -0xf7c(%rbp),%eax
  je     L189
  mov    $0x1,%edx
  mov    $0xe,%esi
  mov    $0x7,%edi
  call   <new_cept@plt>
  mov    %rax,-0xf28(%rbp)
  mov    -0xf28(%rbp),%rax
  lea    D26(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_function@plt>
  mov    -0xf28(%rbp),%rax
  lea    D192(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <add_source@plt>
  mov    -0xf7c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0xf28(%rbp),%rax
  lea    D197(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <add_long@plt>
  mov    -0xf38(%rbp),%eax
  movslq %eax,%rdx
  mov    -0xf28(%rbp),%rax
  lea    D52(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <add_long@plt>
  nop
L189:
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L307
  call   <__stack_chk_fail@plt>
L307:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D26
type: string
name: retrieve_data
arguments: data_tag: D41
type: string
name: retrieve_data
arguments: data_tag: D186
type: string
name: retrieve_data
arguments: data_tag: D123
type: string
name: retrieve_data
arguments: data_tag: D184
type: string
name: retrieve_data
arguments: data_tag: D75
type: string
name: retrieve_data
arguments: data_tag: D34
type: string
name: retrieve_data
arguments: data_tag: D122
type: byte[8]
name: retrieve_data
arguments: data_tag: D188
type: string
name: retrieve_data
arguments: data_tag: D197
type: string
name: retrieve_data
arguments: data_tag: D52
type: string
name: retrieve_data
arguments: data_tag: D192
type: string

tool: D26: sort_points

tool: D41: odd number of points on circle

tool: D186: number of start points

tool: D123: number of stop points

tool: D184: base point not found

tool: D75: starting vertex not found

tool: D34: first start point is not the base point

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

tool: D188: ending point not found

tool: D197: number of points

tool: D52: number of sorted points

tool: D192: mscircle.c

assistant: ```c
void sort_points(double center[3], double radius, double axis[3], int n_points, double circle_points[][3], short orn[], short indices[]) {
  int k, index0, index1, base, n_e, edg_idx;
  int n_start, n_stop, pnt;
  int n_sorted;
  double minimum_angle;
  int point_used[100];
  double point_angle[100];
  double point_vector[100][3];
  char message[255];
  struct cept *ex;
  if (n_points % 2 != 0) {
    ex = new_cept(1, 7, 1);
    add_function(ex, "sort_points");
    add_message(ex, "odd number of points on circle");
    return;
  }
  n_start = 0;
  n_stop = 0;
  for (pnt = 0; pnt < n_points; ++pnt) {
    if (orn[pnt])
      n_stop++;
    else
      n_start++;
    for (k = 0; k < 3; k++)
      point_vector[pnt][k] = (circle_points[pnt][k] - center[k]) / radius;
  }
  if (n_start != n_stop) {
    ex = new_cept(1, 4, 1);
    add_function(ex, "sort_points");
    add_long(ex, "number of start points", (long)n_start);
    add_long(ex, "number of stop points", (long)n_stop);
    return;
  }
  base = -1;
  for (pnt = 0; pnt < n_points; pnt++)
    if (orn[pnt] == 0) {
      base = pnt;
      break;
    }
  if (base < 0) {
    ex = new_cept(1, 4, 1);
    add_function(ex, "sort_points");
    add_message(ex, "base point not found");
    return;
  }
  for (pnt = 0; pnt < n_points; pnt++)
    point_angle[pnt] = positive_angle(point_vector[base], point_vector[pnt], axis);
  point_angle[base] = 0.0;
  for (pnt = 0; pnt < n_points; pnt++)
    point_used[pnt] = 0;
  n_e = n_points / 2;
  n_sorted = 0;
  for (edg_idx = 0; edg_idx < n_e; edg_idx++) {
    index0 = -1;
    for (pnt = 0; pnt < n_points; pnt++) {
      if (point_used[pnt])
        continue;
      if (orn[pnt] == 1)
        continue;
      index0 = pnt;
      break;
    }
    if (index0 < 0) {
      ex = new_cept(1, 4, 1);
      add_function(ex, "sort_points");
      add_message(ex, "starting vertex not found");
      return;
    }
    if (edg_idx == 0 && index0 != base) {
      ex = new_cept(1, 4, 1);
      add_function(ex, "sort_points");
      add_message(ex, "first start point is not the base point");
      return;
    }
    point_used[index0] = 1;
    minimum_angle = 2 * 3.14159265358979323846;
    index1 = -1;
    for (pnt = 0; pnt < n_points; pnt++) {
      if (point_used[pnt])
        continue;
      if (orn[pnt] == 0)
        continue;
      if (point_angle[pnt] <= point_angle[index0])
        continue;
      if (point_angle[pnt] < minimum_angle) {
        index1 = pnt;
        minimum_angle = point_angle[pnt];
      }
    }
    if (index1 < 0) {
      ex = new_cept(1, 4, 1);
      add_function(ex, "sort_points");
      add_message(ex, "ending point not found");
      return;
    }
    point_used[index1] = 1;
    if (n_sorted >= n_points - 1) {
      ex = new_cept(7, 12, 1);
      add_function(ex, "sort_points");
      add_long(ex, "number of points", (long)n_points);
      add_long(ex, "number of sorted points", (long)n_sorted);
      return;
    }
    indices[n_sorted] = (short)index0;
    n_sorted++;
    indices[n_sorted] = (short)index1;
    n_sorted++;
  }
  if (n_sorted != n_points) {
    ex = new_cept(7, 14, 1);
    add_function(ex, "sort_points");
    add_source(ex, "mscircle.c");
    add_long(ex, "number of points", (long)n_points);
    add_long(ex, "number of sorted points", (long)n_sorted);
    return;
  }
}
```