ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请从给定的汇编指令推导出C源代码:

```asm
<f8_1>:
  endbr64
  ret
```

assistant: ```c
void f8_1(int *q) {
  if (*q == 1)
    q = 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<f8_1>:
  endbr64
  ret
```

assistant: ```c
void f8_1(int *q) {
  if (*q == 1)
    q = 0;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<f8_1>:
  endbr64
  ret
```

assistant: ```c
void f8_1(int *q) {
  if (*q == 1)
    q = 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<secondIsBigger>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x4(%rbp)
  mov    %esi,-0x8(%rbp)
  mov    %edx,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  je     L25
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  setg   %al
  movzbl %al,%eax
  jmp    L44
L25:
  cmpl   $0x1,-0x8(%rbp)
  je     L8
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jle    L27
  cmpl   $0x1,-0x4(%rbp)
  je     L27
L8:
  mov    $0x1,%eax
  jmp    L44
L27:
  mov    $0x0,%eax
L44:
  pop    %rbp
  ret
```

assistant: ```c
bool secondIsBigger(int first, int second, bool aceIsOne) {
  if (aceIsOne) {
    return second > first;
  } else
    return (second == 1) || ((second > first) && (first != 1));
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<secondIsBigger>:
  endbr64
  test   %edx,%edx
  je     L13
  cmp    %edi,%esi
  setg   %al
  movzbl %al,%eax
  ret
L13:
  mov    %esi,%eax
  cmp    $0x1,%esi
  je     L10
  cmp    %edi,%esi
  setg   %dl
  cmp    $0x1,%edi
  setne  %al
  movzbl %al,%eax
  and    %edx,%eax
L10:
  ret
```

assistant: ```c
bool secondIsBigger(int first, int second, bool aceIsOne) {
  if (aceIsOne) {
    return second > first;
  } else
    return (second == 1) || ((second > first) && (first != 1));
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<secondIsBigger>:
  endbr64
  test   %edx,%edx
  je     L19
  xor    %eax,%eax
  cmp    %edi,%esi
  setg   %al
  ret
L19:
  mov    $0x1,%eax
  cmp    $0x1,%esi
  je     L17
  cmp    %edi,%esi
  setg   %dl
  xor    %eax,%eax
  cmp    $0x1,%edi
  setne  %al
  and    %edx,%eax
L17:
  ret
```

assistant: ```c
bool secondIsBigger(int first, int second, bool aceIsOne) {
  if (aceIsOne) {
    return second > first;
  } else
    return (second == 1) || ((second > first) && (first != 1));
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<secondIsBigger>:
  endbr64
  test   %edx,%edx
  je     L12
  xor    %eax,%eax
  cmp    %edi,%esi
  setg   %al
  ret
L12:
  mov    $0x1,%eax
  cmp    $0x1,%esi
  je     L5
  cmp    %edi,%esi
  setg   %dl
  xor    %eax,%eax
  cmp    $0x1,%edi
  setne  %al
  and    %edx,%eax
L5:
  ret
```

assistant: ```c
bool secondIsBigger(int first, int second, bool aceIsOne) {
  if (aceIsOne) {
    return second > first;
  } else
    return (second == 1) || ((second > first) && (first != 1));
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<__hsail_sat_mul_s8>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  imul   -0x20(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  mov    D23(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,-0x8(%rbp)
  jle    L3
  mov    D23(%rip),%rax
  mov    (%rax),%rax
  jmp    L10
L3:
  mov    D30(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,-0x8(%rbp)
  jge    L37
  mov    D30(%rip),%rax
  mov    (%rax),%rax
  jmp    L10
L37:
  mov    -0x8(%rbp),%rax
L10:
  pop    %rbp
  ret
```

assistant: ```c
int8_t __hsail_sat_mul_s8(int8_t a, int8_t b) {
  int16_t c = (int16_t)a * (int16_t)b;
  if (c > INT8_MAX)
    return INT8_MAX;
  else if (c < INT8_MIN)
    return INT8_MIN;
  else
    return c;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<__hsail_sat_mul_s8>:
  endbr64
  imul   %rsi,%rdi
  mov    D1(%rip),%rax
  mov    (%rax),%rax
  cmp    %rdi,%rax
  jl     L2
  mov    D0(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdi
  cmovge %rdi,%rax
L2:
  ret
```

