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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1d8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x1c8(%rsp)
  xor    %eax,%eax
  cmp    $0x1,%edi
  jle    L214
  mov    0x8(%rsi),%rsi
  lea    0x50(%rsp),%rbp
  mov    %rbp,%rdi
  call   <strcpy@plt>
  mov    %rbp,%rdi
  lea    D74(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,0x18(%rsp)
  mov    %rax,%rdi
  test   %rax,%rax
  je     L214
  lea    0xc0(%rsp),%rdx
  lea    D81(%rip),%rsi
  xor    %eax,%eax
  call   <fscanf@plt>
  mov    0x18(%rsp),%rdi
  call   <feof@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  jne    L143
  nopl   0x0(%rax)
L165:
  lea    0x40(%rsp),%rax
  lea    0x30(%rsp),%r12
  lea    0x2c(%rsp),%rdx
  push   %rax
  mov    %r12,%rcx
  lea    D82(%rip),%rsi
  lea    0x44(%rsp),%rax
  push   %rax
  mov    0x28(%rsp),%rdi
  xor    %eax,%eax
  lea    0x48(%rsp),%r9
  lea    0x44(%rsp),%r8
  call   <fscanf@plt>
  mov    0x3c(%rsp),%eax
  mov    %eax,%ecx
  mov    %eax,%r15d
  mov    %eax,%ebp
  sar    $0x4,%ecx
  sar    $0x8,%r15d
  mov    %ecx,0x1c(%rsp)
  mov    %eax,%ecx
  mov    %r15d,%r13d
  pop    %rdx
  and    $0x7,%ecx
  shr    $0x4,%bpl
  and    $0xf,%r13d
  pop    %rsi
  cmp    $0x3,%ecx
  je     L260
  test   $0x4,%al
  jne    L157
  cmp    $0x1,%ecx
  je     L244
  cmp    $0x2,%ecx
  jne    L119
  lea    0x48(%rsp),%r14
  lea    D51(%rip),%rsi
  mov    $0xffffffff,%ebx
  mov    %r14,%rdi
  call   <strcpy@plt>
  mov    %ebp,%eax
  movl   $0x1,0x8(%rsp)
  and    %r13d,%eax
  xor    $0xf,%eax
  mov    %eax,%edx
L13:
  movsbl %al,%eax
  movsbl %bpl,%ebp
  xor    %r15d,%r15d
  mov    %eax,0x10(%rsp)
  movsbl %dl,%eax
  mov    %eax,0xc(%rsp)
  movsbl %r13b,%eax
  lea    D30(%rip),%r13
  mov    %eax,0x14(%rsp)
  mov    %ebp,%eax
  mov    %r15,%rbp
  mov    %eax,%r15d
L105:
  mov    (%r12,%rbp,4),%r8d
  mov    %ebp,%ecx
  mov    %r8d,%eax
  mov    %r8d,%esi
  sar    $0x2,%eax
  and    $0x1,%esi
  cmp    0xc(%rsp),%eax
  jne    L101
  cmp    %esi,0x8(%rsp)
  je     L99
L101:
  mov    0x2c(%rsp),%edx
  push   %rsi
  mov    %r15d,%r9d
  mov    %r14,%rsi
  mov    0x10(%rsp),%edi
  push   %rdi
  mov    %r13,%rdi
  push   %rax
  mov    0x28(%rsp),%eax
  push   %rax
  mov    %edx,%eax
  sar    $0x3,%eax
  and    $0x1,%eax
  push   %rax
  mov    0x3c(%rsp),%eax
  push   %rax
  xor    %eax,%eax
  call   <printf@plt>
  add    $0x30,%rsp
  cmp    $0xffffffff,%ebx
  jne    L89
L246:
  mov    $0xa,%edi
  call   <putchar@plt>
L85:
  add    $0x1,%rbp
  cmp    $0x5,%rbp
  jne    L105
  mov    0x18(%rsp),%rdi
  call   <feof@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  je     L165
L143:
  mov    0x18(%rsp),%rdi
  call   <fclose@plt>
  xor    %eax,%eax
L145:
  mov    0x1c8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L43
  add    $0x1d8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L99:
  cmp    $0xffffffff,%ebx
  je     L85
  mov    %r8d,%eax
  sar    %eax
  and    $0x1,%eax
  cmp    %ebx,%eax
  je     L85
  mov    0x8(%rsp),%eax
  mov    0x2c(%rsp),%edx
  mov    %r15d,%r9d
  mov    %r14,%rsi
  mov    %r13,%rdi
  push   %rax
  push   %rax
  mov    0x1c(%rsp),%eax
  push   %rax
  mov    0x28(%rsp),%eax
  push   %rax
  mov    %edx,%eax
  sar    $0x3,%eax
  and    $0x1,%eax
  push   %rax
  mov    0x3c(%rsp),%eax
  push   %rax
  xor    %eax,%eax
  call   <printf@plt>
  add    $0x30,%rsp
  nop
L89:
  mov    (%r12,%rbp,4),%edx
  mov    %ebx,%esi
  lea    D76(%rip),%rdi
  xor    %eax,%eax
  sar    %edx
  and    $0x1,%edx
  call   <printf@plt>
  jmp    L246
  xchg   %ax,%ax
L157:
  lea    0x48(%rsp),%r14
  lea    D37(%rip),%rsi
  mov    %r14,%rdi
  call   <strcpy@plt>
  mov    0x2c(%rsp),%ecx
  lea    0x0(%rbp,%r13,1),%eax
  mov    %r15d,%edx
  and    $0x8,%edx
  sar    $0x3,%ecx
  and    $0x1,%ecx
  add    %ecx,%eax
  movzbl %al,%esi
  sar    $0x4,%esi
  mov    %esi,0x8(%rsp)
  testb  $0x8,0xc(%rsp)
  je     L265
  or     $0xfffffff0,%ebp
  test   %dl,%dl
  jne    L20
  lea    0x0(%rbp,%r13,1),%eax
  add    %cl,%al
  jns    L187
L67:
  mov    %eax,%ebx
  mov    %eax,%edx
  shr    $0x3,%bl
  and    $0xf,%edx
  xor    $0x1,%ebx
  and    $0x1,%ebx
  jmp    L13
  nopl   0x0(%rax)
L265:
  test   %dl,%dl
  je     L187
L20:
  or     $0xfffffff0,%r13d
  lea    0x0(%rbp,%r13,1),%eax
  add    %cl,%al
  js     L67
L187:
  mov    %eax,%ecx
  mov    %eax,%edx
  shr    $0x3,%cl
  and    $0xf,%edx
  and    $0x1,%ecx
  test   %al,%al
  cmovne %ecx,%ebx
  jmp    L13
L260:
  lea    0x48(%rsp),%r14
  lea    D68(%rip),%rsi
  mov    $0xffffffff,%ebx
  mov    %r14,%rdi
  call   <strcpy@plt>
  movzbl 0xc(%rsp),%eax
  movl   $0x1,0x8(%rsp)
  xor    %r15d,%eax
  and    $0xf,%eax
  mov    %eax,%edx
  jmp    L13
L119:
  lea    0x48(%rsp),%r14
  lea    D31(%rip),%rsi
  mov    %r14,%rdi
  call   <strcpy@plt>
  movzbl 0x2c(%rsp),%eax
  mov    0xc(%rsp),%ebx
  mov    %ebp,%edx
  sar    %dl
  and    $0x8,%eax
  and    $0x1,%ebx
  or     %edx,%eax
  mov    %ebx,0x8(%rsp)
  mov    $0xffffffff,%ebx
  mov    %eax,%edx
  jmp    L13
  nopl   0x0(%rax)
L244:
  lea    0x48(%rsp),%r14
  lea    D45(%rip),%rsi
  mov    $0xffffffff,%ebx
  mov    %r14,%rdi
  call   <strcpy@plt>
  mov    0x2c(%rsp),%eax
  movsbl %bpl,%edx
  lea    (%rdx,%rdx,1),%ecx
  sar    $0x3,%edx
  sar    $0x3,%eax
  and    $0xe,%ecx
  mov    %edx,0x8(%rsp)
  and    $0x1,%eax
  or     %ecx,%eax
  mov    %eax,%edx
  jmp    L13
L214:
  or     $0xffffffff,%eax
  jmp    L145
L43:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D74
type_infered: string
name: disassemble_data
arguments: data_label: D81
type_infered: string
name: disassemble_data
arguments: data_label: D82
type_infered: string
name: disassemble_data
arguments: data_label: D51
type_infered: string
name: disassemble_data
arguments: data_label: D30
type_infered: string
name: disassemble_data
arguments: data_label: D76
type_infered: string
name: disassemble_data
arguments: data_label: D37
type_infered: string
name: disassemble_data
arguments: data_label: D68
type_infered: string
name: disassemble_data
arguments: data_label: D31
type_infered: string
name: disassemble_data
arguments: data_label: D45
type_infered: string

tool: D74: rt

tool: D81: %s


tool: D82: %3X:%2X,%2X,%2X,%2X,%2X


tool: D51: NAN

tool: D30: %s %3.3X[%i] %2.2X a=%i b=%i c=%i -> d=%i (%i) c=%i (%i)

tool: D76:  v=%i (%i)

tool: D37: ADD

tool: D68: XOR

tool: D31: RRC

tool: D45: RLC

assistant: ```c
int main(int argc, char **argv) {
  char n[100], s[256], u[8];
  int i, j, r[5], v, c;
  FILE *f;
  signed char a, b, d;
  if (argc < 2)
    return -1;
  strcpy(n, argv[1]);
  f = fopen(n, "rt");
  if (f == NULL)
    return -1;
  fscanf(f, "%s\n", s);
  while (!feof(f)) {
    fscanf(f, "%3X:%2X,%2X,%2X,%2X,%2X\n", &i, &r[0], &r[1], &r[2], &r[3], &r[4]);
    v = -1;
    a = (i >> 4) & 15;
    b = (i >> 8) & 15;
    switch (i & 7) {
    case 0:
      strcpy(u, "RRC");
      d = (i & 8) | (a >> 1);
      c = a & 1;
      break;
    case 1:
      strcpy(u, "RLC");
      d = ((a & 7) << 1) | ((i & 8) >> 3);
      c = (a & 8) >> 3;
      break;
    case 2:
      strcpy(u, "NAN");
      d = (~(a & b)) & 15;
      c = 1;
      break;
    case 3:
      strcpy(u, "XOR");
      d = a ^ b;
      c = 1;
      break;
    case 4:
    case 5:
    case 6:
    case 7:
      strcpy(u, "ADD");
      d = a + b + ((i & 8) >> 3);
      c = (d & 16) >> 4;
      if (a & 8)
        a |= 0xF0;
      if (b & 8)
        b |= 0xF0;
      d = a + b + ((i & 8) >> 3);
      if ((d < 0 && !(d & 8)) || (d > 0 && (d & 8)))
        v = 1;
      else
        v = 0;
      break;
    }
    for (j = 0; j < 5; j++) {
      if ((d & 15) != (r[j] >> 2) || c != (r[j] & 1) || (v >= 0 && ((r[j] & 2) >> 1) != v)) {
        printf("%s %3.3X[%i] %2.2X a=%i b=%i c=%i -> d=%i (%i) c=%i (%i)", u, i, j, r[j], a, b, (i & 8) >> 3, d, r[j] >> 2, c, r[j] & 1);
        if (v >= 0)
          printf(" v=%i (%i)", v, (r[j] & 2) >> 1);
        printf("\n");
      }
    }
  }
  fclose(f);
  return 0;
}
```