user: What would the C source look like for the assembly code provided here:

```asm
<ai_rateres>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x40,%rsp
  mov    %edi,%r13d
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  movl   $0x0,(%rsp)
  movl   $0x0,0x4(%rsp)
  movl   $0x0,0x8(%rsp)
  movl   $0x0,0xc(%rsp)
  movl   $0x0,0x10(%rsp)
  movl   $0x0,0x20(%rsp)
  movl   $0x0,0x24(%rsp)
  movl   $0x0,0x28(%rsp)
  movl   $0x0,0x2c(%rsp)
  movl   $0x0,0x30(%rsp)
  mov    $0x0,%ebx
  mov    $0x6,%r12d
  jmp    L27
L52:
  add    $0x1,%ebx
  cmp    $0x16,%ebx
  je     L65
L27:
  mov    $0x0,%esi
  mov    %ebx,%edi
  call   <map_getdat@plt>
  cmp    $0x5,%eax
  je     L52
  mov    $0x0,%esi
  mov    %ebx,%edi
  call   <map_getdat@plt>
  cmp    $0xffffffff,%eax
  je     L52
  mov    %ebx,%esi
  mov    %r13d,%edi
  call   <data_onhex@plt>
  mov    %eax,%r14d
  mov    $0x1,%esi
  mov    %ebx,%edi
  call   <map_getdat@plt>
  sub    $0x7,%eax
  mov    %eax,%edx
  neg    %edx
  cmovns %edx,%eax
  mov    %r12d,%ebp
  sub    %eax,%ebp
  imul   %r14d,%ebp
  mov    $0x0,%esi
  mov    %ebx,%edi
  call   <map_getdat@plt>
  cltq
  add    %ebp,(%rsp,%rax,4)
  mov    $0x1,%esi
  mov    %ebx,%edi
  call   <map_getdat@plt>
  mov    %eax,%ebp
  mov    $0x0,%esi
  mov    %ebx,%edi
  call   <map_getdat@plt>
  cltq
  lea    -0x7(%rbp),%edx
  mov    %edx,%ecx
  neg    %ecx
  cmovns %ecx,%edx
  mov    %r12d,%ecx
  sub    %edx,%ecx
  add    %ecx,0x20(%rsp,%rax,4)
  jmp    L52
L65:
  mov    $0x0,%eax
  mov    $0x0,%ecx
  mov    $0x0,%edi
  mov    %rsp,%r8
  lea    0x20(%rsp),%rsi
L32:
  mov    (%rax,%r8,1),%edx
  cmp    %edx,%edi
  cmovl  %edx,%edi
  mov    (%rax,%rsi,1),%edx
  cmp    %edx,%ecx
  cmovl  %edx,%ecx
  add    $0x4,%rax
  cmp    $0x14,%rax
  jne    L32
  mov    $0x0,%esi
  lea    D2(%rip),%r9
  mov    $0x4,%r8d
L45:
  mov    0x20(%rsp,%rsi,1),%eax
  lea    (%rax,%rax,2),%eax
  cltd
  idiv   %ecx
  mov    %r8d,%edx
  sub    %eax,%edx
  mov    %edx,(%r9,%rsi,1)
  add    $0x4,%rsi
  cmp    $0x14,%rsi
  jne    L45
  test   %edi,%edi
  je     L56
  lea    D2(%rip),%rcx
  mov    %rsp,%rsi
  lea    0x14(%rcx),%r9
  mov    $0x5,%r8d
L2:
  mov    (%rsi),%eax
  shl    $0x2,%eax
  cltd
  idiv   %edi
  mov    %r8d,%edx
  sub    %eax,%edx
  add    %edx,(%rcx)
  add    $0x4,%rcx
  add    $0x4,%rsi
  cmp    %rcx,%r9
  jne    L2
L56:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L29
  lea    D2(%rip),%rax
  add    $0x40,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L29:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int *ai_rateres(int player) {
  static int res[5];
  int weight[5];
  int mapweight[5];
  int i;
  for (i = 0; i < 5; i++)
    weight[i] = 0;
  for (i = 0; i < 5; i++)
    mapweight[i] = 0;
  for (i = 0; i < 22; i++) {
    if (map_getdat(i, 0) != 5 && map_getdat(i, 0) != -1) {
      weight[map_getdat(i, 0)] += data_onhex(player, i) * (abs(map_getdat(i, 1) - 7) * -1 + 6);
      mapweight[map_getdat(i, 0)] += (abs(map_getdat(i, 1) - 7) * -1 + 6);
    }
  }
  int max = 0;
  int mapmax = 0;
  for (i = 0; i < 5; i++) {
    if (max < weight[i])
      max = weight[i];
    if (mapmax < mapweight[i])
      mapmax = mapweight[i];
  }
  for (i = 0; i < 5; i++) {
    res[i] = 4 - mapweight[i] * 3 / mapmax;
  }
  if (max == 0) {
    return res;
  }
  for (i = 0; i < 5; i++) {
    res[i] += 5 - weight[i] * 4 / max;
  }
  return res;
}
```