assistant: ```c
int8_t __hsail_sat_mul_s8(int8_t a, int8_t b) {
  int16_t c = (int16_t)a * (int16_t)b;
  if (c > INT8_MAX)
    return INT8_MAX;
  else if (c < INT8_MIN)
    return INT8_MIN;
  else
    return c;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<__hsail_sat_mul_s8>:
  endbr64
  mov    D6(%rip),%rax
  imul   %rsi,%rdi
  mov    (%rax),%rax
  cmp    %rdi,%rax
  jl     L4
  mov    D8(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdi
  cmovge %rdi,%rax
L4:
  ret
```

assistant: ```c
int8_t __hsail_sat_mul_s8(int8_t a, int8_t b) {
  int16_t c = (int16_t)a * (int16_t)b;
  if (c > INT8_MAX)
    return INT8_MAX;
  else if (c < INT8_MIN)
    return INT8_MIN;
  else
    return c;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<__hsail_sat_mul_s8>:
  endbr64
  mov    D1(%rip),%rax
  imul   %rsi,%rdi
  mov    (%rax),%rax
  cmp    %rdi,%rax
  jl     L7
  mov    D15(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdi
  cmovge %rdi,%rax
L7:
  ret
```

assistant: ```c
int8_t __hsail_sat_mul_s8(int8_t a, int8_t b) {
  int16_t c = (int16_t)a * (int16_t)b;
  if (c > INT8_MAX)
    return INT8_MAX;
  else if (c < INT8_MIN)
    return INT8_MIN;
  else
    return c;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<ascii2char>:
  endbr64
  mov    %rdi,%r8
  mov    %rsi,%rdi
  test   %rsi,%rsi
  je     L99
  mov    $0x0,%eax
  mov    $0x0,%ecx
  mov    $0x0,%edx
  lea    D18(%rip),%rsi
  jmp    L88
L125:
  lea    0x1(%rax),%edx
  mov    %eax,%r9d
  movb   $0x5c,(%rsi,%r9,1)
  add    $0x2,%eax
  mov    %edx,%edx
  movb   $0x72,(%rsi,%rdx,1)
L112:
  cmp    $0xfec,%eax
  ja     L75
  add    $0x1,%ecx
  mov    %ecx,%edx
  cmp    %rdi,%rdx
  jae    L75
L88:
  movzbl (%r8,%rdx,1),%edx
  cmp    $0xd,%dl
  je     L125
  cmp    $0xa,%dl
  je     L124
  cmp    $0x9,%dl
  je     L128
  cmp    $0x1f,%dl
  jg     L77
  movsbl %dl,%r10d
  lea    0x1(%rax),%r9d
  mov    %eax,%r11d
  movb   $0x5c,(%rsi,%r11,1)
  cmp    $0x9,%dl
  jle    L22
  movslq %r10d,%rdx
  imul   $0x66666667,%rdx,%rdx
  sar    $0x22,%rdx
  mov    %r10d,%r11d
  sar    $0x1f,%r11d
  sub    %r11d,%edx
  lea    (%rdx,%rdx,4),%r11d
  add    %r11d,%r11d
  mov    %r10d,%edx
  sub    %r11d,%edx
  mov    %r9d,%r9d
  lea    0x30(%rdx),%r11d
  mov    %r11b,(%rsi,%r9,1)
  imul   $0xfffffff6,%edx,%edx
  add    %edx,%r10d
  lea    0x2(%rax),%r9d
L22:
  lea    0x1(%r9),%eax
  mov    %r9d,%r9d
  lea    0x30(%r10),%edx
  mov    %dl,(%rsi,%r9,1)
  jmp    L112
L124:
  lea    0x1(%rax),%edx
  mov    %eax,%r9d
  movb   $0x5c,(%rsi,%r9,1)
  add    $0x2,%eax
  mov    %edx,%edx
  movb   $0x6e,(%rsi,%rdx,1)
  jmp    L112
L128:
  lea    0x1(%rax),%edx
  mov    %eax,%r9d
  movb   $0x5c,(%rsi,%r9,1)
  add    $0x2,%eax
  mov    %edx,%edx
  movb   $0x74,(%rsi,%rdx,1)
  jmp    L112
L77:
  mov    %eax,%r9d
  mov    %dl,(%rsi,%r9,1)
  lea    0x1(%rax),%eax
  jmp    L112
L99:
  mov    $0x0,%eax
L75:
  lea    D18(%rip),%rdx
  mov    %eax,%eax
  movb   $0x0,(%rdx,%rax,1)
  mov    %rdx,%rax
  ret
```

