ylfeng/ReF-Decompile-dataset huggingface dataset:
user: What is the c source code of the assembly code below?

```asm
<parse_format>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  lea    D6(%rip),%rsi
  call   <strcmp@plt>
  mov    %eax,%edx
  lea    D9(%rip),%rax
  test   %edx,%edx
  je     L5
  lea    D1(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  mov    %eax,%edx
  lea    D16(%rip),%rax
  test   %edx,%edx
  je     L5
  lea    D10(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  lea    D54(%rip),%rax
  cmovne %rbx,%rax
L5:
  pop    %rbx
  ret
```

tool_calls: name: unpack_data
arguments: label: D6
type: string
name: unpack_data
arguments: label: D9
type: string
name: unpack_data
arguments: label: D1
type: string
name: unpack_data
arguments: label: D16
type: string
name: unpack_data
arguments: label: D10
type: string
name: unpack_data
arguments: label: D54
type: string

tool: D6: rsyslog

tool: D9: %b %e %H:%M:%S

tool: D1: apache

tool: D16: %d/%b/%Y:%H:%M:%S

tool: D10: rfc3339

tool: D54: %Y-%m-%dT%H:%M:%S

assistant: ```c
char *parse_format(char *format) {
  char *new_format = format;
  if (!strcmp(format, "rsyslog")) {
    new_format = "%b %e %H:%M:%S";
  } else if (!strcmp(format, "apache")) {
    new_format = "%d/%b/%Y:%H:%M:%S";
  } else if (!strcmp(format, "rfc3339")) {
    new_format = "%Y-%m-%dT%H:%M:%S";
  }
  return new_format;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<parse_format>:
  endbr64
  push   %rbx
  lea    D40(%rip),%rsi
  mov    %rdi,%rbx
  call   <strcmp@plt>
  mov    %eax,%r8d
  lea    D31(%rip),%rax
  test   %r8d,%r8d
  je     L11
  lea    D2(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  mov    %eax,%r8d
  lea    D47(%rip),%rax
  test   %r8d,%r8d
  jne    L16
L11:
  pop    %rbx
  ret
  nopl   0x0(%rax,%rax,1)
L16:
  mov    %rbx,%rdi
  lea    D46(%rip),%rsi
  call   <strcmp@plt>
  test   %eax,%eax
  lea    D49(%rip),%rax
  cmovne %rbx,%rax
  pop    %rbx
  ret
```

tool_calls: name: read_data
arguments: tag: D40
type_infered: string
name: read_data
arguments: tag: D31
type_infered: string
name: read_data
arguments: tag: D2
type_infered: string
name: read_data
arguments: tag: D47
type_infered: string
name: read_data
arguments: tag: D46
type_infered: string
name: read_data
arguments: tag: D49
type_infered: string

tool: D40: rsyslog

tool: D31: %b %e %H:%M:%S

tool: D2: apache

tool: D47: %d/%b/%Y:%H:%M:%S

tool: D46: rfc3339

tool: D49: %Y-%m-%dT%H:%M:%S

assistant: ```c
char *parse_format(char *format) {
  char *new_format = format;
  if (!strcmp(format, "rsyslog")) {
    new_format = "%b %e %H:%M:%S";
  } else if (!strcmp(format, "apache")) {
    new_format = "%d/%b/%Y:%H:%M:%S";
  } else if (!strcmp(format, "rfc3339")) {
    new_format = "%Y-%m-%dT%H:%M:%S";
  }
  return new_format;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<parse_format>:
  endbr64
  push   %rbx
  lea    D10(%rip),%rsi
  mov    %rdi,%rbx
  call   <strcmp@plt>
  mov    %eax,%r8d
  lea    D54(%rip),%rax
  test   %r8d,%r8d
  je     L13
  lea    D59(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  mov    %eax,%r8d
  lea    D2(%rip),%rax
  test   %r8d,%r8d
  jne    L10
L13:
  pop    %rbx
  ret
  nopl   0x0(%rax,%rax,1)
L10:
  mov    %rbx,%rdi
  lea    D7(%rip),%rsi
  call   <strcmp@plt>
  test   %eax,%eax
  lea    D30(%rip),%rax
  cmovne %rbx,%rax
  pop    %rbx
  ret
```

tool_calls: name: read_data
arguments: tag: D10
datatype: string
name: read_data
arguments: tag: D54
datatype: string
name: read_data
arguments: tag: D59
datatype: string
name: read_data
arguments: tag: D2
datatype: string
name: read_data
arguments: tag: D7
datatype: string
name: read_data
arguments: tag: D30
datatype: string

