ylfeng/ReF-Decompile-dataset huggingface dataset:
user: What would the C source look like for the assembly code provided here?

```asm
<usage>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <pversion@plt>
  lea    D44(%rip),%rdi
  call   <printf@plt>
  lea    D119(%rip),%rdi
  call   <printf@plt>
  lea    D54(%rip),%rdi
  call   <printf@plt>
  lea    D39(%rip),%rdi
  call   <printf@plt>
  lea    D6(%rip),%rdi
  call   <printf@plt>
  lea    D118(%rip),%rdi
  call   <printf@plt>
  lea    D0(%rip),%rdi
  call   <printf@plt>
  lea    D69(%rip),%rdi
  call   <printf@plt>
  lea    D109(%rip),%rdi
  call   <printf@plt>
  lea    D89(%rip),%rdi
  call   <printf@plt>
  lea    D78(%rip),%rdi
  call   <printf@plt>
  lea    D42(%rip),%rdi
  add    $0x8,%rsp
  jmp    1060 <printf@plt>
```

tool_calls: name: disassemble_data
arguments: label: D44
type: string
name: disassemble_data
arguments: label: D119
type: string
name: disassemble_data
arguments: label: D54
type: string
name: disassemble_data
arguments: label: D39
type: string
name: disassemble_data
arguments: label: D6
type: string
name: disassemble_data
arguments: label: D118
type: string
name: disassemble_data
arguments: label: D0
type: string
name: disassemble_data
arguments: label: D69
type: string
name: disassemble_data
arguments: label: D109
type: string
name: disassemble_data
arguments: label: D89
type: string
name: disassemble_data
arguments: label: D78
type: string
name: disassemble_data
arguments: label: D42
type: string

tool: D44: usage: addpath [-bcw] [-df] [-e VAR] [-p VAR] elem ...


tool: D119: 	Only one of bcw should be specified.  Default is detected by


tool: D54: 	examining $SHELL.


tool: D39: 	-b	emit Bourne style path.  e.g. 'a:b:c:...'


tool: D6: 	-c	emit Csh style path.  e.g. 'a b c ...'


tool: D118: 	-w	emit Windows style path.  e.g. 'a;b;c;...'


tool: D0: 	-d	force new elements in even if they are Duplicates


tool: D69: 	-e	only do it if environment variable env_var is defined.


tool: D109: 	-f	prepend elements at Front of path. (default: at end)


tool: D89: 	-p VAR	use VAR for path rather than PATH.


tool: D78: 	-s	print a command that you could "source".


tool: D42: 	-x	check for existence of each element before adding.


assistant: ```c
void usage() {
  pversion();
  printf("usage: addpath [-bcw] [-df] [-e VAR] [-p VAR] elem ...\n");
  printf("\tOnly one of bcw should be specified.  Default is detected by\n");
  printf("\texamining $SHELL.\n");
  printf("\t-b\temit Bourne style path.  e.g. 'a:b:c:...'\n");
  printf("\t-c\temit Csh style path.  e.g. 'a b c ...'\n");
  printf("\t-w\temit Windows style path.  e.g. 'a;b;c;...'\n");
  printf("\t-d\tforce new elements in even if they are Duplicates\n");
  printf("\t-e\tonly do it if environment variable env_var is defined.\n");
  printf("\t-f\tprepend elements at Front of path. (default: at end)\n");
  printf("\t-p VAR\tuse VAR for path rather than PATH.\n");
  printf("\t-s\tprint a command that you could \"source\".\n");
  printf("\t-x\tcheck for existence of each element before adding.\n");
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<selfTest>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    $0x0,%eax
  call   <indietro@plt>
  mov    $0x2,%edi
  call   <sleep@plt>
  mov    $0x0,%eax
  call   <ruotaDX@plt>
  mov    $0x2,%edi
  call   <sleep@plt>
  mov    $0x0,%eax
  call   <ruotaSX@plt>
  mov    $0x2,%edi
  call   <sleep@plt>
  mov    $0x0,%eax
  call   <pwmOff@plt>
  mov    $0x1,%edi
  call   <sleep@plt>
  nop
  pop    %rbp
  ret
```

