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

```asm
<DecompressGotoTable>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    %ecx,-0x38(%rbp)
  movl   $0x0,-0x14(%rbp)
  movl   $0x0,-0x10(%rbp)
  movl   $0x0,-0xc(%rbp)
  movl   $0x0,-0x8(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L120
L95:
  cmpl   $0x0,-0x14(%rbp)
  jne    L122
  mov    -0xc(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x8(%rbp)
  addl   $0x1,-0xc(%rbp)
  jmp    L12
L65:
  mov    -0xc(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    -0x10(%rbp),%edx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x30(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x10(%rbp)
  addl   $0x1,-0xc(%rbp)
  subl   $0x1,-0x8(%rbp)
L12:
  cmpl   $0x0,-0x8(%rbp)
  je     L66
  mov    -0xc(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jae    L66
  mov    -0x10(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jb     L65
L66:
  movl   $0x0,-0x8(%rbp)
  movl   $0x1,-0x14(%rbp)
  jmp    L120
L122:
  cmpl   $0x1,-0x14(%rbp)
  jne    L120
  mov    -0xc(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x8(%rbp)
  addl   $0x1,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  addl   $0x1,-0xc(%rbp)
  jmp    L129
L17:
  mov    -0x10(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rax,%rdx
  mov    -0x4(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x10(%rbp)
  subl   $0x1,-0x8(%rbp)
L129:
  cmpl   $0x0,-0x8(%rbp)
  je     L14
  mov    -0x10(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jb     L17
L14:
  movl   $0x0,-0x8(%rbp)
  movl   $0x0,-0x14(%rbp)
L120:
  mov    -0xc(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jae    L21
  mov    -0x10(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jb     L95
L21:
  nop
  pop    %rbp
  ret
```

assistant: ```c
void DecompressGotoTable(int *source_data, int *dest_data, unsigned int compressed_size, unsigned int total_size) {
  unsigned int mode = 0;
  unsigned int index = 0;
  unsigned int read_index = 0;
  int lengthRep = 0;
  int copy_value = 0;
  while (read_index < compressed_size && index < total_size) {
    if (mode == 0) {
      lengthRep = source_data[read_index];
      read_index++;
      while (lengthRep && read_index < compressed_size && index < total_size) {
        dest_data[index] = source_data[read_index];
        index++;
        read_index++;
        lengthRep--;
      }
      lengthRep = 0;
      mode = 1;
    } else if (mode == 1) {
      lengthRep = source_data[read_index];
      read_index++;
      copy_value = source_data[read_index];
      read_index++;
      while (lengthRep && index < total_size) {
        dest_data[index] = copy_value;
        index++;
        lengthRep--;
      }
      lengthRep = 0;
      mode = 0;
    }
  }
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<DecompressGotoTable>:
  endbr64
  test   %edx,%edx
  je     L66
  mov    %rdi,%r10
  mov    %rsi,%r9
  mov    %edx,%r8d
  test   %ecx,%ecx
  je     L66
  push   %rbp
  push   %rbx
  mov    $0x0,%eax
  mov    $0x0,%esi
  mov    $0x0,%edx
  mov    $0x0,%ebp
  mov    $0x1,%ebx
  jmp    L61
L73:
  mov    %eax,%edx
  mov    (%r10,%rdx,4),%r11d
  add    $0x1,%eax
  cmp    %eax,%r8d
  seta   %dil
  cmp    %esi,%ecx
  seta   %dl
  test   %dl,%dil
  je     L102
  test   %r11d,%r11d
  je     L102
  mov    %esi,%edx
  add    %esi,%r11d
L117:
  mov    %eax,%esi
  mov    (%r10,%rsi,4),%edi
  mov    %edx,%esi
  mov    %edi,(%r9,%rsi,4)
  add    $0x1,%edx
  add    $0x1,%eax
  cmp    %eax,%r8d
  seta   %dil
  cmp    %edx,%ecx
  seta   %sil
  test   %sil,%dil
  je     L153
  cmp    %edx,%r11d
  jne    L117
L153:
  mov    %edx,%esi
  mov    %ebx,%edx
L43:
  cmp    %r8d,%eax
  jae    L104
  cmp    %ecx,%esi
  jae    L104
L61:
  test   %edx,%edx
  je     L73
  mov    %eax,%edx
  mov    (%r10,%rdx,4),%edi
  lea    0x1(%rax),%edx
  mov    (%r10,%rdx,4),%r11d
  add    $0x2,%eax
  test   %edi,%edi
  je     L103
  cmp    %esi,%ecx
  jbe    L103
  mov    %esi,%edx
  add    %esi,%edi
L80:
  mov    %edx,%esi
  mov    %r11d,(%r9,%rsi,4)
  add    $0x1,%edx
  cmp    %edx,%edi
  je     L29
  cmp    %edx,%ecx
  ja     L80
L29:
  mov    %edx,%esi
  mov    %ebp,%edx
  jmp    L43
L102:
  mov    %ebx,%edx
  jmp    L43
L103:
  mov    %ebp,%edx
  jmp    L43
L104:
  pop    %rbx
  pop    %rbp
  ret
L66:
  ret
```