tool: D10: rsyslog

tool: D54: %b %e %H:%M:%S

tool: D59: apache

tool: D2: %d/%b/%Y:%H:%M:%S

tool: D7: rfc3339

tool: D30: %Y-%m-%dT%H:%M:%S

assistant: ```c
char *parse_format(char *format) {
  char *new_format = format;
  if (!strcmp(format, "rsyslog")) {
    new_format = "%b %e %H:%M:%S";
  } else if (!strcmp(format, "apache")) {
    new_format = "%d/%b/%Y:%H:%M:%S";
  } else if (!strcmp(format, "rfc3339")) {
    new_format = "%Y-%m-%dT%H:%M:%S";
  }
  return new_format;
}
```
user: What is the c source code of the assembly code below?

```asm
<test_logical_bar>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  movl   $0x0,-0x4(%rbp)
  mov    $0x0,%eax
  call   <test_logical_foo1@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  jne    L22
  mov    $0x0,%eax
  call   <test_logical_foo2@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  jne    L22
  mov    $0x0,%eax
  call   <test_logical_foo3@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
L22:
  nop
  cmpl   $0x0,-0x4(%rbp)
  jne    L20
  mov    $0x0,%eax
  call   <test_logical_foo1@plt>
  test   %eax,%eax
L20:
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
int test_logical_bar() {
  int x = 0;
  (x = test_logical_foo1()) || (x = test_logical_foo2()) || (x = test_logical_foo3());
  x || test_logical_foo1();
  return x;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<test_logical_bar>:
  endbr64
  push   %rbx
  mov    $0x0,%eax
  call   <test_logical_foo1@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  je     L15
L7:
  mov    %ebx,%eax
  pop    %rbx
  ret
L15:
  mov    $0x0,%eax
  call   <test_logical_foo2@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  jne    L7
  mov    $0x0,%eax
  call   <test_logical_foo3@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  jne    L7
  mov    $0x0,%eax
  call   <test_logical_foo1@plt>
  jmp    L7
```

assistant: ```c
int test_logical_bar() {
  int x = 0;
  (x = test_logical_foo1()) || (x = test_logical_foo2()) || (x = test_logical_foo3());
  x || test_logical_foo1();
  return x;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<test_logical_bar>:
  endbr64
  push   %r12
  xor    %eax,%eax
  call   <test_logical_foo1@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  je     L29
L10:
  mov    %r12d,%eax
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L29:
  xor    %eax,%eax
  call   <test_logical_foo2@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  jne    L10
  xor    %eax,%eax
  call   <test_logical_foo3@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  jne    L10
  xor    %eax,%eax
  call   <test_logical_foo1@plt>
  mov    %r12d,%eax
  pop    %r12
  ret
```

assistant: ```c
int test_logical_bar() {
  int x = 0;
  (x = test_logical_foo1()) || (x = test_logical_foo2()) || (x = test_logical_foo3());
  x || test_logical_foo1();
  return x;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<test_logical_bar>:
  endbr64
  push   %r12
  xor    %eax,%eax
  call   <test_logical_foo1@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  je     L4
L27:
  mov    %r12d,%eax
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L4:
  xor    %eax,%eax
  call   <test_logical_foo2@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  jne    L27
  xor    %eax,%eax
  call   <test_logical_foo3@plt>
  mov    %eax,%r12d
  test   %eax,%eax
  jne    L27
  xor    %eax,%eax
  call   <test_logical_foo1@plt>
  mov    %r12d,%eax
  pop    %r12
  ret
```

assistant: ```c
int test_logical_bar() {
  int x = 0;
  (x = test_logical_foo1()) || (x = test_logical_foo2()) || (x = test_logical_foo3());
  x || test_logical_foo1();
  return x;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<reverseBits_fun_int16_t>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  movl   $0xf,-0x4(%rbp)
  mov    -0x14(%rbp),%eax
  sar    %eax
  and    $0x7fff,%eax
  mov    %eax,-0x14(%rbp)
  jmp    L15
L6:
  mov    -0x8(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x14(%rbp),%eax
  and    $0x1,%eax
  or     %edx,%eax
  mov    %eax,-0x8(%rbp)
  subl   $0x1,-0x4(%rbp)
  sarl   -0x14(%rbp)
L15:
  cmpl   $0x0,-0x14(%rbp)
  jne    L6
  mov    -0x4(%rbp),%eax
  mov    -0x8(%rbp),%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  pop    %rbp
  ret
```

