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

```asm
<minmax>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %rcx,-0x30(%rbp)
  movl   $0x1,-0x4(%rbp)
  jmp    L13
L10:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jle    L0
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
L0:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jge    L35
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x30(%rbp),%rax
  mov    %edx,(%rax)
L35:
  addl   $0x1,-0x4(%rbp)
L13:
  mov    -0x4(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L10
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void minmax(int *arr, int size, int *min, int *max) {
  int count;
  for (count = 1; count < size; count++) {
    if (*min > arr[count]) {
      *min = arr[count];
    }
    if (*max < arr[count]) {
      *max = arr[count];
    }
  }
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<minmax>:
  endbr64
  cmp    $0x1,%esi
  jle    L54
  lea    0x4(%rdi),%rax
  lea    -0x2(%rsi),%esi
  lea    0x8(%rdi,%rsi,4),%r8
  jmp    L32
L50:
  add    $0x4,%rax
  cmp    %r8,%rax
  je     L54
L32:
  mov    %rax,%rdi
  mov    (%rax),%esi
  cmp    %esi,(%rdx)
  jle    L33
  mov    %esi,(%rdx)
L33:
  mov    (%rdi),%esi
  cmp    %esi,(%rcx)
  jge    L50
  mov    %esi,(%rcx)
  jmp    L50
L54:
  ret
```

assistant: ```c
void minmax(int *arr, int size, int *min, int *max) {
  int count;
  for (count = 1; count < size; count++) {
    if (*min > arr[count]) {
      *min = arr[count];
    }
    if (*max < arr[count]) {
      *max = arr[count];
    }
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<minmax>:
  endbr64
  cmp    $0x1,%esi
  jle    L6
  sub    $0x2,%esi
  lea    0x4(%rdi),%rax
  lea    0x8(%rdi,%rsi,4),%rdi
  nopl   (%rax)
L16:
  mov    (%rax),%esi
  cmp    %esi,(%rdx)
  jle    L30
  mov    %esi,(%rdx)
L30:
  cmp    (%rcx),%esi
  jle    L29
  mov    %esi,(%rcx)
L29:
  add    $0x4,%rax
  cmp    %rdi,%rax
  jne    L16
L6:
  ret
```

assistant: ```c
void minmax(int *arr, int size, int *min, int *max) {
  int count;
  for (count = 1; count < size; count++) {
    if (*min > arr[count]) {
      *min = arr[count];
    }
    if (*max < arr[count]) {
      *max = arr[count];
    }
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<minmax>:
  endbr64
  cmp    $0x1,%esi
  jle    L27
  sub    $0x2,%esi
  lea    0x4(%rdi),%rax
  lea    0x8(%rdi,%rsi,4),%rdi
  nopl   (%rax)
L19:
  mov    (%rax),%esi
  cmp    %esi,(%rdx)
  jle    L32
  mov    %esi,(%rdx)
L32:
  cmp    (%rcx),%esi
  jle    L16
  mov    %esi,(%rcx)
L16:
  add    $0x4,%rax
  cmp    %rdi,%rax
  jne    L19
L27:
  ret
```

assistant: ```c
void minmax(int *arr, int size, int *min, int *max) {
  int count;
  for (count = 1; count < size; count++) {
    if (*min > arr[count]) {
      *min = arr[count];
    }
    if (*max < arr[count]) {
      *max = arr[count];
    }
  }
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<wcsutil_null_fill>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jle    L98
  cmpq   $0x0,-0x20(%rbp)
  je     L61
  movl   $0x0,-0x4(%rbp)
  jmp    L43
L27:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L2
  addl   $0x1,-0x4(%rbp)
L43:
  mov    -0x4(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L27
  jmp    L79
L2:
  nop
L79:
  mov    -0x4(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jne    L141
  mov    -0x14(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
L141:
  subl   $0x1,-0x4(%rbp)
  jmp    L110
L106:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  jne    L20
  subl   $0x1,-0x4(%rbp)
L110:
  cmpl   $0x0,-0x4(%rbp)
  jg     L106
  jmp    L108
L20:
  nop
L108:
  addl   $0x1,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jge    L107
  mov    -0x14(%rbp),%eax
  sub    -0x4(%rbp),%eax
  cltq
  mov    -0x4(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x20(%rbp),%rdx
  add    %rdx,%rcx
  mov    %rax,%rdx
  mov    $0x0,%esi
  mov    %rcx,%rdi
  call   <memset@plt>
  jmp    L107
L98:
  nop
  jmp    L139
L61:
  nop
  jmp    L139
L107:
  nop
L139:
  leave
  ret
```

