ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Translate the below assembly code into C programming language:

```asm
<matches>:
  endbr64
  xor    %eax,%eax
  test   %rdx,%rdx
  jne    L17
  jmp    L13
  nopl   (%rax)
L8:
  add    $0x1,%rax
  cmp    %rdx,%rax
  je     L13
L17:
  movzbl (%rsi,%rax,1),%ecx
  cmp    %cl,(%rdi,%rax,1)
  je     L8
  cmp    %rdx,%rax
  sete   %al
  movzbl %al,%eax
  ret
  nopl   0x0(%rax)
L13:
  mov    $0x1,%eax
  ret
```

assistant: ```c
bool matches(const char *a, const char *b, size_t n) {
  for (; n && *a == *b; --n, ++a, ++b)
    ;
  return !n;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<matches>:
  endbr64
  xor    %eax,%eax
  test   %rdx,%rdx
  jne    L4
  jmp    L8
  nopl   (%rax)
L32:
  add    $0x1,%rax
  cmp    %rdx,%rax
  je     L8
L4:
  movzbl (%rsi,%rax,1),%ecx
  cmp    %cl,(%rdi,%rax,1)
  je     L32
  cmp    %rdx,%rax
  sete   %al
  movzbl %al,%eax
  ret
  nopl   0x0(%rax)
L8:
  mov    $0x1,%eax
  ret
```

assistant: ```c
bool matches(const char *a, const char *b, size_t n) {
  for (; n && *a == *b; --n, ++a, ++b)
    ;
  return !n;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<addvec>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  movsd  %xmm0,-0x28(%rbp)
  mov    %rdx,-0x30(%rbp)
  mov    %ecx,-0x34(%rbp)
  movl   $0x1,-0x4(%rbp)
  jmp    L6
L8:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  -0x28(%rbp),%xmm0
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x4(%rbp)
L6:
  mov    -0x4(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jle    L8
  mov    $0x0,%eax
  pop    %rbp
  ret
```

assistant: ```c
int addvec(double *vecnew, double *vec1, double scalar, double *vec2, int length) {
  int i;
  for (i = 1; i <= length; i++)
    vecnew[i] = vec1[i] + scalar * vec2[i];
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<addvec>:
  endbr64
  test   %ecx,%ecx
  jle    L5
  lea    0x1(%rcx),%ecx
  mov    $0x1,%eax
L12:
  movapd %xmm0,%xmm1
  mulsd  (%rdx,%rax,8),%xmm1
  addsd  (%rsi,%rax,8),%xmm1
  movsd  %xmm1,(%rdi,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L12
L5:
  mov    $0x0,%eax
  ret
```

assistant: ```c
int addvec(double *vecnew, double *vec1, double scalar, double *vec2, int length) {
  int i;
  for (i = 1; i <= length; i++)
    vecnew[i] = vec1[i] + scalar * vec2[i];
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<addvec>:
  endbr64
  test   %ecx,%ecx
  jle    L1
  add    $0x1,%ecx
  mov    $0x1,%eax
L8:
  movsd  (%rdx,%rax,8),%xmm1
  mulsd  %xmm0,%xmm1
  addsd  (%rsi,%rax,8),%xmm1
  movsd  %xmm1,(%rdi,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%rcx
  jne    L8
L1:
  xor    %eax,%eax
  ret
```

