ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<main>:
  endbr64
  push   %rbp
  lea    D0(%rip),%rdi
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  lea    -0x3c(%rbp),%rdx
  lea    -0x40(%rbp),%rsi
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  call   <scanf@plt>
  movslq -0x40(%rbp),%rdx
  mov    %rsp,%rsi
  mov    %rdx,%rax
  lea    0xf(,%rdx,4),%rdx
  mov    %rdx,%rcx
  and    $0xfffffffffffff000,%rdx
  sub    %rdx,%rsi
  and    $0xfffffffffffffff0,%rcx
  cmp    %rsi,%rsp
  je     L92
L155:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L155
L92:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  jne    L127
L84:
  mov    %rsp,%r15
  test   %eax,%eax
  jle    L68
  mov    %r15,%r12
  xor    %ebx,%ebx
  lea    D25(%rip),%r13
  nopw   0x0(%rax,%rax,1)
L147:
  mov    %r12,%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  add    $0x1,%ebx
  call   <scanf@plt>
  mov    -0x40(%rbp),%eax
  add    $0x4,%r12
  cmp    %ebx,%eax
  jg     L147
L68:
  cmp    %eax,-0x3c(%rbp)
  jle    L149
  mov    %eax,-0x3c(%rbp)
L149:
  mov    $0xa,%edi
  xor    %r12d,%r12d
  lea    D39(%rip),%r13
  call   <putchar@plt>
  mov    -0x3c(%rbp),%eax
  lea    D5(%rip),%rbx
  test   %eax,%eax
  jle    L10
  nopl   (%rax)
L132:
  mov    -0x40(%rbp),%esi
  lea    0x1(%r12),%eax
  mov    (%r15,%r12,4),%r8d
  movslq %r12d,%rdi
  cmp    %eax,%esi
  jle    L115
  cltq
  mov    %r8d,%ecx
L128:
  mov    (%r15,%rax,4),%edx
  cmp    %ecx,%edx
  jle    L107
  mov    %edx,%ecx
  movslq %eax,%rdi
L107:
  add    $0x1,%rax
  cmp    %eax,%esi
  jg     L128
  mov    %r8d,(%r15,%rdi,4)
  mov    %ecx,(%r15,%r12,4)
L145:
  xor    %r14d,%r14d
L20:
  mov    (%r15,%r14,4),%esi
  mov    %rbx,%rdi
  xor    %eax,%eax
  add    $0x1,%r14
  call   <printf@plt>
  cmp    %r14d,-0x40(%rbp)
  jg     L20
L64:
  mov    %r13,%rdi
  add    $0x1,%r12
  call   <puts@plt>
  cmp    %r12d,-0x3c(%rbp)
  jg     L132
L10:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L37
  lea    -0x28(%rbp),%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopw   0x0(%rax,%rax,1)
L115:
  test   %esi,%esi
  jle    L64
  jmp    L145
L127:
  orq    $0x0,-0x8(%rsp,%rcx,1)
  jmp    L84
L37:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_label: D0
type_guessed: string
name: retrieve_data
arguments: data_label: D25
type_guessed: string
name: retrieve_data
arguments: data_label: D39
type_guessed: string
name: retrieve_data
arguments: data_label: D5
type_guessed: string

tool: D0: %d %d

tool: D25: %d

tool: D39: 



tool: D5: %d 

assistant: ```c
int main() {
  int n, k, i, j;
  scanf("%d %d", &n, &k);
  int array[n];
  for (i = 0; i < n; i++)
    scanf("%d", &array[i]);
  if (k > n)
    k = n;
  printf("\n");
  for (j = 0; j < k; j++) {
    int l, max = j;
    for (l = j + 1; l < n; l++)
      if (array[l] > array[max])
        max = l;
    int t;
    t = array[max];
    array[max] = array[j];
    array[j] = t;
    for (i = 0; i < n; i++)
      printf("%d ", array[i]);
    printf("\n\n\n");
  }
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<scsleep>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x0,-0x14(%rbp)
  je     L1
  mov    -0x14(%rbp),%eax
  add    $0x1,%eax
  movslq %eax,%rdx
  imul   $0x10624dd3,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x6,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  imul   $0x10624dd3,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x6,%edx
  mov    %eax,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%edx
  imul   $0x3e8,%edx,%ecx
  sub    %ecx,%eax
  mov    %eax,%edx
  imul   $0x3e8,%edx,%eax
  mov    %eax,-0xc(%rbp)
  lea    -0x10(%rbp),%rax
  mov    %rax,%r8
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    $0x0,%edi
  call   <select@plt>
  jmp    L26
L1:
  nop
L26:
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L17
  call   <__stack_chk_fail@plt>
L17:
  leave
  ret
```

