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

```asm
<main>:
  endbr64
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0xc18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x1c08(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rsi
  lea    0x400(%rsp),%rdi
  mov    %rdi,%r10
  mov    %rsi,%r9
  mov    $0x0,%r8d
L31:
  mov    $0x0,%edx
  mov    $0x4000,%eax
L77:
  mov    %eax,(%r9,%rdx,1)
  lea    (%r8,%rax,1),%ecx
  mov    %ecx,(%r10,%rdx,1)
  add    $0x1,%eax
  add    $0x40,%rdx
  cmp    $0x4010,%eax
  jne    L77
  add    $0x1,%r8d
  add    $0x4,%r9
  add    $0x4,%r10
  cmp    $0x10,%r8d
  jne    L31
  lea    0xc00(%rsp),%r8
  lea    0x1c00(%rsp),%rcx
  lea    0x1c80(%rsp),%r10
  mov    $0x0,%r9d
L78:
  lea    0x4000(%r9),%edx
  lea    -0x1000(%rcx),%rax
L45:
  mov    %edx,(%rax)
  add    $0x1,%edx
  sub    $0xffffffffffffff80,%rax
  cmp    %rcx,%rax
  jne    L45
  add    $0x1,%r9d
  add    $0x4,%rcx
  cmp    %r10,%rcx
  jne    L78
  lea    0x800(%rsp),%r9
  lea    0x800(%r8),%r10
  mov    %r9,%rcx
L0:
  mov    $0x0,%eax
L65:
  mov    0x840(%r8,%rax,1),%edx
  mov    %edx,(%rcx,%rax,1)
  add    $0x4,%rax
  cmp    $0x40,%rax
  jne    L65
  sub    $0xffffffffffffff80,%r8
  add    $0x40,%rcx
  cmp    %r10,%r8
  jne    L0
  lea    0x400(%r9),%r10
  mov    $0x0,%r8d
L60:
  mov    $0x0,%edx
L24:
  mov    (%rdi,%rdx,1),%eax
  add    (%r9,%rdx,1),%eax
  add    $0x1,%eax
  sar    %eax
  sub    (%rsi,%rdx,1),%eax
  mov    %eax,%ecx
  neg    %ecx
  cmovns %ecx,%eax
  add    %eax,%r8d
  add    $0x4,%rdx
  cmp    $0x40,%rdx
  jne    L24
  add    $0x40,%r9
  add    $0x40,%rdi
  add    $0x40,%rsi
  cmp    %r9,%r10
  jne    L60
  cmp    $0x1780,%r8d
  mov    $0xbadbeef,%eax
  mov    $0xbad,%edx
  cmovne %edx,%eax
  mov    0x1c08(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L39
  add    $0x1c18,%rsp
  ret
L39:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main() {
  int currentBlock[16][16];
  int blockSoFar[16][16];
  int prev[32][32];
  int mx = 4;
  int my = 4;
  int bx = 4;
  int by = 4;
  int diff = 0;
  int localDiff;
  int y;
  int x;
  int yHalf;
  int xHalf;
  int fy;
  int fx;
  int lumMotionBlock[16][16];
  int checksum;
  for (y = 0; y < 16; y++) {
    for (x = 0; x < 16; x++) {
      currentBlock[x][y] = x + (1 << (16 - 2));
      blockSoFar[x][y] = x + y + (1 << (16 - 2));
    }
  }
  for (y = 0; y < 32; y++) {
    for (x = 0; x < 32; x++) {
      prev[x][y] = x + y + (1 << (16 - 2));
    }
  }
  xHalf = ((((mx) < 0) ? -(mx) : (mx)) % 2 == 1);
  yHalf = ((((my) < 0) ? -(my) : (my)) % 2 == 1);
  {
    fy = (by)*8 + (my / 2);
    fx = (bx)*8 + (mx / 2);
  };
  if (xHalf) {
    if (mx < 0) {
      fx--;
    }
    if (yHalf) {
      if (my < 0) {
        fy--;
      }
    } else if (yHalf) {
      if (my < 0) {
        fy--;
      }
    }
  }
  diff = 0;
  if (fx > 16)
    fx = 16;
  if (fy > 16)
    fy = 16;
  for (y = 0; y < 16; y++)
    for (x = 0; x < 16; x++)
      lumMotionBlock[y][x] = prev[y + fy][x + fx];
  for (y = 0; y < 16; y++)
    for (x = 0; x < 16; x++) {
      localDiff = ((lumMotionBlock[y][x] + blockSoFar[y][x] + 1) >> 1) - currentBlock[y][x];
      diff += (((localDiff) < 0) ? -(localDiff) : (localDiff));
    }
  checksum = diff;
  if (checksum == 6016) {
    return 0xbadbeef;
  } else {
    return 0xbad;
  }
}
```