assistant: ```c
int16_t reverseBits_fun_int16_t(int16_t x) {
  int16_t r = x;
  int i = 15;
  for (x = x >> 1 & 0x7fff; x; x >>= 1) {
    r = (r << 1) | (x & 1);
    --i;
  }
  return r << i;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<reverseBits_fun_int16_t>:
  endbr64
  mov    %edi,%eax
  mov    %edi,%edx
  sar    %edx
  and    $0x7fff,%edx
  je     L29
  mov    $0xf,%ecx
L11:
  add    %eax,%eax
  mov    %edx,%esi
  and    $0x1,%esi
  or     %esi,%eax
  sub    $0x1,%ecx
  sar    %edx
  jne    L11
L5:
  shl    %cl,%eax
  ret
L29:
  mov    $0xf,%ecx
  jmp    L5
```

assistant: ```c
int16_t reverseBits_fun_int16_t(int16_t x) {
  int16_t r = x;
  int i = 15;
  for (x = x >> 1 & 0x7fff; x; x >>= 1) {
    r = (r << 1) | (x & 1);
    --i;
  }
  return r << i;
}
```
user: Translate the below assembly code into C programming language:

```asm
<reverseBits_fun_int16_t>:
  endbr64
  mov    %edi,%edx
  mov    %edi,%eax
  mov    $0xf,%ecx
  sar    %edx
  and    $0x7fff,%edx
  je     L11
  nopw   0x0(%rax,%rax,1)
L3:
  mov    %edx,%esi
  add    %eax,%eax
  sub    $0x1,%ecx
  and    $0x1,%esi
  or     %esi,%eax
  sar    %edx
  jne    L3
L11:
  shl    %cl,%eax
  ret
```

assistant: ```c
int16_t reverseBits_fun_int16_t(int16_t x) {
  int16_t r = x;
  int i = 15;
  for (x = x >> 1 & 0x7fff; x; x >>= 1) {
    r = (r << 1) | (x & 1);
    --i;
  }
  return r << i;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<reverseBits_fun_int16_t>:
  endbr64
  mov    %edi,%edx
  mov    %edi,%eax
  mov    $0xf,%ecx
  sar    %edx
  and    $0x7fff,%edx
  je     L6
  nopw   0x0(%rax,%rax,1)
L3:
  mov    %edx,%esi
  add    %eax,%eax
  sub    $0x1,%ecx
  and    $0x1,%esi
  or     %esi,%eax
  sar    %edx
  jne    L3
L6:
  shl    %cl,%eax
  ret
```

assistant: ```c
int16_t reverseBits_fun_int16_t(int16_t x) {
  int16_t r = x;
  int i = 15;
  for (x = x >> 1 & 0x7fff; x; x >>= 1) {
    r = (r << 1) | (x & 1);
    --i;
  }
  return r << i;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<forward_mm>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    $0x0,%eax
  call   <forward@plt>
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <linear_distance_mm@plt>
  nop
  leave
  ret
```

assistant: ```c
void forward_mm(unsigned int DistanceInMM) {
  forward();
  linear_distance_mm(DistanceInMM);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<forward_mm>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  mov    $0x0,%eax
  call   <forward@plt>
  mov    %ebx,%edi
  call   <linear_distance_mm@plt>
  pop    %rbx
  ret
```

assistant: ```c
void forward_mm(unsigned int DistanceInMM) {
  forward();
  linear_distance_mm(DistanceInMM);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<forward_mm>:
  endbr64
  push   %rbp
  xor    %eax,%eax
  mov    %edi,%ebp
  call   <forward@plt>
  mov    %ebp,%edi
  pop    %rbp
  jmp    1070 <linear_distance_mm@plt>
```

assistant: ```c
void forward_mm(unsigned int DistanceInMM) {
  forward();
  linear_distance_mm(DistanceInMM);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<forward_mm>:
  endbr64
  push   %rbp
  xor    %eax,%eax
  mov    %edi,%ebp
  call   <forward@plt>
  mov    %ebp,%edi
  pop    %rbp
  jmp    1070 <linear_distance_mm@plt>
```