assistant: ```c
char *ascii2char(const char *string, size_t len) {
  static char buffer[4096];
  unsigned int idx, bufIdx = 0;
  for (idx = 0; idx < len; ++idx) {
    if (string[idx] == '\r') {
      buffer[bufIdx++] = '\\';
      buffer[bufIdx++] = 'r';
    } else if (string[idx] == '\n') {
      buffer[bufIdx++] = '\\';
      buffer[bufIdx++] = 'n';
    } else if (string[idx] == '\t') {
      buffer[bufIdx++] = '\\';
      buffer[bufIdx++] = 't';
    } else if (string[idx] < 32) {
      int ascii = string[idx];
      buffer[bufIdx++] = '\\';
      if (ascii > 9) {
        buffer[bufIdx++] = (ascii % 10) + 48;
        ascii -= (ascii % 10) * 10;
      }
      buffer[bufIdx++] = ascii + 48;
    } else
      buffer[bufIdx++] = string[idx];
    if (bufIdx > (sizeof(buffer) - 20))
      break;
  }
  buffer[bufIdx] = '\0';
  return buffer;
}
```
user: Translate the below assembly code into C programming language:

```asm
<ascii2char>:
  endbr64
  mov    %rdi,%r9
  xor    %eax,%eax
  lea    D12(%rip),%r8
  mov    %rsi,%rdi
  test   %rsi,%rsi
  je     L63
  xor    %esi,%esi
  xor    %edx,%edx
  lea    D12(%rip),%r8
  jmp    L123
  nopl   0x0(%rax)
L37:
  cmp    $0xa,%cl
  je     L32
  cmp    $0x9,%cl
  je     L43
  cmp    $0x1f,%cl
  jg     L82
  mov    %eax,%r11d
  movsbl %cl,%r10d
  movb   $0x5c,(%r8,%r11,1)
  cmp    $0x9,%cl
  jle    L47
  movslq %r10d,%rcx
  mov    %r10d,%r11d
  imul   $0x66666667,%rcx,%rcx
  sar    $0x1f,%r11d
  sar    $0x22,%rcx
  sub    %r11d,%ecx
  lea    (%rcx,%rcx,4),%r11d
  mov    %r10d,%ecx
  add    %r11d,%r11d
  sub    %r11d,%ecx
  lea    0x30(%rcx),%r11d
  imul   $0xfffffff6,%ecx,%ecx
  mov    %r11b,(%r8,%rdx,1)
  lea    0x2(%rax),%edx
  add    %ecx,%r10d
L47:
  add    $0x30,%r10d
  lea    0x1(%rdx),%eax
  mov    %r10b,(%r8,%rdx,1)
L85:
  cmp    $0xfec,%eax
  ja     L63
L107:
  lea    0x1(%rsi),%edx
  mov    %rdx,%rsi
  cmp    %rdi,%rdx
  jae    L63
L123:
  movzbl (%r9,%rdx,1),%ecx
  lea    0x1(%rax),%edx
  cmp    $0xd,%cl
  jne    L37
  mov    %eax,%ecx
  add    $0x2,%eax
  movb   $0x5c,(%r8,%rcx,1)
  movb   $0x72,(%r8,%rdx,1)
  cmp    $0xfec,%eax
  jbe    L107
L63:
  movb   $0x0,(%r8,%rax,1)
  mov    %r8,%rax
  ret
  nop
L32:
  mov    %eax,%ecx
  add    $0x2,%eax
  movb   $0x5c,(%r8,%rcx,1)
  movb   $0x6e,(%r8,%rdx,1)
  jmp    L85
  nopl   0x0(%rax)
L43:
  mov    %eax,%ecx
  add    $0x2,%eax
  movb   $0x5c,(%r8,%rcx,1)
  movb   $0x74,(%r8,%rdx,1)
  jmp    L85
  nopl   0x0(%rax)
L82:
  mov    %cl,(%r8,%rax,1)
  mov    %edx,%eax
  jmp    L85
```

