ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<draw_tile>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,0x10(%rsp)
  test   %esi,%esi
  js     L102
  mov    %esi,%ebp
  lea    0x8(%rdx),%ebx
  movl   $0x0,0xc(%rsp)
  mov    %edx,%r12d
  shl    $0x6,%ebp
  mov    %ecx,%r15d
  add    0x10(%rdi),%ebp
  cmp    $0x140,%ebx
  jle    L53
  lea    -0x138(%rdx),%eax
  mov    $0x140,%ebx
  mov    %eax,0xc(%rsp)
L53:
  lea    0x8(%r15),%edx
  cmp    $0xe9,%r15d
  mov    $0xf0,%eax
  movl   $0x0,0x18(%rsp)
  cmovl  %edx,%eax
  mov    %eax,0x8(%rsp)
  test   %r12d,%r12d
  js     L88
  test   %r15d,%r15d
  js     L98
L6:
  cmp    %r15d,0x8(%rsp)
  jle    L102
  mov    %ebx,%eax
  sub    %r12d,%eax
  mov    %eax,0x1c(%rsp)
  nopl   0x0(%rax)
L51:
  add    0x18(%rsp),%ebp
  cmp    %r12d,%ebx
  jle    L100
  mov    0x10(%rsp),%rcx
  movslq %ebp,%rax
  mov    %r12d,%r13d
  lea    (%rcx,%rax,4),%r14
  nopl   0x0(%rax,%rax,1)
L74:
  mov    (%r14),%edx
  mov    %r13d,%edi
  mov    %r15d,%esi
  add    $0x1,%r13d
  add    $0x4,%r14
  call   <unsafe_draw_pixel@plt>
  cmp    %r13d,%ebx
  jne    L74
  add    0x1c(%rsp),%ebp
L100:
  add    0xc(%rsp),%ebp
  add    $0x1,%r15d
  cmp    %r15d,0x8(%rsp)
  jne    L51
L102:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L98:
  mov    %r15d,%r9d
  xor    %r15d,%r15d
  neg    %r9d
  lea    0x0(%rbp,%r9,8),%ebp
  jmp    L6
L88:
  neg    %r12d
  mov    %r12d,0x18(%rsp)
  xor    %r12d,%r12d
  test   %r15d,%r15d
  jns    L6
  jmp    L98
