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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  movl   $0x0,-0x1c(%rbp)
  movl   $0x0,-0x18(%rbp)
  movl   $0x0,-0x14(%rbp)
  lea    D26(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  movl   $0x64,-0x1c(%rbp)
  jmp    L17
L83:
  movl   $0x1,-0x18(%rbp)
  jmp    L87
L82:
  mov    -0x18(%rbp),%edx
  mov    -0x1c(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <calculate_c@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x10(%rbp)
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x1c(%rbp),%xmm1
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x18(%rbp),%xmm0
  addsd  %xmm1,%xmm0
  movsd  -0x10(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  -0x8(%rbp),%xmm0
  ucomisd D17(%rip),%xmm0
  jp     L34
  movsd  -0x8(%rbp),%xmm0
  ucomisd D17(%rip),%xmm0
  jne    L34
  movsd  -0x10(%rbp),%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,-0x14(%rbp)
L34:
  cmpl   $0x0,-0x14(%rbp)
  jne    L87
  addl   $0x1,-0x18(%rbp)
L87:
  mov    -0x18(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jg     L8
  cmpl   $0x0,-0x14(%rbp)
  je     L82
L8:
  cmpl   $0x0,-0x14(%rbp)
  jne    L17
  addl   $0x1,-0x1c(%rbp)
L17:
  cmpl   $0x1f4,-0x1c(%rbp)
  jg     L2
  cmpl   $0x0,-0x14(%rbp)
  je     L83
L2:
  mov    -0x1c(%rbp),%eax
  imul   -0x18(%rbp),%eax
  imul   -0x14(%rbp),%eax
  mov    %eax,%esi
  mov    -0x14(%rbp),%ecx
  mov    -0x18(%rbp),%edx
  mov    -0x1c(%rbp),%eax
  mov    %esi,%r8d
  mov    %eax,%esi
  lea    D37(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  nop
  leave
  ret
```

tool_calls: name: parse_data
arguments: label: D26
datatype: string
name: parse_data
arguments: label: D17
datatype: f64
name: parse_data
arguments: label: D37
datatype: string

tool: D26: Problem #9 Solution
-------------------

tool: D17: 1000

tool: D37: a = %d; b = %d; c = %d; product = %d


assistant: ```c
void main() {
  int a = 0, b = 0, c = 0;
  double tmp_c, sum;
  printf("Problem #9 Solution\n-------------------\n");
  a = 100;
  while (a <= 500 && c == 0) {
    b = 1;
    while (b <= a && c == 0) {
      tmp_c = calculate_c(a, b);
      sum = (double)a + (double)b + tmp_c;
      if (sum == 1000.0) {
        c = (int)tmp_c;
      }
      if (!c)
        ++b;
    }
    if (!c)
      ++a;
  }
  printf("a = %d; b = %d; c = %d; product = %d\n", a, b, c, (a * b * c));
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<main>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  lea    D23(%rip),%rdi
  call   <puts@plt>
  mov    $0x64,%ebp
  jmp    L50
L64:
  add    $0x1,%ebx
  cmp    %ebp,%ebx
  jg     L28
L85:
  mov    %ebx,%esi
  mov    %ebp,%edi
  call   <calculate_c@plt>
  pxor   %xmm2,%xmm2
  cvtsi2sd %ebp,%xmm2
  pxor   %xmm3,%xmm3
  cvtsi2sd %ebx,%xmm3
  movapd %xmm2,%xmm1
  addsd  %xmm3,%xmm1
  addsd  %xmm0,%xmm1
  ucomisd D21(%rip),%xmm1
  jp     L64
  jne    L64
  cvttsd2si %xmm0,%ecx
  test   %ecx,%ecx
  je     L64
L81:
  mov    %ebp,%r8d
  imul   %ebx,%r8d
  imul   %ecx,%r8d
  mov    %ebx,%edx
  mov    %ebp,%esi
  lea    D7(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L28:
  add    $0x1,%ebp
  cmp    $0x1f5,%ebp
  je     L59
L50:
  mov    $0x1,%ebx
  test   %ebp,%ebp
  jg     L85
  jmp    L28
L59:
  mov    $0x0,%ecx
  jmp    L81
```

tool_calls: name: parse_data
arguments: label: D23
type_infered: string
name: parse_data
arguments: label: D21
type_infered: f64
name: parse_data
arguments: label: D7
type_infered: string

tool: D23: Problem #9 Solution
-------------------

tool: D21: 1000

tool: D7: a = %d; b = %d; c = %d; product = %d


assistant: ```c
void main() {
  int a = 0, b = 0, c = 0;
  double tmp_c, sum;
  printf("Problem #9 Solution\n-------------------\n");
  a = 100;
  while (a <= 500 && c == 0) {
    b = 1;
    while (b <= a && c == 0) {
      tmp_c = calculate_c(a, b);
      sum = (double)a + (double)b + tmp_c;
      if (sum == 1000.0) {
        c = (int)tmp_c;
      }
      if (!c)
        ++b;
    }
    if (!c)
      ++a;
  }
  printf("a = %d; b = %d; c = %d; product = %d\n", a, b, c, (a * b * c));
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %r12
  lea    D14(%rip),%rdi
  push   %rbp
  push   %rbx
  mov    $0x65,%ebx
  sub    $0x10,%rsp
  call   <puts@plt>
  nopl   (%rax)
L57:
  lea    -0x1(%rbx),%ebp
  pxor   %xmm3,%xmm3
  mov    $0x1,%r12d
  cvtsi2sd %ebp,%xmm3
  movsd  %xmm3,0x8(%rsp)
  nopw   0x0(%rax,%rax,1)
L20:
  mov    %r12d,%esi
  mov    %ebp,%edi
  call   <calculate_c@plt>
  pxor   %xmm1,%xmm1
  cvtsi2sd %r12d,%xmm1
  addsd  0x8(%rsp),%xmm1
  addsd  %xmm0,%xmm1
  ucomisd D3(%rip),%xmm1
  jp     L31
  jne    L31
  cvttsd2si %xmm0,%ecx
  test   %ecx,%ecx
  je     L31
L29:
  mov    %r12d,%r8d
  add    $0x10,%rsp
  mov    %r12d,%edx
  mov    %ebp,%esi
  imul   %ebp,%r8d
  pop    %rbx
  lea    D24(%rip),%rdi
  pop    %rbp
  xor    %eax,%eax
  pop    %r12
  imul   %ecx,%r8d
  jmp    1090 <printf@plt>
  nopw   0x0(%rax,%rax,1)
L31:
  add    $0x1,%r12d
  cmp    %r12d,%ebx
  jne    L20
  mov    %r12d,%ebp
  lea    0x1(%r12),%ebx
  cmp    $0x1f4,%r12d
  jle    L57
  xor    %ecx,%ecx
  jmp    L29
```

tool_calls: name: extract_symbolic_data
arguments: label: D14
type_guessed: string
name: extract_symbolic_data
arguments: label: D3
type_guessed: f64
name: extract_symbolic_data
arguments: label: D24
type_guessed: string

tool: D14: Problem #9 Solution
-------------------

tool: D3: 1000

tool: D24: a = %d; b = %d; c = %d; product = %d


assistant: ```c
void main() {
  int a = 0, b = 0, c = 0;
  double tmp_c, sum;
  printf("Problem #9 Solution\n-------------------\n");
  a = 100;
  while (a <= 500 && c == 0) {
    b = 1;
    while (b <= a && c == 0) {
      tmp_c = calculate_c(a, b);
      sum = (double)a + (double)b + tmp_c;
      if (sum == 1000.0) {
        c = (int)tmp_c;
      }
      if (!c)
        ++b;
    }
    if (!c)
      ++a;
  }
  printf("a = %d; b = %d; c = %d; product = %d\n", a, b, c, (a * b * c));
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %r12
  lea    D29(%rip),%rdi
  push   %rbp
  push   %rbx
  mov    $0x65,%ebx
  sub    $0x10,%rsp
  call   <puts@plt>
  nopl   (%rax)
L56:
  lea    -0x1(%rbx),%ebp
  pxor   %xmm3,%xmm3
  mov    $0x1,%r12d
  cvtsi2sd %ebp,%xmm3
  movsd  %xmm3,0x8(%rsp)
  nopw   0x0(%rax,%rax,1)
L57:
  mov    %r12d,%esi
  mov    %ebp,%edi
  call   <calculate_c@plt>
  pxor   %xmm1,%xmm1
  cvtsi2sd %r12d,%xmm1
  addsd  0x8(%rsp),%xmm1
  addsd  %xmm0,%xmm1
  ucomisd D24(%rip),%xmm1
  jp     L45
  jne    L45
  cvttsd2si %xmm0,%ecx
  test   %ecx,%ecx
  je     L45
L0:
  mov    %r12d,%r8d
  add    $0x10,%rsp
  mov    %r12d,%edx
  mov    %ebp,%esi
  imul   %ebp,%r8d
  pop    %rbx
  lea    D7(%rip),%rdi
  pop    %rbp
  xor    %eax,%eax
  pop    %r12
  imul   %ecx,%r8d
  jmp    1090 <printf@plt>
  nopw   0x0(%rax,%rax,1)
L45:
  add    $0x1,%r12d
  cmp    %r12d,%ebx
  jne    L57
  mov    %r12d,%ebp
  lea    0x1(%r12),%ebx
  cmp    $0x1f4,%r12d
  jle    L56
  xor    %ecx,%ecx
  jmp    L0
```

tool_calls: name: unpack_data
arguments: data_tag: D29
type_guessed: string
name: unpack_data
arguments: data_tag: D24
type_guessed: f64
name: unpack_data
arguments: data_tag: D7
type_guessed: string

tool: D29: Problem #9 Solution
-------------------

tool: D24: 1000

tool: D7: a = %d; b = %d; c = %d; product = %d


assistant: ```c
void main() {
  int a = 0, b = 0, c = 0;
  double tmp_c, sum;
  printf("Problem #9 Solution\n-------------------\n");
  a = 100;
  while (a <= 500 && c == 0) {
    b = 1;
    while (b <= a && c == 0) {
      tmp_c = calculate_c(a, b);
      sum = (double)a + (double)b + tmp_c;
      if (sum == 1000.0) {
        c = (int)tmp_c;
      }
      if (!c)
        ++b;
    }
    if (!c)
      ++a;
  }
  printf("a = %d; b = %d; c = %d; product = %d\n", a, b, c, (a * b * c));
}
```
user: What is the c source code of the assembly code below:

```asm
<tournament>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %ecx,-0x4c(%rbp)
  mov    %r8d,-0x50(%rbp)
  movl   $0x0,-0x24(%rbp)
  jmp    L33
L11:
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idivl  -0x50(%rbp)
  mov    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,-0x20(%rbp)
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idivl  -0x50(%rbp)
  mov    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <getChromosomeFitness@plt>
  mov    %rax,%rbx
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <getChromosomeFitness@plt>
  cmp    %rax,%rbx
  jg     L8
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0x20(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <copyChromosome@plt>
  jmp    L17
L8:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0x18(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <copyChromosome@plt>
L17:
  addl   $0x1,-0x24(%rbp)
L33:
  mov    -0x24(%rbp),%eax
  cmp    -0x4c(%rbp),%eax
  jl     L11
  nop
  nop
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
void tournament(struct parameters *params, struct chromosome **parents, struct chromosome **candidateChromos, int numParents, int numCandidateChromos) {
  int i;
  struct chromosome *candidateA;
  struct chromosome *candidateB;
  for (i = 0; i < numParents; i++) {
    candidateA = candidateChromos[rand() % numCandidateChromos];
    candidateB = candidateChromos[rand() % numCandidateChromos];
    if (getChromosomeFitness(candidateA) <= getChromosomeFitness(candidateB)) {
      copyChromosome(parents[i], candidateA);
    } else {
      copyChromosome(parents[i], candidateB);
    }
  }
}
```
user: Translate the below assembly code into C programming language:

```asm
<tournament>:
  endbr64
  test   %ecx,%ecx
  jle    L25
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdx,%r15
  mov    %r8d,%ebx
  mov    %rsi,%rbp
  lea    -0x1(%rcx),%eax
  lea    0x8(%rsi,%rax,8),%rax
  mov    %rax,0x8(%rsp)
  jmp    L40
L44:
  mov    %r13,%rsi
  mov    0x0(%rbp),%rdi
  call   <copyChromosome@plt>
L19:
  add    $0x8,%rbp
  cmp    0x8(%rsp),%rbp
  je     L37
L40:
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idiv   %ebx
  movslq %edx,%rdx
  mov    (%r15,%rdx,8),%r14
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idiv   %ebx
  movslq %edx,%rdx
  mov    (%r15,%rdx,8),%r13
  mov    %r14,%rdi
  call   <getChromosomeFitness@plt>
  mov    %rax,%r12
  mov    %r13,%rdi
  call   <getChromosomeFitness@plt>
  cmp    %rax,%r12
  jg     L44
  mov    %r14,%rsi
  mov    0x0(%rbp),%rdi
  call   <copyChromosome@plt>
  jmp    L19
L37:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L25:
  ret
```

assistant: ```c
void tournament(struct parameters *params, struct chromosome **parents, struct chromosome **candidateChromos, int numParents, int numCandidateChromos) {
  int i;
  struct chromosome *candidateA;
  struct chromosome *candidateB;
  for (i = 0; i < numParents; i++) {
    candidateA = candidateChromos[rand() % numCandidateChromos];
    candidateB = candidateChromos[rand() % numCandidateChromos];
    if (getChromosomeFitness(candidateA) <= getChromosomeFitness(candidateB)) {
      copyChromosome(parents[i], candidateA);
    } else {
      copyChromosome(parents[i], candidateB);
    }
  }
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<tournament>:
  endbr64
  test   %ecx,%ecx
  jle    L14
  push   %r15
  lea    -0x1(%rcx),%eax
  mov    %rdx,%r15
  push   %r14
  lea    0x8(%rsi,%rax,8),%rax
  push   %r13
  push   %r12
  push   %rbp
  mov    %r8d,%ebp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x18,%rsp
  mov    %rax,0x8(%rsp)
  jmp    L12
  nopw   0x0(%rax,%rax,1)
L26:
  mov    (%rbx),%rdi
  mov    %r14,%rsi
  add    $0x8,%rbx
  call   <copyChromosome@plt>
  cmp    0x8(%rsp),%rbx
  je     L25
L12:
  xor    %eax,%eax
  call   <rand@plt>
  cltd
  idiv   %ebp
  xor    %eax,%eax
  movslq %edx,%rdx
  mov    (%r15,%rdx,8),%r14
  call   <rand@plt>
  cltd
  mov    %r14,%rdi
  idiv   %ebp
  movslq %edx,%rdx
  mov    (%r15,%rdx,8),%r13
  call   <getChromosomeFitness@plt>
  mov    %r13,%rdi
  mov    %rax,%r12
  call   <getChromosomeFitness@plt>
  cmp    %rax,%r12
  jle    L26
  mov    (%rbx),%rdi
  mov    %r13,%rsi
  add    $0x8,%rbx
  call   <copyChromosome@plt>
  cmp    0x8(%rsp),%rbx
  jne    L12
L25:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L14:
  ret
```

assistant: ```c
void tournament(struct parameters *params, struct chromosome **parents, struct chromosome **candidateChromos, int numParents, int numCandidateChromos) {
  int i;
  struct chromosome *candidateA;
  struct chromosome *candidateB;
  for (i = 0; i < numParents; i++) {
    candidateA = candidateChromos[rand() % numCandidateChromos];
    candidateB = candidateChromos[rand() % numCandidateChromos];
    if (getChromosomeFitness(candidateA) <= getChromosomeFitness(candidateB)) {
      copyChromosome(parents[i], candidateA);
    } else {
      copyChromosome(parents[i], candidateB);
    }
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<tournament>:
  endbr64
  test   %ecx,%ecx
  jle    L41
  push   %r15
  lea    -0x1(%rcx),%eax
  mov    %rdx,%r15
  push   %r14
  lea    0x8(%rsi,%rax,8),%rax
  push   %r13
  push   %r12
  push   %rbp
  mov    %r8d,%ebp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x18,%rsp
  mov    %rax,0x8(%rsp)
  jmp    L21
  nopw   0x0(%rax,%rax,1)
L46:
  mov    (%rbx),%rdi
  mov    %r14,%rsi
  add    $0x8,%rbx
  call   <copyChromosome@plt>
  cmp    0x8(%rsp),%rbx
  je     L23
L21:
  xor    %eax,%eax
  call   <rand@plt>
  cltd
  idiv   %ebp
  xor    %eax,%eax
  movslq %edx,%rdx
  mov    (%r15,%rdx,8),%r14
  call   <rand@plt>
  cltd
  mov    %r14,%rdi
  idiv   %ebp
  movslq %edx,%rdx
  mov    (%r15,%rdx,8),%r13
  call   <getChromosomeFitness@plt>
  mov    %r13,%rdi
  mov    %rax,%r12
  call   <getChromosomeFitness@plt>
  cmp    %rax,%r12
  jle    L46
  mov    (%rbx),%rdi
  mov    %r13,%rsi
  add    $0x8,%rbx
  call   <copyChromosome@plt>
  cmp    0x8(%rsp),%rbx
  jne    L21
L23:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L41:
  ret
```

assistant: ```c
void tournament(struct parameters *params, struct chromosome **parents, struct chromosome **candidateChromos, int numParents, int numCandidateChromos) {
  int i;
  struct chromosome *candidateA;
  struct chromosome *candidateB;
  for (i = 0; i < numParents; i++) {
    candidateA = candidateChromos[rand() % numCandidateChromos];
    candidateB = candidateChromos[rand() % numCandidateChromos];
    if (getChromosomeFitness(candidateA) <= getChromosomeFitness(candidateB)) {
      copyChromosome(parents[i], candidateA);
    } else {
      copyChromosome(parents[i], candidateB);
    }
  }
}
```
user: What is the c source code of the assembly code below:

```asm
<maxFreqFromSeqFile>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x60(%rbp)
  mov    %esi,-0x54(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
L28:
  cmp    %rax,%rsp
  je     L55
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L28
L55:
  sub    $0x3f0,%rsp
  orq    $0x0,0x3e8(%rsp)
  mov    %rsp,%r13
  mov    -0x54(%rbp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,%r15
  mov    $0x0,%r12d
  lea    D17(%rip),%r14
  lea    -0x48(%rbp),%rax
  mov    %rax,-0x68(%rbp)
  lea    -0x40(%rbp),%rax
  mov    %rax,-0x70(%rbp)
L23:
  mov    -0x60(%rbp),%rdx
  mov    $0x3e8,%esi
  mov    %r13,%rdi
  call   <fgets@plt>
  cmp    -0x54(%rbp),%r12d
  jge    L2
  test   %rax,%rax
  je     L2
  lea    D9(%rip),%rsi
  mov    %r13,%rdi
  call   <strtok@plt>
  mov    %r14,%rsi
  mov    %r13,%rdi
  call   <strtok@plt>
  mov    %rax,%rdi
  mov    $0xa,%edx
  mov    -0x68(%rbp),%rsi
  call   <strtol@plt>
  mov    %eax,%ebx
  mov    %r14,%rsi
  mov    $0x0,%edi
  call   <strtok@plt>
  mov    %rax,%rdi
  mov    $0xa,%edx
  mov    -0x70(%rbp),%rsi
  call   <strtol@plt>
  movslq %ebx,%rbx
  mov    %eax,(%r15,%rbx,4)
  add    $0x1,%r12d
  jmp    L23
L2:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L25
  mov    %r15,%rax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L25:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D17
type_infered: string
name: extract_symbolic_data
arguments: label: D9
type_infered: string

tool: D17: :

tool: D9: 


assistant: ```c
int *maxFreqFromSeqFile(FILE *seqFile, int totalDocs) {
  const int MAX_BYTES_READ_PER_LINE = 1000;
  char line[MAX_BYTES_READ_PER_LINE];
  int docsCount = 0;
  int *maxFreqPerDocs = (int *)malloc(sizeof(int) * totalDocs);
  int docId;
  int maxFreqInCurrentDoc;
  char *tokens;
  while (fgets(line, MAX_BYTES_READ_PER_LINE, seqFile) != NULL && docsCount < totalDocs) {
    strtok(line, "\n");
    tokens = strtok(line, ":");
    char *ptr1, *ptr2;
    docId = strtol(tokens, &ptr1, 10);
    tokens = strtok(NULL, ":");
    maxFreqInCurrentDoc = strtol(tokens, &ptr2, 10);
    maxFreqPerDocs[docId] = maxFreqInCurrentDoc;
    docsCount++;
  }
  return maxFreqPerDocs;
}
```
user: What is the c source code of the assembly code below?

```asm
<maxFreqFromSeqFile>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x48,%rsp
  mov    %esi,-0x54(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  mov    %rsp,%rax
  cmp    %rax,%rsp
  je     L8
L42:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rax,%rsp
  jne    L42
L8:
  sub    $0x3f0,%rsp
  orq    $0x0,0x3e8(%rsp)
  xor    %r12d,%r12d
  lea    D2(%rip),%r14
  mov    -0x54(%rbp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rsp,%r13
  mov    %rax,-0x60(%rbp)
  lea    -0x48(%rbp),%rax
  mov    %rax,-0x68(%rbp)
  lea    -0x40(%rbp),%rax
  mov    %rax,-0x70(%rbp)
  jmp    L43
  nopw   0x0(%rax,%rax,1)
L34:
  test   %rax,%rax
  je     L25
  lea    D19(%rip),%rsi
  mov    %r13,%rdi
  add    $0x1,%r12d
  call   <strtok@plt>
  mov    %r14,%rsi
  mov    %r13,%rdi
  call   <strtok@plt>
  mov    -0x68(%rbp),%rsi
  mov    $0xa,%edx
  mov    %rax,%rdi
  call   <strtol@plt>
  mov    %r14,%rsi
  xor    %edi,%edi
  movslq %eax,%rbx
  call   <strtok@plt>
  mov    -0x70(%rbp),%rsi
  mov    $0xa,%edx
  mov    %rax,%rdi
  call   <strtol@plt>
  mov    -0x60(%rbp),%rcx
  mov    %eax,(%rcx,%rbx,4)
L43:
  mov    %r15,%rdx
  mov    $0x3e8,%esi
  mov    %r13,%rdi
  call   <fgets@plt>
  cmp    -0x54(%rbp),%r12d
  jl     L34
L25:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L9
  mov    -0x60(%rbp),%rax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L9:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D2
type_guessed: string
name: read_data
arguments: data_tag: D19
type_guessed: string

tool: D2: :

tool: D19: 


assistant: ```c
int *maxFreqFromSeqFile(FILE *seqFile, int totalDocs) {
  const int MAX_BYTES_READ_PER_LINE = 1000;
  char line[MAX_BYTES_READ_PER_LINE];
  int docsCount = 0;
  int *maxFreqPerDocs = (int *)malloc(sizeof(int) * totalDocs);
  int docId;
  int maxFreqInCurrentDoc;
  char *tokens;
  while (fgets(line, MAX_BYTES_READ_PER_LINE, seqFile) != NULL && docsCount < totalDocs) {
    strtok(line, "\n");
    tokens = strtok(line, ":");
    char *ptr1, *ptr2;
    docId = strtol(tokens, &ptr1, 10);
    tokens = strtok(NULL, ":");
    maxFreqInCurrentDoc = strtol(tokens, &ptr2, 10);
    maxFreqPerDocs[docId] = maxFreqInCurrentDoc;
    docsCount++;
  }
  return maxFreqPerDocs;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<maxFreqFromSeqFile>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x48,%rsp
  mov    %esi,-0x54(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  mov    %rsp,%rax
  cmp    %rax,%rsp
  je     L2
L9:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rax,%rsp
  jne    L9
L2:
  sub    $0x3f0,%rsp
  orq    $0x0,0x3e8(%rsp)
  xor    %r12d,%r12d
  lea    D19(%rip),%r14
  mov    -0x54(%rbp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rsp,%r13
  mov    %rax,-0x60(%rbp)
  lea    -0x48(%rbp),%rax
  mov    %rax,-0x68(%rbp)
  lea    -0x40(%rbp),%rax
  mov    %rax,-0x70(%rbp)
  jmp    L8
  nopw   0x0(%rax,%rax,1)
L4:
  test   %rax,%rax
  je     L46
  lea    D5(%rip),%rsi
  mov    %r13,%rdi
  add    $0x1,%r12d
  call   <strtok@plt>
  mov    %r14,%rsi
  mov    %r13,%rdi
  call   <strtok@plt>
  mov    -0x68(%rbp),%rsi
  mov    $0xa,%edx
  mov    %rax,%rdi
  call   <strtol@plt>
  mov    %r14,%rsi
  xor    %edi,%edi
  movslq %eax,%rbx
  call   <strtok@plt>
  mov    -0x70(%rbp),%rsi
  mov    $0xa,%edx
  mov    %rax,%rdi
  call   <strtol@plt>
  mov    -0x60(%rbp),%rcx
  mov    %eax,(%rcx,%rbx,4)
L8:
  mov    %r15,%rdx
  mov    $0x3e8,%esi
  mov    %r13,%rdi
  call   <fgets@plt>
  cmp    -0x54(%rbp),%r12d
  jl     L4
L46:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L51
  mov    -0x60(%rbp),%rax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L51:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D19
data_type: string
name: unpack_data
arguments: label: D5
data_type: string

tool: D19: :

tool: D5: 


assistant: ```c
int *maxFreqFromSeqFile(FILE *seqFile, int totalDocs) {
  const int MAX_BYTES_READ_PER_LINE = 1000;
  char line[MAX_BYTES_READ_PER_LINE];
  int docsCount = 0;
  int *maxFreqPerDocs = (int *)malloc(sizeof(int) * totalDocs);
  int docId;
  int maxFreqInCurrentDoc;
  char *tokens;
  while (fgets(line, MAX_BYTES_READ_PER_LINE, seqFile) != NULL && docsCount < totalDocs) {
    strtok(line, "\n");
    tokens = strtok(line, ":");
    char *ptr1, *ptr2;
    docId = strtol(tokens, &ptr1, 10);
    tokens = strtok(NULL, ":");
    maxFreqInCurrentDoc = strtol(tokens, &ptr2, 10);
    maxFreqPerDocs[docId] = maxFreqInCurrentDoc;
    docsCount++;
  }
  return maxFreqPerDocs;
}
```