ylfeng/ReF-Decompile-dataset huggingface dataset:
user: What is the c source code of the assembly code below:

```asm
<main>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    D49(%rip),%rax
  mov    (%rax),%edi
  call   <sysconf@plt>
  mov    %rax,%rbx
  mov    $0x4d,%eax
  cmp    $0x101,%rbx
  jbe    L16
  mov    D34(%rip),%rax
  mov    (%rax),%ecx
  mov    D59(%rip),%rax
  or     (%rax),%ecx
  mov    D67(%rip),%rax
  mov    (%rax),%edx
  mov    D42(%rip),%rax
  or     (%rax),%edx
  lea    (%rbx,%rbx,1),%rsi
  mov    $0x0,%r9d
  mov    $0xffffffff,%r8d
  mov    $0x0,%edi
  call   <mmap@plt>
  mov    %rax,%rbp
  mov    D16(%rip),%rax
  cmp    %rbp,(%rax)
  je     L10
  lea    0x0(%rbp,%rbx,1),%rdi
  mov    D33(%rip),%rax
  mov    (%rax),%edx
  mov    %rbx,%rsi
  call   <mprotect@plt>
  test   %rax,%rax
  jne    L36
  mov    %rbx,%rdx
  mov    $0x0,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  lea    -0x101(%rbp,%rbx,1),%rbx
  mov    $0x100,%edx
  mov    $0x2f,%esi
  mov    %rbx,%rdi
  call   <memset@plt>
  mov    %rbx,%rdi
  call   <chdir@plt>
  neg    %rax
  sbb    %eax,%eax
  and    $0x4d,%eax
L16:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L10:
  mov    $0x4d,%eax
  jmp    L16
L36:
  mov    $0x4d,%eax
  jmp    L16
```

assistant: ```c
int main(void) {
  const size_t page_len = sysconf(_SC_PAGESIZE);
  const size_t tail_len = 257;
  if (tail_len >= page_len)
    return 77;
  void *p = mmap(NULL, page_len * 2, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  if (p == MAP_FAILED || mprotect(p + page_len, page_len, PROT_NONE))
    return 77;
  memset(p, 0, page_len);
  char *addr = p + page_len - tail_len;
  memset(addr, '/', tail_len - 1);
  if (chdir(addr))
    return 77;
  return 0;
}
```
user: What is the c source code of the assembly code below:

```asm
<main>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    D51(%rip),%rax
  mov    (%rax),%edi
  call   <sysconf@plt>
  cmp    $0x101,%rax
  jbe    L29
  mov    %rax,%rbx
  mov    D21(%rip),%rax
  xor    %r9d,%r9d
  xor    %edi,%edi
  lea    (%rbx,%rbx,1),%rsi
  or     $0xffffffff,%r8d
  mov    (%rax),%ecx
  mov    D32(%rip),%rax
  or     (%rax),%ecx
  mov    D56(%rip),%rax
  mov    (%rax),%edx
  mov    D67(%rip),%rax
  or     (%rax),%edx
  call   <mmap@plt>
  mov    %rax,%rbp
  mov    D66(%rip),%rax
  cmp    %rbp,(%rax)
  je     L29
  mov    D3(%rip),%rax
  lea    0x0(%rbp,%rbx,1),%rdi
  mov    %rbx,%rsi
  mov    (%rax),%edx
  call   <mprotect@plt>
  test   %rax,%rax
  jne    L29
  mov    %rbp,%rdi
  mov    %rbx,%rdx
  lea    -0x101(%rbp,%rbx,1),%rbp
  xor    %esi,%esi
  call   <memset@plt>
  mov    $0x100,%edx
  mov    $0x2f,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    %rbp,%rdi
  call   <chdir@plt>
  mov    %rax,%r8
  xor    %eax,%eax
  test   %r8,%r8
  je     L7
L29:
  mov    $0x4d,%eax
L7:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
int main(void) {
  const size_t page_len = sysconf(_SC_PAGESIZE);
  const size_t tail_len = 257;
  if (tail_len >= page_len)
    return 77;
  void *p = mmap(NULL, page_len * 2, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  if (p == MAP_FAILED || mprotect(p + page_len, page_len, PROT_NONE))
    return 77;
  memset(p, 0, page_len);
  char *addr = p + page_len - tail_len;
  memset(addr, '/', tail_len - 1);
  if (chdir(addr))
    return 77;
  return 0;
}
```
user: What is the c source code of the assembly code below?