assistant: ```c
void DecompressGotoTable(int *source_data, int *dest_data, unsigned int compressed_size, unsigned int total_size) {
  unsigned int mode = 0;
  unsigned int index = 0;
  unsigned int read_index = 0;
  int lengthRep = 0;
  int copy_value = 0;
  while (read_index < compressed_size && index < total_size) {
    if (mode == 0) {
      lengthRep = source_data[read_index];
      read_index++;
      while (lengthRep && read_index < compressed_size && index < total_size) {
        dest_data[index] = source_data[read_index];
        index++;
        read_index++;
        lengthRep--;
      }
      lengthRep = 0;
      mode = 1;
    } else if (mode == 1) {
      lengthRep = source_data[read_index];
      read_index++;
      copy_value = source_data[read_index];
      read_index++;
      while (lengthRep && index < total_size) {
        dest_data[index] = copy_value;
        index++;
        lengthRep--;
      }
      lengthRep = 0;
      mode = 0;
    }
  }
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<DecompressGotoTable>:
  endbr64
  test   %ecx,%ecx
  je     L70
  mov    %edx,%r10d
  push   %rbp
  mov    %rdi,%r8
  mov    %rsi,%r9
  push   %rbx
  mov    %ecx,%edi
  xor    %edx,%edx
  xor    %ecx,%ecx
  xor    %ebx,%ebx
  test   %r10d,%r10d
  je     L71
  nopl   0x0(%rax)
L126:
  mov    %ecx,%eax
  cmp    %edx,%edi
  lea    0x1(%rcx),%esi
  mov    (%r8,%rax,4),%r11d
  seta   %al
  test   %ebx,%ebx
  je     L75
  add    $0x2,%ecx
  mov    (%r8,%rsi,4),%ebx
  cmp    %ecx,%r10d
  seta   %bpl
  test   %r11d,%r11d
  je     L81
  mov    %edx,%esi
  add    %edx,%r11d
  test   %al,%al
  je     L81
  nopw   0x0(%rax,%rax,1)
L57:
  mov    %esi,%eax
  add    $0x1,%esi
  cmp    %esi,%edi
  mov    %ebx,(%r9,%rax,4)
  seta   %al
  cmp    %esi,%r11d
  je     L92
  test   %al,%al
  jne    L57
L92:
  and    %ebp,%eax
  mov    %esi,%edx
  xor    %ebx,%ebx
L51:
  test   %al,%al
  jne    L126
L71:
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax)
L75:
  cmp    %esi,%r10d
  seta   %cl
  and    %ecx,%eax
  mov    %esi,%ecx
  test   %r11d,%r11d
  je     L139
  test   %al,%al
  je     L139
  add    %edx,%r11d
  jmp    L142
L5:
  test   %al,%al
  je     L139
L142:
  mov    %ecx,%eax
  add    $0x1,%ecx
  mov    (%r8,%rax,4),%esi
  mov    %edx,%eax
  add    $0x1,%edx
  cmp    %ecx,%r10d
  mov    %esi,(%r9,%rax,4)
  seta   %al
  cmp    %edx,%edi
  seta   %sil
  and    %esi,%eax
  cmp    %edx,%r11d
  jne    L5
L139:
  mov    $0x1,%ebx
  jmp    L51
L81:
  and    %ebp,%eax
  xor    %ebx,%ebx
  jmp    L51
L70:
  ret
```