assistant: ```c
void scsleep(int ms) {
  struct timeval tv;
  if (!ms)
    return;
  tv.tv_sec = (ms + 1) / 1000;
  tv.tv_usec = (ms % 1000) * 1000;
  select(0, NULL, NULL, NULL, &tv);
}
```
user: Translate the below assembly code into C programming language:

```asm
<scsleep>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  jne    L19
L23:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L15
  add    $0x18,%rsp
  ret
L19:
  lea    0x1(%rdi),%edx
  movslq %edx,%rax
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  sar    $0x1f,%edx
  sub    %edx,%eax
  mov    %eax,(%rsp)
  movslq %edi,%rax
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  mov    %edi,%edx
  sar    $0x1f,%edx
  sub    %edx,%eax
  imul   $0x3e8,%eax,%eax
  sub    %eax,%edi
  imul   $0x3e8,%edi,%edi
  mov    %edi,0x4(%rsp)
  mov    %rsp,%r8
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    $0x0,%edi
  call   <select@plt>
  jmp    L23
L15:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void scsleep(int ms) {
  struct timeval tv;
  if (!ms)
    return;
  tv.tv_sec = (ms + 1) / 1000;
  tv.tv_usec = (ms % 1000) * 1000;
  select(0, NULL, NULL, NULL, &tv);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<scsleep>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  je     L5
  lea    0x1(%rdi),%edx
  mov    %rsp,%r8
  xor    %ecx,%ecx
  xor    %esi,%esi
  movslq %edx,%rax
  sar    $0x1f,%edx
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  sub    %edx,%eax
  mov    %edi,%edx
  mov    %eax,(%rsp)
  movslq %edi,%rax
  sar    $0x1f,%edx
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  sub    %edx,%eax
  xor    %edx,%edx
  imul   $0x3e8,%eax,%eax
  sub    %eax,%edi
  imul   $0x3e8,%edi,%edi
  mov    %edi,0x4(%rsp)
  xor    %edi,%edi
  call   <select@plt>
L5:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L6
  add    $0x18,%rsp
  ret
L6:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void scsleep(int ms) {
  struct timeval tv;
  if (!ms)
    return;
  tv.tv_sec = (ms + 1) / 1000;
  tv.tv_usec = (ms % 1000) * 1000;
  select(0, NULL, NULL, NULL, &tv);
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<scsleep>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  je     L0
  lea    0x1(%rdi),%edx
  mov    %edi,%ecx
  mov    %rsp,%r8
  xor    %esi,%esi
  movslq %edx,%rax
  sar    $0x1f,%edx
  imul   $0x10624dd3,%rax,%rax
  sar    $0x1f,%ecx
  sar    $0x26,%rax
  sub    %edx,%eax
  movslq %edi,%rdx
  imul   $0x10624dd3,%rdx,%rdx
  movd   %eax,%xmm0
  sar    $0x26,%rdx
  sub    %ecx,%edx
  xor    %ecx,%ecx
  imul   $0x3e8,%edx,%edx
  sub    %edx,%edi
  xor    %edx,%edx
  imul   $0x3e8,%edi,%edi
  movd   %edi,%xmm1
  xor    %edi,%edi
  punpckldq %xmm1,%xmm0
  movq   %xmm0,(%rsp)
  call   <select@plt>
L0:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L8
  add    $0x18,%rsp
  ret
L8:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void scsleep(int ms) {
  struct timeval tv;
  if (!ms)
    return;
  tv.tv_sec = (ms + 1) / 1000;
  tv.tv_usec = (ms % 1000) * 1000;
  select(0, NULL, NULL, NULL, &tv);
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<test1>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  setg   %al
  movzbl %al,%eax
  pop    %rbp
  ret
```