assistant: ```c
void wcsutil_null_fill(int n, char c[]) {
  if (n <= 0)
    return;
  if (c == 0x0) {
    return;
  }
  int j;
  for (j = 0; j < n; j++) {
    if (c[j] == '\0') {
      break;
    }
  }
  if (j == n) {
    j = n - 1;
    c[j] = '\0';
  }
  j--;
  for (; j > 0; j--) {
    if (c[j] != ' ') {
      break;
    }
  }
  if (++j < n) {
    memset(c + j, '\0', n - j);
  }
  return;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<wcsutil_null_fill>:
  endbr64
  test   %rsi,%rsi
  je     L37
  test   %edi,%edi
  jle    L37
  mov    %rsi,%rcx
  mov    $0x0,%eax
L95:
  cmpb   $0x0,(%rcx)
  je     L59
  add    $0x1,%eax
  add    $0x1,%rcx
  cmp    %eax,%edi
  jg     L95
L59:
  cmp    %eax,%edi
  je     L29
L24:
  sub    $0x1,%eax
  test   %eax,%eax
  jle    L47
  movslq %eax,%rcx
  add    %rsi,%rcx
L53:
  cmpb   $0x20,(%rcx)
  jne    L47
  sub    $0x1,%rcx
  sub    $0x1,%eax
  jne    L53
L47:
  add    $0x1,%eax
  cmp    %eax,%edi
  jg     L89
L37:
  ret
L29:
  lea    -0x1(%rdi),%eax
  movslq %eax,%rdx
  movb   $0x0,(%rsi,%rdx,1)
  jmp    L24
L89:
  sub    $0x8,%rsp
  sub    %eax,%edi
  movslq %edi,%rdx
  cltq
  lea    (%rsi,%rax,1),%rdi
  mov    $0x0,%esi
  call   <memset@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
void wcsutil_null_fill(int n, char c[]) {
  if (n <= 0)
    return;
  if (c == 0x0) {
    return;
  }
  int j;
  for (j = 0; j < n; j++) {
    if (c[j] == '\0') {
      break;
    }
  }
  if (j == n) {
    j = n - 1;
    c[j] = '\0';
  }
  j--;
  for (; j > 0; j--) {
    if (c[j] != ' ') {
      break;
    }
  }
  if (++j < n) {
    memset(c + j, '\0', n - j);
  }
  return;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<wcsutil_null_fill>:
  endbr64
  test   %edi,%edi
  jle    L80
  mov    %rsi,%rax
  xor    %ecx,%ecx
  test   %rsi,%rsi
  je     L80
  nopw   0x0(%rax,%rax,1)
L34:
  cmpb   $0x0,(%rax)
  je     L25
  add    $0x1,%ecx
  add    $0x1,%rax
  cmp    %ecx,%edi
  jg     L34
L25:
  cmp    %ecx,%edi
  je     L53
L106:
  lea    -0x1(%rcx),%eax
  test   %eax,%eax
  jle    L92
  cltq
  jmp    L38
  nopw   0x0(%rax,%rax,1)
L102:
  sub    $0x1,%rax
  test   %eax,%eax
  jle    L92
L38:
  cmpb   $0x20,(%rsi,%rax,1)
  mov    %eax,%ecx
  je     L102
  add    $0x1,%ecx
L92:
  cmp    %ecx,%edi
  jg     L73
L80:
  ret
  nopl   0x0(%rax,%rax,1)
L53:
  lea    -0x1(%rdi),%ecx
  movslq %ecx,%rax
  movb   $0x0,(%rsi,%rax,1)
  jmp    L106
  nopl   0x0(%rax)
L73:
  sub    %ecx,%edi
  movslq %ecx,%rcx
  movslq %edi,%rdx
  lea    (%rsi,%rcx,1),%rdi
  xor    %esi,%esi
  jmp    1050 <memset@plt>
```

