user: Converte this assembly snippet into its equivalent C code:

```asm
<writeParagraph>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x438,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x428(%rsp)
  xor    %eax,%eax
  movzbl (%rdi),%eax
  movl   $0x0,0xc(%rsp)
  test   %al,%al
  je     L15
  mov    %rdi,%r14
  mov    %rsi,%rbx
  mov    %edx,%ebp
  xor    %r12d,%r12d
  lea    D72(%rip),%r13
  jmp    L242
  nop
L46:
  cmp    $0x3c,%al
  je     L150
  cmp    $0x3e,%al
  je     L221
  test   %ebp,%ebp
  lea    0x1(%r14),%r15
  sete   %dl
  cmp    $0x5b,%al
  jne    L9
  test   %dl,%dl
  jne    L20
L9:
  cmp    $0x27,%al
  je     L90
  cmp    $0x2a,%al
  jne    L206
  test   %dl,%dl
  jne    L72
L206:
  cmp    $0x5c,%al
  je     L58
  movsbl %al,%edi
  mov    %rbx,%rsi
  mov    %r14,%r15
  call   <fputc@plt>
L129:
  movzbl 0x1(%r15),%eax
  lea    0x1(%r15),%r14
  test   %al,%al
  je     L15
L242:
  cmp    $0x26,%al
  jne    L46
  mov    %r14,%r15
  mov    %rbx,%rcx
  mov    $0x5,%edx
  mov    $0x1,%esi
  lea    D16(%rip),%rdi
  lea    0x1(%r15),%r14
  call   <fwrite@plt>
  movzbl 0x1(%r15),%eax
  test   %al,%al
  jne    L242
  nopl   0x0(%rax)
L15:
  mov    0x428(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L188
  add    $0x438,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L150:
  mov    %rbx,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  mov    %r14,%r15
  lea    D67(%rip),%rdi
  call   <fwrite@plt>
  jmp    L129
  nopl   0x0(%rax)
L90:
  mov    %rbx,%rcx
  test   %r12d,%r12d
  jne    L169
  mov    $0x12,%edx
  mov    $0x1,%esi
  lea    D26(%rip),%rdi
  mov    %r14,%r15
  call   <fwrite@plt>
  mov    $0x1,%r12d
  jmp    L129
  nopl   0x0(%rax)
L221:
  mov    %rbx,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  mov    %r14,%r15
  lea    D28(%rip),%rdi
  call   <fwrite@plt>
  jmp    L129
  nopl   0x0(%rax)
L58:
  movsbl 0x1(%r14),%edi
  mov    %rbx,%rsi
  call   <fputc@plt>
  jmp    L129
  nopw   0x0(%rax,%rax,1)
L169:
  mov    $0x7,%edx
  mov    $0x1,%esi
  mov    %r13,%rdi
  mov    %r14,%r15
  call   <fwrite@plt>
  xor    %r12d,%r12d
  jmp    L129
  nopl   (%rax)
L72:
  mov    0xc(%rsp),%eax
  mov    %rbx,%rcx
  test   %eax,%eax
  jne    L39
  mov    $0x13,%edx
  mov    $0x1,%esi
  lea    D79(%rip),%rdi
  mov    %r14,%r15
  call   <fwrite@plt>
  movl   $0x1,0xc(%rsp)
  jmp    L129
  nopl   (%rax)
L20:
  movzbl 0x1(%r14),%eax
  lea    0x20(%rsp),%r14
  mov    %r14,%rdx
  cmp    $0x5d,%al
  je     L197
  nopl   0x0(%rax)
L226:
  add    $0x1,%r15
  mov    %al,(%rdx)
  add    $0x1,%rdx
  movzbl (%r15),%eax
  cmp    $0x5d,%al
  jne    L226
L197:
  movb   $0x0,(%rdx)
  mov    $0x2e,%esi
  mov    %r14,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L129
  movb   $0x0,(%rax)
  lea    0x1c(%rsp),%rdx
  lea    0x1(%rax),%rdi
  lea    D32(%rip),%rsi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L129
  mov    0x1c(%rsp),%ecx
  mov    %r14,%r8
  mov    %r14,%rdx
  mov    %rbx,%rdi
  lea    D46(%rip),%rsi
  xor    %eax,%eax
  mov    %ecx,%r9d
  call   <fprintf@plt>
  jmp    L129
  nopw   0x0(%rax,%rax,1)
L39:
  mov    $0x7,%edx
  mov    $0x1,%esi
  mov    %r13,%rdi
  mov    %r14,%r15
  call   <fwrite@plt>
  movl   $0x0,0xc(%rsp)
  jmp    L129
L188:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D72
datatype: string
name: read_data
arguments: label: D16
datatype: string
name: read_data
arguments: label: D67
datatype: string
name: read_data
arguments: label: D26
datatype: string
name: read_data
arguments: label: D28
datatype: string
name: read_data
arguments: label: D79
datatype: string
name: read_data
arguments: label: D32
datatype: string
name: read_data
arguments: label: D46
datatype: string

tool: D72: </span>

tool: D16: &amp;

tool: D67: &lt;

tool: D26: <span class="ref">

tool: D28: &gt;

tool: D79: <span class="emph">

tool: D32: %d

tool: D46: <a href="%s.%d.html">%s(%d)</a>

assistant: ```c
void writeParagraph(const char *scan, FILE *out, int codeMode) {
  int refState = 0;
  int emphState = 0;
  for (; *scan != 0; scan++) {
    if (*scan == '&') {
      fprintf(out, "&amp;");
    } else if (*scan == '<') {
      fprintf(out, "&lt;");
    } else if (*scan == '>') {
      fprintf(out, "&gt;");
    } else if ((*scan == '[') && (!codeMode)) {
      char buffer[1024];
      scan++;
      char *put = buffer;
      while (*scan != ']') {
        *put++ = *scan++;
      };
      *put = 0;
      char *dot = strchr(buffer, '.');
      if (dot == NULL)
        continue;
      *dot = 0;
      int chapter;
      if (sscanf(dot + 1, "%d", &chapter) != 1)
        continue;
      fprintf(out, "<a href=\"%s.%d.html\">%s(%d)</a>", buffer, chapter, buffer, chapter);
    } else if (*scan == '\'') {
      refState = !refState;
      if (refState) {
        fprintf(out, "<span class=\"ref\">");
      } else {
        fprintf(out, "</span>");
      };
    } else if ((*scan == '*') && (!codeMode)) {
      emphState = !emphState;
      if (emphState) {
        fprintf(out, "<span class=\"emph\">");
      } else {
        fprintf(out, "</span>");
      };
    } else if (*scan == '\\') {
      scan++;
      fprintf(out, "%c", *scan);
    } else {
      fprintf(out, "%c", *scan);
    };
  };
}
```