assistant: ```c
void DecompressGotoTable(int *source_data, int *dest_data, unsigned int compressed_size, unsigned int total_size) {
  unsigned int mode = 0;
  unsigned int index = 0;
  unsigned int read_index = 0;
  int lengthRep = 0;
  int copy_value = 0;
  while (read_index < compressed_size && index < total_size) {
    if (mode == 0) {
      lengthRep = source_data[read_index];
      read_index++;
      while (lengthRep && read_index < compressed_size && index < total_size) {
        dest_data[index] = source_data[read_index];
        index++;
        read_index++;
        lengthRep--;
      }
      lengthRep = 0;
      mode = 1;
    } else if (mode == 1) {
      lengthRep = source_data[read_index];
      read_index++;
      copy_value = source_data[read_index];
      read_index++;
      while (lengthRep && index < total_size) {
        dest_data[index] = copy_value;
        index++;
        lengthRep--;
      }
      lengthRep = 0;
      mode = 0;
    }
  }
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<DecompressGotoTable>:
  endbr64
  test   %ecx,%ecx
  je     L126
  mov    %edx,%r10d
  push   %rbp
  mov    %rdi,%r8
  mov    %rsi,%r9
  push   %rbx
  mov    %ecx,%edi
  xor    %edx,%edx
  xor    %ecx,%ecx
  xor    %ebx,%ebx
  test   %r10d,%r10d
  je     L12
  nopl   0x0(%rax)
L73:
  mov    %ecx,%eax
  cmp    %edx,%edi
  lea    0x1(%rcx),%esi
  mov    (%r8,%rax,4),%r11d
  seta   %al
  test   %ebx,%ebx
  je     L79
  add    $0x2,%ecx
  mov    (%r8,%rsi,4),%ebx
  cmp    %ecx,%r10d
  seta   %bpl
  test   %r11d,%r11d
  je     L141
  mov    %edx,%esi
  add    %edx,%r11d
  test   %al,%al
  je     L141
  nopw   0x0(%rax,%rax,1)
L55:
  mov    %esi,%eax
  add    $0x1,%esi
  cmp    %esi,%edi
  mov    %ebx,(%r9,%rax,4)
  seta   %al
  cmp    %esi,%r11d
  je     L90
  test   %al,%al
  jne    L55
L90:
  and    %ebp,%eax
  mov    %esi,%edx
  xor    %ebx,%ebx
L113:
  test   %al,%al
  jne    L73
L12:
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax)
L79:
  cmp    %esi,%r10d
  seta   %cl
  and    %ecx,%eax
  mov    %esi,%ecx
  test   %r11d,%r11d
  je     L86
  test   %al,%al
  je     L86
  add    %edx,%r11d
  jmp    L139
L104:
  test   %al,%al
  je     L86
L139:
  mov    %ecx,%eax
  add    $0x1,%ecx
  mov    (%r8,%rax,4),%esi
  mov    %edx,%eax
  add    $0x1,%edx
  cmp    %ecx,%r10d
  mov    %esi,(%r9,%rax,4)
  seta   %al
  cmp    %edx,%edi
  seta   %sil
  and    %esi,%eax
  cmp    %edx,%r11d
  jne    L104
L86:
  mov    $0x1,%ebx
  jmp    L113
L141:
  and    %ebp,%eax
  xor    %ebx,%ebx
  jmp    L113
L126:
  ret
```

assistant: ```c
void DecompressGotoTable(int *source_data, int *dest_data, unsigned int compressed_size, unsigned int total_size) {
  unsigned int mode = 0;
  unsigned int index = 0;
  unsigned int read_index = 0;
  int lengthRep = 0;
  int copy_value = 0;
  while (read_index < compressed_size && index < total_size) {
    if (mode == 0) {
      lengthRep = source_data[read_index];
      read_index++;
      while (lengthRep && read_index < compressed_size && index < total_size) {
        dest_data[index] = source_data[read_index];
        index++;
        read_index++;
        lengthRep--;
      }
      lengthRep = 0;
      mode = 1;
    } else if (mode == 1) {
      lengthRep = source_data[read_index];
      read_index++;
      copy_value = source_data[read_index];
      read_index++;
      while (lengthRep && index < total_size) {
        dest_data[index] = copy_value;
        index++;
        lengthRep--;
      }
      lengthRep = 0;
      mode = 0;
    }
  }
}
```
user: What is the c source code of the assembly code below:

