user: 请将以下的汇编代码转换成C语言代码:

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x20000(%rsp),%r11
L87:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L87
  sub    $0x428,%rsp
  mov    %fs:0x28,%rdx
  mov    %rdx,0x20418(%rsp)
  xor    %edx,%edx
  cmp    $0x1,%edi
  jle    L118
  mov    %rsi,%rbx
  cmp    $0x2,%edi
  jle    L68
  lea    D51(%rip),%rdi
  call   <printf@plt>
L92:
  mov    0x20418(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L168
  mov    $0x0,%eax
  add    $0x20428,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L118:
  lea    D86(%rip),%rdi
  call   <printf@plt>
  jmp    L92
L68:
  mov    0x8(%rsi),%rdi
  lea    D78(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%rbp
  lea    0x410(%rsp),%rdi
  mov    %rax,%rcx
  mov    $0x10000,%edx
  mov    $0x1,%esi
  call   <fread@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  mov    0x8(%rbx),%rdi
  lea    D161(%rip),%rsi
  call   <strtok@plt>
  mov    %rax,%rbx
  lea    D79(%rip),%rdi
  call   <printf@plt>
  lea    0xc(%rsp),%rsi
  lea    D112(%rip),%rdi
  call   <scanf@plt>
  mov    0xc(%rsp),%edi
  mov    0x40c(%rsp),%ecx
  mov    0x10(%rsp),%edx
  mov    $0x0,%r9d
  mov    $0x0,%r8d
  mov    $0x0,%eax
  mov    $0x1,%esi
  jmp    L91
L97:
  add    $0x1,%ecx
  mov    %esi,%r9d
L202:
  add    $0x1,%eax
  cmp    $0x100,%eax
  je     L71
L91:
  cmp    %eax,%edi
  jle    L97
  add    $0x1,%edx
  mov    %esi,%r8d
  jmp    L202
L71:
  test   %r9b,%r9b
  je     L73
  mov    %ecx,0x40c(%rsp)
L73:
  test   %r8b,%r8b
  je     L131
  mov    %edx,0x10(%rsp)
L131:
  lea    0x410(%rsp),%rcx
  lea    0x10410(%rsp),%rsi
  mov    %rsi,%r8
L33:
  mov    $0x0,%eax
L132:
  movzbl (%rcx,%rax,1),%edx
  cmp    %edx,%edi
  setl   %dl
  neg    %edx
  mov    %dl,(%rsi,%rax,1)
  add    $0x1,%rax
  cmp    $0x100,%rax
  jne    L132
  add    $0x100,%rcx
  add    $0x100,%rsi
  cmp    %r8,%rcx
  jne    L33
  lea    D54(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L146
  lea    D52(%rip),%rsi
  lea    D156(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%r12
L114:
  mov    $0x0,%ebp
  lea    D98(%rip),%r13
L149:
  mov    0x10(%rsp,%rbp,4),%ecx
  mov    %ebp,%edx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <fprintf@plt>
  add    $0x1,%rbp
  cmp    $0x100,%rbp
  jne    L149
  mov    %r12,%rdi
  call   <fclose@plt>
  lea    D54(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L29
  lea    D52(%rip),%rsi
  lea    D69(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%rbp
L117:
  lea    0x10410(%rsp),%rdi
  mov    %rbp,%rcx
  mov    $0x10000,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  lea    D54(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L35
  lea    D87(%rip),%rdi
  call   <system@plt>
  jmp    L92
L146:
  lea    D52(%rip),%rsi
  lea    D120(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  jmp    L114
L29:
  lea    D52(%rip),%rsi
  lea    D44(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%rbp
  jmp    L117
L35:
  lea    D172(%rip),%rdi
  call   <system@plt>
  jmp    L92
L168:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D51
type: string
name: parse_data
arguments: tag: D86
type: string
name: parse_data
arguments: tag: D78
type: string
name: parse_data
arguments: tag: D161
type: string
name: parse_data
arguments: tag: D79
type: string
name: parse_data
arguments: tag: D112
type: string
name: parse_data
arguments: tag: D54
type: string
name: parse_data
arguments: tag: D52
type: string
name: parse_data
arguments: tag: D156
type: string
name: parse_data
arguments: tag: D98
type: string
name: parse_data
arguments: tag: D69
type: string
name: parse_data
arguments: tag: D87
type: string
name: parse_data
arguments: tag: D120
type: string
name: parse_data
arguments: tag: D44
type: string
name: parse_data
arguments: tag: D172
type: string

tool: D51: many arguments


tool: D86: don't read filename


tool: D78: rb

tool: D161: .

tool: D79: input theta value


tool: D112: %d

tool: D54: girl

tool: D52: wb

tool: D156: plot_ex1girl.dat

tool: D98: %3d %3d


tool: D69: girlex1_binary.dat

tool: D87: zsh mode_girl.sh

tool: D120: plot_ex1ei.dat

tool: D44: eiex1_binary.dat

tool: D172: zsh mode_ei.sh

assistant: ```c
int main(int argc, char *argv[]) {
  unsigned char image[256][256];
  unsigned char image_w[256][256];
  int histgram[256] = {0};
  int mode;
  char *fn;
  FILE *fp;
  if (argc < 2) {
    printf("don't read filename\n");
    return 0;
  } else if (argc > 2) {
    printf("many arguments\n");
    return 0;
  } else {
    fp = fopen(argv[1], "rb");
    fread(image, sizeof(unsigned char), 256 * 256, fp);
    fclose(fp);
    fn = strtok(argv[1], ".");
    printf("input theta value\n");
    scanf("%d", &mode);
    int newhist[256];
    for (int i = 0; i < 256; i++) {
      if (i < mode) {
        newhist[0]++;
      } else {
        newhist[255]++;
      }
    }
    for (int i = 0; i < 256; i++) {
      for (int j = 0; j < 256; j++) {
        if (image[i][j] > mode) {
          image_w[i][j] = 255;
        } else {
          image_w[i][j] = 0;
        }
      }
    }
    if (strcmp(fn, "girl") == 0) {
      fp = fopen("plot_ex1girl.dat", "wb");
    } else {
      fp = fopen("plot_ex1ei.dat", "wb");
    }
    for (int i = 0; i < 256; i++) {
      fprintf(fp, "%3d %3d\n", i, newhist[i]);
    }
    fclose(fp);
    if (strcmp(fn, "girl") == 0) {
      fp = fopen("girlex1_binary.dat", "wb");
    } else {
      fp = fopen("eiex1_binary.dat", "wb");
    }
    fwrite(image_w, sizeof(unsigned char), 256 * 256, fp);
    fclose(fp);
    if (strcmp(fn, "girl") == 0) {
      system("zsh mode_girl.sh");
    } else {
      system("zsh mode_ei.sh");
    }
    return 0;
  }
}
```