assistant: ```c
void selfTest() {
  indietro();
  sleep(2);
  ruotaDX();
  sleep(2);
  ruotaSX();
  sleep(2);
  pwmOff();
  sleep(1);
}
```
user: What is the c source code of the assembly code below?

```asm
<selfTest>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x0,%eax
  call   <indietro@plt>
  mov    $0x2,%edi
  call   <sleep@plt>
  mov    $0x0,%eax
  call   <ruotaDX@plt>
  mov    $0x2,%edi
  call   <sleep@plt>
  mov    $0x0,%eax
  call   <ruotaSX@plt>
  mov    $0x2,%edi
  call   <sleep@plt>
  mov    $0x0,%eax
  call   <pwmOff@plt>
  mov    $0x1,%edi
  call   <sleep@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
void selfTest() {
  indietro();
  sleep(2);
  ruotaDX();
  sleep(2);
  ruotaSX();
  sleep(2);
  pwmOff();
  sleep(1);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<selfTest>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <indietro@plt>
  mov    $0x2,%edi
  call   <sleep@plt>
  xor    %eax,%eax
  call   <ruotaDX@plt>
  mov    $0x2,%edi
  call   <sleep@plt>
  xor    %eax,%eax
  call   <ruotaSX@plt>
  mov    $0x2,%edi
  call   <sleep@plt>
  xor    %eax,%eax
  call   <pwmOff@plt>
  mov    $0x1,%edi
  add    $0x8,%rsp
  jmp    10c0 <sleep@plt>
```

assistant: ```c
void selfTest() {
  indietro();
  sleep(2);
  ruotaDX();
  sleep(2);
  ruotaSX();
  sleep(2);
  pwmOff();
  sleep(1);
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<selfTest>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <indietro@plt>
  mov    $0x2,%edi
  call   <sleep@plt>
  xor    %eax,%eax
  call   <ruotaDX@plt>
  mov    $0x2,%edi
  call   <sleep@plt>
  xor    %eax,%eax
  call   <ruotaSX@plt>
  mov    $0x2,%edi
  call   <sleep@plt>
  xor    %eax,%eax
  call   <pwmOff@plt>
  mov    $0x1,%edi
  add    $0x8,%rsp
  jmp    10c0 <sleep@plt>
```

assistant: ```c
void selfTest() {
  indietro();
  sleep(2);
  ruotaDX();
  sleep(2);
  ruotaSX();
  sleep(2);
  pwmOff();
  sleep(1);
}
```
user: Translate the below assembly code into C programming language:

```asm
<RandomFunc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x18(%rbp),%rax
  movzwl (%rax),%eax
  shl    $0x7,%eax
  and    $0xb500,%ax
  mov    %ax,-0xa(%rbp)
  movw   $0x0,-0xc(%rbp)
  nop
  mov    -0x20(%rbp),%rax
  movw   $0x0,(%rax)
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L2
  call   <__stack_chk_fail@plt>
L2:
  leave
  ret
```

assistant: ```c
void RandomFunc(unsigned short input[1], unsigned short output[1]) {
  unsigned short state[1];
  unsigned short local2;
  unsigned short local1;
  char copy11;
  {
    state[0UL] = (input[0UL] & 914778474UL) << (unsigned short)7;
    local1 = 0UL;
    while (local1 < (unsigned short)0) {
      local2 = 0UL;
      while (local2 < (unsigned short)0) {
        copy11 = *((char *)(&state[local1]) + 1);
        *((char *)(&state[local1]) + 1) = *((char *)(&state[local1]) + 0);
        *((char *)(&state[local1]) + 0) = copy11;
        local2 += 2UL;
      }
      local1++;
    }
    output[0UL] = (state[0UL] << (unsigned short)7) & (unsigned short)34;
  }
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<RandomFunc>:
  endbr64
  movw   $0x0,(%rsi)
  ret
```