assistant: ```c
void forward_mm(unsigned int DistanceInMM) {
  forward();
  linear_distance_mm(DistanceInMM);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<lms_strstrip>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  je     L159
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L72
  mov    -0x20(%rbp),%rax
  movl   $0x0,(%rax)
  jmp    L21
L72:
  mov    -0xc(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0xc(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x10(%rbp)
  jmp    L28
L52:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L118
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L93
L118:
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
  subl   $0x1,-0xc(%rbp)
  subq   $0x1,-0x8(%rbp)
  subl   $0x1,-0x10(%rbp)
L28:
  cmpl   $0x0,-0x10(%rbp)
  jns    L52
L93:
  cmpl   $0x0,-0xc(%rbp)
  jne    L39
  mov    -0x20(%rbp),%rax
  movl   $0x0,(%rax)
  jmp    L21
L39:
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x10(%rbp)
  jmp    L109
L176:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isspace@plt>
  test   %rax,%rax
  je     L111
  addq   $0x1,-0x8(%rbp)
  addl   $0x1,-0x10(%rbp)
L109:
  mov    -0x10(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jl     L176
  jmp    L150
L111:
  nop
L150:
  mov    -0x10(%rbp),%eax
  sub    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  jne    L80
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x20(%rbp),%rax
  movl   $0x0,(%rax)
  jmp    L21
L80:
  mov    -0xc(%rbp),%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x18(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jae    L21
  jmp    L98
L140:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %dl,(%rax)
  subl   $0x1,-0xc(%rbp)
  addq   $0x1,-0x18(%rbp)
  addq   $0x1,-0x8(%rbp)
L98:
  cmpl   $0x0,-0xc(%rbp)
  jns    L140
  jmp    L21
L159:
  nop
L21:
  leave
  ret
```

assistant: ```c
void lms_strstrip(char *str, unsigned int *p_len) {
  int i, len;
  char *p;
  len = *p_len;
  if (len == 0)
    return;
  if (*str == '\0') {
    *p_len = 0;
    return;
  }
  p = str + len - 1;
  for (i = len - 1; i >= 0; i--) {
    if (isspace(*p) || *p == '\0') {
      *p = '\0';
      len--;
      p--;
    } else
      break;
  }
  if (len == 0) {
    *p_len = 0;
    return;
  }
  p = str;
  for (i = 0; i < len; i++) {
    if (isspace(*p))
      p++;
    else
      break;
  }
  len -= i;
  if (len == 0) {
    *str = '\0';
    *p_len = 0;
    return;
  }
  *p_len = len;
  if (str < p)
    for (; len >= 0; len--, str++, p++)
      *str = *p;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<lms_strstrip>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    (%rsi),%ebp
  test   %ebp,%ebp
  je     L81
  mov    %rdi,%r12
  mov    %rsi,%r13
  cmpb   $0x0,(%rdi)
  je     L16
  movslq %ebp,%rax
  lea    -0x1(%rdi,%rax,1),%rbx
  test   %ebp,%ebp
  jg     L151
  jmp    L36
L16:
  movl   $0x0,(%rsi)
L81:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L105:
  movb   $0x0,(%rbx)
  sub    $0x1,%rbx
  sub    $0x1,%ebp
  je     L32
L151:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L105
  cmpb   $0x0,(%rbx)
  je     L105
  test   %ebp,%ebp
  je     L32
L36:
  mov    %r12,%rbx
  mov    $0x0,%r14d
  test   %ebp,%ebp
  jle    L93
L144:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  test   %rax,%rax
  je     L50
  add    $0x1,%rbx
  add    $0x1,%r14d
  cmp    %r14d,%ebp
  jne    L144
L68:
  movb   $0x0,(%r12)
  movl   $0x0,0x0(%r13)
  jmp    L81
L32:
  movl   $0x0,0x0(%r13)
  jmp    L81
L50:
  sub    %r14d,%ebp
  je     L68
  mov    %ebp,0x0(%r13)
  cmp    %rbx,%r12
  jae    L81
  test   %ebp,%ebp
  js     L81
  mov    %ebp,%ecx
  mov    $0x0,%eax
L23:
  movzbl (%rbx,%rax,1),%edx
  mov    %dl,(%r12,%rax,1)
  mov    %rax,%rdx
  add    $0x1,%rax
  cmp    %rcx,%rdx
  jne    L23
  jmp    L81
L93:
  mov    %ebp,0x0(%r13)
  jmp    L81
```

