user: 请从给定的汇编指令推导出C源代码：

```asm
<assign_class_by_k_medoids>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  mov    %rcx,%r15
  push   %r14
  push   %r13
  mov    %edi,%r13d
  push   %r12
  mov    %esi,%r12d
  push   %rbx
  sub    $0x78,%rsp
  mov    %rdx,-0x88(%rbp)
  mov    %r8,-0x58(%rbp)
  mov    %rsp,%rcx
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  movslq %esi,%rax
  lea    0xf(,%rax,4),%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L125
L28:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L28
L125:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L174
L172:
  movslq %r13d,%rax
  mov    %rsp,%rcx
  mov    %rsp,%r14
  lea    0xf(,%rax,4),%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L195
L26:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L26
L195:
  mov    %rdx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  jne    L50
L17:
  mov    %r15,%rdx
  mov    %r12d,%esi
  mov    %r13d,%edi
  mov    %rsp,-0x60(%rbp)
  movq   $0x0,-0x48(%rbp)
  lea    -0x1(%r12),%ebx
  movq   $0x0,-0x40(%rbp)
  call   <srswor@plt>
  mov    -0x58(%rbp),%r8
  lea    -0x48(%rbp),%r9
  mov    %r15,%rcx
  mov    -0x88(%rbp),%rdx
  mov    %r12d,%esi
  mov    %r13d,%edi
  call   <assign_class_id_compute_total_cost@plt>
  lea    0x4(,%rbx,4),%rax
  mov    %rbx,-0x90(%rbp)
  mov    -0x88(%rbp),%rbx
  mov    %rax,-0x80(%rbp)
  lea    -0x1(%r13),%eax
  mov    %rax,-0x98(%rbp)
  lea    0x4(,%rax,4),%rax
  mov    %rax,-0x78(%rbp)
  lea    -0x40(%rbp),%rax
  movl   $0x64,-0x6c(%rbp)
  mov    %rax,-0x68(%rbp)
  jmp    L46
  nopw   0x0(%rax,%rax,1)
L110:
  movsd  %xmm0,-0x48(%rbp)
  test   %r12d,%r12d
  jle    L40
  mov    -0x80(%rbp),%rdx
  mov    %r14,%rsi
  mov    %r15,%rdi
  call   <memcpy@plt>
L40:
  test   %r13d,%r13d
  jle    L148
  mov    -0x78(%rbp),%rdx
  mov    -0x60(%rbp),%rsi
  mov    -0x58(%rbp),%rdi
  call   <memcpy@plt>
L148:
  subl   $0x1,-0x6c(%rbp)
  je     L192
L46:
  mov    -0x58(%rbp),%r8
  mov    %r14,%r9
  mov    %r15,%rcx
  mov    %rbx,%rdx
  mov    %r12d,%esi
  mov    %r13d,%edi
  call   <classify_by_EDM@plt>
  mov    -0x68(%rbp),%r9
  mov    -0x60(%rbp),%r8
  mov    %r14,%rcx
  mov    %rbx,%rdx
  mov    %r12d,%esi
  mov    %r13d,%edi
  call   <assign_class_id_compute_total_cost@plt>
  movsd  -0x40(%rbp),%xmm0
  movsd  -0x48(%rbp),%xmm1
  comisd %xmm0,%xmm1
  ja     L110
L192:
  mov    -0x90(%rbp),%rbx
  test   %r13d,%r13d
  jle    L149
  mov    -0x58(%rbp),%rsi
  mov    -0x98(%rbp),%rax
  lea    0x4(%rsi,%rax,4),%rdi
  nopw   0x0(%rax,%rax,1)
L153:
  test   %r12d,%r12d
  jle    L132
  mov    (%rsi),%ecx
  xor    %eax,%eax
  jmp    L126
  nopl   0x0(%rax,%rax,1)
L157:
  lea    0x1(%rax),%rdx
  cmp    %rax,%rbx
  je     L132
  mov    %rdx,%rax
L126:
  cmp    (%r15,%rax,4),%ecx
  jne    L157
  mov    %eax,(%rsi)
L132:
  add    $0x4,%rsi
  cmp    %rdi,%rsi
  jne    L153
L149:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L70
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L174:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L172
L50:
  orq    $0x0,-0x8(%rsp,%rax,1)
  jmp    L17
L70:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void assign_class_by_k_medoids(int N_X, int K, double **EDM, int *center_id, int *class_id) {
  int max_kmed_iter = 100;
  int i, n_X, k;
  int new_center_id[K], new_class_id[N_X];
  double total_cost = 0.0, new_total_cost = 0.0;
  srswor(N_X, K, center_id);
  assign_class_id_compute_total_cost(N_X, K, EDM, center_id, class_id, &total_cost);
  for (i = 0; i < max_kmed_iter; i++) {
    classify_by_EDM(N_X, K, EDM, center_id, class_id, new_center_id);
    assign_class_id_compute_total_cost(N_X, K, EDM, new_center_id, new_class_id, &new_total_cost);
    if (new_total_cost < total_cost) {
      total_cost = new_total_cost;
      for (k = 0; k < K; k++) {
        center_id[k] = new_center_id[k];
      }
      for (n_X = 0; n_X < N_X; n_X++) {
        class_id[n_X] = new_class_id[n_X];
      }
    } else {
      break;
    }
  }
  for (n_X = 0; n_X < N_X; n_X++) {
    for (k = 0; k < K; k++) {
      if (class_id[n_X] == center_id[k]) {
        class_id[n_X] = k;
        break;
      }
    }
  }
}
```