assistant: ```c
void RandomFunc(unsigned short input[1], unsigned short output[1]) {
  unsigned short state[1];
  unsigned short local2;
  unsigned short local1;
  char copy11;
  {
    state[0UL] = (input[0UL] & 914778474UL) << (unsigned short)7;
    local1 = 0UL;
    while (local1 < (unsigned short)0) {
      local2 = 0UL;
      while (local2 < (unsigned short)0) {
        copy11 = *((char *)(&state[local1]) + 1);
        *((char *)(&state[local1]) + 1) = *((char *)(&state[local1]) + 0);
        *((char *)(&state[local1]) + 0) = copy11;
        local2 += 2UL;
      }
      local1++;
    }
    output[0UL] = (state[0UL] << (unsigned short)7) & (unsigned short)34;
  }
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<RandomFunc>:
  endbr64
  xor    %eax,%eax
  mov    %ax,(%rsi)
  ret
```

assistant: ```c
void RandomFunc(unsigned short input[1], unsigned short output[1]) {
  unsigned short state[1];
  unsigned short local2;
  unsigned short local1;
  char copy11;
  {
    state[0UL] = (input[0UL] & 914778474UL) << (unsigned short)7;
    local1 = 0UL;
    while (local1 < (unsigned short)0) {
      local2 = 0UL;
      while (local2 < (unsigned short)0) {
        copy11 = *((char *)(&state[local1]) + 1);
        *((char *)(&state[local1]) + 1) = *((char *)(&state[local1]) + 0);
        *((char *)(&state[local1]) + 0) = copy11;
        local2 += 2UL;
      }
      local1++;
    }
    output[0UL] = (state[0UL] << (unsigned short)7) & (unsigned short)34;
  }
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<RandomFunc>:
  endbr64
  xor    %eax,%eax
  mov    %ax,(%rsi)
  ret
```

assistant: ```c
void RandomFunc(unsigned short input[1], unsigned short output[1]) {
  unsigned short state[1];
  unsigned short local2;
  unsigned short local1;
  char copy11;
  {
    state[0UL] = (input[0UL] & 914778474UL) << (unsigned short)7;
    local1 = 0UL;
    while (local1 < (unsigned short)0) {
      local2 = 0UL;
      while (local2 < (unsigned short)0) {
        copy11 = *((char *)(&state[local1]) + 1);
        *((char *)(&state[local1]) + 1) = *((char *)(&state[local1]) + 0);
        *((char *)(&state[local1]) + 0) = copy11;
        local2 += 2UL;
      }
      local1++;
    }
    output[0UL] = (state[0UL] << (unsigned short)7) & (unsigned short)34;
  }
}
```
user: Translate the below assembly code into C programming language:

```asm
<fp_size>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L1
  mov    $0x0,%eax
  jmp    L9
L1:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <ftell@plt>
  mov    %rax,-0x10(%rbp)
  mov    D19(%rip),%rax
  mov    (%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <fseek@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <ftell@plt>
  mov    %rax,-0x8(%rbp)
  mov    D0(%rip),%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <fseek@plt>
  mov    -0x8(%rbp),%rax
L9:
  leave
  ret
```

assistant: ```c
size_t fp_size(FILE *fp) {
  size_t startpos, out;
  if (fp == NULL)
    return 0;
  startpos = ftell(fp);
  fseek(fp, 0, SEEK_END);
  out = ftell(fp);
  fseek(fp, startpos, SEEK_SET);
  return out;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<fp_size>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    $0x0,%ebp
  test   %rdi,%rdi
  je     L6
  mov    %rdi,%rbx
  call   <ftell@plt>
  mov    %rax,%r12
  mov    D18(%rip),%rax
  mov    (%rax),%edx
  mov    $0x0,%esi
  mov    %rbx,%rdi
  call   <fseek@plt>
  mov    %rbx,%rdi
  call   <ftell@plt>
  mov    %rax,%rbp
  mov    D12(%rip),%rax
  mov    (%rax),%edx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <fseek@plt>
L6:
  mov    %rbp,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
size_t fp_size(FILE *fp) {
  size_t startpos, out;
  if (fp == NULL)
    return 0;
  startpos = ftell(fp);
  fseek(fp, 0, SEEK_END);
  out = ftell(fp);
  fseek(fp, startpos, SEEK_SET);
  return out;
}
```
user: What is the c source code of the assembly code below?