assistant: ```c
int addvec(double *vecnew, double *vec1, double scalar, double *vec2, int length) {
  int i;
  for (i = 1; i <= length; i++)
    vecnew[i] = vec1[i] + scalar * vec2[i];
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<addvec>:
  endbr64
  mov    %ecx,%r8d
  test   %ecx,%ecx
  jle    L57
  lea    0x8(%rdi),%rax
  lea    0x10(%rdx),%rcx
  cmp    %rcx,%rax
  lea    0x10(%rsi),%r9
  setne  %cl
  cmp    %r9,%rax
  setne  %al
  test   %al,%cl
  je     L49
  lea    -0x1(%r8),%eax
  cmp    $0x1,%eax
  jbe    L49
  mov    %r8d,%eax
  movapd %xmm0,%xmm2
  shr    %eax
  unpcklpd %xmm2,%xmm2
  lea    -0x1(%rax),%ecx
  mov    $0x8,%eax
  shl    $0x4,%rcx
  add    $0x18,%rcx
  nopl   0x0(%rax)
L4:
  movupd (%rdx,%rax,1),%xmm1
  movupd (%rsi,%rax,1),%xmm3
  mulpd  %xmm2,%xmm1
  addpd  %xmm3,%xmm1
  movups %xmm1,(%rdi,%rax,1)
  add    $0x10,%rax
  cmp    %rcx,%rax
  jne    L4
  mov    %r8d,%eax
  or     $0x1,%eax
  and    $0x1,%r8d
  je     L57
  cltq
  mulsd  (%rdx,%rax,8),%xmm0
  addsd  (%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%rdi,%rax,8)
L57:
  xor    %eax,%eax
  ret
  nopw   0x0(%rax,%rax,1)
L49:
  lea    0x1(%r8),%ecx
  mov    $0x1,%eax
  nopl   0x0(%rax)
L53:
  movsd  (%rdx,%rax,8),%xmm1
  mulsd  %xmm0,%xmm1
  addsd  (%rsi,%rax,8),%xmm1
  movsd  %xmm1,(%rdi,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%rcx
  jne    L53
  xor    %eax,%eax
  ret
```