assistant: ```c
void wcsutil_null_fill(int n, char c[]) {
  if (n <= 0)
    return;
  if (c == 0x0) {
    return;
  }
  int j;
  for (j = 0; j < n; j++) {
    if (c[j] == '\0') {
      break;
    }
  }
  if (j == n) {
    j = n - 1;
    c[j] = '\0';
  }
  j--;
  for (; j > 0; j--) {
    if (c[j] != ' ') {
      break;
    }
  }
  if (++j < n) {
    memset(c + j, '\0', n - j);
  }
  return;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<wcsutil_null_fill>:
  endbr64
  test   %edi,%edi
  jle    L70
  mov    %rsi,%rax
  xor    %ecx,%ecx
  test   %rsi,%rsi
  je     L70
  nopw   0x0(%rax,%rax,1)
L2:
  cmpb   $0x0,(%rax)
  je     L18
  add    $0x1,%ecx
  add    $0x1,%rax
  cmp    %ecx,%edi
  jg     L2
L18:
  cmp    %ecx,%edi
  je     L34
L12:
  lea    -0x1(%rcx),%eax
  test   %eax,%eax
  jle    L64
  cltq
  jmp    L40
  nopw   0x0(%rax,%rax,1)
L14:
  sub    $0x1,%rax
  test   %eax,%eax
  jle    L64
L40:
  cmpb   $0x20,(%rsi,%rax,1)
  mov    %eax,%ecx
  je     L14
  add    $0x1,%ecx
L64:
  cmp    %ecx,%edi
  jg     L56
L70:
  ret
  nopl   0x0(%rax,%rax,1)
L34:
  lea    -0x1(%rdi),%ecx
  movslq %ecx,%rax
  movb   $0x0,(%rsi,%rax,1)
  jmp    L12
  nopl   0x0(%rax)
L56:
  sub    %ecx,%edi
  movslq %ecx,%rcx
  movslq %edi,%rdx
  lea    (%rsi,%rcx,1),%rdi
  xor    %esi,%esi
  jmp    1050 <memset@plt>
```

assistant: ```c
void wcsutil_null_fill(int n, char c[]) {
  if (n <= 0)
    return;
  if (c == 0x0) {
    return;
  }
  int j;
  for (j = 0; j < n; j++) {
    if (c[j] == '\0') {
      break;
    }
  }
  if (j == n) {
    j = n - 1;
    c[j] = '\0';
  }
  j--;
  for (; j > 0; j--) {
    if (c[j] != ' ') {
      break;
    }
  }
  if (++j < n) {
    memset(c + j, '\0', n - j);
  }
  return;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<Cyc_List_rrev>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %rsi,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L19
  mov    $0x0,%eax
  jmp    L1
L19:
  mov    -0x10(%rbp),%rcx
  mov    -0x8(%rbp),%rax
  mov    $0x0,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <Cyc_List_rrevappend@plt>
  cltq
L1:
  leave
  ret
```

assistant: ```c
struct Cyc_List_List *Cyc_List_rrev(struct _RegionHandle *r2, struct Cyc_List_List *x) {
  if (x == 0)
    return 0;
  return ({ Cyc_List_rrevappend(r2, x, 0); });
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<Cyc_List_rrev>:
  endbr64
  test   %rsi,%rsi
  je     L8
  sub    $0x8,%rsp
  mov    $0x0,%edx
  call   <Cyc_List_rrevappend@plt>
  cltq
  add    $0x8,%rsp
  ret
L8:
  mov    %rsi,%rax
  ret
```