```asm
<fp_size>:
  endbr64
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  test   %rdi,%rdi
  je     L3
  mov    %rdi,%rbp
  call   <ftell@plt>
  xor    %esi,%esi
  mov    %rbp,%rdi
  mov    %rax,%r13
  mov    D10(%rip),%rax
  mov    (%rax),%edx
  call   <fseek@plt>
  mov    %rbp,%rdi
  call   <ftell@plt>
  mov    %r13,%rsi
  mov    %rbp,%rdi
  mov    %rax,%r12
  mov    D4(%rip),%rax
  mov    (%rax),%edx
  call   <fseek@plt>
L3:
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
size_t fp_size(FILE *fp) {
  size_t startpos, out;
  if (fp == NULL)
    return 0;
  startpos = ftell(fp);
  fseek(fp, 0, SEEK_END);
  out = ftell(fp);
  fseek(fp, startpos, SEEK_SET);
  return out;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<fp_size>:
  endbr64
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  test   %rdi,%rdi
  je     L6
  mov    %rdi,%rbp
  call   <ftell@plt>
  xor    %esi,%esi
  mov    %rbp,%rdi
  mov    %rax,%r13
  mov    D5(%rip),%rax
  mov    (%rax),%edx
  call   <fseek@plt>
  mov    %rbp,%rdi
  call   <ftell@plt>
  mov    %r13,%rsi
  mov    %rbp,%rdi
  mov    %rax,%r12
  mov    D14(%rip),%rax
  mov    (%rax),%edx
  call   <fseek@plt>
L6:
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
size_t fp_size(FILE *fp) {
  size_t startpos, out;
  if (fp == NULL)
    return 0;
  startpos = ftell(fp);
  fseek(fp, 0, SEEK_END);
  out = ftell(fp);
  fseek(fp, startpos, SEEK_SET);
  return out;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<waitForETX>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    %rdx,-0x18(%rbp)
  movl   $0x2,D37(%rip)
  movl   $0x0,D112(%rip)
  movl   $0xffffffff,D156(%rip)
  jmp    L93
L94:
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <bytesWaiting@plt>
  mov    %eax,D152(%rip)
  mov    D152(%rip),%eax
  test   %eax,%eax
  jle    L88
  mov    D37(%rip),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x4(%rbp),%eax
  mov    $0x1,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  mov    D37(%rip),%eax
  add    $0x1,%eax
  mov    %eax,D64(%rip)
  mov    D64(%rip),%eax
  cmp    $0x5,%eax
  jle    L78
  mov    -0x10(%rbp),%rax
  add    $0x5,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  add    $0x9,%eax
  mov    %eax,D64(%rip)
L78:
  mov    D64(%rip),%eax
  test   %eax,%eax
  jle    L93
  mov    D64(%rip),%edx
  mov    D64(%rip),%eax
  cmp    %eax,%edx
  jl     L93
  mov    D64(%rip),%eax
  cltq
  lea    -0x2(%rax),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x1b,%al
  jne    L71
  mov    D64(%rip),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x3,%al
  jne    L71
  mov    D64(%rip),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,(%rax)
  mov    $0x1,%eax
  jmp    L43
L71:
  mov    $0x0,%eax
  jmp    L43
L88:
  mov    $0x64,%edi
  call   <usleep@plt>
  mov    D112(%rip),%eax
  add    $0x1,%eax
  mov    %eax,D64(%rip)
L93:
  mov    D64(%rip),%eax
  cmp    $0x1d,%eax
  jle    L94
  mov    $0x0,%eax
L43:
  leave
  ret
```

