user: 请将以下的汇编代码转换成C语言代码:

```asm
<populate_grid>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %esi,-0x4c(%rbp)
  mov    %edx,-0x50(%rbp)
  mov    %rcx,-0x58(%rbp)
  mov    %r8d,-0x5c(%rbp)
  mov    -0x50(%rbp),%eax
  cmp    -0x4c(%rbp),%eax
  sete   %al
  movzbl %al,%eax
  mov    %eax,-0x20(%rbp)
  cmpl   $0x0,-0x20(%rbp)
  je     L4
  mov    $0x2,%edx
  jmp    L13
L4:
  mov    $0x3,%edx
L13:
  mov    -0x4c(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0x1c(%rbp)
  movl   $0x1,-0x34(%rbp)
  movl   $0x0,-0x30(%rbp)
  mov    -0x5c(%rbp),%eax
  shl    $0x3,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x50(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x28(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L42
L81:
  mov    -0x30(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x1c(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x28(%rbp),%eax
  imul   -0x4c(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  cmpl   $0x5,-0x24(%rbp)
  jg     L45
  cmpl   $0x0,-0x20(%rbp)
  je     L45
  subl   $0x1,-0x24(%rbp)
L45:
  mov    -0x24(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  and    $0xf0,%eax
  test   %eax,%eax
  jne    L67
  mov    -0x24(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  lea    (%rdx,%rax,1),%rbx
  mov    -0x2c(%rbp),%edx
  mov    -0x58(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cwbit@plt>
  mov    %al,(%rbx)
  addl   $0x1,-0x2c(%rbp)
L67:
  mov    -0x2c(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jge    L27
  mov    -0x14(%rbp),%edx
  mov    -0x24(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  and    $0xf0,%eax
  test   %eax,%eax
  jne    L27
  mov    -0x14(%rbp),%edx
  mov    -0x24(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  lea    (%rdx,%rax,1),%rbx
  mov    -0x2c(%rbp),%edx
  mov    -0x58(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <cwbit@plt>
  mov    %al,(%rbx)
  addl   $0x1,-0x2c(%rbp)
L27:
  cmpl   $0x0,-0x34(%rbp)
  je     L92
  subl   $0x1,-0x28(%rbp)
  cmpl   $0xffffffff,-0x28(%rbp)
  jne    L42
  addl   $0x1,-0x30(%rbp)
  movl   $0x0,-0x28(%rbp)
  movl   $0x0,-0x34(%rbp)
  jmp    L42
L92:
  addl   $0x1,-0x28(%rbp)
  mov    -0x28(%rbp),%eax
  cmp    -0x50(%rbp),%eax
  jne    L42
  addl   $0x1,-0x30(%rbp)
  mov    -0x50(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x28(%rbp)
  movl   $0x1,-0x34(%rbp)
L42:
  mov    -0x2c(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jl     L81
  nop
  nop
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
void populate_grid(unsigned char *grid, const int h_size, const int v_size, const unsigned char *fullstream, const int cw) {
  const int not_rmqr = v_size == h_size;
  const int x_start = h_size - (not_rmqr ? 2 : 3);
  int direction = 1;
  int row = 0;
  int i, n, y;
  n = cw * 8;
  y = v_size - 1;
  i = 0;
  while (i < n) {
    int x = x_start - (row * 2);
    int r = y * h_size;
    if ((x < 6) && (not_rmqr))
      x--;
    if (!(grid[r + (x + 1)] & 0xf0)) {
      grid[r + (x + 1)] = cwbit(fullstream, i);
      i++;
    }
    if (i < n) {
      if (!(grid[r + x] & 0xf0)) {
        grid[r + x] = cwbit(fullstream, i);
        i++;
      }
    }
    if (direction) {
      y--;
      if (y == -1) {
        row++;
        y = 0;
        direction = 0;
      }
    } else {
      y++;
      if (y == v_size) {
        row++;
        y = v_size - 1;
        direction = 1;
      }
    }
  }
}
```