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

```asm
<main>:
  endbr64
  push   %r12
  pxor   %xmm0,%xmm0
  lea    D50(%rip),%rsi
  lea    D92(%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     L50
  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    L61
  movb   $0x0,0x1f(%rsp,%rax,1)
L61:
  mov    %rbp,%rdi
  call   <fclose@plt>
  lea    D93(%rip),%rsi
  lea    D86(%rip),%rdi
  call   <iconv_open@plt>
  mov    %rax,%rbp
  cmp    $0xffffffffffffffff,%rax
  je     L59
L37:
  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     L78
  mov    %rbp,%rdi
  call   <iconv_close@plt>
  lea    D70(%rip),%rsi
  lea    D53(%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
L48:
  mov    0x228(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L10
  add    $0x238,%rsp
  pop    %rbp
  pop    %r12
  ret
L59:
  lea    D73(%rip),%rdi
  call   <printf@plt>
  jmp    L37
L78:
  lea    D27(%rip),%rdi
  call   <printf@plt>
  lea    D41(%rip),%rdi
  call   <perror@plt>
  mov    $0xfffffffd,%eax
  jmp    L48
L50:
  lea    D94(%rip),%rdi
  call   <printf@plt>
  or     $0xffffffff,%eax
  jmp    L48
L10:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D50
datatype: string
name: disassemble_data
arguments: tag: D92
datatype: string
name: disassemble_data
arguments: tag: D93
datatype: string
name: disassemble_data
arguments: tag: D86
datatype: string
name: disassemble_data
arguments: tag: D70
datatype: string
name: disassemble_data
arguments: tag: D53
datatype: string
name: disassemble_data
arguments: tag: D73
datatype: string
name: disassemble_data
arguments: tag: D27
datatype: string
name: disassemble_data
arguments: tag: D41
datatype: string
name: disassemble_data
arguments: tag: D94
datatype: string

tool: D50: r

tool: D92: test1.txt

tool: D93: utf-8

tool: D86: Shift_JIS

tool: D70: w

tool: D53: test2.txt

tool: D73: iconv_open error!


tool: D27: iconv error!


tool: D41: iconv error detail

tool: D94: 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;
}
```