assistant: ```c
struct Cyc_List_List *Cyc_List_rrev(struct _RegionHandle *r2, struct Cyc_List_List *x) {
  if (x == 0)
    return 0;
  return ({ Cyc_List_rrevappend(r2, x, 0); });
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<Cyc_List_rrev>:
  endbr64
  test   %rsi,%rsi
  je     L4
  sub    $0x8,%rsp
  xor    %edx,%edx
  call   <Cyc_List_rrevappend@plt>
  add    $0x8,%rsp
  cltq
  ret
  nopl   0x0(%rax,%rax,1)
L4:
  xor    %eax,%eax
  ret
```

assistant: ```c
struct Cyc_List_List *Cyc_List_rrev(struct _RegionHandle *r2, struct Cyc_List_List *x) {
  if (x == 0)
    return 0;
  return ({ Cyc_List_rrevappend(r2, x, 0); });
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<Cyc_List_rrev>:
  endbr64
  test   %rsi,%rsi
  je     L1
  sub    $0x8,%rsp
  xor    %edx,%edx
  call   <Cyc_List_rrevappend@plt>
  add    $0x8,%rsp
  cltq
  ret
  nopl   0x0(%rax,%rax,1)
L1:
  xor    %eax,%eax
  ret
```

assistant: ```c
struct Cyc_List_List *Cyc_List_rrev(struct _RegionHandle *r2, struct Cyc_List_List *x) {
  if (x == 0)
    return 0;
  return ({ Cyc_List_rrevappend(r2, x, 0); });
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<handle_data>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x110,%rsp
  mov    %rdi,-0xf8(%rbp)
  mov    %esi,-0xfc(%rbp)
  mov    %edx,-0x100(%rbp)
  mov    %rcx,-0x108(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x100(%rbp),%rax
  mov    %rax,%rdi
  call   <localtime@plt>
  mov    %rax,-0xf0(%rbp)
  mov    -0xf0(%rbp),%rdx
  lea    -0xe0(%rbp),%rax
  mov    %rdx,%rcx
  lea    D9(%rip),%rdx
  mov    $0x64,%esi
  mov    %rax,%rdi
  call   <strftime@plt>
  lea    -0xe0(%rbp),%rcx
  mov    -0x108(%rbp),%rdx
  lea    -0x70(%rbp),%rax
  lea    D75(%rip),%r8
  lea    D47(%rip),%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  lea    -0x70(%rbp),%rax
  lea    D25(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0xe8(%rbp)
  cmpq   $0x0,-0xe8(%rbp)
  jne    L12
  lea    D62(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0xffffffff,%eax
  jmp    L27
L12:
  mov    -0xf0(%rbp),%rdx
  lea    -0xe0(%rbp),%rax
  mov    %rdx,%rcx
  lea    D26(%rip),%rdx
  mov    $0x64,%esi
  mov    %rax,%rdi
  call   <strftime@plt>
  mov    -0xf8(%rbp),%rdx
  lea    -0xe0(%rbp),%rax
  mov    %rax,%rsi
  lea    D42(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    -0xf8(%rbp),%rcx
  lea    -0xe0(%rbp),%rdx
  mov    -0xe8(%rbp),%rax
  lea    D5(%rip),%rsi
  mov    %rax,%rdi
  call   <fprintf@plt>
  mov    -0xe8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
L27:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L19
  call   <__stack_chk_fail@plt>
L19:
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_label: D9
type_guessed: string
name: parse_data
arguments: data_label: D75
type_guessed: string
name: parse_data
arguments: data_label: D47
type_guessed: string
name: parse_data
arguments: data_label: D25
type_guessed: string
name: parse_data
arguments: data_label: D62
type_guessed: string
name: parse_data
arguments: data_label: D26
type_guessed: string
name: parse_data
arguments: data_label: D42
type_guessed: string
name: parse_data
arguments: data_label: D5
type_guessed: string

tool: D9: %F

tool: D75: txt

tool: D47: %s/%s.%s

tool: D25: a

tool: D62: Client: fopen()

tool: D26: %F %T

tool: D42: Client: %s;%s


tool: D5: %s;%s


assistant: ```c
int handle_data(char *buf, const int bufsize, const time_t polltime, char *datadir) {
  struct tm *loctime;
  char timestr[100];
  char fname[100];
  FILE *logfile;
  loctime = localtime(&polltime);
  strftime(timestr, sizeof(timestr), "%F", loctime);
  sprintf(fname, "%s/%s.%s", datadir, timestr, "txt");
  if ((logfile = fopen(fname, "a")) == NULL) {
    perror("Client: fopen()");
    return -1;
  }
  strftime(timestr, sizeof(timestr), "%F %T", loctime);
  printf("Client: %s;%s\n", timestr, buf);
  fprintf(logfile, "%s;%s\n", timestr, buf);
  fclose(logfile);
  return 0;
}
```
user: What is the c source code of the assembly code below:

```asm
<handle_data>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xf0,%rsp
  mov    %rdi,%r13
  mov    %edx,0xc(%rsp)
  mov    %rcx,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0xe8(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%rdi
  call   <localtime@plt>
  mov    %rax,%r12
  lea    0x10(%rsp),%rbx
  mov    %rax,%rcx
  lea    D68(%rip),%rdx
  mov    $0x64,%esi
  mov    %rbx,%rdi
  call   <strftime@plt>
  lea    0x80(%rsp),%r14
  lea    D46(%rip),%r8
  mov    %rbx,%rcx
  mov    %rbp,%rdx
  lea    D52(%rip),%rsi
  mov    %r14,%rdi
  call   <sprintf@plt>
  lea    D37(%rip),%rsi
  mov    %r14,%rdi
  call   <fopen@plt>
  test   %rax,%rax
  je     L13
  mov    %rax,%rbx
  lea    0x10(%rsp),%rbp
  mov    %r12,%rcx
  lea    D7(%rip),%rdx
  mov    $0x64,%esi
  mov    %rbp,%rdi
  call   <strftime@plt>
  mov    %r13,%rdx
  mov    %rbp,%rsi
  lea    D53(%rip),%rdi
  call   <printf@plt>
  mov    %r13,%rcx
  mov    %rbp,%rdx
  lea    D48(%rip),%rsi
  mov    %rbx,%rdi
  call   <fprintf@plt>
  mov    %rbx,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
L11:
  mov    0xe8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L5
  add    $0xf0,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L13:
  lea    D47(%rip),%rdi
  call   <perror@plt>
  mov    $0xffffffff,%eax
  jmp    L11
L5:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D68
datatype: string
name: read_data
arguments: tag: D46
datatype: string
name: read_data
arguments: tag: D52
datatype: string
name: read_data
arguments: tag: D37
datatype: string
name: read_data
arguments: tag: D7
datatype: string
name: read_data
arguments: tag: D53
datatype: string
name: read_data
arguments: tag: D48
datatype: string
name: read_data
arguments: tag: D47
datatype: string

tool: D68: %F

tool: D46: txt

tool: D52: %s/%s.%s

tool: D37: a

tool: D7: %F %T

tool: D53: Client: %s;%s


tool: D48: %s;%s


tool: D47: Client: fopen()

assistant: ```c
int handle_data(char *buf, const int bufsize, const time_t polltime, char *datadir) {
  struct tm *loctime;
  char timestr[100];
  char fname[100];
  FILE *logfile;
  loctime = localtime(&polltime);
  strftime(timestr, sizeof(timestr), "%F", loctime);
  sprintf(fname, "%s/%s.%s", datadir, timestr, "txt");
  if ((logfile = fopen(fname, "a")) == NULL) {
    perror("Client: fopen()");
    return -1;
  }
  strftime(timestr, sizeof(timestr), "%F %T", loctime);
  printf("Client: %s;%s\n", timestr, buf);
  fprintf(logfile, "%s;%s\n", timestr, buf);
  fclose(logfile);
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<handle_data>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  push   %rbp
  sub    $0xf0,%rsp
  mov    %edx,0xc(%rsp)
  lea    0xc(%rsp),%rdi
  lea    0x10(%rsp),%r12
  lea    0x80(%rsp),%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0xe8(%rsp)
  xor    %eax,%eax
  call   <localtime@plt>
  lea    D62(%rip),%rdx
  mov    $0x64,%esi
  mov    %r12,%rdi
  mov    %rax,%rcx
  mov    %rax,%r13
  call   <strftime@plt>
  mov    %rbp,%rdi
  mov    %r12,%rcx
  mov    %r15,%rdx
  lea    D7(%rip),%rsi
  lea    D4(%rip),%r8
  call   <sprintf@plt>
  lea    D48(%rip),%rsi
  mov    %rbp,%rdi
  call   <fopen@plt>
  test   %rax,%rax
  je     L29
  mov    %r13,%rcx
  lea    D73(%rip),%rdx
  mov    %r12,%rdi
  mov    %rax,%rbp
  mov    $0x64,%esi
  call   <strftime@plt>
  mov    %r14,%rdx
  mov    %r12,%rsi
  lea    D61(%rip),%rdi
  call   <printf@plt>
  mov    %r14,%rcx
  mov    %r12,%rdx
  mov    %rbp,%rdi
  lea    D46(%rip),%rsi
  call   <fprintf@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  xor    %eax,%eax
L18:
  mov    0xe8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L22
  add    $0xf0,%rsp
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L29:
  lea    D70(%rip),%rdi
  call   <perror@plt>
  mov    $0xffffffff,%eax
  jmp    L18
L22:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D62
data_type: string
name: parse_data
arguments: label: D7
data_type: string
name: parse_data
arguments: label: D4
data_type: string
name: parse_data
arguments: label: D48
data_type: string
name: parse_data
arguments: label: D73
data_type: string
name: parse_data
arguments: label: D61
data_type: string
name: parse_data
arguments: label: D46
data_type: string
name: parse_data
arguments: label: D70
data_type: string

tool: D62: %F

tool: D7: %s/%s.%s

tool: D4: txt

tool: D48: a

tool: D73: %F %T

tool: D61: Client: %s;%s


tool: D46: %s;%s


tool: D70: Client: fopen()

assistant: ```c
int handle_data(char *buf, const int bufsize, const time_t polltime, char *datadir) {
  struct tm *loctime;
  char timestr[100];
  char fname[100];
  FILE *logfile;
  loctime = localtime(&polltime);
  strftime(timestr, sizeof(timestr), "%F", loctime);
  sprintf(fname, "%s/%s.%s", datadir, timestr, "txt");
  if ((logfile = fopen(fname, "a")) == NULL) {
    perror("Client: fopen()");
    return -1;
  }
  strftime(timestr, sizeof(timestr), "%F %T", loctime);
  printf("Client: %s;%s\n", timestr, buf);
  fprintf(logfile, "%s;%s\n", timestr, buf);
  fclose(logfile);
  return 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<handle_data>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  push   %rbp
  sub    $0xf0,%rsp
  mov    %edx,0xc(%rsp)
  lea    0xc(%rsp),%rdi
  lea    0x10(%rsp),%r12
  lea    0x80(%rsp),%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0xe8(%rsp)
  xor    %eax,%eax
  call   <localtime@plt>
  lea    D28(%rip),%rdx
  mov    $0x64,%esi
  mov    %r12,%rdi
  mov    %rax,%rcx
  mov    %rax,%r13
  call   <strftime@plt>
  mov    %rbp,%rdi
  mov    %r12,%rcx
  mov    %r15,%rdx
  lea    D48(%rip),%rsi
  lea    D20(%rip),%r8
  call   <sprintf@plt>
  lea    D65(%rip),%rsi
  mov    %rbp,%rdi
  call   <fopen@plt>
  test   %rax,%rax
  je     L10
  mov    %r13,%rcx
  lea    D43(%rip),%rdx
  mov    %r12,%rdi
  mov    %rax,%rbp
  mov    $0x64,%esi
  call   <strftime@plt>
  mov    %r14,%rdx
  mov    %r12,%rsi
  lea    D58(%rip),%rdi
  call   <printf@plt>
  mov    %r14,%rcx
  mov    %r12,%rdx
  mov    %rbp,%rdi
  lea    D16(%rip),%rsi
  call   <fprintf@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  xor    %eax,%eax
L25:
  mov    0xe8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L5
  add    $0xf0,%rsp
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L10:
  lea    D37(%rip),%rdi
  call   <perror@plt>
  mov    $0xffffffff,%eax
  jmp    L25
L5:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: tag: D28
type_infered: string
name: extract_symbolic_data
arguments: tag: D48
type_infered: string
name: extract_symbolic_data
arguments: tag: D20
type_infered: string
name: extract_symbolic_data
arguments: tag: D65
type_infered: string
name: extract_symbolic_data
arguments: tag: D43
type_infered: string
name: extract_symbolic_data
arguments: tag: D58
type_infered: string
name: extract_symbolic_data
arguments: tag: D16
type_infered: string
name: extract_symbolic_data
arguments: tag: D37
type_infered: string

tool: D28: %F

tool: D48: %s/%s.%s

tool: D20: txt

tool: D65: a

tool: D43: %F %T

tool: D58: Client: %s;%s


tool: D16: %s;%s


tool: D37: Client: fopen()

assistant: ```c
int handle_data(char *buf, const int bufsize, const time_t polltime, char *datadir) {
  struct tm *loctime;
  char timestr[100];
  char fname[100];
  FILE *logfile;
  loctime = localtime(&polltime);
  strftime(timestr, sizeof(timestr), "%F", loctime);
  sprintf(fname, "%s/%s.%s", datadir, timestr, "txt");
  if ((logfile = fopen(fname, "a")) == NULL) {
    perror("Client: fopen()");
    return -1;
  }
  strftime(timestr, sizeof(timestr), "%F %T", loctime);
  printf("Client: %s;%s\n", timestr, buf);
  fprintf(logfile, "%s;%s\n", timestr, buf);
  fclose(logfile);
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<fwrite_usmatrix>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8,-0x48(%rbp)
  mov    %r9,-0x50(%rbp)
  mov    -0x48(%rbp),%rax
  sub    -0x40(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x50(%rbp),%rax
  lea    D11(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L8
  lea    D0(%rip),%rax
  mov    %rax,%rdi
  call   <nrerror@plt>
L8:
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  jmp    L17
L1:
  mov    -0x18(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x30(%rbp),%rax
  shl    $0x2,%rax
  lea    (%rdx,%rax,1),%rdi
  mov    -0x8(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rdx,%rcx
  mov    %rax,%rdx
  mov    $0x4,%esi
  call   <fwrite@plt>
  addq   $0x1,-0x18(%rbp)
L17:
  mov    -0x18(%rbp),%rax
  cmp    -0x38(%rbp),%rax
  jle    L1
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  nop
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D11
datatype: string
name: extract_symbolic_data
arguments: label: D0
datatype: string

tool: D11: wb

tool: D0: Can't open file in fwrite_usmatrix

assistant: ```c
void fwrite_usmatrix(ushort **m, long nrl, long nrh, long ncl, long nch, char *filename) {
  long i, ncol = nch - ncl + 1;
  FILE *f;
  f = fopen(filename, "wb");
  if (f == NULL)
    nrerror("Can't open file in fwrite_usmatrix");
  for (i = nrl; i <= nrh; i++) {
    fwrite(m[i] + nrl, sizeof(ushort), ncol, f);
  }
  fclose(f);
}
```