assistant: ```c
int waitForETX(int fd, unsigned char *buf, int *len) {
  static int pos, loop, val, dlen;
  pos = 2;
  loop = 0;
  dlen = -1;
  while (loop < 30) {
    val = bytesWaiting(fd);
    if (val > 0) {
      read(fd, &(buf[pos]), 1);
      pos++;
      if (pos > 5) {
        dlen = buf[5] + 9;
      }
      if (dlen > 0 && pos >= dlen) {
        if (buf[dlen - 2] == 0x1b && buf[dlen - 1] == 0x03) {
          *len = dlen;
          return (1);
        } else {
          return (0);
        }
      }
    } else {
      usleep(100);
      loop++;
    }
  }
  return (0);
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<waitForETX>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,%ebx
  mov    %rsi,%rbp
  mov    %rdx,%r12
  movl   $0x2,D15(%rip)
  movl   $0x0,D6(%rip)
  movl   $0xffffffff,D16(%rip)
  jmp    L64
L72:
  mov    $0x64,%edi
  call   <usleep@plt>
  addl   $0x1,D6(%rip)
L40:
  cmpl   $0x1d,D6(%rip)
  jg     L30
L64:
  mov    %ebx,%edi
  call   <bytesWaiting@plt>
  test   %eax,%eax
  jle    L72
  movslq D15(%rip),%rsi
  add    %rbp,%rsi
  mov    $0x1,%edx
  mov    %ebx,%edi
  call   <read@plt>
  mov    D15(%rip),%eax
  add    $0x1,%eax
  mov    %eax,D96(%rip)
  cmp    $0x5,%eax
  jle    L86
  movzbl 0x5(%rbp),%edx
  add    $0x9,%edx
  mov    %edx,D96(%rip)
L86:
  mov    D96(%rip),%edx
  cmp    %edx,%eax
  jl     L40
  test   %edx,%edx
  jle    L40
  movslq %edx,%rcx
  mov    $0x0,%eax
  cmpb   $0x1b,-0x2(%rbp,%rcx,1)
  jne    L62
  cmpb   $0x3,-0x1(%rbp,%rcx,1)
  jne    L62
  mov    %edx,(%r12)
  mov    $0x1,%eax
  jmp    L62
L30:
  mov    $0x0,%eax
L62:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int waitForETX(int fd, unsigned char *buf, int *len) {
  static int pos, loop, val, dlen;
  pos = 2;
  loop = 0;
  dlen = -1;
  while (loop < 30) {
    val = bytesWaiting(fd);
    if (val > 0) {
      read(fd, &(buf[pos]), 1);
      pos++;
      if (pos > 5) {
        dlen = buf[5] + 9;
      }
      if (dlen > 0 && pos >= dlen) {
        if (buf[dlen - 2] == 0x1b && buf[dlen - 1] == 0x03) {
          *len = dlen;
          return (1);
        } else {
          return (0);
        }
      }
    } else {
      usleep(100);
      loop++;
    }
  }
  return (0);
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<waitForETX>:
  endbr64
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %edi,%ebx
  movl   $0x2,D41(%rip)
  movl   $0x0,D7(%rip)
  movl   $0xffffffff,D22(%rip)
  jmp    L60
L87:
  movslq D41(%rip),%rsi
  mov    $0x1,%edx
  mov    %ebx,%edi
  add    %rbp,%rsi
  call   <read@plt>
  mov    D41(%rip),%eax
  add    $0x1,%eax
  mov    %eax,D43(%rip)
  cmp    $0x5,%eax
  jg     L45
  mov    D22(%rip),%edx
  test   %edx,%edx
  setg   %cl
L9:
  cmp    %edx,%eax
  jl     L89
  test   %cl,%cl
  jne    L11
L89:
  mov    D7(%rip),%eax
  cmp    $0x1d,%eax
  jg     L52
L60:
  mov    %ebx,%edi
  call   <bytesWaiting@plt>
  test   %eax,%eax
  jg     L87
  mov    $0x64,%edi
  call   <usleep@plt>
  mov    D7(%rip),%eax
  add    $0x1,%eax
  mov    %eax,D43(%rip)
  cmp    $0x1d,%eax
  jle    L60
L52:
  xor    %eax,%eax
L17:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L45:
  movzbl 0x5(%rbp),%edx
  mov    $0x1,%ecx
  add    $0x9,%edx
  mov    %edx,D43(%rip)
  jmp    L9
  nopl   0x0(%rax)
L11:
  movslq %edx,%rax
  cmpb   $0x1b,-0x2(%rbp,%rax,1)
  jne    L52
  cmpb   $0x3,-0x1(%rbp,%rax,1)
  jne    L52
  mov    %edx,(%r12)
  mov    $0x1,%eax
  jmp    L17
```