assistant: ```c
int addvec(double *vecnew, double *vec1, double scalar, double *vec2, int length) {
  int i;
  for (i = 1; i <= length; i++)
    vecnew[i] = vec1[i] + scalar * vec2[i];
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<add>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%r9
  mov    %ecx,%esi
  mov    %edx,%ebx
  imul   %r8d,%ebx
  lea    (%rbx,%rcx,1),%eax
  cltq
  mov    D16(%rip),%rcx
  mov    %rcx,(%rdi,%rax,8)
  test   %edx,%edx
  jle    L44
  mov    %rdi,%r11
  movslq %edx,%r10
  shl    $0x3,%r10
  movslq %r8d,%r8
  lea    (%r9,%r8,8),%rbp
  mov    %esi,%ecx
  mov    %rbp,%rax
  mov    $0x0,%r8d
  movsd  D16(%rip),%xmm0
  movapd %xmm0,%xmm1
  movapd %xmm0,%xmm2
  jmp    L50
L28:
  lea    0x1(%r8),%edi
  add    %r10,%rax
  add    %edx,%ecx
  cmp    %edi,%edx
  je     L79
  mov    %edi,%r8d
L50:
  ucomisd (%rax),%xmm0
  jp     L28
  ucomisd (%rax),%xmm1
  jne    L28
  movslq %ecx,%rdi
  movsd  %xmm2,(%r11,%rdi,8)
  jmp    L28
L79:
  mov    %r8d,%r13d
  imul   %edi,%esi
  movslq %esi,%rsi
  lea    (%r9,%rsi,8),%r12
  mov    $0x0,%esi
  movsd  D16(%rip),%xmm3
  movapd %xmm3,%xmm4
  movapd %xmm3,%xmm5
  mov    $0x0,%r14d
  movapd %xmm3,%xmm0
  movapd %xmm3,%xmm1
  movapd %xmm3,%xmm2
  jmp    L60
L147:
  lea    0x1(%rdx),%r9d
  add    %r10,%rax
  add    %edi,%ecx
  cmp    %edx,%r8d
  je     L13
  mov    %r9d,%edx
L124:
  ucomisd (%rax),%xmm0
  jp     L147
  ucomisd (%rax),%xmm1
  jne    L147
  movslq %ecx,%r9
  movsd  %xmm2,(%r11,%r9,8)
  jmp    L147
L13:
  lea    0x1(%rsi),%rax
  cmp    %r13,%rsi
  je     L44
  mov    %rax,%rsi
L60:
  ucomisd (%r12,%rsi,8),%xmm3
  jp     L13
  ucomisd (%r12,%rsi,8),%xmm4
  jne    L13
  mov    %esi,%ecx
  lea    (%rbx,%rsi,1),%eax
  cltq
  movsd  %xmm5,(%r11,%rax,8)
  mov    %rbp,%rax
  mov    %r14d,%edx
  jmp    L124
L44:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

tool_calls: name: retrieve_data
arguments: label: D16
type: byte[8]

tool: {"D16": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f]}

assistant: ```c
void add(double *ancMatrixUpdated, double *ancMatrix, int nr, int source, int sink) {
  int j, p;
  ancMatrixUpdated[source + nr * sink] = 1;
  for (j = 0; j < nr; j++) {
    if (ancMatrix[sink + j * nr] == 1)
      ancMatrixUpdated[source + j * nr] = 1;
  }
  for (p = 0; p < nr; p++) {
    if (ancMatrix[p + source * nr] == 1) {
      ancMatrixUpdated[p + sink * nr] = 1;
      for (j = 0; j < nr; j++) {
        if (ancMatrix[sink + j * nr] == 1)
          ancMatrixUpdated[p + j * nr] = 1;
      }
    }
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<add>:
  endbr64
  push   %r13
  movsd  D1(%rip),%xmm0
  mov    %rdi,%r11
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  imul   %r8d,%ebp
  push   %rbx
  lea    0x0(%rbp,%rcx,1),%eax
  cltq
  movsd  %xmm0,(%rdi,%rax,8)
  test   %edx,%edx
  jle    L112
  mov    %rsi,%r9
  movslq %r8d,%r8
  movslq %edx,%rbx
  mov    %edx,%esi
  lea    (%r9,%r8,8),%r12
  mov    %ecx,%edi
  lea    0x0(,%rbx,8),%r10
  xor    %r8d,%r8d
  mov    %r12,%rax
  jmp    L99
  nop
L110:
  mov    %edx,%r8d
L99:
  ucomisd (%rax),%xmm0
  jp     L104
  jne    L104
  movslq %ecx,%rdx
  movsd  %xmm0,(%r11,%rdx,8)
L104:
  lea    0x1(%r8),%edx
  add    %r10,%rax
  add    %esi,%ecx
  cmp    %edx,%esi
  jne    L110
  imul   %esi,%edi
  movslq %edi,%rdi
  lea    (%r9,%rdi,8),%r13
  xor    %edi,%edi
  jmp    L131
  nop
L85:
  add    $0x1,%rdi
  cmp    %rdi,%rbx
  je     L112
L131:
  ucomisd 0x0(%r13,%rdi,8),%xmm0
  jp     L85
  jne    L85
  lea    0x0(%rbp,%rdi,1),%eax
  mov    %edi,%ecx
  xor    %edx,%edx
  cltq
  movsd  %xmm0,(%r11,%rax,8)
  mov    %r12,%rax
  jmp    L59
  nopl   0x0(%rax)
L97:
  mov    %r9d,%edx
L59:
  ucomisd (%rax),%xmm0
  jp     L79
  jne    L79
  movslq %ecx,%r9
  movsd  %xmm0,(%r11,%r9,8)
L79:
  lea    0x1(%rdx),%r9d
  add    %r10,%rax
  add    %esi,%ecx
  cmp    %edx,%r8d
  jne    L97
  add    $0x1,%rdi
  cmp    %rdi,%rbx
  jne    L131
L112:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D1
type: byte[8]

tool: {"D1": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f]}

assistant: ```c
void add(double *ancMatrixUpdated, double *ancMatrix, int nr, int source, int sink) {
  int j, p;
  ancMatrixUpdated[source + nr * sink] = 1;
  for (j = 0; j < nr; j++) {
    if (ancMatrix[sink + j * nr] == 1)
      ancMatrixUpdated[source + j * nr] = 1;
  }
  for (p = 0; p < nr; p++) {
    if (ancMatrix[p + source * nr] == 1) {
      ancMatrixUpdated[p + sink * nr] = 1;
      for (j = 0; j < nr; j++) {
        if (ancMatrix[sink + j * nr] == 1)
          ancMatrixUpdated[p + j * nr] = 1;
      }
    }
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<add>:
  endbr64
  mov    %edx,%r9d
  movslq %r8d,%rax
  movslq %ecx,%rdx
  movsd  D0(%rip),%xmm0
  mov    %r9d,%r8d
  imul   %eax,%r8d
  lea    (%r8,%rdx,1),%ecx
  movslq %ecx,%rcx
  movsd  %xmm0,(%rdi,%rcx,8)
  test   %r9d,%r9d
  jle    L136
  cmp    $0x1,%r9d
  jne    L8
  ucomisd (%rsi,%rax,8),%xmm0
  jp     L13
  jne    L13
  movsd  %xmm0,(%rdi,%rdx,8)
L13:
  ucomisd (%rsi,%rdx,8),%xmm0
  jp     L136
  je     L70
L136:
  ret
  nopl   0x0(%rax,%rax,1)
L70:
  movsd  %xmm0,(%rdi,%rax,8)
  ucomisd (%rsi,%rax,8),%xmm0
  jp     L136
  jne    L136
  movsd  %xmm0,(%rdi)
  ret
L8:
  movslq %r9d,%r10
  push   %r12
  lea    (%rsi,%rax,8),%r11
  xor    %ecx,%ecx
  push   %rbp
  lea    0x0(,%r10,8),%rbp
  push   %rbx
  mov    %edx,%ebx
  nopw   0x0(%rax,%rax,1)
L124:
  ucomisd (%r11),%xmm0
  jp     L161
  jne    L161
  movslq %ebx,%r12
  movsd  %xmm0,(%rdi,%r12,8)
L161:
  add    $0x1,%ecx
  add    %rbp,%r11
  add    %r9d,%ebx
  cmp    %ecx,%r9d
  jne    L124
  imul   %r9d,%edx
  lea    (%rsi,%rax,8),%r12
  lea    0x0(,%r10,8),%r11
  movslq %edx,%rdx
  lea    (%rsi,%rdx,8),%rbp
  xor    %esi,%esi
  jmp    L37
  nopl   0x0(%rax,%rax,1)
L38:
  add    $0x1,%rsi
  cmp    %r10,%rsi
  je     L100
L37:
  ucomisd 0x0(%rbp,%rsi,8),%xmm0
  jp     L38
  jne    L38
  lea    (%r8,%rsi,1),%eax
  mov    %esi,%ecx
  mov    %r12,%rdx
  cltq
  movsd  %xmm0,(%rdi,%rax,8)
  xor    %eax,%eax
  nopl   (%rax)
L82:
  ucomisd (%rdx),%xmm0
  jp     L53
  jne    L53
  movslq %ecx,%rbx
  movsd  %xmm0,(%rdi,%rbx,8)
L53:
  add    $0x1,%eax
  add    %r11,%rdx
  add    %r9d,%ecx
  cmp    %eax,%r9d
  jne    L82
  add    $0x1,%rsi
  cmp    %r10,%rsi
  jne    L37
L100:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D0
type_guessed: byte[8]

tool: {"D0": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f]}

assistant: ```c
void add(double *ancMatrixUpdated, double *ancMatrix, int nr, int source, int sink) {
  int j, p;
  ancMatrixUpdated[source + nr * sink] = 1;
  for (j = 0; j < nr; j++) {
    if (ancMatrix[sink + j * nr] == 1)
      ancMatrixUpdated[source + j * nr] = 1;
  }
  for (p = 0; p < nr; p++) {
    if (ancMatrix[p + source * nr] == 1) {
      ancMatrixUpdated[p + sink * nr] = 1;
      for (j = 0; j < nr; j++) {
        if (ancMatrix[sink + j * nr] == 1)
          ancMatrixUpdated[p + j * nr] = 1;
      }
    }
  }
}
```
user: Translate the below assembly code into C programming language:

```asm
<has_arg>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  movl   $0x1,-0x4(%rbp)
  jmp    L21
L19:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0x28(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L13
  mov    $0x1,%eax
  jmp    L23
L13:
  addl   $0x1,-0x4(%rbp)
L21:
  mov    -0x4(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L19
  mov    $0x0,%eax
L23:
  leave
  ret
```

assistant: ```c
int has_arg(int argc, char **argv, char *search) {
  for (int idx = 1; idx < argc; idx++) {
    if (strcmp(argv[idx], search) == 0) {
      return 1;
    }
  }
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<has_arg>:
  endbr64
  cmp    $0x1,%edi
  jle    L16
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdx,%rbp
  lea    0x8(%rsi),%rbx
  lea    -0x2(%rdi),%eax
  lea    0x10(%rsi,%rax,8),%r12
L6:
  mov    %rbp,%rsi
  mov    (%rbx),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L22
  add    $0x8,%rbx
  cmp    %r12,%rbx
  jne    L6
  mov    $0x0,%eax
  jmp    L9
L16:
  mov    $0x0,%eax
  ret
L22:
  mov    $0x1,%eax
L9:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int has_arg(int argc, char **argv, char *search) {
  for (int idx = 1; idx < argc; idx++) {
    if (strcmp(argv[idx], search) == 0) {
      return 1;
    }
  }
  return 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<has_arg>:
  endbr64
  cmp    $0x1,%edi
  jle    L11
  lea    -0x2(%rdi),%eax
  push   %r12
  lea    0x10(%rsi,%rax,8),%r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  lea    0x8(%rsi),%rbx
  jmp    L33
  xchg   %ax,%ax
L23:
  add    $0x8,%rbx
  cmp    %r12,%rbx
  je     L30
L33:
  mov    (%rbx),%rdi
  mov    %rbp,%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L23
  pop    %rbx
  mov    $0x1,%eax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L30:
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
L11:
  xor    %eax,%eax
  ret
```

assistant: ```c
int has_arg(int argc, char **argv, char *search) {
  for (int idx = 1; idx < argc; idx++) {
    if (strcmp(argv[idx], search) == 0) {
      return 1;
    }
  }
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<has_arg>:
  endbr64
  cmp    $0x1,%edi
  jle    L23
  lea    -0x2(%rdi),%eax
  push   %r12
  lea    0x10(%rsi,%rax,8),%r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  lea    0x8(%rsi),%rbx
  jmp    L20
  xchg   %ax,%ax
L28:
  add    $0x8,%rbx
  cmp    %r12,%rbx
  je     L36
L20:
  mov    (%rbx),%rdi
  mov    %rbp,%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L28
  pop    %rbx
  mov    $0x1,%eax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L36:
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
L23:
  xor    %eax,%eax
  ret
```

assistant: ```c
int has_arg(int argc, char **argv, char *search) {
  for (int idx = 1; idx < argc; idx++) {
    if (strcmp(argv[idx], search) == 0) {
      return 1;
    }
  }
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<populate_grid>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,(%rsp)
  mov    %esi,0x18(%rsp)
  mov    %edx,0x28(%rsp)
  mov    %rcx,0x20(%rsp)
  mov    %edx,%ecx
  cmp    %esi,%edx
  sete   0x1f(%rsp)
  mov    %esi,%edx
  setne  %al
  movzbl %al,%eax
  add    $0x2,%eax
  sub    %eax,%edx
  mov    %edx,0x14(%rsp)
  lea    0x0(,%r8,8),%r15d
  lea    -0x1(%rcx),%eax
  mov    %eax,0x2c(%rsp)
  test   %r15d,%r15d
  jle    L59
  mov    %eax,%r12d
  mov    $0x0,%r13d
  movl   $0x0,0x10(%rsp)
  movl   $0x1,0xc(%rsp)
  jmp    L71
L81:
  mov    %r13d,%esi
  mov    0x20(%rsp),%rdi
  call   <cwbit@plt>
  mov    %al,0x0(%rbp)
  add    $0x1,%r13d
  jmp    L27
L139:
  mov    %r13d,%esi
  mov    0x20(%rsp),%rdi
  call   <cwbit@plt>
  mov    %al,(%rbx)
  add    $0x1,%r13d
  jmp    L48
L119:
  add    $0x1,%r12d
  cmp    %r12d,0x28(%rsp)
  je     L13
L103:
  cmp    %r15d,%r13d
  jge    L59
L71:
  mov    0x10(%rsp),%eax
  add    %eax,%eax
  mov    0x14(%rsp),%ebx
  sub    %eax,%ebx
  mov    0x18(%rsp),%r14d
  imul   %r12d,%r14d
  cmp    $0x5,%ebx
  jg     L14
  cmpb   $0x1,0x1f(%rsp)
  adc    $0xffffffff,%ebx
L14:
  lea    0x1(%rbx,%r14,1),%ebp
  movslq %ebp,%rbp
  add    (%rsp),%rbp
  testb  $0xf0,0x0(%rbp)
  je     L81
L27:
  cmp    %r15d,%r13d
  jge    L48
  add    %r14d,%ebx
  movslq %ebx,%rbx
  add    (%rsp),%rbx
  testb  $0xf0,(%rbx)
  je     L139
L48:
  cmpl   $0x0,0xc(%rsp)
  je     L119
  sub    $0x1,%r12d
  cmp    $0xffffffff,%r12d
  jne    L103
  addl   $0x1,0x10(%rsp)
  mov    $0x0,%r12d
  movl   $0x0,0xc(%rsp)
  jmp    L103
L13:
  addl   $0x1,0x10(%rsp)
  mov    0x2c(%rsp),%r12d
  movl   $0x1,0xc(%rsp)
  jmp    L103
L59:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  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;
      }
    }
  }
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<populate_grid>:
  endbr64
  push   %r15
  mov    %rdi,%r9
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  cmp    %esi,%edx
  setne  %al
  sete   0x1f(%rsp)
  shl    $0x3,%r8d
  movzbl %al,%eax
  mov    %esi,0x4(%rsp)
  add    $0x2,%eax
  mov    %edx,0x28(%rsp)
  sub    %eax,%esi
  lea    -0x1(%rdx),%eax
  mov    %rcx,0x20(%rsp)
  mov    %esi,(%rsp)
  mov    %eax,0x2c(%rsp)
  test   %r8d,%r8d
  jle    L12
  mov    $0x1,%r15d
  xor    %r12d,%r12d
  xor    %r13d,%r13d
  mov    %eax,%edx
  mov    %r15d,%r14d
  mov    %r8d,%r15d
  jmp    L82
  nopl   0x0(%rax)
L105:
  sub    $0x1,%edx
  jae    L103
  add    $0x1,%r12d
  xor    %edx,%edx
  xor    %r14d,%r14d
L103:
  cmp    %r15d,%r13d
  jge    L12
L82:
  mov    (%rsp),%eax
  lea    (%r12,%r12,1),%ecx
  sub    %ecx,%eax
  mov    0x4(%rsp),%ecx
  imul   %edx,%ecx
  cmp    $0x5,%eax
  jg     L11
  cmpb   $0x0,0x1f(%rsp)
  lea    -0x1(%rax),%ebp
  mov    %eax,%ebx
  je     L11
L3:
  add    %ecx,%ebx
  movslq %ebx,%rbx
  add    %r9,%rbx
  testb  $0xf0,(%rbx)
  je     L131
L96:
  add    %ecx,%ebp
  movslq %ebp,%rbp
  add    %r9,%rbp
  testb  $0xf0,0x0(%rbp)
  je     L95
L87:
  test   %r14d,%r14d
  jne    L105
  add    $0x1,%edx
  cmp    %edx,0x28(%rsp)
  jne    L103
  mov    0x2c(%rsp),%edx
  add    $0x1,%r12d
  mov    $0x1,%r14d
  cmp    %r15d,%r13d
  jl     L82
L12:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L131:
  mov    0x20(%rsp),%rdi
  mov    %r13d,%esi
  add    $0x1,%r13d
  mov    %edx,0x8(%rsp)
  mov    %r9,0x10(%rsp)
  mov    %ecx,0x18(%rsp)
  call   <cwbit@plt>
  cmp    %r13d,%r15d
  mov    0x18(%rsp),%ecx
  mov    0x8(%rsp),%edx
  mov    %al,(%rbx)
  mov    0x10(%rsp),%r9
  jle    L87
  jmp    L96
  nopl   0x0(%rax)
L11:
  lea    0x1(%rax),%ebx
  mov    %eax,%ebp
  jmp    L3
  nopw   0x0(%rax,%rax,1)
L95:
  mov    0x20(%rsp),%rdi
  mov    %r13d,%esi
  mov    %edx,0x18(%rsp)
  add    $0x1,%r13d
  mov    %r9,0x8(%rsp)
  call   <cwbit@plt>
  mov    0x8(%rsp),%r9
  mov    0x18(%rsp),%edx
  mov    %al,0x0(%rbp)
  jmp    L87
```

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;
      }
    }
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<populate_grid>:
  endbr64
  push   %r15
  mov    %rdi,%r9
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  cmp    %esi,%edx
  setne  %al
  sete   0x1f(%rsp)
  shl    $0x3,%r8d
  movzbl %al,%eax
  mov    %esi,0x4(%rsp)
  add    $0x2,%eax
  mov    %edx,0x28(%rsp)
  sub    %eax,%esi
  lea    -0x1(%rdx),%eax
  mov    %rcx,0x20(%rsp)
  mov    %esi,(%rsp)
  mov    %eax,0x2c(%rsp)
  test   %r8d,%r8d
  jle    L29
  mov    $0x1,%r15d
  xor    %r12d,%r12d
  xor    %r13d,%r13d
  mov    %eax,%edx
  mov    %r15d,%r14d
  mov    %r8d,%r15d
  jmp    L116
  nopl   0x0(%rax)
L7:
  sub    $0x1,%edx
  jae    L139
  add    $0x1,%r12d
  xor    %edx,%edx
  xor    %r14d,%r14d
L139:
  cmp    %r15d,%r13d
  jge    L29
L116:
  mov    (%rsp),%eax
  lea    (%r12,%r12,1),%ecx
  sub    %ecx,%eax
  mov    0x4(%rsp),%ecx
  imul   %edx,%ecx
  cmp    $0x5,%eax
  jg     L147
  cmpb   $0x0,0x1f(%rsp)
  lea    -0x1(%rax),%ebp
  mov    %eax,%ebx
  je     L147
L95:
  add    %ecx,%ebx
  movslq %ebx,%rbx
  add    %r9,%rbx
  testb  $0xf0,(%rbx)
  je     L41
L33:
  add    %ecx,%ebp
  movslq %ebp,%rbp
  add    %r9,%rbp
  testb  $0xf0,0x0(%rbp)
  je     L79
L126:
  test   %r14d,%r14d
  jne    L7
  add    $0x1,%edx
  cmp    %edx,0x28(%rsp)
  jne    L139
  mov    0x2c(%rsp),%edx
  add    $0x1,%r12d
  mov    $0x1,%r14d
  cmp    %r15d,%r13d
  jl     L116
L29:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L41:
  mov    0x20(%rsp),%rdi
  mov    %r13d,%esi
  add    $0x1,%r13d
  mov    %edx,0x8(%rsp)
  mov    %r9,0x10(%rsp)
  mov    %ecx,0x18(%rsp)
  call   <cwbit@plt>
  cmp    %r13d,%r15d
  mov    0x18(%rsp),%ecx
  mov    0x8(%rsp),%edx
  mov    %al,(%rbx)
  mov    0x10(%rsp),%r9
  jle    L126
  jmp    L33
  nopl   0x0(%rax)
L147:
  lea    0x1(%rax),%ebx
  mov    %eax,%ebp
  jmp    L95
  nopw   0x0(%rax,%rax,1)
L79:
  mov    0x20(%rsp),%rdi
  mov    %r13d,%esi
  mov    %edx,0x18(%rsp)
  add    $0x1,%r13d
  mov    %r9,0x8(%rsp)
  call   <cwbit@plt>
  mov    0x8(%rsp),%r9
  mov    0x18(%rsp),%edx
  mov    %al,0x0(%rbp)
  jmp    L126
```

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;
      }
    }
  }
}
```