user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %r12
  pxor   %xmm0,%xmm0
  lea    D41(%rip),%rsi
  lea    D5(%rip),%rdi
  push   %rbp
  sub    $0x238,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x228(%rsp)
  xor    %eax,%eax
  movaps %xmm0,0x20(%rsp)
  movaps %xmm0,0x30(%rsp)
  movaps %xmm0,0x40(%rsp)
  movaps %xmm0,0x50(%rsp)
  movaps %xmm0,0x60(%rsp)
  movaps %xmm0,0x70(%rsp)
  movaps %xmm0,0x80(%rsp)
  movaps %xmm0,0x90(%rsp)
  movaps %xmm0,0xa0(%rsp)
  movaps %xmm0,0xb0(%rsp)
  movaps %xmm0,0xc0(%rsp)
  movaps %xmm0,0xd0(%rsp)
  movaps %xmm0,0xe0(%rsp)
  movaps %xmm0,0xf0(%rsp)
  movaps %xmm0,0x100(%rsp)
  movaps %xmm0,0x110(%rsp)
  movaps %xmm0,0x120(%rsp)
  movaps %xmm0,0x130(%rsp)
  movaps %xmm0,0x140(%rsp)
  movaps %xmm0,0x150(%rsp)
  movaps %xmm0,0x160(%rsp)
  movaps %xmm0,0x170(%rsp)
  movaps %xmm0,0x180(%rsp)
  movaps %xmm0,0x190(%rsp)
  movaps %xmm0,0x1a0(%rsp)
  movaps %xmm0,0x1b0(%rsp)
  movaps %xmm0,0x1c0(%rsp)
  movaps %xmm0,0x1d0(%rsp)
  movaps %xmm0,0x1e0(%rsp)
  movaps %xmm0,0x1f0(%rsp)
  movaps %xmm0,0x200(%rsp)
  movaps %xmm0,0x210(%rsp)
  call   <fopen@plt>
  test   %rax,%rax
  je     L51
  lea    0x20(%rsp),%r12
  mov    %rax,%rdx
  mov    $0x100,%esi
  mov    %rax,%rbp
  mov    %r12,%rdi
  call   <fgets@plt>
  mov    %r12,%rdi
  call   <strlen@plt>
  cmpb   $0xa,0x1f(%rsp,%rax,1)
  mov    %rax,0x8(%rsp)
  jne    L44
  movb   $0x0,0x1f(%rsp,%rax,1)
L44:
  mov    %rbp,%rdi
  call   <fclose@plt>
  lea    D89(%rip),%rsi
  lea    D21(%rip),%rdi
  call   <iconv_open@plt>
  mov    %rax,%rbp
  cmp    $0xffffffffffffffff,%rax
  je     L50
L20:
  mov    %r12,%rdi
  mov    %r12,(%rsp)
  lea    0x120(%rsp),%r12
  call   <strlen@plt>
  lea    0x18(%rsp),%rcx
  mov    %rsp,%rsi
  mov    %rbp,%rdi
  lea    0x8(%rsp),%rdx
  lea    0x10(%rsp),%r8
  mov    %rax,0x8(%rsp)
  movq   $0x100,0x10(%rsp)
  mov    %r12,0x18(%rsp)
  call   <iconv@plt>
  cmp    $0xffffffffffffffff,%rax
  je     L13
  mov    %rbp,%rdi
  call   <iconv_close@plt>
  lea    D83(%rip),%rsi
  lea    D94(%rip),%rdi
  call   <fopen@plt>
  mov    %r12,%rdi
  mov    %rax,%rbp
  mov    %rax,%rsi
  call   <fputs@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  xor    %eax,%eax
L8:
  mov    0x228(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L29
  add    $0x238,%rsp
  pop    %rbp
  pop    %r12
  ret
L50:
  lea    D59(%rip),%rdi
  call   <printf@plt>
  jmp    L20
L13:
  lea    D85(%rip),%rdi
  call   <printf@plt>
  lea    D30(%rip),%rdi
  call   <perror@plt>
  mov    $0xfffffffd,%eax
  jmp    L8
L51:
  lea    D36(%rip),%rdi
  call   <printf@plt>
  or     $0xffffffff,%eax
  jmp    L8
L29:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D41
data_type: string
name: read_data
arguments: label: D5
data_type: string
name: read_data
arguments: label: D89
data_type: string
name: read_data
arguments: label: D21
data_type: string
name: read_data
arguments: label: D83
data_type: string
name: read_data
arguments: label: D94
data_type: string
name: read_data
arguments: label: D59
data_type: string
name: read_data
arguments: label: D85
data_type: string
name: read_data
arguments: label: D30
data_type: string
name: read_data
arguments: label: D36
data_type: string

tool: D41: r

tool: D5: test1.txt

tool: D89: utf-8

tool: D21: Shift_JIS

tool: D83: w

tool: D94: test2.txt

tool: D59: iconv_open error!


tool: D85: iconv error!


tool: D30: iconv error detail

tool: D36: fopen error!


assistant: ```c
int main(void) {
  FILE *fp = NULL;
  char buf[256] = {0};
  char *buf_ptr;
  size_t len;
  iconv_t iconv_dsc;
  char buf2[256] = {0};
  size_t len2;
  char *buf2_ptr;
  size_t ret_len;
  fp = fopen("test1.txt", "r");
  if (fp == NULL) {
    printf("fopen error!\n");
    return -1;
  }
  fgets(buf, 256, fp);
  len = strlen(buf);
  if (buf[len - 1] == '\n') {
    buf[len - 1] = '\0';
  }
  fclose(fp);
  iconv_dsc = iconv_open("Shift_JIS", "utf-8");
  if (iconv_dsc == (iconv_t)-1) {
    printf("iconv_open error!\n");
  }
  buf_ptr = buf;
  len = strlen(buf);
  len2 = sizeof(buf2);
  buf2_ptr = buf2;
  ret_len = iconv(iconv_dsc, &buf_ptr, &len, &buf2_ptr, &len2);
  if (ret_len == -1) {
    printf("iconv error!\n");
    perror("iconv error detail");
    return -3;
  }
  iconv_close(iconv_dsc);
  fp = fopen("test2.txt", "w");
  fputs(buf2, fp);
  fclose(fp);
  return 0;
}
```