assistant: ```c
int waitForETX(int fd, unsigned char *buf, int *len) {
  static int pos, loop, val, dlen;
  pos = 2;
  loop = 0;
  dlen = -1;
  while (loop < 30) {
    val = bytesWaiting(fd);
    if (val > 0) {
      read(fd, &(buf[pos]), 1);
      pos++;
      if (pos > 5) {
        dlen = buf[5] + 9;
      }
      if (dlen > 0 && pos >= dlen) {
        if (buf[dlen - 2] == 0x1b && buf[dlen - 1] == 0x03) {
          *len = dlen;
          return (1);
        } else {
          return (0);
        }
      }
    } else {
      usleep(100);
      loop++;
    }
  }
  return (0);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<waitForETX>:
  endbr64
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %edi,%ebx
  movl   $0x2,D52(%rip)
  movl   $0x0,D7(%rip)
  movl   $0xffffffff,D31(%rip)
  jmp    L88
L94:
  movslq D52(%rip),%rsi
  mov    $0x1,%edx
  mov    %ebx,%edi
  add    %rbp,%rsi
  call   <read@plt>
  mov    D52(%rip),%eax
  add    $0x1,%eax
  mov    %eax,D23(%rip)
  cmp    $0x5,%eax
  jg     L97
  mov    D31(%rip),%edx
  test   %edx,%edx
  setg   %cl
L48:
  cmp    %edx,%eax
  jl     L86
  test   %cl,%cl
  jne    L95
L86:
  mov    D7(%rip),%eax
  cmp    $0x1d,%eax
  jg     L7
L88:
  mov    %ebx,%edi
  call   <bytesWaiting@plt>
  test   %eax,%eax
  jg     L94
  mov    $0x64,%edi
  call   <usleep@plt>
  mov    D7(%rip),%eax
  add    $0x1,%eax
  mov    %eax,D23(%rip)
  cmp    $0x1d,%eax
  jle    L88
L7:
  xor    %eax,%eax
L23:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L97:
  movzbl 0x5(%rbp),%edx
  mov    $0x1,%ecx
  add    $0x9,%edx
  mov    %edx,D23(%rip)
  jmp    L48
  nopl   0x0(%rax)
L95:
  movslq %edx,%rax
  cmpb   $0x1b,-0x2(%rbp,%rax,1)
  jne    L7
  cmpb   $0x3,-0x1(%rbp,%rax,1)
  jne    L7
  mov    %edx,(%r12)
  mov    $0x1,%eax
  jmp    L23
```

assistant: ```c
int waitForETX(int fd, unsigned char *buf, int *len) {
  static int pos, loop, val, dlen;
  pos = 2;
  loop = 0;
  dlen = -1;
  while (loop < 30) {
    val = bytesWaiting(fd);
    if (val > 0) {
      read(fd, &(buf[pos]), 1);
      pos++;
      if (pos > 5) {
        dlen = buf[5] + 9;
      }
      if (dlen > 0 && pos >= dlen) {
        if (buf[dlen - 2] == 0x1b && buf[dlen - 1] == 0x03) {
          *len = dlen;
          return (1);
        } else {
          return (0);
        }
      }
    } else {
      usleep(100);
      loop++;
    }
  }
  return (0);
}
```
user: What is the c source code of the assembly code below:

```asm
<strchr_nesc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  mov    %ecx,-0x28(%rbp)
  movl   $0x0,-0xc(%rbp)
  movq   $0x0,-0x8(%rbp)
  jmp    L43
L97:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x5c,%al
  jne    L87
  cmpl   $0x0,-0xc(%rbp)
  jne    L87
  movl   $0x1,-0xc(%rbp)
  jmp    L55
L87:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    %eax,-0x24(%rbp)
  jne    L95
  cmpl   $0x0,-0xc(%rbp)
  jne    L95
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  cmpl   $0x0,-0x28(%rbp)
  je     L113
L95:
  movl   $0x0,-0xc(%rbp)
L55:
  addq   $0x1,-0x18(%rbp)
  cmpq   $0xffffffffffffffff,-0x20(%rbp)
  je     L83
  mov    $0x1,%eax
  jmp    L22
L83:
  mov    $0x0,%eax
L22:
  sub    %rax,-0x20(%rbp)
L43:
  cmpq   $0x0,-0x20(%rbp)
  je     L103
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L97
  jmp    L103
L113:
  nop
L103:
  mov    -0x8(%rbp),%rax
  pop    %rbp
  ret
```