```asm
<main>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    D20(%rip),%rax
  mov    (%rax),%edi
  call   <sysconf@plt>
  cmp    $0x101,%rax
  jbe    L12
  mov    %rax,%rbx
  mov    D43(%rip),%rax
  xor    %r9d,%r9d
  xor    %edi,%edi
  lea    (%rbx,%rbx,1),%rsi
  or     $0xffffffff,%r8d
  mov    (%rax),%ecx
  mov    D17(%rip),%rax
  or     (%rax),%ecx
  mov    D35(%rip),%rax
  mov    (%rax),%edx
  mov    D66(%rip),%rax
  or     (%rax),%edx
  call   <mmap@plt>
  mov    %rax,%rbp
  mov    D67(%rip),%rax
  cmp    %rbp,(%rax)
  je     L12
  mov    D33(%rip),%rax
  lea    0x0(%rbp,%rbx,1),%rdi
  mov    %rbx,%rsi
  mov    (%rax),%edx
  call   <mprotect@plt>
  test   %rax,%rax
  jne    L12
  mov    %rbp,%rdi
  mov    %rbx,%rdx
  lea    -0x101(%rbp,%rbx,1),%rbp
  xor    %esi,%esi
  call   <memset@plt>
  mov    $0x100,%edx
  mov    $0x2f,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    %rbp,%rdi
  call   <chdir@plt>
  mov    %rax,%r8
  xor    %eax,%eax
  test   %r8,%r8
  je     L23
L12:
  mov    $0x4d,%eax
L23:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
int main(void) {
  const size_t page_len = sysconf(_SC_PAGESIZE);
  const size_t tail_len = 257;
  if (tail_len >= page_len)
    return 77;
  void *p = mmap(NULL, page_len * 2, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  if (p == MAP_FAILED || mprotect(p + page_len, page_len, PROT_NONE))
    return 77;
  memset(p, 0, page_len);
  char *addr = p + page_len - tail_len;
  memset(addr, '/', tail_len - 1);
  if (chdir(addr))
    return 77;
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  add    $0xffffffffffffff80,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x78(%rbp)
  mov    $0x0,%eax
  call   <compile_re@plt>
  jmp    L58
L57:
  cmpl   $0x63,-0x78(%rbp)
  jg     L58
  mov    -0x74(%rbp),%eax
  mov    %eax,%edi
  call   <isnumber@plt>
  test   %rax,%rax
  jne    L22
  cmpl   $0x2d,-0x74(%rbp)
  je     L22
  cmpl   $0x2e,-0x74(%rbp)
  jne    L29
L22:
  mov    -0x78(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x78(%rbp)
  mov    -0x74(%rbp),%edx
  cltq
  mov    %dl,-0x70(%rbp,%rax,1)
  jmp    L58
L29:
  mov    -0x78(%rbp),%eax
  cltq
  movb   $0x0,-0x70(%rbp,%rax,1)
  lea    -0x70(%rbp),%rax
  mov    %rax,%rdi
  call   <is_number@plt>
  test   %rax,%rax
  je     L27
  lea    -0x70(%rbp),%rax
  mov    %rax,%rdi
  call   <match_print@plt>
  lea    -0x70(%rbp),%rax
  mov    %rax,%rdi
  call   <atoi@plt>
  mov    %eax,%edi
  call   <printd@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
L27:
  movl   $0x0,-0x78(%rbp)
L58:
  mov    $0x0,%eax
  call   <getchar@plt>
  mov    %eax,-0x74(%rbp)
  mov    D0(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x74(%rbp)
  jne    L57
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L43
  call   <__stack_chk_fail@plt>
L43:
  leave
  ret
```