assistant: ```c
void lms_strstrip(char *str, unsigned int *p_len) {
  int i, len;
  char *p;
  len = *p_len;
  if (len == 0)
    return;
  if (*str == '\0') {
    *p_len = 0;
    return;
  }
  p = str + len - 1;
  for (i = len - 1; i >= 0; i--) {
    if (isspace(*p) || *p == '\0') {
      *p = '\0';
      len--;
      p--;
    } else
      break;
  }
  if (len == 0) {
    *p_len = 0;
    return;
  }
  p = str;
  for (i = 0; i < len; i++) {
    if (isspace(*p))
      p++;
    else
      break;
  }
  len -= i;
  if (len == 0) {
    *str = '\0';
    *p_len = 0;
    return;
  }
  *p_len = len;
  if (str < p)
    for (; len >= 0; len--, str++, p++)
      *str = *p;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<lms_strstrip>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    (%rsi),%ebp
  push   %rbx
  test   %ebp,%ebp
  je     L87
  cmpb   $0x0,(%rdi)
  mov    %rdi,%r12
  mov    %rsi,%r13
  je     L60
  movslq %ebp,%rax
  lea    -0x1(%rdi,%rax,1),%rbx
  test   %ebp,%ebp
  jle    L6
  nopl   (%rax)
L139:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L118
  cmpb   $0x0,(%rbx)
  jne    L96
L118:
  movb   $0x0,(%rbx)
  sub    $0x1,%rbx
  sub    $0x1,%ebp
  jne    L139
L60:
  movl   $0x0,0x0(%r13)
L87:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nop
L96:
  test   %ebp,%ebp
  jle    L6
  mov    %r12,%rbx
  xor    %r14d,%r14d
  jmp    L53
  nopl   0x0(%rax)
L148:
  add    $0x1,%r14d
  add    $0x1,%rbx
  cmp    %r14d,%ebp
  je     L86
L53:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L148
  sub    %r14d,%ebp
  je     L86
  mov    %ebp,0x0(%r13)
  cmp    %rbx,%r12
  jae    L87
  test   %ebp,%ebp
  js     L87
  mov    %ebp,%ecx
  xor    %eax,%eax
L73:
  movzbl (%rbx,%rax,1),%edx
  mov    %dl,(%r12,%rax,1)
  mov    %rax,%rdx
  add    $0x1,%rax
  cmp    %rcx,%rdx
  jne    L73
  jmp    L87
  cs nopw 0x0(%rax,%rax,1)
L86:
  movb   $0x0,(%r12)
  jmp    L60
L6:
  mov    %ebp,0x0(%r13)
  jmp    L87
```

assistant: ```c
void lms_strstrip(char *str, unsigned int *p_len) {
  int i, len;
  char *p;
  len = *p_len;
  if (len == 0)
    return;
  if (*str == '\0') {
    *p_len = 0;
    return;
  }
  p = str + len - 1;
  for (i = len - 1; i >= 0; i--) {
    if (isspace(*p) || *p == '\0') {
      *p = '\0';
      len--;
      p--;
    } else
      break;
  }
  if (len == 0) {
    *p_len = 0;
    return;
  }
  p = str;
  for (i = 0; i < len; i++) {
    if (isspace(*p))
      p++;
    else
      break;
  }
  len -= i;
  if (len == 0) {
    *str = '\0';
    *p_len = 0;
    return;
  }
  *p_len = len;
  if (str < p)
    for (; len >= 0; len--, str++, p++)
      *str = *p;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<readline>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L33
L43:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    -0x8(%rbp),%edx
  mov    %dl,(%rax)
  addl   $0x1,-0x4(%rbp)
L33:
  mov    -0x1c(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x4(%rbp)
  jge    L7
  mov    $0x0,%eax
  call   <getchar@plt>
  mov    %eax,-0x8(%rbp)
  mov    D3(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x8(%rbp)
  je     L7
  cmpl   $0xa,-0x8(%rbp)
  jne    L43
L7:
  cmpl   $0xa,-0x8(%rbp)
  jne    L41
  mov    -0x4(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x4(%rbp)
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    -0x8(%rbp),%edx
  mov    %dl,(%rax)
L41:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
int readline(char s[], int lim) {
  int c, i;
  for (i = 0; i < lim - 1 && (c = getchar()) != EOF && c != '\n'; ++i)
    s[i] = c;
  if (c == '\n')
    s[i++] = c;
  s[i] = '\0';
  return i;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<readline>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r13
  cmp    $0x1,%esi
  jle    L14
  mov    %rdi,%rbp
  lea    -0x1(%rsi),%r12d
  mov    $0x0,%ebx
L46:
  mov    $0x0,%eax
  call   <getchar@plt>
  mov    D8(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L67
  cmp    $0xa,%eax
  je     L67
  mov    %al,0x0(%rbp)
  add    $0x1,%ebx
  add    $0x1,%rbp
  cmp    %r12d,%ebx
  jne    L46
  mov    %r12d,%ebx
  jmp    L49
L14:
  mov    $0x0,%ebx
L67:
  cmp    $0xa,%eax
  je     L55
L49:
  movslq %ebx,%rax
  movb   $0x0,0x0(%r13,%rax,1)
  mov    %ebx,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L55:
  movslq %ebx,%rax
  movb   $0xa,0x0(%r13,%rax,1)
  lea    0x1(%rbx),%ebx
  jmp    L49
```