assistant: ```c
const char *strchr_nesc(const char *str, size_t len, int c, int last) {
  int esc = 0;
  const char *ret = 0;
  for (; len && *str; str++, len -= (len != (size_t)-1 ? 1 : 0)) {
    if (*str == '\\' && !esc) {
      esc = 1;
      continue;
    }
    if (*str == c && !esc) {
      ret = str;
      if (!last)
        break;
    }
    esc = 0;
  }
  return ret;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<strchr_nesc>:
  endbr64
  mov    $0x0,%r10d
  mov    $0x0,%r8d
  mov    $0x0,%r9d
  mov    $0x1,%r11d
  test   %rsi,%rsi
  jne    L91
  jmp    L51
L26:
  mov    %r11d,%r8d
  jmp    L19
L79:
  mov    %r9d,%r8d
L19:
  add    $0x1,%rdi
  cmp    $0xffffffffffffffff,%rsi
  setne  %al
  movzbl %al,%eax
  sub    %rax,%rsi
  je     L51
L91:
  movzbl (%rdi),%eax
  test   %al,%al
  je     L51
  test   %r8d,%r8d
  sete   %r8b
  cmp    $0x5c,%al
  jne    L13
  test   %r8b,%r8b
  jne    L26
L13:
  movsbl %al,%eax
  cmp    %edx,%eax
  jne    L79
  test   %r8b,%r8b
  je     L79
  test   %ecx,%ecx
  je     L96
  mov    %rdi,%r10
  mov    %r9d,%r8d
  jmp    L19
L96:
  mov    %rdi,%r10
L51:
  mov    %r10,%rax
  ret
```

assistant: ```c
const char *strchr_nesc(const char *str, size_t len, int c, int last) {
  int esc = 0;
  const char *ret = 0;
  for (; len && *str; str++, len -= (len != (size_t)-1 ? 1 : 0)) {
    if (*str == '\\' && !esc) {
      esc = 1;
      continue;
    }
    if (*str == c && !esc) {
      ret = str;
      if (!last)
        break;
    }
    esc = 0;
  }
  return ret;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<strchr_nesc>:
  endbr64
  xor    %r10d,%r10d
  xor    %r8d,%r8d
  mov    $0x1,%r9d
  test   %rsi,%rsi
  jne    L49
  jmp    L66
  nopw   0x0(%rax,%rax,1)
L76:
  cmp    %edx,%eax
  jne    L40
  and    $0x1,%r8d
  je     L50
L40:
  xor    %r8d,%r8d
L23:
  xor    %eax,%eax
  add    $0x1,%rdi
  cmp    $0xffffffffffffffff,%rsi
  setne  %al
  sub    %rax,%rsi
  je     L66
L49:
  movsbl (%rdi),%eax
  test   %al,%al
  je     L66
  cmp    $0x5c,%al
  jne    L76
  mov    %r9d,%eax
  sub    %r8d,%eax
  mov    %eax,%r8d
  jmp    L23
  nopl   (%rax)
L50:
  mov    %rdi,%r10
  test   %ecx,%ecx
  jne    L40
L66:
  mov    %r10,%rax
  ret
```

assistant: ```c
const char *strchr_nesc(const char *str, size_t len, int c, int last) {
  int esc = 0;
  const char *ret = 0;
  for (; len && *str; str++, len -= (len != (size_t)-1 ? 1 : 0)) {
    if (*str == '\\' && !esc) {
      esc = 1;
      continue;
    }
    if (*str == c && !esc) {
      ret = str;
      if (!last)
        break;
    }
    esc = 0;
  }
  return ret;
}
```