assistant: ```c
int main(void) {
  int character, element = 0;
  char string[100];
  compile_re();
  while ((character = getchar()) != EOF) {
    if (element < 100) {
      if (isnumber(character) || character == '-' || character == '.')
        string[element++] = character;
      else {
        string[element] = '\0';
        if (is_number(string)) {
          match_print(string);
          printd(atoi(string));
          putchar('\n');
        }
        element = 0;
      }
    }
  }
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x70,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x68(%rsp)
  xor    %eax,%eax
  call   <compile_re@plt>
  mov    $0x0,%ebp
  mov    %rsp,%r12
L15:
  mov    $0x0,%eax
  call   <getchar@plt>
  mov    %eax,%ebx
  mov    D5(%rip),%rax
  cmp    %ebx,(%rax)
  je     L42
  cmp    $0x63,%ebp
  jg     L15
  mov    %ebx,%edi
  call   <isnumber@plt>
  test   %rax,%rax
  jne    L26
  lea    -0x2d(%rbx),%eax
  cmp    $0x1,%eax
  ja     L22
L26:
  movslq %ebp,%rax
  mov    %bl,(%rsp,%rax,1)
  lea    0x1(%rbp),%ebp
  jmp    L15
L22:
  movslq %ebp,%rbp
  movb   $0x0,(%rsp,%rbp,1)
  mov    %r12,%rdi
  call   <is_number@plt>
  mov    $0x0,%ebp
  test   %rax,%rax
  je     L15
  mov    %r12,%rdi
  call   <match_print@plt>
  mov    %r12,%rdi
  call   <atoi@plt>
  mov    %eax,%edi
  call   <printd@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  jmp    L15
L42:
  mov    0x68(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L65
  mov    $0x0,%eax
  add    $0x70,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L65:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main(void) {
  int character, element = 0;
  char string[100];
  compile_re();
  while ((character = getchar()) != EOF) {
    if (element < 100) {
      if (isnumber(character) || character == '-' || character == '.')
        string[element++] = character;
      else {
        string[element] = '\0';
        if (is_number(string)) {
          match_print(string);
          printd(atoi(string));
          putchar('\n');
        }
        element = 0;
      }
    }
  }
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  sub    $0x78,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x68(%rsp)
  xor    %eax,%eax
  mov    %rsp,%r13
  call   <compile_re@plt>
  mov    D2(%rip),%r12
  jmp    L84
  nopl   0x0(%rax)
L86:
  cmp    $0x63,%ebp
  jle    L39
L84:
  xor    %eax,%eax
  call   <getchar@plt>
  mov    %eax,%ebx
  cmp    %eax,(%r12)
  jne    L86
  mov    0x68(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L88
  add    $0x78,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L39:
  mov    %ebx,%edi
  call   <isnumber@plt>
  test   %rax,%rax
  je     L0
L73:
  movslq %ebp,%rax
  add    $0x1,%ebp
  mov    %bl,(%rsp,%rax,1)
  jmp    L84
L0:
  lea    -0x2d(%rbx),%eax
  cmp    $0x1,%eax
  jbe    L73
  movslq %ebp,%rbp
  mov    %r13,%rdi
  movb   $0x0,(%rsp,%rbp,1)
  xor    %ebp,%ebp
  call   <is_number@plt>
  test   %rax,%rax
  je     L84
  mov    %r13,%rdi
  call   <match_print@plt>
  mov    %r13,%rdi
  call   <atoi@plt>
  mov    %eax,%edi
  call   <printd@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  jmp    L84
L88:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main(void) {
  int character, element = 0;
  char string[100];
  compile_re();
  while ((character = getchar()) != EOF) {
    if (element < 100) {
      if (isnumber(character) || character == '-' || character == '.')
        string[element++] = character;
      else {
        string[element] = '\0';
        if (is_number(string)) {
          match_print(string);
          printd(atoi(string));
          putchar('\n');
        }
        element = 0;
      }
    }
  }
  return 0;
}
```
user: What is the c source code of the assembly code below?

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  push   %rbx
  sub    $0x78,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x68(%rsp)
  xor    %eax,%eax
  mov    %rsp,%r13
  call   <compile_re@plt>
  mov    D5(%rip),%rbx
L82:
  xor    %eax,%eax
  call   <getchar@plt>
  mov    %eax,%ebp
  cmp    %eax,(%rbx)
  je     L44
  mov    %ebp,%edi
  call   <isnumber@plt>
  test   %rax,%rax
  je     L31
