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

```asm
<plot_hexagon>:
  endbr64
  push   %r15
  mov    %esi,%eax
  mov    %r8d,%r10d
  push   %r14
  sub    %ecx,%eax
  mov    %ecx,%r14d
  push   %r13
  sub    %r9d,%eax
  mov    %esi,%r13d
  push   %r12
  mov    %eax,%r15d
  push   %rbp
  shr    $0x1f,%r15d
  mov    %rdi,%rbp
  push   %rbx
  add    %eax,%r15d
  mov    %eax,%ebx
  sar    %r15d
  and    $0x1,%ebx
  add    %ecx,%r15d
  sub    $0x28,%rsp
  mov    %edx,0x10(%rsp)
  sub    %ecx,%edx
  sub    %r9d,%edx
  mov    %r9d,0x14(%rsp)
  mov    %r15d,%r9d
  mov    %edx,%r11d
  mov    %edx,%r12d
  shr    $0x1f,%r11d
  and    $0x1,%r12d
  add    %edx,%r11d
  sar    %r11d
  lea    0x1(%r11),%edx
  mov    %edx,%r8d
  shr    $0x1f,%r8d
  add    %edx,%r8d
  sar    %r8d
  add    %r10d,%r8d
  cmp    $0x5,%eax
  jle    L96
  cmp    $0x13,%eax
  jle    L147
  test   %ebx,%ebx
  je     L147
L96:
  mov    %r11d,0x4(%rsp)
  sub    $0x8,%rsp
  mov    %r14d,%ecx
  mov    %r13d,%esi
  push   %r10
  mov    0x20(%rsp),%edx
  mov    %rbp,%rdi
  mov    %r10d,0x10(%rsp)
  call   <plot_hexline@plt>
  mov    0x10(%rsp),%r10d
  mov    0x14(%rsp),%r11d
  pop    %rax
  pop    %rdx
  lea    (%r11,%r10,1),%ecx
  add    %r12d,%ecx
  cmp    %ecx,%r10d
  jge    L130
  add    %r15d,%ebx
  mov    %r13d,%r8d
  mov    %r10d,%r9d
  xor    %r15d,%r15d
  mov    %ebx,%eax
  imul   %r10d,%r8d
  mov    %r10d,0x1c(%rsp)
  mov    %r13d,%r10d
  sub    %r14d,%eax
  mov    %r9d,%r13d
  sub    $0x1,%eax
  add    $0x1,%rax
  mov    %r8d,0x18(%rsp)
  mov    %r8d,%r12d
  mov    %r14d,%r8d
  mov    %rax,0x8(%rsp)
  mov    %r15d,%r14d
  mov    %ecx,%r15d
  nopl   0x0(%rax)
L79:
  mov    %r8d,%edx
  mov    $0xffffffff,%esi
  movslq %r12d,%r11
  cmp    %ebx,%r8d
  jl     L66
  jmp    L87
  nopl   (%rax)
L237:
  mov    %ecx,%edx
  movb   $0x31,(%rax)
  mov    $0x1,%r14d
  cmp    %edx,%ebx
  jle    L156
L66:
  lea    (%r12,%rdx,1),%eax
  lea    0x1(%rdx),%ecx
  cltq
  add    %rbp,%rax
  cmp    $0xffffffff,%esi
  jne    L237
  movslq %edx,%rax
  mov    %edx,%esi
  add    %r11,%rax
  add    %rbp,%rax
L61:
  add    $0x1,%esi
  cmpb   $0x31,(%rax)
  je     L157
  add    $0x1,%rax
  cmp    %esi,%ebx
  jg     L61
  mov    $0x1,%eax
L71:
  test   %r14d,%r14d
  je     L87
  test   %al,%al
  je     L87
  movslq %r8d,%rdi
  movslq %r12d,%rax
  mov    0x8(%rsp),%rdx
  mov    $0x31,%esi
  add    %rax,%rdi
  mov    %r10d,0x4(%rsp)
  add    %rbp,%rdi
  mov    %r8d,(%rsp)
  call   <memset@plt>
  mov    0x4(%rsp),%r10d
  mov    (%rsp),%r8d
L87:
  add    $0x1,%r13d
  add    %r10d,%r12d
  cmp    %r15d,%r13d
  jne    L79
  mov    %r10d,%r13d
  mov    0x1c(%rsp),%r10d
  mov    %r8d,%r14d
  mov    0x18(%rsp),%r8d
  mov    %r14d,%eax
  sub    0x14(%rsp),%eax
  mov    %r15d,%ecx
  lea    0x1(%r10),%esi
  mov    %r8d,%r12d
  mov    %esi,%r11d
  imul   %r13d,%r11d
  add    %eax,%r11d
  nopl   0x0(%rax)
L3:
  movslq %r12d,%rdx
  movslq %r14d,%rax
  lea    -0x1(%r11),%r9d
  add    %rbp,%rdx
  cmp    %ebx,%r14d
  jge    L73
  nopw   0x0(%rax,%rax,1)
L54:
  cmpb   $0x31,(%rdx,%rax,1)
  jne    L42
  mov    %r9d,%edi
  sub    %eax,%edi
  movslq %edi,%rdi
  movb   $0x31,0x0(%rbp,%rdi,1)
L42:
  add    $0x1,%rax
  cmp    %eax,%ebx
  jg     L54
L73:
  add    $0x1,%r10d
  add    %r13d,%r12d
  add    %r13d,%r11d
  cmp    %ecx,%r10d
  jne    L3
  mov    0x10(%rsp),%eax
  sub    0x60(%rsp),%eax
  movslq %r14d,%r11
  lea    -0x1(%rax),%r10d
  mov    %eax,%edi
  mov    %r10d,%eax
  imul   %r13d,%edi
  imul   %r13d,%eax
  lea    (%rax,%r14,1),%r10d
  sub    %edi,%r10d
  nopl   (%rax)
L170:
  cmp    %r14d,%r13d
  jle    L53
  movslq %r8d,%rax
  lea    (%r10,%rdi,1),%edx
  add    %r11,%rax
  add    %rbp,%rax
  nopw   0x0(%rax,%rax,1)
L176:
  cmpb   $0x31,(%rax)
  jne    L227
  movslq %edx,%r9
  movb   $0x31,0x0(%rbp,%r9,1)
L227:
  add    $0x1,%edx
  add    $0x1,%rax
  cmp    %edi,%edx
  jne    L176
L53:
  sub    %r13d,%edi
  add    %r13d,%r8d
  cmp    %ecx,%esi
  je     L130
  add    $0x1,%esi
  jmp    L170
  nopl   0x0(%rax,%rax,1)
L157:
  mov    %esi,%edx
  cmp    %edx,%ebx
  jg     L66
  nopw   0x0(%rax,%rax,1)
L156:
  cmp    $0xffffffff,%esi
  sete   %al
  jmp    L71
  nopl   0x0(%rax,%rax,1)
L130:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L147:
  lea    -0x1(%r15),%r9d
  jmp    L96
```