assistant: ```c
int test1(int i) {
  enum en { zero };
  return i > zero;
}
```
user: What is the c source code of the assembly code below?

```asm
<test1>:
  endbr64
  test   %edi,%edi
  setg   %al
  movzbl %al,%eax
  ret
```

assistant: ```c
int test1(int i) {
  enum en { zero };
  return i > zero;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<test1>:
  endbr64
  xor    %eax,%eax
  test   %edi,%edi
  setg   %al
  ret
```

assistant: ```c
int test1(int i) {
  enum en { zero };
  return i > zero;
}
```
user: Translate the below assembly code into C programming language:

```asm
<test1>:
  endbr64
  xor    %eax,%eax
  test   %edi,%edi
  setg   %al
  ret
```

assistant: ```c
int test1(int i) {
  enum en { zero };
  return i > zero;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<categorize_pixels>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %esi,-0x4c(%rbp)
  mov    %rdx,-0x58(%rbp)
  mov    %rcx,-0x60(%rbp)
  mov    %r8d,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x24(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L22
L29:
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  lea    -0x30(%rbp),%rcx
  lea    -0x31(%rbp),%rdx
  lea    -0x32(%rbp),%rsi
  mov    %eax,%edi
  call   <bm_get_rgb@plt>
  mov    D3(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x20(%rbp)
  movl   $0x0,-0x1c(%rbp)
  movl   $0x0,-0x28(%rbp)
  jmp    L9
L42:
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  lea    -0x2d(%rbp),%rcx
  lea    -0x2e(%rbp),%rdx
  lea    -0x2f(%rbp),%rsi
  mov    %eax,%edi
  call   <bm_get_rgb@plt>
  movzbl -0x32(%rbp),%eax
  movzbl %al,%eax
  movzbl -0x2f(%rbp),%edx
  movzbl %dl,%edx
  sub    %edx,%eax
  mov    %eax,-0x18(%rbp)
  movzbl -0x31(%rbp),%eax
  movzbl %al,%eax
  movzbl -0x2e(%rbp),%edx
  movzbl %dl,%edx
  sub    %edx,%eax
  mov    %eax,-0x14(%rbp)
  movzbl -0x30(%rbp),%eax
  movzbl %al,%eax
  movzbl -0x2d(%rbp),%edx
  movzbl %dl,%edx
  sub    %edx,%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x18(%rbp),%eax
  imul   %eax,%eax
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  imul   %eax,%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%eax
  imul   %eax,%eax
  add    %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  cmp    -0x20(%rbp),%eax
  jge    L51
  mov    -0xc(%rbp),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
L51:
  addl   $0x1,-0x28(%rbp)
L9:
  mov    -0x28(%rbp),%eax
  cmp    %eax,-0x50(%rbp)
  ja     L42
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x1c(%rbp)
  je     L16
  addl   $0x1,-0x24(%rbp)
L16:
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x58(%rbp),%rax
  add    %rax,%rdx
  mov    -0x1c(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x2c(%rbp)
L22:
  mov    -0x2c(%rbp),%eax
  cmp    -0x4c(%rbp),%eax
  jl     L29
  mov    -0x24(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L34
  call   <__stack_chk_fail@plt>
L34:
  leave
  ret
```