```asm
<g2_string_>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8d,-0x44(%rbp)
  mov    -0x44(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%edi
  call   <g2_malloc@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x44(%rbp),%edx
  mov    -0x40(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x44(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x38(%rbp),%rax
  movss  (%rax),%xmm2
  movss  %xmm2,-0x48(%rbp)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%ebx
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  movd   %eax,%xmm0
  call   <dtoi@plt>
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %rax,%rsi
  movss  -0x48(%rbp),%xmm1
  movd   %ebx,%xmm0
  mov    %edx,%edi
  call   <g2_string@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <g2_free@plt>
  nop
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
void g2_string_(float *dev, float *x, float *y, char *text, int length) {
  char *str;
  str = g2_malloc((length + 1) * sizeof(char));
  strncpy(str, text, length);
  str[length] = '\0';
  g2_string(dtoi(*dev), *x, *y, str);
  g2_free(str);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<g2_string_>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r12
  mov    %rsi,%r13
  mov    %rdx,%r14
  mov    %rcx,%r15
  mov    %r8d,%ebx
  lea    0x1(%r8),%edi
  call   <g2_malloc@plt>
  mov    %rax,%rbp
  mov    %ebx,%edx
  mov    %r15,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  movslq %ebx,%rbx
  movb   $0x0,0x0(%rbp,%rbx,1)
  mov    (%r14),%ebx
  mov    0x0(%r13),%r13d
  movss  (%r12),%xmm0
  call   <dtoi@plt>
  mov    %eax,%edi
  mov    %rbp,%rsi
  movd   %ebx,%xmm1
  movd   %r13d,%xmm0
  call   <g2_string@plt>
  mov    %rbp,%rdi
  call   <g2_free@plt>
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void g2_string_(float *dev, float *x, float *y, char *text, int length) {
  char *str;
  str = g2_malloc((length + 1) * sizeof(char));
  strncpy(str, text, length);
  str[length] = '\0';
  g2_string(dtoi(*dev), *x, *y, str);
  g2_free(str);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<g2_string_>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  movslq %r8d,%rbx
  lea    0x1(%rbx),%edi
  sub    $0x18,%rsp
  call   <g2_malloc@plt>
  mov    %ebx,%edx
  mov    %r15,%rsi
  mov    %rax,%rbp
  mov    %rax,%rdi
  call   <strncpy@plt>
  movb   $0x0,0x0(%rbp,%rbx,1)
  movss  (%r14),%xmm1
  movss  0x0(%r13),%xmm2
  movss  (%r12),%xmm0
  movss  %xmm1,0xc(%rsp)
  movss  %xmm2,0x8(%rsp)
  call   <dtoi@plt>
  movss  0x8(%rsp),%xmm2
  movss  0xc(%rsp),%xmm1
  mov    %rbp,%rsi
  mov    %eax,%edi
  movaps %xmm2,%xmm0
  call   <g2_string@plt>
  add    $0x18,%rsp
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10d0 <g2_free@plt>
```

assistant: ```c
void g2_string_(float *dev, float *x, float *y, char *text, int length) {
  char *str;
  str = g2_malloc((length + 1) * sizeof(char));
  strncpy(str, text, length);
  str[length] = '\0';
  g2_string(dtoi(*dev), *x, *y, str);
  g2_free(str);
}
```
user: What is the c source code of the assembly code below:

```asm
<g2_string_>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  movslq %r8d,%rbx
  lea    0x1(%rbx),%edi
  sub    $0x18,%rsp
  call   <g2_malloc@plt>
  mov    %ebx,%edx
  mov    %r15,%rsi
  mov    %rax,%rbp
  mov    %rax,%rdi
  call   <strncpy@plt>
  movb   $0x0,0x0(%rbp,%rbx,1)
  movss  (%r14),%xmm1
  movss  0x0(%r13),%xmm2
  movss  (%r12),%xmm0
  movss  %xmm1,0xc(%rsp)
  movss  %xmm2,0x8(%rsp)
  call   <dtoi@plt>
  movss  0x8(%rsp),%xmm2
  movss  0xc(%rsp),%xmm1
  mov    %rbp,%rsi
  mov    %eax,%edi
  movaps %xmm2,%xmm0
  call   <g2_string@plt>
  add    $0x18,%rsp
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10d0 <g2_free@plt>
```