```

assistant: ```c
void draw_tile(int32_t *m, int32_t tile, int32_t px, int32_t py) {
  if (tile < 0)
    return;
  tile &= ~0x40000000;
  uint32_t i = m[4] + tile * 64;
  int x_pre = 0;
  int x_post = 0;
  int y_pre = 0;
  int x_lim = px + 8;
  int y_lim = py + 8;
  int x_str = px;
  int y_str = py;
  if (x_lim > 320) {
    x_lim = 320;
    x_post = 8 + px - 320;
  }
  if (8 + py > 240) {
    y_lim = 240;
  }
  if (px < 0) {
    x_str = 0;
    x_pre = -px;
  }
  if (py < 0) {
    y_str = 0;
    y_pre = -py * 8;
  }
  i += y_pre;
  for (int y = y_str; y < y_lim; y++) {
    i += x_pre;
    for (int x = x_str; x < x_lim; x++)
      unsafe_draw_pixel(x, y, m[i++]);
    i += x_post;
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<draw_tile>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,0x10(%rsp)
  test   %esi,%esi
  js     L107
  mov    %esi,%ebp
  lea    0x8(%rdx),%ebx
  movl   $0x0,0xc(%rsp)
  mov    %edx,%r12d
  shl    $0x6,%ebp
  mov    %ecx,%r15d
  add    0x10(%rdi),%ebp
  cmp    $0x140,%ebx
  jle    L0
  lea    -0x138(%rdx),%eax
  mov    $0x140,%ebx
  mov    %eax,0xc(%rsp)
L0:
  lea    0x8(%r15),%edx
  cmp    $0xe9,%r15d
  mov    $0xf0,%eax
  movl   $0x0,0x18(%rsp)
  cmovl  %edx,%eax
  mov    %eax,0x8(%rsp)
  test   %r12d,%r12d
  js     L29
  test   %r15d,%r15d
  js     L20
L87:
  cmp    %r15d,0x8(%rsp)
  jle    L107
  cmp    %r12d,%ebx
  jle    L107
  mov    %ebx,%eax
  sub    %r12d,%eax
  mov    %eax,0x1c(%rsp)
  nopl   0x0(%rax)
L17:
  mov    0x10(%rsp),%rcx
  add    0x18(%rsp),%ebp
  mov    %r12d,%r14d
  movslq %ebp,%rax
  lea    (%rcx,%rax,4),%r13
  nopl   0x0(%rax,%rax,1)
L82:
  mov    0x0(%r13),%edx
  mov    %r14d,%edi
  mov    %r15d,%esi
  add    $0x1,%r14d
  add    $0x4,%r13
  call   <unsafe_draw_pixel@plt>
  cmp    %r14d,%ebx
  jne    L82
  add    0x1c(%rsp),%ebp
  add    $0x1,%r15d
  add    0xc(%rsp),%ebp
  cmp    %r15d,0x8(%rsp)
  jne    L17
L107:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L20:
  mov    %r15d,%r9d
  xor    %r15d,%r15d
  neg    %r9d
  lea    0x0(%rbp,%r9,8),%ebp
  jmp    L87
L29:
  neg    %r12d
  mov    %r12d,0x18(%rsp)
  xor    %r12d,%r12d
  test   %r15d,%r15d
  jns    L87
  jmp    L20
```

assistant: ```c
void draw_tile(int32_t *m, int32_t tile, int32_t px, int32_t py) {
  if (tile < 0)
    return;
  tile &= ~0x40000000;
  uint32_t i = m[4] + tile * 64;
  int x_pre = 0;
  int x_post = 0;
  int y_pre = 0;
  int x_lim = px + 8;
  int y_lim = py + 8;
  int x_str = px;
  int y_str = py;
  if (x_lim > 320) {
    x_lim = 320;
    x_post = 8 + px - 320;
  }
  if (8 + py > 240) {
    y_lim = 240;
  }
  if (px < 0) {
    x_str = 0;
    x_pre = -px;
  }
  if (py < 0) {
    y_str = 0;
    y_pre = -py * 8;
  }
  i += y_pre;
  for (int y = y_str; y < y_lim; y++) {
    i += x_pre;
    for (int x = x_str; x < x_lim; x++)
      unsafe_draw_pixel(x, y, m[i++]);
    i += x_post;
  }
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<next_power_of_two>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x4(%rbp)
  subl   $0x1,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  sar    %eax
  or     %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  sar    $0x2,%eax
  or     %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  sar    $0x4,%eax
  or     %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  sar    $0x8,%eax
  or     %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  sar    $0x10,%eax
  or     %eax,-0x4(%rbp)
  addl   $0x1,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int next_power_of_two(int n) {
  n--;
  n |= n >> 1;
  n |= n >> 2;
  n |= n >> 4;
  n |= n >> 8;
  n |= n >> 16;
  return ++n;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<next_power_of_two>:
  endbr64
  sub    $0x1,%edi
  mov    %edi,%eax
  sar    %eax
  or     %edi,%eax
  mov    %eax,%edi
  sar    $0x2,%edi
  or     %eax,%edi
  mov    %edi,%eax
  sar    $0x4,%eax
  or     %edi,%eax
  mov    %eax,%edx
  sar    $0x8,%edx
  or     %eax,%edx
  mov    %edx,%eax
  sar    $0x10,%eax
  or     %edx,%eax
  add    $0x1,%eax
  ret
```

assistant: ```c
int next_power_of_two(int n) {
  n--;
  n |= n >> 1;
  n |= n >> 2;
  n |= n >> 4;
  n |= n >> 8;
  n |= n >> 16;
  return ++n;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<next_power_of_two>:
  endbr64
  sub    $0x1,%edi
  mov    %edi,%eax
  sar    %eax
  or     %edi,%eax
  mov    %eax,%edi
  sar    $0x2,%edi
  or     %eax,%edi
  mov    %edi,%eax
  sar    $0x4,%eax
  or     %edi,%eax
  mov    %eax,%edx
  sar    $0x8,%edx
  or     %eax,%edx
  mov    %edx,%eax
  sar    $0x10,%eax
  or     %edx,%eax
  add    $0x1,%eax
  ret
```

assistant: ```c
int next_power_of_two(int n) {
  n--;
  n |= n >> 1;
  n |= n >> 2;
  n |= n >> 4;
  n |= n >> 8;
  n |= n >> 16;
  return ++n;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<next_power_of_two>:
  endbr64
  sub    $0x1,%edi
  mov    %edi,%eax
  sar    %eax
  or     %edi,%eax
  mov    %eax,%edi
  sar    $0x2,%edi
  or     %eax,%edi
  mov    %edi,%eax
  sar    $0x4,%eax
  or     %edi,%eax
  mov    %eax,%edx
  sar    $0x8,%edx
  or     %eax,%edx
  mov    %edx,%eax
  sar    $0x10,%eax
  or     %edx,%eax
  add    $0x1,%eax
  ret
```

assistant: ```c
int next_power_of_two(int n) {
  n--;
  n |= n >> 1;
  n |= n >> 2;
  n |= n >> 4;
  n |= n >> 8;
  n |= n >> 16;
  return ++n;
}
```
user: What is the c source code of the assembly code below?

```asm
<sommeTableau>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movl   $0x0,-0xc(%rbp)
  jmp    L5
L6:
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  -0x8(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  addl   $0x1,-0xc(%rbp)
L5:
  mov    -0xc(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L6
  movsd  -0x8(%rbp),%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  pop    %rbp
  ret
```

assistant: ```c
double sommeTableau(double tableau[], int tailleTableau) {
  int i;
  double somme = 0;
  for (i = 0; i < tailleTableau; i++) {
    somme = somme + tableau[i];
  }
  return somme;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<sommeTableau>:
  endbr64
  test   %esi,%esi
  jle    L9
  mov    %rdi,%rax
  lea    -0x1(%rsi),%edx
  lea    0x8(%rdi,%rdx,8),%rdx
  pxor   %xmm0,%xmm0
L17:
  addsd  (%rax),%xmm0
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L17
  ret
L9:
  pxor   %xmm0,%xmm0
  ret
```

assistant: ```c
double sommeTableau(double tableau[], int tailleTableau) {
  int i;
  double somme = 0;
  for (i = 0; i < tailleTableau; i++) {
    somme = somme + tableau[i];
  }
  return somme;
}
```
user: Translate the below assembly code into C programming language:

```asm
<sommeTableau>:
  endbr64
  test   %esi,%esi
  jle    L11
  lea    -0x1(%rsi),%eax
  pxor   %xmm0,%xmm0
  lea    0x8(%rdi,%rax,8),%rax
  nopl   0x0(%rax)
L14:
  addsd  (%rdi),%xmm0
  add    $0x8,%rdi
  cmp    %rax,%rdi
  jne    L14
  ret
  cs nopw 0x0(%rax,%rax,1)
L11:
  pxor   %xmm0,%xmm0
  ret
```

assistant: ```c
double sommeTableau(double tableau[], int tailleTableau) {
  int i;
  double somme = 0;
  for (i = 0; i < tailleTableau; i++) {
    somme = somme + tableau[i];
  }
  return somme;
}
```
user: What is the c source code of the assembly code below?

```asm
<sommeTableau>:
  endbr64
  test   %esi,%esi
  jle    L41
  cmp    $0x1,%esi
  je     L1
  mov    %esi,%edx
  mov    %rdi,%rax
  pxor   %xmm0,%xmm0
  shr    %edx
  sub    $0x1,%edx
  shl    $0x4,%rdx
  lea    0x10(%rdi,%rdx,1),%rdx
  nopl   0x0(%rax)
L3:
  movsd  (%rax),%xmm1
  add    $0x10,%rax
  addsd  %xmm1,%xmm0
  movsd  -0x8(%rax),%xmm1
  addsd  %xmm1,%xmm0
  cmp    %rdx,%rax
  jne    L3
  mov    %esi,%eax
  and    $0xfffffffe,%eax
  and    $0x1,%esi
  je     L21
L6:
  cltq
  addsd  (%rdi,%rax,8),%xmm0
  ret
  nopl   0x0(%rax)
L21:
  ret
  nopl   0x0(%rax)
L41:
  pxor   %xmm0,%xmm0
  ret
L1:
  pxor   %xmm0,%xmm0
  xor    %eax,%eax
  jmp    L6
```

assistant: ```c
double sommeTableau(double tableau[], int tailleTableau) {
  int i;
  double somme = 0;
  for (i = 0; i < tailleTableau; i++) {
    somme = somme + tableau[i];
  }
  return somme;
}
```
user: Translate the below assembly code into C programming language:

```asm
<load_vsx_to_gpr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  mov    %rdi,-0x20(%rbp)
  mov    %rsi,-0x28(%rbp)
  mov    -0x20(%rbp),%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x18(%rbp)
  movsd  -0x18(%rbp),%xmm0
  movq   %xmm0,%rax
  mov    %rax,-0x18(%rbp)
  movsd  -0x18(%rbp),%xmm0
  movsd  %xmm0,-0x10(%rbp)
  movsd  -0x10(%rbp),%xmm0
  movq   %xmm0,%rax
  mov    %rax,%rbx
  mov    %rbx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  movsd  -0x10(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  nop
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
void __attribute__((__no__)) load_vsx_to_gpr(double *a, double *b) {
  double c = *a;
  double d;
  __asm__("# vsx, reg = %x0" : "+wa"(c));
  d = c;
  __asm__("# gpr, reg = %0" : "+b"(d));
  *b = d;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<load_vsx_to_gpr>:
  endbr64
  push   %rbx
  mov    (%rdi),%rax
  mov    %rax,%rbx
  mov    %rbx,(%rsi)
  pop    %rbx
  ret
```

assistant: ```c
void __attribute__((__no__)) load_vsx_to_gpr(double *a, double *b) {
  double c = *a;
  double d;
  __asm__("# vsx, reg = %x0" : "+wa"(c));
  d = c;
  __asm__("# gpr, reg = %0" : "+b"(d));
  *b = d;
}
```
user: Translate the below assembly code into C programming language:

```asm
<load_vsx_to_gpr>:
  endbr64
  movsd  (%rdi),%xmm0
  push   %rbx
  movq   %xmm0,%rax
  mov    %rax,%rbx
  mov    %rbx,(%rsi)
  pop    %rbx
  ret
```

assistant: ```c
void __attribute__((__no__)) load_vsx_to_gpr(double *a, double *b) {
  double c = *a;
  double d;
  __asm__("# vsx, reg = %x0" : "+wa"(c));
  d = c;
  __asm__("# gpr, reg = %0" : "+b"(d));
  *b = d;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<load_vsx_to_gpr>:
  endbr64
  movsd  (%rdi),%xmm0
  push   %rbx
  movq   %xmm0,%rax
  mov    %rax,%rbx
  mov    %rbx,(%rsi)
  pop    %rbx
  ret
```

assistant: ```c
void __attribute__((__no__)) load_vsx_to_gpr(double *a, double *b) {
  double c = *a;
  double d;
  __asm__("# vsx, reg = %x0" : "+wa"(c));
  d = c;
  __asm__("# gpr, reg = %0" : "+b"(d));
  *b = d;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<main>:
  endbr64
  push   %r12
  lea    D8(%rip),%rdi
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rdx
  mov    %rsp,%rsi
  call   <scanf@plt>
  mov    0x4(%rsp),%edi
  test   %edi,%edi
  je     L125
  mov    (%rsp),%r12d
  mov    %r12d,%esi
  test   %r12d,%r12d
  je     L144
  test   %r12d,%r12d
  js     L119
  test   %edi,%edi
  js     L131
L86:
  cmp    %esi,%edi
  mov    %esi,%ecx
  cmovle %edi,%ecx
  cmp    $0x1,%ecx
  jle    L12
  nopl   0x0(%rax,%rax,1)
L186:
  mov    %esi,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  jne    L136
  mov    %edi,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  je     L12
L136:
  sub    $0x1,%ecx
  cmp    $0x1,%ecx
  jne    L186
L12:
  mov    %esi,%eax
  cltd
  idiv   %ecx
  mov    %eax,%esi
  mov    %eax,(%rsp)
  mov    %edi,%eax
  cltd
  idiv   %ecx
  mov    %eax,%edi
  mov    %eax,0x4(%rsp)
  mov    %esi,%eax
  cltd
  idiv   %edi
  mov    %eax,%esi
  test   %eax,%eax
  jne    L95
  mov    %edx,%r12d
  test   %edx,%edx
  jne    L54
L31:
  xor    %r12d,%r12d
L78:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L13
  add    $0x10,%rsp
  mov    %r12d,%eax
  pop    %r12
  ret
L119:
  test   %edi,%edi
  js     L69
  neg    %esi
  mov    %esi,(%rsp)
L152:
  mov    $0x2d,%edi
  call   <putchar@plt>
  mov    0x4(%rsp),%edi
  mov    (%rsp),%esi
  jmp    L86
L95:
  lea    D23(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    (%rsp),%eax
  cltd
  idivl  0x4(%rsp)
  mov    %edx,%r12d
  test   %edx,%edx
  je     L31
  mov    $0x20,%edi
  call   <putchar@plt>
L54:
  mov    0x4(%rsp),%edx
  mov    %r12d,%esi
  lea    D33(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L31
L144:
  mov    $0x30,%edi
  call   <putchar@plt>
  jmp    L78
L69:
  neg    %edi
  neg    %esi
  jmp    L86
L131:
  neg    %edi
  mov    %edi,0x4(%rsp)
  jmp    L152
L125:
  lea    D25(%rip),%rdi
  xor    %eax,%eax
  or     $0xffffffff,%r12d
  call   <printf@plt>
  jmp    L78
L13:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D8
type: string
name: unpack_data
arguments: tag: D23
type: string
name: unpack_data
arguments: tag: D33
type: string
name: unpack_data
arguments: tag: D25
type: string

tool: D8: %d%d

tool: D23: %d

tool: D33: %d/%d

tool: D25: Divide by zero!

assistant: ```c
int main(void) {
  int num, denom, neg = 1, gcd, whole_no, rmdr;
  scanf("%d%d", &num, &denom);
  if (denom == 0) {
    printf("Divide by zero!");
    return -1;
  } else if (num == 0) {
    printf("0");
    return 0;
  }
  if (num < 0)
    neg *= -1;
  if (denom < 0)
    neg *= -1;
  num = abs(num);
  denom = abs(denom);
  if (neg == -1)
    printf("-");
  gcd = (num < denom) ? num : denom;
  while (gcd > 1) {
    if (num % gcd == 0 && denom % gcd == 0)
      break;
    gcd--;
  }
  num /= gcd;
  denom /= gcd;
  whole_no = num / denom;
  if (whole_no != 0)
    printf("%d", whole_no);
  rmdr = num % denom;
  if (whole_no != 0 && rmdr != 0)
    printf(" ");
  if (rmdr != 0)
    printf("%d/%d", rmdr, denom);
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<main>:
  endbr64
  push   %r12
  lea    D39(%rip),%rdi
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rdx
  mov    %rsp,%rsi
  call   <scanf@plt>
  mov    0x4(%rsp),%edi
  test   %edi,%edi
  je     L27
  mov    (%rsp),%r12d
  mov    %r12d,%esi
  test   %r12d,%r12d
  je     L78
  test   %r12d,%r12d
  js     L138
  test   %edi,%edi
  js     L124
L97:
  cmp    %esi,%edi
  mov    %esi,%ecx
  cmovle %edi,%ecx
  cmp    $0x1,%ecx
  jle    L38
  nopl   0x0(%rax,%rax,1)
L129:
  mov    %esi,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  jne    L147
  mov    %edi,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  je     L38
L147:
  sub    $0x1,%ecx
  cmp    $0x1,%ecx
  jne    L129
L38:
  mov    %esi,%eax
  cltd
  idiv   %ecx
  mov    %eax,%esi
  mov    %eax,(%rsp)
  mov    %edi,%eax
  cltd
  idiv   %ecx
  mov    %eax,%edi
  mov    %eax,0x4(%rsp)
  mov    %esi,%eax
  cltd
  idiv   %edi
  mov    %eax,%esi
  test   %eax,%eax
  jne    L54
  mov    %edx,%r12d
  test   %edx,%edx
  jne    L153
L22:
  xor    %r12d,%r12d
L20:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L127
  add    $0x10,%rsp
  mov    %r12d,%eax
  pop    %r12
  ret
L138:
  test   %edi,%edi
  js     L59
  neg    %esi
  mov    %esi,(%rsp)
L80:
  mov    $0x2d,%edi
  call   <putchar@plt>
  mov    0x4(%rsp),%edi
  mov    (%rsp),%esi
  jmp    L97
L54:
  lea    D8(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    (%rsp),%eax
  cltd
  idivl  0x4(%rsp)
  mov    %edx,%r12d
  test   %edx,%edx
  je     L22
  mov    $0x20,%edi
  call   <putchar@plt>
L153:
  mov    0x4(%rsp),%edx
  mov    %r12d,%esi
  lea    D3(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L22
L78:
  mov    $0x30,%edi
  call   <putchar@plt>
  jmp    L20
L59:
  neg    %edi
  neg    %esi
  jmp    L97
L124:
  neg    %edi
  mov    %edi,0x4(%rsp)
  jmp    L80
L27:
  lea    D10(%rip),%rdi
  xor    %eax,%eax
  or     $0xffffffff,%r12d
  call   <printf@plt>
  jmp    L20
L127:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D39
type: string
name: unpack_data
arguments: data_label: D8
type: string
name: unpack_data
arguments: data_label: D3
type: string
name: unpack_data
arguments: data_label: D10
type: string

tool: D39: %d%d

tool: D8: %d

tool: D3: %d/%d

tool: D10: Divide by zero!

assistant: ```c
int main(void) {
  int num, denom, neg = 1, gcd, whole_no, rmdr;
  scanf("%d%d", &num, &denom);
  if (denom == 0) {
    printf("Divide by zero!");
    return -1;
  } else if (num == 0) {
    printf("0");
    return 0;
  }
  if (num < 0)
    neg *= -1;
  if (denom < 0)
    neg *= -1;
  num = abs(num);
  denom = abs(denom);
  if (neg == -1)
    printf("-");
  gcd = (num < denom) ? num : denom;
  while (gcd > 1) {
    if (num % gcd == 0 && denom % gcd == 0)
      break;
    gcd--;
  }
  num /= gcd;
  denom /= gcd;
  whole_no = num / denom;
  if (whole_no != 0)
    printf("%d", whole_no);
  rmdr = num % denom;
  if (whole_no != 0 && rmdr != 0)
    printf(" ");
  if (rmdr != 0)
    printf("%d/%d", rmdr, denom);
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<zipEncodeLength>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,%eax
  mov    %edx,-0x20(%rbp)
  mov    %al,-0x1c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movb   $0x1,-0xe(%rbp)
  movzbl -0x1c(%rbp),%eax
  and    $0xc0,%eax
  cmp    $0xbf,%eax
  jg     L102
  cmpl   $0x3f,-0x20(%rbp)
  ja     L35
  cmpq   $0x0,-0x18(%rbp)
  jne    L126
  movzbl -0xe(%rbp),%eax
  jmp    L109
L126:
  mov    -0x20(%rbp),%eax
  mov    %al,-0xd(%rbp)
  jmp    L124
L35:
  cmpl   $0x3fff,-0x20(%rbp)
  ja     L25
  addb   $0x1,-0xe(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L48
  movzbl -0xe(%rbp),%eax
  jmp    L109
L48:
  mov    -0x20(%rbp),%eax
  shr    $0x8,%eax
  and    $0x3f,%eax
  or     $0x40,%eax
  mov    %al,-0xd(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %al,-0xc(%rbp)
  jmp    L124
L25:
  addb   $0x4,-0xe(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L93
  movzbl -0xe(%rbp),%eax
  jmp    L109
L93:
  movb   $0x80,-0xd(%rbp)
  mov    -0x20(%rbp),%eax
  shr    $0x18,%eax
  mov    %al,-0xc(%rbp)
  mov    -0x20(%rbp),%eax
  shr    $0x10,%eax
  mov    %al,-0xb(%rbp)
  mov    -0x20(%rbp),%eax
  shr    $0x8,%eax
  mov    %al,-0xa(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %al,-0x9(%rbp)
  jmp    L124
L102:
  cmpq   $0x0,-0x18(%rbp)
  jne    L105
  movzbl -0xe(%rbp),%eax
  jmp    L109
L105:
  movzbl -0x1c(%rbp),%eax
  mov    %al,-0xd(%rbp)
L124:
  movzbl -0xe(%rbp),%edx
  lea    -0xd(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  movzbl -0xe(%rbp),%eax
L109:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L137
  call   <__stack_chk_fail@plt>
L137:
  leave
  ret
```

assistant: ```c
unsigned int zipEncodeLength(unsigned char *p, unsigned char encoding, unsigned int rawlen) {
  unsigned char len = 1, buf[5];
  if ((((encoding)&0xc0) < 0xc0)) {
    if (rawlen <= 0x3f) {
      if (!p)
        return len;
      buf[0] = (0 << 6) | rawlen;
    } else if (rawlen <= 0x3fff) {
      len += 1;
      if (!p)
        return len;
      buf[0] = (1 << 6) | ((rawlen >> 8) & 0x3f);
      buf[1] = rawlen & 0xff;
    } else {
      len += 4;
      if (!p)
        return len;
      buf[0] = (2 << 6);
      buf[1] = (rawlen >> 24) & 0xff;
      buf[2] = (rawlen >> 16) & 0xff;
      buf[3] = (rawlen >> 8) & 0xff;
      buf[4] = rawlen & 0xff;
    }
  } else {
    if (!p)
      return len;
    buf[0] = encoding;
  }
  memcpy(p, buf, len);
  return len;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<zipEncodeLength>:
  endbr64
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %esi,%eax
  and    $0xffffffc0,%eax
  cmp    $0xbf,%al
  ja     L142
  cmp    $0x3f,%edx
  ja     L138
  test   %rdi,%rdi
  je     L128
  mov    %dl,0x3(%rsp)
  mov    $0x1,%ebx
  jmp    L109
L138:
  cmp    $0x3fff,%edx
  ja     L103
  test   %rdi,%rdi
  je     L55
  mov    %edx,%eax
  shr    $0x8,%eax
  or     $0x40,%eax
  mov    %al,0x3(%rsp)
  mov    %dl,0x4(%rsp)
  mov    $0x2,%ebx
  jmp    L109
L103:
  test   %rdi,%rdi
  je     L49
  movb   $0x80,0x3(%rsp)
  mov    %edx,%eax
  shr    $0x18,%eax
  mov    %al,0x4(%rsp)
  mov    %edx,%eax
  shr    $0x10,%eax
  mov    %al,0x5(%rsp)
  movzbl %dh,%eax
  mov    %al,0x6(%rsp)
  mov    %dl,0x7(%rsp)
  mov    $0x5,%ebx
  jmp    L109
L142:
  test   %rdi,%rdi
  je     L122
  mov    %sil,0x3(%rsp)
  mov    $0x1,%ebx
L109:
  movzbl %bl,%ebx
  lea    0x3(%rsp),%rsi
  mov    %ebx,%edx
  call   <memcpy@plt>
  mov    %ebx,%eax
L121:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L22
  add    $0x10,%rsp
  pop    %rbx
  ret
L128:
  mov    $0x1,%eax
  jmp    L121
L55:
  mov    $0x2,%eax
  jmp    L121
L49:
  mov    $0x5,%eax
  jmp    L121
L122:
  mov    $0x1,%eax
  jmp    L121
L22:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
unsigned int zipEncodeLength(unsigned char *p, unsigned char encoding, unsigned int rawlen) {
  unsigned char len = 1, buf[5];
  if ((((encoding)&0xc0) < 0xc0)) {
    if (rawlen <= 0x3f) {
      if (!p)
        return len;
      buf[0] = (0 << 6) | rawlen;
    } else if (rawlen <= 0x3fff) {
      len += 1;
      if (!p)
        return len;
      buf[0] = (1 << 6) | ((rawlen >> 8) & 0x3f);
      buf[1] = rawlen & 0xff;
    } else {
      len += 4;
      if (!p)
        return len;
      buf[0] = (2 << 6);
      buf[1] = (rawlen >> 24) & 0xff;
      buf[2] = (rawlen >> 16) & 0xff;
      buf[3] = (rawlen >> 8) & 0xff;
      buf[4] = rawlen & 0xff;
    }
  } else {
    if (!p)
      return len;
    buf[0] = encoding;
  }
  memcpy(p, buf, len);
  return len;
}
```