assistant: ```c
int categorize_pixels(unsigned int *bytes, int np, int *cat, unsigned int *pal, unsigned int K) {
  int i, k, change = 0;
  for (i = 0; i < np; i++) {
    unsigned char iR, iG, iB;
    bm_get_rgb(bytes[i], &iR, &iG, &iB);
    int minD = INT_MAX, dk = 0;
    for (k = 0; k < K; k++) {
      unsigned char pR, pG, pB;
      bm_get_rgb(pal[k], &pR, &pG, &pB);
      int dR = (int)iR - (int)pR;
      int dG = (int)iG - (int)pG;
      int dB = (int)iB - (int)pB;
      int d = dR * dR + dG * dG + dB * dB;
      if (d < minD) {
        minD = d;
        dk = k;
      }
    }
    if (cat[i] != dk)
      change++;
    cat[i] = dk;
  }
  return change;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<categorize_pixels>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rcx,%r14
  mov    %r8d,0x1c(%rsp)
  mov    %fs:0x28,%rcx
  mov    %rcx,0x38(%rsp)
  xor    %ecx,%ecx
  test   %esi,%esi
  jle    L88
  mov    %rdi,0x10(%rsp)
  mov    %rdx,%r15
  lea    -0x1(%rsi),%edx
  lea    0x4(%rdi,%rdx,4),%rax
  mov    %rax,0x20(%rsp)
  movl   $0x0,0x18(%rsp)
  lea    0x34(%rsp),%rax
  mov    %rax,0x28(%rsp)
  jmp    L41
L22:
  add    $0x1,%rbx
  cmp    %r13,%rbx
  je     L20
L45:
  lea    0x36(%rsp),%rdx
  lea    0x35(%rsp),%rsi
  mov    (%r14,%rbx,4),%edi
  mov    %r12,%rcx
  call   <bm_get_rgb@plt>
  movzbl 0x32(%rsp),%eax
  movzbl 0x35(%rsp),%edx
  sub    %edx,%eax
  movzbl 0x33(%rsp),%ecx
  movzbl 0x36(%rsp),%edx
  sub    %edx,%ecx
  movzbl 0x34(%rsp),%edx
  movzbl 0x37(%rsp),%esi
  sub    %esi,%edx
  imul   %eax,%eax
  imul   %ecx,%ecx
  add    %ecx,%eax
  imul   %edx,%edx
  add    %edx,%eax
  cmp    %ebp,%eax
  jge    L22
  mov    %ebx,0xc(%rsp)
  mov    %eax,%ebp
  jmp    L22
L47:
  movl   $0x0,0xc(%rsp)
L20:
  mov    0xc(%rsp),%edi
  cmp    %edi,(%r15)
  setne  %al
  movzbl %al,%eax
  add    %eax,0x18(%rsp)
  mov    %edi,(%r15)
  addq   $0x4,0x10(%rsp)
  mov    0x10(%rsp),%rax
  add    $0x4,%r15
  cmp    0x20(%rsp),%rax
  je     L42
L41:
  lea    0x33(%rsp),%rdx
  lea    0x32(%rsp),%rsi
  mov    0x28(%rsp),%rcx
  mov    0x10(%rsp),%rax
  mov    (%rax),%edi
  call   <bm_get_rgb@plt>
  mov    D6(%rip),%rax
  mov    (%rax),%ebp
  mov    0x1c(%rsp),%eax
  test   %eax,%eax
  je     L47
  mov    %eax,%r13d
  mov    $0x0,%ebx
  movl   $0x0,0xc(%rsp)
  lea    0x37(%rsp),%r12
  jmp    L45
L88:
  movl   $0x0,0x18(%rsp)
L42:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L83
  mov    0x18(%rsp),%eax
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L83:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int categorize_pixels(unsigned int *bytes, int np, int *cat, unsigned int *pal, unsigned int K) {
  int i, k, change = 0;
  for (i = 0; i < np; i++) {
    unsigned char iR, iG, iB;
    bm_get_rgb(bytes[i], &iR, &iG, &iB);
    int minD = INT_MAX, dk = 0;
    for (k = 0; k < K; k++) {
      unsigned char pR, pG, pB;
      bm_get_rgb(pal[k], &pR, &pG, &pB);
      int dR = (int)iR - (int)pR;
      int dG = (int)iG - (int)pG;
      int dB = (int)iB - (int)pB;
      int d = dR * dR + dG * dG + dB * dB;
      if (d < minD) {
        minD = d;
        dk = k;
      }
    }
    if (cat[i] != dk)
      change++;
    cat[i] = dk;
  }
  return change;
}
```
user: Translate the below assembly code into C programming language:

```asm
<categorize_pixels>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %r8d,0x2c(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  test   %esi,%esi
  jle    L77
  lea    -0x1(%rsi),%eax
  mov    %rdi,0x18(%rsp)
  mov    %rcx,%r15
  lea    0x4(%rdi,%rax,4),%rax
  mov    %rdx,0x20(%rsp)
  mov    %rax,0x30(%rsp)
  lea    0x54(%rsp),%rax
  mov    %rax,0x48(%rsp)
  lea    0x53(%rsp),%rax
  mov    %rax,0x40(%rsp)
  lea    0x52(%rsp),%rax
  movl   $0x0,0x28(%rsp)
  mov    %rax,0x38(%rsp)
  nop
L68:
  mov    0x18(%rsp),%rax
  mov    0x48(%rsp),%rcx
  mov    0x40(%rsp),%rdx
  mov    0x38(%rsp),%rsi
  mov    (%rax),%edi
  call   <bm_get_rgb@plt>
  mov    D5(%rip),%rax
  mov    (%rax),%ebx
  mov    0x2c(%rsp),%eax
  test   %eax,%eax
  je     L52
  lea    0x57(%rsp),%r13
  movl   $0x0,0x14(%rsp)
  xor    %r14d,%r14d
  lea    0x56(%rsp),%r12
  lea    0x55(%rsp),%rbp
  mov    %rax,0x8(%rsp)
  mov    %r13,%rax
  mov    %r12,%r13
  mov    %rbp,%r12
  mov    %r15,%rbp
  mov    %r14,%r15
  mov    %rax,%r14
  nopl   0x0(%rax)
L54:
  mov    0x0(%rbp,%r15,4),%edi
  mov    %r14,%rcx
  mov    %r13,%rdx
  mov    %r12,%rsi
  call   <bm_get_rgb@plt>
  movzbl 0x55(%rsp),%edx
  movzbl 0x52(%rsp),%eax
  movzbl 0x53(%rsp),%ecx
  movzbl 0x57(%rsp),%esi
  sub    %edx,%eax
  movzbl 0x56(%rsp),%edx
  imul   %eax,%eax
  sub    %edx,%ecx
  movzbl 0x54(%rsp),%edx
  imul   %ecx,%ecx
  sub    %esi,%edx
  imul   %edx,%edx
  add    %ecx,%eax
  add    %edx,%eax
  cmp    %ebx,%eax
  jge    L41
  mov    %r15d,0x14(%rsp)
  mov    %eax,%ebx
L41:
  add    $0x1,%r15
  cmp    0x8(%rsp),%r15
  jne    L54
  mov    %rbp,%r15
L13:
  mov    0x20(%rsp),%rbx
  mov    0x14(%rsp),%edi
  xor    %eax,%eax
  cmp    %edi,(%rbx)
  mov    %edi,(%rbx)
  setne  %al
  add    $0x4,%rbx
  add    %eax,0x28(%rsp)
  addq   $0x4,0x18(%rsp)
  mov    0x18(%rsp),%rax
  mov    %rbx,0x20(%rsp)
  cmp    0x30(%rsp),%rax
  jne    L68
L22:
  mov    0x58(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L76
  mov    0x28(%rsp),%eax
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L52:
  movl   $0x0,0x14(%rsp)
  jmp    L13
L77:
  movl   $0x0,0x28(%rsp)
  jmp    L22
L76:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int categorize_pixels(unsigned int *bytes, int np, int *cat, unsigned int *pal, unsigned int K) {
  int i, k, change = 0;
  for (i = 0; i < np; i++) {
    unsigned char iR, iG, iB;
    bm_get_rgb(bytes[i], &iR, &iG, &iB);
    int minD = INT_MAX, dk = 0;
    for (k = 0; k < K; k++) {
      unsigned char pR, pG, pB;
      bm_get_rgb(pal[k], &pR, &pG, &pB);
      int dR = (int)iR - (int)pR;
      int dG = (int)iG - (int)pG;
      int dB = (int)iB - (int)pB;
      int d = dR * dR + dG * dG + dB * dB;
      if (d < minD) {
        minD = d;
        dk = k;
      }
    }
    if (cat[i] != dk)
      change++;
    cat[i] = dk;
  }
  return change;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<categorize_pixels>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %r8d,0x2c(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  test   %esi,%esi
  jle    L51
  lea    -0x1(%rsi),%eax
  mov    %rdi,0x18(%rsp)
  mov    %rcx,%r15
  lea    0x4(%rdi,%rax,4),%rax
  mov    %rdx,0x20(%rsp)
  mov    %rax,0x30(%rsp)
  lea    0x54(%rsp),%rax
  mov    %rax,0x48(%rsp)
  lea    0x53(%rsp),%rax
  mov    %rax,0x40(%rsp)
  lea    0x52(%rsp),%rax
  movl   $0x0,0x28(%rsp)
  mov    %rax,0x38(%rsp)
  nop
L9:
  mov    0x18(%rsp),%rax
  mov    0x48(%rsp),%rcx
  mov    0x40(%rsp),%rdx
  mov    0x38(%rsp),%rsi
  mov    (%rax),%edi
  call   <bm_get_rgb@plt>
  mov    D7(%rip),%rax
  mov    (%rax),%ebx
  mov    0x2c(%rsp),%eax
  test   %eax,%eax
  je     L19
  lea    0x57(%rsp),%r13
  movl   $0x0,0x14(%rsp)
  xor    %r14d,%r14d
  lea    0x56(%rsp),%r12
  lea    0x55(%rsp),%rbp
  mov    %rax,0x8(%rsp)
  mov    %r13,%rax
  mov    %r12,%r13
  mov    %rbp,%r12
  mov    %r15,%rbp
  mov    %r14,%r15
  mov    %rax,%r14
  nopl   0x0(%rax)
L2:
  mov    0x0(%rbp,%r15,4),%edi
  mov    %r14,%rcx
  mov    %r13,%rdx
  mov    %r12,%rsi
  call   <bm_get_rgb@plt>
  movzbl 0x55(%rsp),%edx
  movzbl 0x52(%rsp),%eax
  movzbl 0x53(%rsp),%ecx
  movzbl 0x57(%rsp),%esi
  sub    %edx,%eax
  movzbl 0x56(%rsp),%edx
  imul   %eax,%eax
  sub    %edx,%ecx
  movzbl 0x54(%rsp),%edx
  imul   %ecx,%ecx
  sub    %esi,%edx
  imul   %edx,%edx
  add    %ecx,%eax
  add    %edx,%eax
  cmp    %ebx,%eax
  jge    L12
  mov    %r15d,0x14(%rsp)
  mov    %eax,%ebx
L12:
  add    $0x1,%r15
  cmp    0x8(%rsp),%r15
  jne    L2
  mov    %rbp,%r15
L65:
  mov    0x20(%rsp),%rbx
  mov    0x14(%rsp),%edi
  xor    %eax,%eax
  cmp    %edi,(%rbx)
  mov    %edi,(%rbx)
  setne  %al
  add    $0x4,%rbx
  add    %eax,0x28(%rsp)
  addq   $0x4,0x18(%rsp)
  mov    0x18(%rsp),%rax
  mov    %rbx,0x20(%rsp)
  cmp    0x30(%rsp),%rax
  jne    L9
L58:
  mov    0x58(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L49
  mov    0x28(%rsp),%eax
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L19:
  movl   $0x0,0x14(%rsp)
  jmp    L65
L51:
  movl   $0x0,0x28(%rsp)
  jmp    L58
L49:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int categorize_pixels(unsigned int *bytes, int np, int *cat, unsigned int *pal, unsigned int K) {
  int i, k, change = 0;
  for (i = 0; i < np; i++) {
    unsigned char iR, iG, iB;
    bm_get_rgb(bytes[i], &iR, &iG, &iB);
    int minD = INT_MAX, dk = 0;
    for (k = 0; k < K; k++) {
      unsigned char pR, pG, pB;
      bm_get_rgb(pal[k], &pR, &pG, &pB);
      int dR = (int)iR - (int)pR;
      int dG = (int)iG - (int)pG;
      int dB = (int)iB - (int)pB;
      int d = dR * dR + dG * dG + dB * dB;
      if (d < minD) {
        minD = d;
        dk = k;
      }
    }
    if (cat[i] != dk)
      change++;
    cat[i] = dk;
  }
  return change;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<map2check_binop_sdiv>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %esi,-0x8(%rbp)
  mov    %edx,-0xc(%rbp)
  mov    %ecx,-0x10(%rbp)
  mov    %r8,-0x18(%rbp)
  cmpl   $0x0,-0x8(%rbp)
  jne    L2
  mov    $0x0,%eax
  call   <divisionByZeroError@plt>
L2:
  mov    D17(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x4(%rbp)
  je     L23
  mov    D17(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x8(%rbp)
  jne    L48
L23:
  cmpl   $0xffffffff,-0x4(%rbp)
  je     L10
  cmpl   $0xffffffff,-0x8(%rbp)
  jne    L48
L10:
  mov    -0x18(%rbp),%rdx
  mov    -0xc(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <overflowError@plt>
  nop
L48:
  nop
  leave
  ret
```