assistant: ```c
void plot_hexagon(unsigned char *scaled_hexagon, const int hex_width, const int hex_height, const int hx_start, const int hy_start, const int hx_end, const int hy_end) {
  int line, i;
  int not_top;
  const int hx_width = hex_width - hx_start - hx_end;
  const int hy_height = hex_height - hx_start - hx_end;
  const int hx_width_odd = hx_width & 1;
  const int hy_height_odd = hy_height & 1;
  const int hx_radius = hx_width / 2;
  const int hy_radius = hy_height / 2;
  int start_y = hy_start + (hy_radius + 1) / 2;
  int end_x = hx_start + hx_radius;
  if (hx_radius > 2 && (hx_radius < 10 || !hx_width_odd)) {
    end_x--;
  }
  plot_hexline(scaled_hexagon, hex_width, hex_height, hx_start, start_y, end_x, hy_start);
  not_top = 0;
  for (line = hy_start; line < hy_start + hy_radius + hy_height_odd; line++) {
    int first = -1;
    for (i = hx_start; i < hx_start + hx_radius + hx_width_odd; i++) {
      if (first != -1) {
        scaled_hexagon[(hex_width * line) + i] = '1';
        not_top = 1;
      } else if (scaled_hexagon[(hex_width * line) + i] == '1') {
        first = i + 1;
      }
    }
    if (not_top && first == -1) {
      for (i = hx_start; i < hx_start + hx_radius + hx_width_odd; i++) {
        scaled_hexagon[(hex_width * line) + i] = '1';
      }
    }
  }
  for (line = hy_start; line < hy_start + hy_radius + hy_height_odd; line++) {
    for (i = hx_start; i < hx_start + hx_radius + hx_width_odd; i++) {
      if (scaled_hexagon[(hex_width * line) + i] == '1') {
        scaled_hexagon[(hex_width * line) + hex_width - hx_end - (i - hx_start + 1)] = '1';
      }
    }
  }
  for (line = hy_start; line < hy_start + hy_radius + hy_height_odd; line++) {
    for (i = hx_start; i < hex_width; i++) {
      if (scaled_hexagon[(hex_width * line) + i] == '1') {
        scaled_hexagon[(hex_width * (hex_height - hy_end - (line - hy_start + 1))) + i] = '1';
      }
    }
  }
}
```