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

```asm
<evaluate>:
  endbr64
  push   %rbp
  mov    %rdi,%r10
  mov    %edx,%ecx
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  mov    %esi,%eax
  mov    %rsp,%rdi
  imul   %esi,%eax
  mov    %eax,-0x60(%rbp)
  cltq
  add    $0xf,%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rdi
  and    $0xfffffffffffffff0,%rdx
  cmp    %rdi,%rsp
  je     L441
L552:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rdi,%rsp
  jne    L552
L441:
  mov    %rdx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  jne    L456
L84:
  mov    %rsp,%rdi
  test   %esi,%esi
  jle    L502
  movslq %esi,%rax
  xor    %r11d,%r11d
  nopw   0x0(%rax,%rax,1)
L493:
  mov    %r11,%r8
  xor    %r9d,%r9d
  cs nopw 0x0(%rax,%rax,1)
L743:
  movzbl (%r10,%r8,1),%edx
  mov    %r9d,%ebx
  lea    0x1(%r9),%r9d
  sar    %cl,%edx
  and    $0x1,%edx
  add    $0x30,%edx
  mov    %dl,(%rdi,%r8,1)
  add    %rax,%r8
  cmp    %r9d,%esi
  jne    L743
  add    $0x1,%r11
  cmp    %rax,%r11
  jne    L493
  xor    %r13d,%r13d
  xor    %r11d,%r11d
  lea    (%rdi,%rax,1),%r14
  nopl   0x0(%rax,%rax,1)
L27:
  movzbl (%rdi,%r13,1),%r10d
  lea    (%r14,%r13,1),%rcx
  xor    %r9d,%r9d
  xor    %edx,%edx
  mov    %r10d,%r8d
  jmp    L671
  nopl   0x0(%rax,%rax,1)
L0:
  cmp    $0x5,%r9d
  jle    L314
  lea    -0x2(%r9,%r11,1),%r11d
  mov    %r8d,%r10d
  xor    %r9d,%r9d
L128:
  lea    0x1(%rdx),%r12d
  cmp    %edx,%ebx
  je     L140
L186:
  movzbl (%rcx),%r8d
  mov    %r12d,%edx
  add    %rax,%rcx
L671:
  cmp    %r10b,%r8b
  jne    L0
  add    $0x1,%r9d
  lea    0x1(%rdx),%r12d
  cmp    %edx,%ebx
  jne    L186
L140:
  cmp    $0x5,%r9d
  lea    -0x2(%r9,%r11,1),%edx
  cmovg  %edx,%r11d
  add    $0x1,%r13
  cmp    %rax,%r13
  jne    L27
  lea    (%rdi,%rax,1),%r10
  lea    0x1(%rdi),%r12
  xor    %r13d,%r13d
  nopl   0x0(%rax)
L670:
  movzbl -0x1(%r12),%r9d
  mov    %r12,%rdx
  xor    %r8d,%r8d
  mov    %r9d,%ecx
  jmp    L525
  nopl   0x0(%rax)
L309:
  cmp    $0x5,%r8d
  jle    L485
  lea    -0x2(%r8,%r11,1),%r11d
  mov    %ecx,%r9d
  xor    %r8d,%r8d
L744:
  cmp    %r10,%rdx
  je     L658
L362:
  movzbl (%rdx),%ecx
  add    $0x1,%rdx
L525:
  cmp    %r9b,%cl
  jne    L309
  add    $0x1,%r8d
  cmp    %r10,%rdx
  jne    L362
L658:
  lea    -0x2(%r8,%r11,1),%ecx
  cmp    $0x5,%r8d
  lea    (%rdx,%rax,1),%r10
  cmovg  %ecx,%r11d
  lea    0x1(%r13),%ecx
  add    %rax,%r12
  cmp    %r13d,%ebx
  je     L133
  mov    %ecx,%r13d
  jmp    L670
  nopl   (%rax)
L314:
  mov    %r8d,%r10d
  xor    %r9d,%r9d
  jmp    L128
  nopl   0x0(%rax,%rax,1)
L485:
  mov    %ecx,%r9d
  xor    %r8d,%r8d
  jmp    L744
L133:
  mov    %esi,%r12d
  lea    -0x2(%rsi),%r15d
  lea    (%rdi,%rax,1),%r14
  xor    %r13d,%r13d
  sub    $0x1,%r12d
  je     L32
  nopl   0x0(%rax)
L286:
  movzbl (%rdi,%r13,1),%edx
  lea    (%r14,%r13,1),%r9
  lea    0x1(%r13),%ecx
  xor    %r8d,%r8d
  jmp    L182
  nopw   0x0(%rax,%rax,1)
L256:
  add    %rax,%r9
  mov    %r10d,%ecx
  cmp    %r12d,%r8d
  je     L722
L182:
  mov    %edx,%ebx
  movzbl (%r9),%edx
  add    $0x1,%r8d
  lea    (%rcx,%rsi,1),%r10d
  cmp    %bl,%dl
  jne    L256
  movslq %ecx,%rcx
  cmp    %dl,(%rdi,%rcx,1)
  jne    L256
  movslq %r10d,%rcx
  cmp    %dl,(%rdi,%rcx,1)
  jne    L256
  add    $0x3,%r11d
  add    %rax,%r9
  mov    %r10d,%ecx
  cmp    %r12d,%r8d
  jne    L182
  nopl   0x0(%rax)
L722:
  lea    0x1(%r13),%rdx
  cmp    %r15,%r13
  je     L537
  mov    %rdx,%r13
  jmp    L286
L537:
  test   %esi,%esi
  jle    L44
L32:
  mov    %esi,%ebx
  mov    %r11d,-0x5c(%rbp)
  lea    -0x7(%rsi),%r15d
  mov    $0x40,%r10d
  mov    %rbx,-0x58(%rbp)
  imul   $0xfffffff5,%esi,%ebx
  lea    0x0(,%rsi,8),%edx
  sub    %esi,%edx
  movq   $0x0,-0x48(%rbp)
  mov    %edx,-0x50(%rbp)
  mov    %ebx,-0x4c(%rbp)
  nopl   0x0(%rax)
L562:
  mov    -0x48(%rbp),%rbx
  mov    -0x50(%rbp),%r9d
  xor    %edx,%edx
  add    %ebx,%r9d
  lea    (%rdi,%rbx,1),%r8
  test   %r15d,%r15d
  jle    L205
  xchg   %ax,%ax
L421:
  mov    %r8,%r11
  xor    %ebx,%ebx
  xor    %ecx,%ecx
  nopw   0x0(%rax,%rax,1)
L499:
  cmpb   $0x31,(%r11)
  jne    L299
  mov    %r10d,%r12d
  sar    %cl,%r12d
  add    %r12d,%ebx
L299:
  add    $0x1,%ecx
  add    %rax,%r11
  cmp    $0x7,%ecx
  jne    L499
  cmp    $0x5d,%ebx
  je     L122
L216:
  add    $0x1,%edx
  add    %esi,%r9d
  add    %rax,%r8
  cmp    %edx,%r15d
  jne    L421
L205:
  addq   $0x1,-0x48(%rbp)
  mov    -0x48(%rbp),%rbx
  cmp    -0x58(%rbp),%rbx
  jne    L562
  mov    -0x5c(%rbp),%r11d
  xor    %r13d,%r13d
  xor    %r12d,%r12d
  mov    $0x40,%r8d
L201:
  movslq %r13d,%rax
  xor    %r10d,%r10d
  add    %rdi,%rax
  test   %r15d,%r15d
  jle    L587
  xchg   %ax,%ax
L272:
  xor    %ecx,%ecx
  xor    %edx,%edx
  nopl   0x0(%rax)
L577:
  cmpb   $0x31,(%rax,%rcx,1)
  jne    L664
  mov    %r8d,%r9d
  sar    %cl,%r9d
  add    %r9d,%edx
L664:
  add    $0x1,%rcx
  cmp    $0x7,%rcx
  jne    L577
  cmp    $0x5d,%edx
  je     L414
L424:
  add    $0x1,%r10d
  add    $0x1,%rax
  cmp    %r10d,%r15d
  jne    L272
L587:
  lea    0x1(%r12),%eax
  add    %esi,%r13d
  cmp    %eax,%esi
  je     L57
  mov    %eax,%r12d
  jmp    L201
  nopl   0x0(%rax,%rax,1)
L414:
  lea    -0x4(%r10),%edx
  xor    %r9d,%r9d
L727:
  test   %edx,%edx
  js     L3
  lea    (%rdx,%r13,1),%ecx
  movslq %ecx,%rcx
  cmpb   $0x30,(%rdi,%rcx,1)
  je     L3
  xor    %r9d,%r9d
L112:
  add    $0x1,%edx
  cmp    %r10d,%edx
  jne    L727
  lea    0x7(%r10),%edx
  xor    %ecx,%ecx
  lea    0xb(%r10),%r14d
L476:
  cmp    %edx,%esi
  jle    L481
  lea    (%rdx,%r13,1),%ebx
  movslq %ebx,%rbx
  cmpb   $0x30,(%rdi,%rbx,1)
  je     L481
  xor    %ecx,%ecx
L333:
  add    $0x1,%edx
  cmp    %r14d,%edx
  jne    L476
  cmp    $0x4,%r9d
  je     L551
  cmp    $0x4,%ecx
  jne    L424
L551:
  add    $0x28,%r11d
  jmp    L424
  nopl   0x0(%rax)
L481:
  add    $0x1,%ecx
  jmp    L333
  nopl   (%rax)
L3:
  add    $0x1,%r9d
  jmp    L112
  xchg   %ax,%ax
L122:
  mov    -0x4c(%rbp),%ebx
  lea    -0x4(%rdx),%ecx
  lea    (%r9,%rbx,1),%r11d
  xor    %ebx,%ebx
L96:
  test   %ecx,%ecx
  js     L647
  movslq %r11d,%r12
  cmpb   $0x30,(%rdi,%r12,1)
  je     L647
  xor    %ebx,%ebx
L478:
  add    $0x1,%ecx
  add    %esi,%r11d
  cmp    %edx,%ecx
  jne    L96
  lea    0x7(%rdx),%ecx
  mov    %r9d,%r11d
  lea    0xb(%rdx),%r13d
  xor    %r12d,%r12d
L97:
  cmp    %ecx,%esi
  jle    L341
  movslq %r11d,%r14
  cmpb   $0x30,(%rdi,%r14,1)
  je     L341
  xor    %r12d,%r12d
L601:
  add    $0x1,%ecx
  add    %esi,%r11d
  cmp    %r13d,%ecx
  jne    L97
  cmp    $0x4,%ebx
  je     L119
  cmp    $0x4,%r12d
  jne    L216
L119:
  addl   $0x28,-0x5c(%rbp)
  jmp    L216
  nopw   0x0(%rax,%rax,1)
L341:
  add    $0x1,%r12d
  jmp    L601
  cs nopw 0x0(%rax,%rax,1)
L647:
  add    $0x1,%ebx
  jmp    L478
L57:
  mov    -0x58(%rbp),%r10
  xor    %r9d,%r9d
  xor    %eax,%eax
  movslq %esi,%rsi
  nopl   0x0(%rax)
L273:
  lea    (%rdi,%r9,1),%rdx
  xor    %ecx,%ecx
  jmp    L277
L539:
  mov    %r8d,%ecx
L277:
  xor    %r8d,%r8d
  cmpb   $0x31,(%rdx)
  sete   %r8b
  add    %rsi,%rdx
  add    %r8d,%eax
  lea    0x1(%rcx),%r8d
  cmp    %ecx,%r12d
  jne    L539
  add    $0x1,%r9
  cmp    %r10,%r9
  jne    L273
  cltd
  idivl  -0x60(%rbp)
  imul   $0x64,%eax,%eax
  cmp    $0x32,%eax
  jle    L609
  sub    $0x32,%eax
L293:
  mov    $0xcccccccd,%edx
  imul   %rdx,%rax
  shr    $0x22,%rax
  lea    (%rax,%rax,4),%eax
  add    %eax,%eax
L435:
  add    %r11d,%eax
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L509
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L609:
  mov    $0x32,%edx
  sub    %eax,%edx
  mov    %edx,%eax
  jmp    L293
L456:
  orq    $0x0,-0x8(%rsp,%rax,1)
  jmp    L84
L44:
  mov    $0x64,%eax
  jmp    L435
L502:
  mov    $0x64,%eax
  xor    %r11d,%r11d
  jmp    L435
L509:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int evaluate(unsigned char *eval, const int size, const int pattern) {
  int x, y, block, weight;
  int result = 0;
  char state;
  int p;
  int dark_mods;
  int percentage, k;
  int a, b, afterCount, beforeCount;
  char local[size * size];
  for (x = 0; x < size; x++) {
    for (y = 0; y < size; y++) {
      if ((eval[(y * size) + x] & (0x01 << pattern)) != 0) {
        local[(y * size) + x] = '1';
      } else {
        local[(y * size) + x] = '0';
      }
    }
  }
  for (x = 0; x < size; x++) {
    state = local[x];
    block = 0;
    for (y = 0; y < size; y++) {
      if (local[(y * size) + x] == state) {
        block++;
      } else {
        if (block > 5) {
          result += (3 + (block - 5));
        }
        block = 0;
        state = local[(y * size) + x];
      }
    }
    if (block > 5) {
      result += (3 + (block - 5));
    }
  }
  for (y = 0; y < size; y++) {
    state = local[y * size];
    block = 0;
    for (x = 0; x < size; x++) {
      if (local[(y * size) + x] == state) {
        block++;
      } else {
        if (block > 5) {
          result += (3 + (block - 5));
        }
        block = 0;
        state = local[(y * size) + x];
      }
    }
    if (block > 5) {
      result += (3 + (block - 5));
    }
  }
  for (x = 0; x < size - 1; x++) {
    for (y = 0; y < size - 1; y++) {
      if (((local[(y * size) + x] == local[((y + 1) * size) + x]) && (local[(y * size) + x] == local[(y * size) + (x + 1)])) && (local[(y * size) + x] == local[((y + 1) * size) + (x + 1)])) {
        result += 3;
      }
    }
  }
  for (x = 0; x < size; x++) {
    for (y = 0; y < (size - 7); y++) {
      p = 0;
      for (weight = 0; weight < 7; weight++) {
        if (local[((y + weight) * size) + x] == '1') {
          p += (0x40 >> weight);
        }
      }
      if (p == 0x5d) {
        beforeCount = 0;
        for (b = (y - 4); b < y; b++) {
          if (b < 0) {
            beforeCount++;
          } else {
            if (local[(b * size) + x] == '0') {
              beforeCount++;
            } else {
              beforeCount = 0;
            }
          }
        }
        afterCount = 0;
        for (a = (y + 7); a <= (y + 10); a++) {
          if (a >= size) {
            afterCount++;
          } else {
            if (local[(a * size) + x] == '0') {
              afterCount++;
            } else {
              afterCount = 0;
            }
          }
        }
        if ((beforeCount == 4) || (afterCount == 4)) {
          result += 40;
        }
      }
    }
  }
  for (y = 0; y < size; y++) {
    for (x = 0; x < (size - 7); x++) {
      p = 0;
      for (weight = 0; weight < 7; weight++) {
        if (local[(y * size) + x + weight] == '1') {
          p += (0x40 >> weight);
        }
      }
      if (p == 0x5d) {
        beforeCount = 0;
        for (b = (x - 4); b < x; b++) {
          if (b < 0) {
            beforeCount++;
          } else {
            if (local[(y * size) + b] == '0') {
              beforeCount++;
            } else {
              beforeCount = 0;
            }
          }
        }
        afterCount = 0;
        for (a = (x + 7); a <= (x + 10); a++) {
          if (a >= size) {
            afterCount++;
          } else {
            if (local[(y * size) + a] == '0') {
              afterCount++;
            } else {
              afterCount = 0;
            }
          }
        }
        if ((beforeCount == 4) || (afterCount == 4)) {
          result += 40;
        }
      }
    }
  }
  dark_mods = 0;
  for (x = 0; x < size; x++) {
    for (y = 0; y < size; y++) {
      if (local[(y * size) + x] == '1') {
        dark_mods++;
      }
    }
  }
  percentage = 100 * (dark_mods / (size * size));
  if (percentage <= 50) {
    k = ((100 - percentage) - 50) / 5;
  } else {
    k = (percentage - 50) / 5;
  }
  result += 10 * k;
  return result;
}
```