assistant: ```c
int readline(char s[], int lim) {
  int c, i;
  for (i = 0; i < lim - 1 && (c = getchar()) != EOF && c != '\n'; ++i)
    s[i] = c;
  if (c == '\n')
    s[i++] = c;
  s[i] = '\0';
  return i;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<readline>:
  endbr64
  push   %r14
  mov    %rdi,%rcx
  xor    %r14d,%r14d
  push   %r13
  mov    %rdi,%r13
  push   %r12
  push   %rbp
  lea    -0x1(%rsi),%ebp
  push   %rbx
  test   %ebp,%ebp
  jle    L38
  mov    D6(%rip),%r12
  mov    %rdi,%rbx
  xor    %r14d,%r14d
  jmp    L26
  nopl   0x0(%rax,%rax,1)
L3:
  lea    0x1(%r14),%edx
  cmp    $0xa,%eax
  je     L54
  mov    %al,(%rcx)
  lea    0x1(%rcx),%rbx
  cmp    %edx,%ebp
  je     L18
  mov    %edx,%r14d
L26:
  xor    %eax,%eax
  call   <getchar@plt>
  mov    %rbx,%rcx
  cmp    %eax,(%r12)
  jne    L3
  cmp    $0xa,%eax
  je     L15
L38:
  movb   $0x0,(%rcx)
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L15:
  lea    0x1(%r14),%edx
L54:
  movslq %edx,%rcx
  movb   $0xa,(%rbx)
  mov    %rcx,%r14
  add    %r13,%rcx
  movb   $0x0,(%rcx)
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax)
L18:
  movslq %ebp,%rcx
  mov    %ebp,%r14d
  add    %r13,%rcx
  mov    %r14d,%eax
  movb   $0x0,(%rcx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
int readline(char s[], int lim) {
  int c, i;
  for (i = 0; i < lim - 1 && (c = getchar()) != EOF && c != '\n'; ++i)
    s[i] = c;
  if (c == '\n')
    s[i++] = c;
  s[i] = '\0';
  return i;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<readline>:
  endbr64
  push   %r14
  mov    %rdi,%rcx
  xor    %r14d,%r14d
  push   %r13
  mov    %rdi,%r13
  push   %r12
  push   %rbp
  lea    -0x1(%rsi),%ebp
  push   %rbx
  test   %ebp,%ebp
  jle    L32
  mov    D1(%rip),%r12
  mov    %rdi,%rbx
  xor    %r14d,%r14d
  jmp    L44
  nopl   0x0(%rax,%rax,1)
L42:
  lea    0x1(%r14),%edx
  cmp    $0xa,%eax
  je     L58
  mov    %al,(%rcx)
  lea    0x1(%rcx),%rbx
  cmp    %edx,%ebp
  je     L57
  mov    %edx,%r14d
L44:
  xor    %eax,%eax
  call   <getchar@plt>
  mov    %rbx,%rcx
  cmp    %eax,(%r12)
  jne    L42
  cmp    $0xa,%eax
  je     L29
L32:
  movb   $0x0,(%rcx)
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L29:
  lea    0x1(%r14),%edx
L58:
  movslq %edx,%rcx
  movb   $0xa,(%rbx)
  mov    %rcx,%r14
  add    %r13,%rcx
  movb   $0x0,(%rcx)
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax)
L57:
  movslq %ebp,%rcx
  mov    %ebp,%r14d
  add    %r13,%rcx
  mov    %r14d,%eax
  movb   $0x0,(%rcx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
int readline(char s[], int lim) {
  int c, i;
  for (i = 0; i < lim - 1 && (c = getchar()) != EOF && c != '\n'; ++i)
    s[i] = c;
  if (c == '\n')
    s[i++] = c;
  s[i] = '\0';
  return i;
}
```