L12:
  movslq %r12d,%rax
  lea    0x1(%r12),%edx
  mov    %bpl,(%rsp,%rax,1)
  cmp    $0x63,%r12d
  jne    L23
  nopl   0x0(%rax,%rax,1)
L40:
  xor    %eax,%eax
  call   <getchar@plt>
  cmp    (%rbx),%eax
  jne    L40
L44:
  mov    0x68(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L32
  add    $0x78,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L31:
  lea    -0x2d(%rbp),%eax
  cmp    $0x1,%eax
  jbe    L12
  mov    %r13,%rdi
  movb   $0x0,(%rsp,%r12,1)
  call   <is_number@plt>
  test   %rax,%rax
  jne    L47
L48:
  xor    %edx,%edx
L23:
  movslq %edx,%r12
  jmp    L82
L47:
  mov    %r13,%rdi
  call   <match_print@plt>
  mov    %r13,%rdi
  call   <atoi@plt>
  mov    %eax,%edi
  call   <printd@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  jmp    L48
L32:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main(void) {
  int character, element = 0;
  char string[100];
  compile_re();
  while ((character = getchar()) != EOF) {
    if (element < 100) {
      if (isnumber(character) || character == '-' || character == '.')
        string[element++] = character;
      else {
        string[element] = '\0';
        if (is_number(string)) {
          match_print(string);
          printd(atoi(string));
          putchar('\n');
        }
        element = 0;
      }
    }
  }
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<assign_class_id_compute_total_cost>:
  endbr64
  movq   $0x0,(%r9)
  test   %edi,%edi
  jle    L72
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %esi,%ebx
  mov    %rdx,%r11
  mov    %rcx,%r12
  mov    %r8,%rbp
  mov    %r9,%r13
  mov    %edi,%r9d
  lea    -0x2(%rsi),%eax
  lea    0x8(%rcx,%rax,4),%r8
  mov    $0x0,%ecx
  jmp    L34
L4:
  sub    %ecx,%eax
  cltq
  mov    (%r11,%rcx,8),%rdx
  movsd  -0x8(%rdx,%rax,8),%xmm1
  jmp    L26
L20:
  jge    L44
  movslq %eax,%r14
  mov    %r10d,%esi
  sub    %eax,%esi
  movslq %esi,%rsi
  mov    (%r11,%r14,8),%r14
  movsd  -0x8(%r14,%rsi,8),%xmm0
  jmp    L73
L44:
  mov    %eax,0x0(%rbp,%rcx,4)
  pxor   %xmm1,%xmm1
L2:
  addsd  0x0(%r13),%xmm1
  movsd  %xmm1,0x0(%r13)
L64:
  add    $0x1,%rcx
  cmp    %r9,%rcx
  je     L1
L34:
  mov    %ecx,%r10d
  mov    (%r12),%eax
  mov    %eax,0x0(%rbp,%rcx,4)
  mov    %ecx,%edi
  cmp    %ecx,%eax
  jg     L4
  jge    L64
  movslq %eax,%rsi
  mov    %ecx,%edx
  sub    %eax,%edx
  movslq %edx,%rax
  mov    (%r11,%rsi,8),%rdx
  movsd  -0x8(%rdx,%rax,8),%xmm1
L26:
  lea    0x4(%r12),%rdx
  cmp    $0x1,%ebx
  jg     L30
  jmp    L2
L108:
  add    $0x4,%rdx
  cmp    %r8,%rdx
  je     L2
L30:
  mov    (%rdx),%eax
  cmp    %edi,%eax
  jle    L20
  mov    %eax,%esi
  sub    %r10d,%esi
  movslq %esi,%rsi
  mov    (%r11,%rcx,8),%r14
  movsd  -0x8(%r14,%rsi,8),%xmm0
L73:
  comisd %xmm0,%xmm1
  jbe    L108
  mov    %eax,0x0(%rbp,%rcx,4)
  movapd %xmm0,%xmm1
  jmp    L108
L1:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L72:
  ret
```

assistant: ```c
void assign_class_id_compute_total_cost(int N_X, int K, double **EDM, int *center_id, int *new_class_id, double *new_total_cost) {
  int n_X, k;
  double tmp_dist, dist;
  *new_total_cost = 0.0;
  for (n_X = 0; n_X < N_X; n_X++) {
    new_class_id[n_X] = center_id[0];
    if (n_X < center_id[0]) {
      dist = EDM[n_X][center_id[0] - n_X - 1];
    } else if (n_X > center_id[0]) {
      dist = EDM[center_id[0]][n_X - center_id[0] - 1];
    } else {
      continue;
    }
    for (k = 1; k < K; k++) {
      if (n_X < center_id[k]) {
        tmp_dist = EDM[n_X][center_id[k] - n_X - 1];
      } else if (n_X > center_id[k]) {
        tmp_dist = EDM[center_id[k]][n_X - center_id[k] - 1];
      } else {
        new_class_id[n_X] = center_id[k];
        dist = 0.0;
        break;
      }
      if (tmp_dist < dist) {
        new_class_id[n_X] = center_id[k];
        dist = tmp_dist;
      }
    }
    *new_total_cost += dist;
  }
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<assign_class_id_compute_total_cost>:
  endbr64
  movq   $0x0,(%r9)
  test   %edi,%edi
  jle    L34
  lea    -0x2(%rsi),%eax
  push   %r14
  mov    %rdx,%r11
  push   %r13
  mov    %r9,%r13
  movslq %edi,%r9
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  mov    %r8,%rbp
  lea    0x8(%rcx,%rax,4),%r8
  xor    %ecx,%ecx
  push   %rbx
  mov    %esi,%ebx
  jmp    L72
  nopl   0x0(%rax,%rax,1)
L137:
  add    $0x1,%rcx
  cmp    %rcx,%r9
  je     L77
L72:
  mov    (%r12),%eax
  mov    %ecx,%edi
  mov    %ecx,%r10d
  mov    %eax,0x0(%rbp,%rcx,4)
  cmp    %ecx,%eax
  jg     L55
  jge    L137
  mov    %ecx,%edx
  movslq %eax,%rsi
  sub    %eax,%edx
  movslq %edx,%rax
  mov    (%r11,%rsi,8),%rdx
  movsd  -0x8(%rdx,%rax,8),%xmm1
L79:
  lea    0x4(%r12),%rax
  cmp    $0x1,%ebx
  jg     L35
  jmp    L37
  nopl   0x0(%rax)
L42:
  mov    %edx,%esi
  mov    (%r11,%rcx,8),%r14
  sub    %edi,%esi
  movslq %esi,%rsi
  movsd  -0x8(%r14,%rsi,8),%xmm0
L126:
  comisd %xmm0,%xmm1
  jbe    L22
  mov    %edx,0x0(%rbp,%rcx,4)
  movapd %xmm0,%xmm1
L22:
  add    $0x4,%rax
  cmp    %r8,%rax
  je     L37
L35:
  mov    (%rax),%edx
  cmp    %r10d,%edx
  jg     L42
  jge    L115
  movslq %edx,%r14
  mov    %edi,%esi
  mov    (%r11,%r14,8),%r14
  sub    %edx,%esi
  movslq %esi,%rsi
  movsd  -0x8(%r14,%rsi,8),%xmm0
  jmp    L126
  nopl   0x0(%rax)
L115:
  mov    %edx,0x0(%rbp,%rcx,4)
  pxor   %xmm1,%xmm1
L37:
  addsd  0x0(%r13),%xmm1
  add    $0x1,%rcx
  movsd  %xmm1,0x0(%r13)
  cmp    %rcx,%r9
  jne    L72
L77:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopw   0x0(%rax,%rax,1)
L55:
  mov    (%r11,%rcx,8),%rdx
  sub    %ecx,%eax
  cltq
  movsd  -0x8(%rdx,%rax,8),%xmm1
  jmp    L79
L34:
  ret
```

assistant: ```c
void assign_class_id_compute_total_cost(int N_X, int K, double **EDM, int *center_id, int *new_class_id, double *new_total_cost) {
  int n_X, k;
  double tmp_dist, dist;
  *new_total_cost = 0.0;
  for (n_X = 0; n_X < N_X; n_X++) {
    new_class_id[n_X] = center_id[0];
    if (n_X < center_id[0]) {
      dist = EDM[n_X][center_id[0] - n_X - 1];
    } else if (n_X > center_id[0]) {
      dist = EDM[center_id[0]][n_X - center_id[0] - 1];
    } else {
      continue;
    }
    for (k = 1; k < K; k++) {
      if (n_X < center_id[k]) {
        tmp_dist = EDM[n_X][center_id[k] - n_X - 1];
      } else if (n_X > center_id[k]) {
        tmp_dist = EDM[center_id[k]][n_X - center_id[k] - 1];
      } else {
        new_class_id[n_X] = center_id[k];
        dist = 0.0;
        break;
      }
      if (tmp_dist < dist) {
        new_class_id[n_X] = center_id[k];
        dist = tmp_dist;
      }
    }
    *new_total_cost += dist;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<assign_class_id_compute_total_cost>:
  endbr64
  movq   $0x0,(%r9)
  test   %edi,%edi
  jle    L117
  lea    -0x2(%rsi),%eax
  push   %r14
  mov    %rdx,%r11
  push   %r13
  mov    %r9,%r13
  movslq %edi,%r9
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  mov    %r8,%rbp
  lea    0x8(%rcx,%rax,4),%r8
  xor    %ecx,%ecx
  push   %rbx
  mov    %esi,%ebx
  jmp    L74
  nopl   0x0(%rax,%rax,1)
L123:
  add    $0x1,%rcx
  cmp    %rcx,%r9
  je     L9
L74:
  mov    (%r12),%eax
  mov    %ecx,%edi
  mov    %ecx,%r10d
  mov    %eax,0x0(%rbp,%rcx,4)
  cmp    %ecx,%eax
  jg     L1
  jge    L123
  mov    %ecx,%edx
  movslq %eax,%rsi
  sub    %eax,%edx
  movslq %edx,%rax
  mov    (%r11,%rsi,8),%rdx
  movsd  -0x8(%rdx,%rax,8),%xmm1
L55:
  lea    0x4(%r12),%rax
  cmp    $0x1,%ebx
  jg     L129
  jmp    L4
  nopl   0x0(%rax)
L88:
  mov    %edx,%esi
  mov    (%r11,%rcx,8),%r14
  sub    %edi,%esi
  movslq %esi,%rsi
  movsd  -0x8(%r14,%rsi,8),%xmm0
L25:
  comisd %xmm0,%xmm1
  jbe    L50
  mov    %edx,0x0(%rbp,%rcx,4)
  movapd %xmm0,%xmm1
L50:
  add    $0x4,%rax
  cmp    %rax,%r8
  je     L4
L129:
  mov    (%rax),%edx
  cmp    %r10d,%edx
  jg     L88
  jge    L132
  movslq %edx,%r14
  mov    %edi,%esi
  mov    (%r11,%r14,8),%r14
  sub    %edx,%esi
  movslq %esi,%rsi
  movsd  -0x8(%r14,%rsi,8),%xmm0
  jmp    L25
  nopl   0x0(%rax)
L132:
  mov    %edx,0x0(%rbp,%rcx,4)
  pxor   %xmm1,%xmm1
L4:
  addsd  0x0(%r13),%xmm1
  add    $0x1,%rcx
  movsd  %xmm1,0x0(%r13)
  cmp    %rcx,%r9
  jne    L74
L9:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopw   0x0(%rax,%rax,1)
L1:
  mov    (%r11,%rcx,8),%rdx
  sub    %ecx,%eax
  cltq
  movsd  -0x8(%rdx,%rax,8),%xmm1
  jmp    L55
L117:
  ret
```

assistant: ```c
void assign_class_id_compute_total_cost(int N_X, int K, double **EDM, int *center_id, int *new_class_id, double *new_total_cost) {
  int n_X, k;
  double tmp_dist, dist;
  *new_total_cost = 0.0;
  for (n_X = 0; n_X < N_X; n_X++) {
    new_class_id[n_X] = center_id[0];
    if (n_X < center_id[0]) {
      dist = EDM[n_X][center_id[0] - n_X - 1];
    } else if (n_X > center_id[0]) {
      dist = EDM[center_id[0]][n_X - center_id[0] - 1];
    } else {
      continue;
    }
    for (k = 1; k < K; k++) {
      if (n_X < center_id[k]) {
        tmp_dist = EDM[n_X][center_id[k] - n_X - 1];
      } else if (n_X > center_id[k]) {
        tmp_dist = EDM[center_id[k]][n_X - center_id[k] - 1];
      } else {
        new_class_id[n_X] = center_id[k];
        dist = 0.0;
        break;
      }
      if (tmp_dist < dist) {
        new_class_id[n_X] = center_id[k];
        dist = tmp_dist;
      }
    }
    *new_total_cost += dist;
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<test_misbehave>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movabs $0x6f77206f6c6c6548,%rax
  movabs $0x6d6f726620646c72,%rdx
  mov    %rax,-0x30(%rbp)
  mov    %rdx,-0x28(%rbp)
  movabs $0x2072657375206120,%rax
  movabs $0x216d6172676f7270,%rdx
  mov    %rax,-0x20(%rbp)
  mov    %rdx,-0x18(%rbp)
  movw   $0xa,-0x10(%rbp)
  mov    D25(%rip),%rax
  mov    (%rax),%eax
  lea    -0x30(%rbp),%rcx
  mov    $0x21,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  cmp    $0x21,%eax
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    D25(%rip),%rax
  mov    (%rax),%eax
  mov    $0x64,%edx
  mov    $0xdeadc0de,%ecx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  cmp    $0xffffffff,%eax
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    D35(%rip),%rax
  mov    (%rax),%rdx
  mov    D20(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    D25(%rip),%rax
  mov    (%rax),%eax
  mov    $0x64,%edx
  mov    $0x1ee7c0de,%esi
  mov    %eax,%edi
  call   <write@plt>
  cmp    $0xffffffff,%eax
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    D35(%rip),%rax
  mov    (%rax),%rdx
  mov    D20(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L8
  call   <__stack_chk_fail@plt>
L8:
  leave
  ret
```

assistant: ```c
int test_misbehave() {
  const char str[] = "Hello world from a user program!\n";
  assert(write(STDOUT_FILENO, str, sizeof(str) - 1) == sizeof(str) - 1);
  assert(write(STDOUT_FILENO, (char *)0xDEADC0DE, 100) == -1);
  assert(errno == EFAULT);
  assert(write(STDOUT_FILENO, (char *)0x1EE7C0DE, 100) == -1);
  assert(errno == EFAULT);
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<test_misbehave>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x30,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  movabs $0x6f77206f6c6c6548,%rax
  movabs $0x6d6f726620646c72,%rdx
  mov    %rax,(%rsp)
  mov    %rdx,0x8(%rsp)
  movabs $0x2072657375206120,%rax
  movabs $0x216d6172676f7270,%rdx
  mov    %rax,0x10(%rsp)
  mov    %rdx,0x18(%rsp)
  movw   $0xa,0x20(%rsp)
  mov    %rsp,%rsi
  mov    D1(%rip),%rbx
  mov    $0x21,%edx
  mov    (%rbx),%edi
  call   <write@plt>
  cmp    $0x21,%eax
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    $0x64,%edx
  mov    $0xdeadc0de,%esi
  mov    (%rbx),%edi
  call   <write@plt>
  cmp    $0xffffffff,%eax
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    D8(%rip),%r12
  mov    D20(%rip),%rbp
  mov    0x0(%rbp),%rax
  cmp    %rax,(%r12)
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    $0x64,%edx
  mov    $0x1ee7c0de,%esi
  mov    (%rbx),%edi
  call   <write@plt>
  cmp    $0xffffffff,%eax
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x0(%rbp),%rax
  cmp    %rax,(%r12)
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L6
  mov    $0x0,%eax
  add    $0x30,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L6:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int test_misbehave() {
  const char str[] = "Hello world from a user program!\n";
  assert(write(STDOUT_FILENO, str, sizeof(str) - 1) == sizeof(str) - 1);
  assert(write(STDOUT_FILENO, (char *)0xDEADC0DE, 100) == -1);
  assert(errno == EFAULT);
  assert(write(STDOUT_FILENO, (char *)0x1EE7C0DE, 100) == -1);
  assert(errno == EFAULT);
  return 0;
}
```