assistant: ```c
void g2_string_(float *dev, float *x, float *y, char *text, int length) {
  char *str;
  str = g2_malloc((length + 1) * sizeof(char));
  strncpy(str, text, length);
  str[length] = '\0';
  g2_string(dtoi(*dev), *x, *y, str);
  g2_free(str);
}
```
user: What is the c source code of the assembly code below?

```asm
<binarySearch>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    %rdx,-0x20(%rbp)
  mov    %ecx,-0x24(%rbp)
  mov    %r8d,-0x28(%rbp)
  jmp    L37
L36:
  mov    -0x24(%rbp),%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x4(%rbp)
  mov    -0x24(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jne    L42
  mov    -0x4(%rbp),%eax
  jmp    L50
L42:
  mov    -0x4(%rbp),%ecx
  mov    -0x20(%rbp),%rdx
  mov    -0x18(%rbp),%esi
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <isValid@plt>
  test   %rax,%rax
  je     L24
  mov    -0x4(%rbp),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L37
L24:
  mov    -0x4(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x24(%rbp)
L37:
  mov    -0x24(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jle    L36
L50:
  leave
  ret
```

assistant: ```c
int binarySearch(int books, int scribes, short *pages, int low, int high) {
  int mid;
  while (low <= high) {
    mid = (low + high) / 2;
    if (low == high) {
      return mid;
    }
    if (isValid(books, scribes, pages, mid)) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<binarySearch>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  cmp    %r8d,%ecx
  jg     L55
  mov    %edi,%r13d
  mov    %esi,%r14d
  mov    %rdx,%r15
  mov    %ecx,%r12d
  mov    %r8d,%ebp
  lea    (%rcx,%r8,1),%eax
  mov    %eax,%ebx
  shr    $0x1f,%ebx
  add    %eax,%ebx
  sar    %ebx
  cmp    %r8d,%ecx
  jne    L39
L55:
  mov    %ebx,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L16:
  mov    %ebx,%ebp
L27:
  cmp    %ebp,%r12d
  jg     L55
  lea    (%r12,%rbp,1),%eax
  mov    %eax,%ebx
  shr    $0x1f,%ebx
  add    %eax,%ebx
  sar    %ebx
  cmp    %ebp,%r12d
  je     L55
L39:
  mov    %ebx,%ecx
  mov    %r15,%rdx
  mov    %r14d,%esi
  mov    %r13d,%edi
  call   <isValid@plt>
  test   %rax,%rax
  jne    L16
  lea    0x1(%rbx),%r12d
  jmp    L27
```