assistant: ```c
char *ascii2char(const char *string, size_t len) {
  static char buffer[4096];
  unsigned int idx, bufIdx = 0;
  for (idx = 0; idx < len; ++idx) {
    if (string[idx] == '\r') {
      buffer[bufIdx++] = '\\';
      buffer[bufIdx++] = 'r';
    } else if (string[idx] == '\n') {
      buffer[bufIdx++] = '\\';
      buffer[bufIdx++] = 'n';
    } else if (string[idx] == '\t') {
      buffer[bufIdx++] = '\\';
      buffer[bufIdx++] = 't';
    } else if (string[idx] < 32) {
      int ascii = string[idx];
      buffer[bufIdx++] = '\\';
      if (ascii > 9) {
        buffer[bufIdx++] = (ascii % 10) + 48;
        ascii -= (ascii % 10) * 10;
      }
      buffer[bufIdx++] = ascii + 48;
    } else
      buffer[bufIdx++] = string[idx];
    if (bufIdx > (sizeof(buffer) - 20))
      break;
  }
  buffer[bufIdx] = '\0';
  return buffer;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<ascii2char>:
  endbr64
  mov    %rdi,%r9
  xor    %eax,%eax
  lea    D6(%rip),%r8
  mov    %rsi,%rdi
  test   %rsi,%rsi
  je     L18
  xor    %esi,%esi
  xor    %edx,%edx
  lea    D6(%rip),%r8
  jmp    L104
  nopl   0x0(%rax)
L117:
  cmp    $0xa,%cl
  je     L83
  cmp    $0x9,%cl
  je     L57
  cmp    $0x1f,%cl
  jg     L0
  mov    %eax,%r11d
  movsbl %cl,%r10d
  movb   $0x5c,(%r8,%r11,1)
  cmp    $0x9,%cl
  jle    L100
  movslq %r10d,%rcx
  mov    %r10d,%r11d
  imul   $0x66666667,%rcx,%rcx
  sar    $0x1f,%r11d
  sar    $0x22,%rcx
  sub    %r11d,%ecx
  lea    (%rcx,%rcx,4),%r11d
  mov    %r10d,%ecx
  add    %r11d,%r11d
  sub    %r11d,%ecx
  lea    0x30(%rcx),%r11d
  imul   $0xfffffff6,%ecx,%ecx
  mov    %r11b,(%r8,%rdx,1)
  lea    0x2(%rax),%edx
  add    %ecx,%r10d
L100:
  add    $0x30,%r10d
  lea    0x1(%rdx),%eax
  mov    %r10b,(%r8,%rdx,1)
L101:
  cmp    $0xfec,%eax
  ja     L18
L41:
  lea    0x1(%rsi),%edx
  mov    %rdx,%rsi
  cmp    %rdi,%rdx
  jae    L18
L104:
  movzbl (%r9,%rdx,1),%ecx
  lea    0x1(%rax),%edx
  cmp    $0xd,%cl
  jne    L117
  mov    %eax,%ecx
  add    $0x2,%eax
  movb   $0x5c,(%r8,%rcx,1)
  movb   $0x72,(%r8,%rdx,1)
  cmp    $0xfec,%eax
  jbe    L41
L18:
  movb   $0x0,(%r8,%rax,1)
  mov    %r8,%rax
  ret
  nop
L83:
  mov    %eax,%ecx
  add    $0x2,%eax
  movb   $0x5c,(%r8,%rcx,1)
  movb   $0x6e,(%r8,%rdx,1)
  jmp    L101
  nopl   0x0(%rax)
L57:
  mov    %eax,%ecx
  add    $0x2,%eax
  movb   $0x5c,(%r8,%rcx,1)
  movb   $0x74,(%r8,%rdx,1)
  jmp    L101
  nopl   0x0(%rax)
L0:
  mov    %cl,(%r8,%rax,1)
  mov    %edx,%eax
  jmp    L101
```

assistant: ```c
char *ascii2char(const char *string, size_t len) {
  static char buffer[4096];
  unsigned int idx, bufIdx = 0;
  for (idx = 0; idx < len; ++idx) {
    if (string[idx] == '\r') {
      buffer[bufIdx++] = '\\';
      buffer[bufIdx++] = 'r';
    } else if (string[idx] == '\n') {
      buffer[bufIdx++] = '\\';
      buffer[bufIdx++] = 'n';
    } else if (string[idx] == '\t') {
      buffer[bufIdx++] = '\\';
      buffer[bufIdx++] = 't';
    } else if (string[idx] < 32) {
      int ascii = string[idx];
      buffer[bufIdx++] = '\\';
      if (ascii > 9) {
        buffer[bufIdx++] = (ascii % 10) + 48;
        ascii -= (ascii % 10) * 10;
      }
      buffer[bufIdx++] = ascii + 48;
    } else
      buffer[bufIdx++] = string[idx];
    if (bufIdx > (sizeof(buffer) - 20))
      break;
  }
  buffer[bufIdx] = '\0';
  return buffer;
}
```
user: What is the c source code of the assembly code below:

```asm
<people_in>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  movl   $0x0,(%rsp)
  movl   $0x0,0x4(%rsp)
  test   %rsi,%rsi
  je     L31
  mov    %rdi,%r11
  mov    %rsi,%rbx
  mov    %edx,%r10d
  mov    $0x0,%edi
  mov    $0x0,%ebp
  jmp    L62
L96:
  mov    %r9d,%edi
  mov    %esi,%ebp
L73:
  movslq %edi,%rax
  cmp    %rbx,%rax
  jae    L70
L62:
  lea    0x1(%rdi),%r9d
  movzbl (%r11,%rax,1),%esi
  cmp    $0x4d,%sil
  setne  %r8b
  movzbl %r8b,%r8d
  setne  %al
  movzbl %al,%eax
  mov    (%rsp,%rax,4),%eax
  add    $0x1,%eax
  cmp    $0x4d,%sil
  sete   %dl
  movzbl %dl,%edx
  mov    %eax,%ecx
  sub    (%rsp,%rdx,4),%ecx
  mov    %ecx,%edx
  neg    %edx
  cmovs  %ecx,%edx
  cmp    %r10d,%edx
  jg     L104
  movslq %r8d,%r8
  mov    %eax,(%rsp,%r8,4)
  mov    %r9d,%edi
  jmp    L73
L70:
  test   %bpl,%bpl
  je     L31
  cmp    $0x4d,%bpl
  setne  %sil
  movzbl %sil,%esi
  setne  %al
  movzbl %al,%eax
  mov    (%rsp,%rax,4),%eax
  add    $0x1,%eax
  cmp    $0x4d,%bpl
  sete   %dl
  movzbl %dl,%edx
  mov    %eax,%ecx
  sub    (%rsp,%rdx,4),%ecx
  mov    %ecx,%edx
  neg    %edx
  cmovs  %ecx,%edx
  cmp    %r10d,%edx
  jg     L31
  movslq %esi,%rsi
  mov    %eax,(%rsp,%rsi,4)
L31:
  mov    0x4(%rsp),%eax
  add    (%rsp),%eax
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L61
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L104:
  test   %bpl,%bpl
  je     L96
  cmp    $0x4d,%bpl
  setne  %sil
  movzbl %sil,%esi
  setne  %al
  movzbl %al,%eax
  mov    (%rsp,%rax,4),%eax
  add    $0x1,%eax
  cmp    $0x4d,%bpl
  sete   %dl
  movzbl %dl,%edx
  mov    %eax,%ecx
  sub    (%rsp,%rdx,4),%ecx
  mov    %ecx,%edx
  neg    %edx
  cmovs  %ecx,%edx
  cmp    %r10d,%edx
  jg     L31
  movslq %esi,%rsi
  mov    %eax,(%rsp,%rsi,4)
  jmp    L73
L61:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int people_in(char *str, size_t size, int max) {
  char waiting = 0;
  int index = 0;
  int counts[2] = {0, 0};
  while (1) {
    if (index >= size) {
      if (waiting != 0 && ((counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')]) < 0 ? -(counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')]) : (counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')])) <= max)
        counts[((waiting) != 'M')]++;
      break;
    }
    char next = str[index++];
    if (((counts[((next) != 'M')] + 1 - counts[!((next) != 'M')]) < 0 ? -(counts[((next) != 'M')] + 1 - counts[!((next) != 'M')]) : (counts[((next) != 'M')] + 1 - counts[!((next) != 'M')])) <= max) {
      counts[((next) != 'M')]++;
    } else if (waiting == 0) {
      waiting = next;
    } else if (((counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')]) < 0 ? -(counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')]) : (counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')])) <= max) {
      counts[((waiting) != 'M')]++;
      index--;
    } else {
      break;
    }
  }
  return counts[0] + counts[1];
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<people_in>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsp)
  test   %rsi,%rsi
  je     L83
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  mov    %edx,%r10d
  xor    %edi,%edi
  xor    %r11d,%r11d
  jmp    L98
  nopl   0x0(%rax,%rax,1)
L16:
  mov    %eax,(%rsp,%r8,4)
  mov    %r9d,%edi
L84:
  movslq %edi,%rax
  cmp    %rbp,%rax
  jae    L91
L98:
  movzbl (%rbx,%rax,1),%esi
  xor    %r8d,%r8d
  lea    0x1(%rdi),%r9d
  cmp    $0x4d,%sil
  setne  %r8b
  xor    %edx,%edx
  mov    (%rsp,%r8,4),%eax
  add    $0x1,%eax
  cmp    $0x4d,%sil
  sete   %dl
  mov    %eax,%ecx
  sub    (%rsp,%rdx,4),%ecx
  mov    %ecx,%edx
  neg    %edx
  cmovs  %ecx,%edx
  cmp    %r10d,%edx
  jle    L16
  test   %r11b,%r11b
  je     L64
  xor    %esi,%esi
  cmp    $0x4d,%r11b
  setne  %sil
  xor    %edx,%edx
  mov    (%rsp,%rsi,4),%eax
  add    $0x1,%eax
  cmp    $0x4d,%r11b
  sete   %dl
  mov    %eax,%ecx
  sub    (%rsp,%rdx,4),%ecx
  mov    %ecx,%edx
  neg    %edx
  cmovs  %ecx,%edx
  cmp    %r10d,%edx
  jg     L19
  mov    %eax,(%rsp,%rsi,4)
  movslq %edi,%rax
  cmp    %rbp,%rax
  jb     L98
L91:
  test   %r11b,%r11b
  je     L19
  xor    %esi,%esi
  cmp    $0x4d,%r11b
  setne  %sil
  xor    %edx,%edx
  mov    (%rsp,%rsi,4),%eax
  add    $0x1,%eax
  cmp    $0x4d,%r11b
  sete   %dl
  mov    %eax,%ecx
  sub    (%rsp,%rdx,4),%ecx
  mov    %ecx,%edx
  neg    %edx
  cmovs  %ecx,%edx
  cmp    %r10d,%edx
  jg     L19
  mov    %eax,(%rsp,%rsi,4)
L19:
  mov    0x4(%rsp),%eax
  add    (%rsp),%eax
L33:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L78
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax)
L64:
  mov    %r9d,%edi
  mov    %esi,%r11d
  jmp    L84
L83:
  xor    %eax,%eax
  jmp    L33
L78:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int people_in(char *str, size_t size, int max) {
  char waiting = 0;
  int index = 0;
  int counts[2] = {0, 0};
  while (1) {
    if (index >= size) {
      if (waiting != 0 && ((counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')]) < 0 ? -(counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')]) : (counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')])) <= max)
        counts[((waiting) != 'M')]++;
      break;
    }
    char next = str[index++];
    if (((counts[((next) != 'M')] + 1 - counts[!((next) != 'M')]) < 0 ? -(counts[((next) != 'M')] + 1 - counts[!((next) != 'M')]) : (counts[((next) != 'M')] + 1 - counts[!((next) != 'M')])) <= max) {
      counts[((next) != 'M')]++;
    } else if (waiting == 0) {
      waiting = next;
    } else if (((counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')]) < 0 ? -(counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')]) : (counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')])) <= max) {
      counts[((waiting) != 'M')]++;
      index--;
    } else {
      break;
    }
  }
  return counts[0] + counts[1];
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<people_in>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsp)
  test   %rsi,%rsi
  je     L94
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  mov    %edx,%r10d
  xor    %edi,%edi
  xor    %r11d,%r11d
  jmp    L96
  nopl   0x0(%rax,%rax,1)
L32:
  mov    %eax,(%rsp,%r8,4)
  mov    %r9d,%edi
L42:
  movslq %edi,%rax
  cmp    %rbp,%rax
  jae    L77
L96:
  movzbl (%rbx,%rax,1),%esi
  xor    %r8d,%r8d
  lea    0x1(%rdi),%r9d
  cmp    $0x4d,%sil
  setne  %r8b
  xor    %edx,%edx
  mov    (%rsp,%r8,4),%eax
  add    $0x1,%eax
  cmp    $0x4d,%sil
  sete   %dl
  mov    %eax,%ecx
  sub    (%rsp,%rdx,4),%ecx
  mov    %ecx,%edx
  neg    %edx
  cmovs  %ecx,%edx
  cmp    %r10d,%edx
  jle    L32
  test   %r11b,%r11b
  je     L21
  xor    %esi,%esi
  cmp    $0x4d,%r11b
  setne  %sil
  xor    %edx,%edx
  mov    (%rsp,%rsi,4),%eax
  add    $0x1,%eax
  cmp    $0x4d,%r11b
  sete   %dl
  mov    %eax,%ecx
  sub    (%rsp,%rdx,4),%ecx
  mov    %ecx,%edx
  neg    %edx
  cmovs  %ecx,%edx
  cmp    %r10d,%edx
  jg     L66
  mov    %eax,(%rsp,%rsi,4)
  movslq %edi,%rax
  cmp    %rbp,%rax
  jb     L96
L77:
  test   %r11b,%r11b
  je     L66
  xor    %esi,%esi
  cmp    $0x4d,%r11b
  setne  %sil
  xor    %edx,%edx
  mov    (%rsp,%rsi,4),%eax
  add    $0x1,%eax
  cmp    $0x4d,%r11b
  sete   %dl
  mov    %eax,%ecx
  sub    (%rsp,%rdx,4),%ecx
  mov    %ecx,%edx
  neg    %edx
  cmovs  %ecx,%edx
  cmp    %r10d,%edx
  jg     L66
  mov    %eax,(%rsp,%rsi,4)
L66:
  mov    0x4(%rsp),%eax
  add    (%rsp),%eax
L33:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L63
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax)
L21:
  mov    %r9d,%edi
  mov    %esi,%r11d
  jmp    L42
L94:
  xor    %eax,%eax
  jmp    L33
L63:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int people_in(char *str, size_t size, int max) {
  char waiting = 0;
  int index = 0;
  int counts[2] = {0, 0};
  while (1) {
    if (index >= size) {
      if (waiting != 0 && ((counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')]) < 0 ? -(counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')]) : (counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')])) <= max)
        counts[((waiting) != 'M')]++;
      break;
    }
    char next = str[index++];
    if (((counts[((next) != 'M')] + 1 - counts[!((next) != 'M')]) < 0 ? -(counts[((next) != 'M')] + 1 - counts[!((next) != 'M')]) : (counts[((next) != 'M')] + 1 - counts[!((next) != 'M')])) <= max) {
      counts[((next) != 'M')]++;
    } else if (waiting == 0) {
      waiting = next;
    } else if (((counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')]) < 0 ? -(counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')]) : (counts[((waiting) != 'M')] + 1 - counts[!((waiting) != 'M')])) <= max) {
      counts[((waiting) != 'M')]++;
      index--;
    } else {
      break;
    }
  }
  return counts[0] + counts[1];
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<yy_flex_strncpy>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L4
L8:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    -0x4(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x4(%rbp)
L4:
  mov    -0x4(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L8
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void yy_flex_strncpy(char *s1, const char *s2, int n) {
  int i;
  for (i = 0; i < n; ++i)
    s1[i] = s2[i];
}
```
user: Translate the below assembly code into C programming language:

```asm
<yy_flex_strncpy>:
  endbr64
  test   %edx,%edx
  jle    L9
  mov    %edx,%edx
  mov    $0x0,%eax
L18:
  movzbl (%rsi,%rax,1),%ecx
  mov    %cl,(%rdi,%rax,1)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L18
L9:
  ret
```

assistant: ```c
void yy_flex_strncpy(char *s1, const char *s2, int n) {
  int i;
  for (i = 0; i < n; ++i)
    s1[i] = s2[i];
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<yy_flex_strncpy>:
  endbr64
  test   %edx,%edx
  jle    L13
  movslq %edx,%rdx
  xor    %eax,%eax
  nopl   (%rax)
L6:
  movzbl (%rsi,%rax,1),%ecx
  mov    %cl,(%rdi,%rax,1)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L6
L13:
  ret
```

assistant: ```c
void yy_flex_strncpy(char *s1, const char *s2, int n) {
  int i;
  for (i = 0; i < n; ++i)
    s1[i] = s2[i];
}
```