assistant: ```c
void map2check_binop_sdiv(int param1, int param2, unsigned line, unsigned scope, char *function_name) {
  if (param2 == 0) {
    divisionByZeroError();
  }
  if ((param1 == INT_MIN) || (param2 == INT_MIN)) {
    if ((param1 == (-1)) || (param2 == (-1))) {
      overflowError(line, function_name);
    }
  }
  return;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<map2check_binop_sdiv>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %edi,%ebp
  mov    %esi,%ebx
  mov    %edx,%r12d
  mov    %r8,%r13
  test   %esi,%esi
  je     L23
L45:
  mov    D2(%rip),%rax
  mov    (%rax),%eax
  cmp    %ebx,%eax
  je     L8
  cmp    %ebp,%eax
  je     L8
L62:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L23:
  mov    $0x0,%eax
  call   <divisionByZeroError@plt>
  jmp    L45
L8:
  cmp    $0xffffffff,%ebp
  je     L13
  cmp    $0xffffffff,%ebx
  jne    L62
L13:
  mov    %r13,%rsi
  mov    %r12d,%edi
  call   <overflowError@plt>
  jmp    L62
```

assistant: ```c
void map2check_binop_sdiv(int param1, int param2, unsigned line, unsigned scope, char *function_name) {
  if (param2 == 0) {
    divisionByZeroError();
  }
  if ((param1 == INT_MIN) || (param2 == INT_MIN)) {
    if ((param1 == (-1)) || (param2 == (-1))) {
      overflowError(line, function_name);
    }
  }
  return;
}
```
user: What is the c source code of the assembly code below:

```asm
<map2check_binop_sdiv>:
  endbr64
  push   %r13
  mov    %r8,%r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x8,%rsp
  test   %esi,%esi
  je     L33
L29:
  mov    D4(%rip),%rax
  mov    (%rax),%eax
  cmp    %ebx,%eax
  je     L17
  cmp    %ebp,%eax
  je     L17
L1:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax,%rax,1)
L17:
  cmp    $0xffffffff,%ebp
  je     L39
  cmp    $0xffffffff,%ebx
  jne    L1
L39:
  add    $0x8,%rsp
  mov    %r13,%rsi
  mov    %r12d,%edi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    1060 <overflowError@plt>
  nop
L33:
  xor    %eax,%eax
  call   <divisionByZeroError@plt>
  jmp    L29
```

assistant: ```c
void map2check_binop_sdiv(int param1, int param2, unsigned line, unsigned scope, char *function_name) {
  if (param2 == 0) {
    divisionByZeroError();
  }
  if ((param1 == INT_MIN) || (param2 == INT_MIN)) {
    if ((param1 == (-1)) || (param2 == (-1))) {
      overflowError(line, function_name);
    }
  }
  return;
}
```