assistant: ```c
int binarySearch(int books, int scribes, short *pages, int low, int high) {
  int mid;
  while (low <= high) {
    mid = (low + high) / 2;
    if (low == high) {
      return mid;
    }
    if (isValid(books, scribes, pages, mid)) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<binarySearch>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  cmp    %r8d,%ecx
  jg     L63
  lea    (%rcx,%r8,1),%eax
  mov    %edi,%ebx
  mov    %esi,%ebp
  mov    %rdx,%r13
  mov    %eax,%r12d
  mov    %ecx,%r14d
  mov    %r8d,%r15d
  shr    $0x1f,%r12d
  add    %eax,%r12d
  sar    %r12d
  cmp    %r8d,%ecx
  jne    L61
  jmp    L63
  nopl   0x0(%rax)
L62:
  lea    0x1(%r12),%r14d
  cmp    %r14d,%r15d
  jl     L63
L31:
  lea    (%r15,%r14,1),%eax
  mov    %eax,%r12d
  shr    $0x1f,%r12d
  add    %eax,%r12d
  sar    %r12d
  cmp    %r14d,%r15d
  je     L63
L61:
  mov    %r12d,%ecx
  mov    %r13,%rdx
  mov    %ebp,%esi
  mov    %ebx,%edi
  call   <isValid@plt>
  test   %rax,%rax
  je     L62
  mov    %r12d,%r15d
  cmp    %r14d,%r15d
  jge    L31
L63:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int binarySearch(int books, int scribes, short *pages, int low, int high) {
  int mid;
  while (low <= high) {
    mid = (low + high) / 2;
    if (low == high) {
      return mid;
    }
    if (isValid(books, scribes, pages, mid)) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<binarySearch>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  cmp    %r8d,%ecx
  jg     L28
  lea    (%rcx,%r8,1),%eax
  mov    %edi,%ebx
  mov    %esi,%ebp
  mov    %rdx,%r13
  mov    %eax,%r12d
  mov    %ecx,%r14d
  mov    %r8d,%r15d
  shr    $0x1f,%r12d
  add    %eax,%r12d
  sar    %r12d
  cmp    %r8d,%ecx
  jne    L19
  jmp    L28
  nopl   0x0(%rax)
L5:
  lea    0x1(%r12),%r14d
  cmp    %r14d,%r15d
  jl     L28
L29:
  lea    (%r15,%r14,1),%eax
  mov    %eax,%r12d
  shr    $0x1f,%r12d
  add    %eax,%r12d
  sar    %r12d
  cmp    %r14d,%r15d
  je     L28
L19:
  mov    %r12d,%ecx
  mov    %r13,%rdx
  mov    %ebp,%esi
  mov    %ebx,%edi
  call   <isValid@plt>
  test   %rax,%rax
  je     L5
  mov    %r12d,%r15d
  cmp    %r14d,%r15d
  jge    L29
L28:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int binarySearch(int books, int scribes, short *pages, int low, int high) {
  int mid;
  while (low <= high) {
    mid = (low + high) / 2;
    if (low == high) {
      return mid;
    }
    if (isValid(books, scribes, pages, mid)) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D17(%rip),%rax
  mov    %rax,%rsi
  lea    D66(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x10(%rbp)
  movl   $0x0,-0x28(%rbp)
  lea    -0x28(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  lea    D71(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <fscanf@plt>
  movl   $0x0,-0x18(%rbp)
  movl   $0x1,-0x18(%rbp)
  jmp    L4
L29:
  movl   $0x0,-0x24(%rbp)
  movl   $0x0,-0x20(%rbp)
  movl   $0x0,-0x1c(%rbp)
  lea    -0x24(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  lea    D71(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <fscanf@plt>
  lea    -0x20(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  lea    D71(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <fscanf@plt>
  lea    -0x1c(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  lea    D71(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <fscanf@plt>
  mov    -0x24(%rbp),%edx
  mov    -0x24(%rbp),%eax
  imul   %edx,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movsd  D7(%rip),%xmm1
  divsd  %xmm1,%xmm0
  mov    -0x20(%rbp),%eax
  pxor   %xmm2,%xmm2
  cvtsi2sd %eax,%xmm2
  movapd %xmm0,%xmm1
  divsd  %xmm2,%xmm1
  mov    -0x1c(%rbp),%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  %xmm0,%xmm1
  movsd  D49(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,%edi
  call   <ceil@plt>
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%edx
  mov    -0x18(%rbp),%eax
  mov    %eax,%esi
  lea    D54(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  addl   $0x1,-0x18(%rbp)
L4:
  mov    -0x28(%rbp),%eax
  cmp    %eax,-0x18(%rbp)
  jle    L29
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L19
  call   <__stack_chk_fail@plt>
L19:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D17
data_type: string
name: retrieve_data
arguments: tag: D66
data_type: string
name: retrieve_data
arguments: tag: D71
data_type: string
name: retrieve_data
arguments: tag: D7
data_type: byte[8]
name: retrieve_data
arguments: tag: D49
data_type: byte[8]
name: retrieve_data
arguments: tag: D54
data_type: string

tool: D17: r

tool: D66: pizza.in

tool: D71: %d

tool: {"D7": [0xf1,0xd4,0xc8,0x53,0xfb,0x21,0x29,0x40]}

tool: {"D49": [0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x40]}

tool: D54: Perfectly Popular Pizza %d: Perry consumed %d calories.


assistant: ```c
int main() {
  FILE *ifp;
  ifp = fopen("pizza.in", "r");
  int cases = 0;
  fscanf(ifp, "%d", &cases);
  int i = 0;
  for (i = 1; i <= cases; i++) {
    int p = 0;
    int t = 0;
    int c = 0;
    fscanf(ifp, "%d", &p);
    fscanf(ifp, "%d", &t);
    fscanf(ifp, "%d", &c);
    int ans = ((int)ceil((((p * p) / (4 * 3.14159265)) / t) * c * 10));
    printf("Perfectly Popular Pizza %d: Perry consumed %d calories.\n", i, ans);
  }
}
```