user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  lea    -0x20000(%rsp),%r11
L224:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L224
  sub    $0x850,%rsp
  mov    %edi,-0x20844(%rbp)
  mov    %rsi,-0x20850(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x20810(%rbp),%rdx
  mov    $0x0,%eax
  mov    $0x80,%ecx
  mov    %rdx,%rdi
  rep stos %rax,%es:(%rdi)
  cmpl   $0x1,-0x20844(%rbp)
  jg     L152
  lea    D88(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  jmp    L201
L152:
  cmpl   $0x2,-0x20844(%rbp)
  jle    L220
  lea    D175(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  jmp    L201
L220:
  mov    -0x20850(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  lea    D101(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x20820(%rbp)
  mov    -0x20820(%rbp),%rdx
  lea    -0x20010(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x10000,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  mov    -0x20820(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x20850(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  lea    D60(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strtok@plt>
  mov    %rax,-0x20818(%rbp)
  lea    D18(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    -0x20834(%rbp),%rax
  mov    %rax,%rsi
  lea    D181(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
  movl   $0x0,-0x20830(%rbp)
  jmp    L22
L95:
  mov    -0x20834(%rbp),%eax
  cmp    %eax,-0x20830(%rbp)
  jge    L59
  mov    -0x20410(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x20410(%rbp)
  jmp    L42
L59:
  mov    -0x20014(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x20014(%rbp)
L42:
  addl   $0x1,-0x20830(%rbp)
L22:
  cmpl   $0xff,-0x20830(%rbp)
  jle    L95
  movl   $0x0,-0x2082c(%rbp)
  jmp    L195
L149:
  movl   $0x0,-0x20828(%rbp)
  jmp    L86
L185:
  mov    -0x20828(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x2082c(%rbp),%eax
  cltq
  shl    $0x8,%rax
  add    %rbp,%rax
  add    %rdx,%rax
  sub    $0x20010,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x20834(%rbp),%eax
  cmp    %eax,%edx
  jle    L0
  mov    -0x20828(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x2082c(%rbp),%eax
  cltq
  shl    $0x8,%rax
  add    %rbp,%rax
  add    %rdx,%rax
  sub    $0x10010,%rax
  movb   $0xff,(%rax)
  jmp    L138
L0:
  mov    -0x20828(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x2082c(%rbp),%eax
  cltq
  shl    $0x8,%rax
  add    %rbp,%rax
  add    %rdx,%rax
  sub    $0x10010,%rax
  movb   $0x0,(%rax)
L138:
  addl   $0x1,-0x20828(%rbp)
L86:
  cmpl   $0xff,-0x20828(%rbp)
  jle    L185
  addl   $0x1,-0x2082c(%rbp)
L195:
  cmpl   $0xff,-0x2082c(%rbp)
  jle    L149
  mov    -0x20818(%rbp),%rax
  lea    D167(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L226
  lea    D19(%rip),%rax
  mov    %rax,%rsi
  lea    D52(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x20820(%rbp)
  jmp    L51
L226:
  lea    D19(%rip),%rax
  mov    %rax,%rsi
  lea    D50(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x20820(%rbp)
L51:
  movl   $0x0,-0x20824(%rbp)
  jmp    L25
L168:
  mov    -0x20824(%rbp),%eax
  cltq
  mov    -0x20410(%rbp,%rax,4),%ecx
  mov    -0x20824(%rbp),%edx
  mov    -0x20820(%rbp),%rax
  lea    D66(%rip),%rsi
  mov    %rax,%rdi
  call   <fprintf@plt>
  addl   $0x1,-0x20824(%rbp)
L25:
  cmpl   $0xff,-0x20824(%rbp)
  jle    L168
  mov    -0x20820(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x20818(%rbp),%rax
  lea    D167(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L52
  lea    D19(%rip),%rax
  mov    %rax,%rsi
  lea    D79(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x20820(%rbp)
  jmp    L134
L52:
  lea    D19(%rip),%rax
  mov    %rax,%rsi
  lea    D10(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x20820(%rbp)
L134:
  mov    -0x20820(%rbp),%rdx
  lea    -0x10010(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x10000,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fwrite@plt>
  mov    -0x20820(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x20818(%rbp),%rax
  lea    D167(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L7
  lea    D155(%rip),%rax
  mov    %rax,%rdi
  call   <system@plt>
  jmp    L161
L7:
  lea    D153(%rip),%rax
  mov    %rax,%rdi
  call   <system@plt>
L161:
  mov    $0x0,%eax
L201:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L218
  call   <__stack_chk_fail@plt>
L218:
  leave
  ret
```

tool_calls: name: read_data
arguments: data_label: D88
data_type: string
name: read_data
arguments: data_label: D175
data_type: string
name: read_data
arguments: data_label: D101
data_type: string
name: read_data
arguments: data_label: D60
data_type: string
name: read_data
arguments: data_label: D18
data_type: string
name: read_data
arguments: data_label: D181
data_type: string
name: read_data
arguments: data_label: D167
data_type: string
name: read_data
arguments: data_label: D19
data_type: string
name: read_data
arguments: data_label: D52
data_type: string
name: read_data
arguments: data_label: D50
data_type: string
name: read_data
arguments: data_label: D66
data_type: string
name: read_data
arguments: data_label: D79
data_type: string
name: read_data
arguments: data_label: D10
data_type: string
name: read_data
arguments: data_label: D155
data_type: string
name: read_data
arguments: data_label: D153
data_type: string

tool: D88: don't read filename


tool: D175: many arguments


tool: D101: rb

tool: D60: .

tool: D18: input theta value


tool: D181: %d

tool: D167: girl

tool: D19: wb

tool: D52: plot_ex1girl.dat

tool: D50: plot_ex1ei.dat

tool: D66: %3d %3d


tool: D79: girlex1_binary.dat

tool: D10: eiex1_binary.dat

tool: D155: zsh mode_girl.sh

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