ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<push_cigar>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbp
  mov    %rsi,%r9
  mov    %rdx,%rdi
  mov    %ecx,%r12d
  mov    %r8d,%ebx
  mov    0x0(%rbp),%eax
  test   %eax,%eax
  je     L7
  movslq %eax,%rdx
  lea    -0x4(%rdi,%rdx,4),%rdx
  mov    (%rdx),%ecx
  mov    %ecx,%esi
  and    $0xf,%esi
  cmp    %r12d,%esi
  je     L23
L7:
  mov    (%r9),%edx
  cmp    %edx,%eax
  je     L19
L29:
  mov    0x0(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,0x0(%rbp)
  cltq
  shl    $0x4,%ebx
  or     %r12d,%ebx
  mov    %ebx,(%rdi,%rax,4)
  mov    %rdi,%rax
L17:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L19:
  lea    (%rdx,%rdx,1),%esi
  test   %edx,%edx
  mov    $0x4,%eax
  cmove  %eax,%esi
  mov    %esi,(%r9)
  shl    $0x2,%esi
  call   <realloc@plt>
  mov    %rax,%rdi
  jmp    L29
L23:
  shl    $0x4,%ebx
  add    %ecx,%ebx
  mov    %ebx,(%rdx)
  mov    %rdi,%rax
  jmp    L17
```

assistant: ```c
uint32_t *push_cigar(int *n_cigar, int *m_cigar, uint32_t *cigar, int op, int len) {
  if (*n_cigar == 0 || op != (cigar[(*n_cigar) - 1] & 0xf)) {
    if (*n_cigar == *m_cigar) {
      *m_cigar = *m_cigar ? (*m_cigar) << 1 : 4;
      cigar = (uint32_t *)realloc(cigar, (*m_cigar) << 2);
    }
    cigar[(*n_cigar)++] = len << 4 | op;
  } else
    cigar[(*n_cigar) - 1] += len << 4;
  return cigar;
}
```
user: What is the c source code of the assembly code below:

```asm
<push_cigar>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  mov    %rsi,%rdi
  shl    $0x4,%r8d
  movslq (%r12),%rsi
  push   %rbp
  mov    %rdx,%rax
  mov    %r8d,%ebp
  push   %rbx
  mov    %ecx,%ebx
  test   %esi,%esi
  je     L44
  movslq %esi,%rdx
  lea    -0x4(%rax,%rdx,4),%rcx
  mov    (%rcx),%edx
  mov    %edx,%r8d
  and    $0xf,%r8d
  cmp    %ebx,%r8d
  je     L9
L44:
  cmp    (%rdi),%esi
  je     L8
L43:
  or     %ebp,%ebx
  lea    0x1(%rsi),%edx
  mov    %edx,(%r12)
  mov    %ebx,(%rax,%rsi,4)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   (%rax)
L8:
  test   %esi,%esi
  jne    L10
  mov    $0x10,%esi
  mov    $0x4,%edx
L21:
  mov    %edx,(%rdi)
  mov    %rax,%rdi
  call   <realloc@plt>
  movslq (%r12),%rsi
  jmp    L43
  xchg   %ax,%ax
L9:
  add    %ebp,%edx
  mov    %edx,(%rcx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L10:
  lea    (%rsi,%rsi,1),%edx
  shl    $0x3,%esi
  jmp    L21
```

assistant: ```c
uint32_t *push_cigar(int *n_cigar, int *m_cigar, uint32_t *cigar, int op, int len) {
  if (*n_cigar == 0 || op != (cigar[(*n_cigar) - 1] & 0xf)) {
    if (*n_cigar == *m_cigar) {
      *m_cigar = *m_cigar ? (*m_cigar) << 1 : 4;
      cigar = (uint32_t *)realloc(cigar, (*m_cigar) << 2);
    }
    cigar[(*n_cigar)++] = len << 4 | op;
  } else
    cigar[(*n_cigar) - 1] += len << 4;
  return cigar;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<push_cigar>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  mov    %rsi,%rdi
  shl    $0x4,%r8d
  movslq (%r12),%rsi
  push   %rbp
  mov    %rdx,%rax
  mov    %r8d,%ebp
  push   %rbx
  mov    %ecx,%ebx
  test   %esi,%esi
  je     L48
  movslq %esi,%rdx
  lea    -0x4(%rax,%rdx,4),%rcx
  mov    (%rcx),%edx
  mov    %edx,%r8d
  and    $0xf,%r8d
  cmp    %ebx,%r8d
  je     L16
L48:
  cmp    (%rdi),%esi
  je     L26
L25:
  or     %ebp,%ebx
  lea    0x1(%rsi),%edx
  mov    %edx,(%r12)
  mov    %ebx,(%rax,%rsi,4)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   (%rax)
L26:
  test   %esi,%esi
  jne    L14
  mov    $0x10,%esi
  mov    $0x4,%edx
L0:
  mov    %edx,(%rdi)
  mov    %rax,%rdi
  call   <realloc@plt>
  movslq (%r12),%rsi
  jmp    L25
  xchg   %ax,%ax
L16:
  add    %ebp,%edx
  mov    %edx,(%rcx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L14:
  lea    (%rsi,%rsi,1),%edx
  shl    $0x3,%esi
  jmp    L0
```

assistant: ```c
uint32_t *push_cigar(int *n_cigar, int *m_cigar, uint32_t *cigar, int op, int len) {
  if (*n_cigar == 0 || op != (cigar[(*n_cigar) - 1] & 0xf)) {
    if (*n_cigar == *m_cigar) {
      *m_cigar = *m_cigar ? (*m_cigar) << 1 : 4;
      cigar = (uint32_t *)realloc(cigar, (*m_cigar) << 2);
    }
    cigar[(*n_cigar)++] = len << 4 | op;
  } else
    cigar[(*n_cigar) - 1] += len << 4;
  return cigar;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<getmodmask>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    $0x53,%eax
  je     L58
  cmp    $0x53,%eax
  jg     L22
  cmp    $0x43,%eax
  je     L70
  cmp    $0x4d,%eax
  je     L31
  jmp    L22
L70:
  mov    D8(%rip),%rax
  mov    (%rax),%eax
  jmp    L61
L58:
  mov    D4(%rip),%rax
  mov    (%rax),%eax
  jmp    L61
L31:
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <getmodnumber@plt>
  jmp    L61
L22:
  mov    $0x0,%eax
L61:
  leave
  ret
```

assistant: ```c
unsigned int getmodmask(char *c) {
  switch (c[0]) {
  case 'C':
    return ControlMask;
  case 'S':
    return ShiftMask;
  case 'M':
    return getmodnumber(c[1]);
  default:
    return 0;
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<getmodmask>:
  endbr64
  movzbl (%rdi),%edx
  cmp    $0x4d,%dl
  je     L1
  cmp    $0x53,%dl
  je     L8
  mov    $0x0,%eax
  cmp    $0x43,%dl
  je     L6
  ret
L6:
  mov    D12(%rip),%rax
  mov    (%rax),%eax
  ret
L8:
  mov    D7(%rip),%rax
  mov    (%rax),%eax
  ret
L1:
  sub    $0x8,%rsp
  movsbl 0x1(%rdi),%edi
  call   <getmodnumber@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
unsigned int getmodmask(char *c) {
  switch (c[0]) {
  case 'C':
    return ControlMask;
  case 'S':
    return ShiftMask;
  case 'M':
    return getmodnumber(c[1]);
  default:
    return 0;
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<getmodmask>:
  endbr64
  movzbl (%rdi),%eax
  cmp    $0x4d,%al
  je     L14
  cmp    $0x53,%al
  je     L8
  xor    %r8d,%r8d
  cmp    $0x43,%al
  je     L11
  mov    %r8d,%eax
  ret
  nopw   0x0(%rax,%rax,1)
L14:
  movsbl 0x1(%rdi),%edi
  jmp    1050 <getmodnumber@plt>
  nopl   0x0(%rax)
L11:
  mov    D14(%rip),%rax
  mov    (%rax),%r8d
  mov    %r8d,%eax
  ret
  xchg   %ax,%ax
L8:
  mov    D16(%rip),%rax
  mov    (%rax),%r8d
  mov    %r8d,%eax
  ret
```

assistant: ```c
unsigned int getmodmask(char *c) {
  switch (c[0]) {
  case 'C':
    return ControlMask;
  case 'S':
    return ShiftMask;
  case 'M':
    return getmodnumber(c[1]);
  default:
    return 0;
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<getmodmask>:
  endbr64
  movzbl (%rdi),%eax
  cmp    $0x4d,%al
  je     L29
  cmp    $0x53,%al
  je     L23
  xor    %r8d,%r8d
  cmp    $0x43,%al
  je     L0
  mov    %r8d,%eax
  ret
  nopw   0x0(%rax,%rax,1)
L29:
  movsbl 0x1(%rdi),%edi
  jmp    1050 <getmodnumber@plt>
  nopl   0x0(%rax)
L0:
  mov    D17(%rip),%rax
  mov    (%rax),%r8d
  mov    %r8d,%eax
  ret
  xchg   %ax,%ax
L23:
  mov    D13(%rip),%rax
  mov    (%rax),%r8d
  mov    %r8d,%eax
  ret
```

assistant: ```c
unsigned int getmodmask(char *c) {
  switch (c[0]) {
  case 'C':
    return ControlMask;
  case 'S':
    return ShiftMask;
  case 'M':
    return getmodnumber(c[1]);
  default:
    return 0;
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<samplebinsearch>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x28(%rbp)
  mov    -0x28(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x10(%rbp)
  mov    -0x10(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  mov    $0x0,%esi
  movq   %rdx,%xmm0
  mov    %eax,%edi
  call   <ighmm_rand_uniform_cont@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x1c(%rbp)
  mov    -0x28(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x18(%rbp)
L60:
  mov    -0x1c(%rbp),%edx
  mov    -0x18(%rbp),%eax
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  -0x8(%rbp),%xmm0
  comisd %xmm1,%xmm0
  jbe    L30
  mov    -0x1c(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jne    L53
  mov    -0x18(%rbp),%eax
  jmp    L58
L53:
  mov    -0x14(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
  jmp    L60
L30:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  comisd -0x8(%rbp),%xmm0
  jbe    L79
  mov    -0x1c(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jne    L72
  mov    -0x1c(%rbp),%eax
  jmp    L58
L72:
  mov    -0x14(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  jmp    L60
L79:
  mov    -0x14(%rbp),%eax
L58:
  leave
  ret
```

assistant: ```c
int samplebinsearch(int seed, double *distribution, int N) {
  double total = distribution[N - 1];
  double rn = ighmm_rand_uniform_cont(seed, total, 0);
  int l = 0;
  int r = N - 1;
  int m;
  while (1) {
    m = (l + r) >> 1;
    if (distribution[m] < rn) {
      if (l == m)
        return r;
      else
        l = m;
    } else if (distribution[m] > rn) {
      if (l == m)
        return l;
      else
        r = m;
    } else {
      return m;
    }
  }
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<samplebinsearch>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rsi,%rbx
  mov    %edx,%ebp
  movslq %edx,%rax
  movsd  -0x8(%rsi,%rax,8),%xmm0
  mov    $0x0,%esi
  call   <ighmm_rand_uniform_cont@plt>
  lea    -0x1(%rbp),%esi
  mov    $0x0,%edx
  jmp    L56
L35:
  comisd %xmm0,%xmm1
  jbe    L52
  cmp    %eax,%edx
  je     L52
  mov    %eax,%esi
L56:
  lea    (%rdx,%rsi,1),%eax
  sar    %eax
  movslq %eax,%rcx
  movsd  (%rbx,%rcx,8),%xmm1
  comisd %xmm1,%xmm0
  jbe    L35
  cmp    %eax,%edx
  je     L50
  mov    %eax,%edx
  jmp    L56
L50:
  mov    %esi,%eax
L52:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
int samplebinsearch(int seed, double *distribution, int N) {
  double total = distribution[N - 1];
  double rn = ighmm_rand_uniform_cont(seed, total, 0);
  int l = 0;
  int r = N - 1;
  int m;
  while (1) {
    m = (l + r) >> 1;
    if (distribution[m] < rn) {
      if (l == m)
        return r;
      else
        l = m;
    } else if (distribution[m] > rn) {
      if (l == m)
        return l;
      else
        r = m;
    } else {
      return m;
    }
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<samplebinsearch>:
  endbr64
  push   %rbp
  movslq %edx,%rax
  mov    %rsi,%rbp
  push   %rbx
  mov    %rax,%rbx
  sub    $0x8,%rsp
  movsd  -0x8(%rsi,%rax,8),%xmm0
  xor    %esi,%esi
  call   <ighmm_rand_uniform_cont@plt>
  lea    -0x1(%rbx),%esi
  xor    %edx,%edx
  nopl   (%rax)
L51:
  lea    (%rdx,%rsi,1),%eax
  sar    %eax
  movslq %eax,%rcx
  movsd  0x0(%rbp,%rcx,8),%xmm1
  comisd %xmm1,%xmm0
  jbe    L4
  cmp    %eax,%edx
  je     L20
  mov    %eax,%edx
  jmp    L51
  nopl   0x0(%rax)
L4:
  comisd %xmm0,%xmm1
  jbe    L28
  cmp    %eax,%edx
  je     L28
  mov    %eax,%esi
  jmp    L51
  cs nopw 0x0(%rax,%rax,1)
L20:
  mov    %esi,%eax
L28:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
int samplebinsearch(int seed, double *distribution, int N) {
  double total = distribution[N - 1];
  double rn = ighmm_rand_uniform_cont(seed, total, 0);
  int l = 0;
  int r = N - 1;
  int m;
  while (1) {
    m = (l + r) >> 1;
    if (distribution[m] < rn) {
      if (l == m)
        return r;
      else
        l = m;
    } else if (distribution[m] > rn) {
      if (l == m)
        return l;
      else
        r = m;
    } else {
      return m;
    }
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<samplebinsearch>:
  endbr64
  push   %rbp
  movslq %edx,%rax
  mov    %rsi,%rbp
  push   %rbx
  mov    %rax,%rbx
  sub    $0x8,%rsp
  movsd  -0x8(%rsi,%rax,8),%xmm0
  xor    %esi,%esi
  call   <ighmm_rand_uniform_cont@plt>
  lea    -0x1(%rbx),%esi
  xor    %edx,%edx
  nopl   (%rax)
L47:
  lea    (%rdx,%rsi,1),%eax
  sar    %eax
  movslq %eax,%rcx
  movsd  0x0(%rbp,%rcx,8),%xmm1
  comisd %xmm1,%xmm0
  jbe    L28
  cmp    %eax,%edx
  je     L48
  mov    %eax,%edx
  jmp    L47
  nopl   0x0(%rax)
L28:
  comisd %xmm0,%xmm1
  jbe    L58
  cmp    %eax,%edx
  je     L58
  mov    %eax,%esi
  jmp    L47
  cs nopw 0x0(%rax,%rax,1)
L48:
  mov    %esi,%eax
L58:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
int samplebinsearch(int seed, double *distribution, int N) {
  double total = distribution[N - 1];
  double rn = ighmm_rand_uniform_cont(seed, total, 0);
  int l = 0;
  int r = N - 1;
  int m;
  while (1) {
    m = (l + r) >> 1;
    if (distribution[m] < rn) {
      if (l == m)
        return r;
      else
        l = m;
    } else if (distribution[m] > rn) {
      if (l == m)
        return l;
      else
        r = m;
    } else {
      return m;
    }
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<udp_read_timeout>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %ecx,-0x38(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x0,-0x38(%rbp)
  setg   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x34(%rbp),%eax
  mov    %eax,-0x20(%rbp)
  mov    D34(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x10(%rbp)
  movq   $0x0,-0x18(%rbp)
  mov    -0x38(%rbp),%edx
  lea    -0x20(%rbp),%rax
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <poll@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  jne    L37
  mov    -0x48(%rbp),%rax
  movq   $0x0,(%rax)
  mov    D11(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L67
L37:
  mov    D32(%rip),%rax
  mov    (%rax),%edx
  mov    -0x40(%rbp),%rsi
  mov    -0x34(%rbp),%eax
  mov    %edx,%ecx
  mov    $0x2000,%edx
  mov    %eax,%edi
  call   <recv@plt>
  mov    -0x48(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  cmp    $0xffffffffffffffff,%rax
  jne    L20
  mov    D14(%rip),%rax
  mov    (%rax),%eax
  jmp    L67
L20:
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L13
  mov    D0(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L67
L13:
  mov    $0x0,%eax
L67:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L57
  call   <__stack_chk_fail@plt>
L57:
  leave
  ret
```

assistant: ```c
int udp_read_timeout(int fd, void *buf, size_t *len, int timeout_ms) {
  int x;
  struct pollfd fds;
  assert(timeout_ms > 0);
  fds.fd = fd;
  fds.events = POLLIN;
  fds.revents = 0;
  x = poll(&fds, 1, timeout_ms);
  if (x == 0) {
    *len = 0;
    return -ETIMEDOUT;
  }
  *len = recv(fd, buf, 8192, MSG_DONTWAIT);
  if (*len == -1)
    return errno;
  if (*len == 0)
    return -ECONNRESET;
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<udp_read_timeout>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,%ebp
  mov    %rsi,%r13
  mov    %rdx,%r12
  mov    %ecx,%ebx
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %ecx,%ecx
  setg   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    %ebp,(%rsp)
  mov    D37(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,0x10(%rsp)
  movq   $0x0,0x8(%rsp)
  mov    %rsp,%rdi
  mov    %ebx,%edx
  mov    $0x1,%esi
  call   <poll@plt>
  test   %eax,%eax
  jne    L11
  movq   $0x0,(%r12)
  mov    D13(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
L58:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L53
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L11:
  mov    D21(%rip),%rax
  mov    (%rax),%ecx
  mov    $0x2000,%edx
  mov    %r13,%rsi
  mov    %ebp,%edi
  call   <recv@plt>
  mov    %rax,%rdx
  mov    %rax,(%r12)
  cmp    $0xffffffffffffffff,%rax
  je     L44
  mov    $0x0,%eax
  test   %rdx,%rdx
  jne    L58
  mov    D7(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L58
L44:
  mov    D41(%rip),%rax
  mov    (%rax),%eax
  jmp    L58
L53:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int udp_read_timeout(int fd, void *buf, size_t *len, int timeout_ms) {
  int x;
  struct pollfd fds;
  assert(timeout_ms > 0);
  fds.fd = fd;
  fds.events = POLLIN;
  fds.revents = 0;
  x = poll(&fds, 1, timeout_ms);
  if (x == 0) {
    *len = 0;
    return -ETIMEDOUT;
  }
  *len = recv(fd, buf, 8192, MSG_DONTWAIT);
  if (*len == -1)
    return errno;
  if (*len == 0)
    return -ECONNRESET;
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<udp_read_timeout>:
  endbr64
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %ecx,%r12d
  push   %rbp
  mov    %edi,%ebp
  xor    %edi,%edi
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %ecx,%ecx
  setg   %dil
  call   <assert@plt>
  mov    %rsp,%rdi
  mov    %r12d,%edx
  mov    $0x1,%esi
  mov    D16(%rip),%rax
  mov    %ebp,(%rsp)
  movq   $0x0,0x8(%rsp)
  mov    (%rax),%eax
  mov    %eax,0x10(%rsp)
  call   <poll@plt>
  test   %eax,%eax
  jne    L52
  mov    D36(%rip),%rax
  movq   $0x0,(%rbx)
  mov    (%rax),%eax
  neg    %eax
L10:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L54
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L52:
  mov    D41(%rip),%rax
  mov    $0x2000,%edx
  mov    %r13,%rsi
  mov    %ebp,%edi
  mov    (%rax),%ecx
  call   <recv@plt>
  mov    %rax,(%rbx)
  mov    %rax,%rdx
  cmp    $0xffffffffffffffff,%rax
  je     L15
  xor    %eax,%eax
  test   %rdx,%rdx
  jne    L10
  mov    D17(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L10
  nopl   0x0(%rax,%rax,1)
L15:
  mov    D45(%rip),%rax
  mov    (%rax),%eax
  jmp    L10
L54:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int udp_read_timeout(int fd, void *buf, size_t *len, int timeout_ms) {
  int x;
  struct pollfd fds;
  assert(timeout_ms > 0);
  fds.fd = fd;
  fds.events = POLLIN;
  fds.revents = 0;
  x = poll(&fds, 1, timeout_ms);
  if (x == 0) {
    *len = 0;
    return -ETIMEDOUT;
  }
  *len = recv(fd, buf, 8192, MSG_DONTWAIT);
  if (*len == -1)
    return errno;
  if (*len == 0)
    return -ECONNRESET;
  return 0;
}
```
user: What is the c source code of the assembly code below:

```asm
<udp_read_timeout>:
  endbr64
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %ecx,%r12d
  push   %rbp
  mov    %edi,%ebp
  xor    %edi,%edi
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %ecx,%ecx
  setg   %dil
  call   <assert@plt>
  mov    %rsp,%rdi
  mov    %r12d,%edx
  mov    $0x1,%esi
  mov    D36(%rip),%rax
  mov    %ebp,(%rsp)
  movq   $0x0,0x8(%rsp)
  mov    (%rax),%eax
  mov    %eax,0x10(%rsp)
  call   <poll@plt>
  test   %eax,%eax
  jne    L29
  mov    D35(%rip),%rax
  movq   $0x0,(%rbx)
  mov    (%rax),%eax
  neg    %eax
L3:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L53
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L29:
  mov    D34(%rip),%rax
  mov    $0x2000,%edx
  mov    %r13,%rsi
  mov    %ebp,%edi
  mov    (%rax),%ecx
  call   <recv@plt>
  mov    %rax,(%rbx)
  mov    %rax,%rdx
  cmp    $0xffffffffffffffff,%rax
  je     L40
  xor    %eax,%eax
  test   %rdx,%rdx
  jne    L3
  mov    D6(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L3
  nopl   0x0(%rax,%rax,1)
L40:
  mov    D23(%rip),%rax
  mov    (%rax),%eax
  jmp    L3
L53:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int udp_read_timeout(int fd, void *buf, size_t *len, int timeout_ms) {
  int x;
  struct pollfd fds;
  assert(timeout_ms > 0);
  fds.fd = fd;
  fds.events = POLLIN;
  fds.revents = 0;
  x = poll(&fds, 1, timeout_ms);
  if (x == 0) {
    *len = 0;
    return -ETIMEDOUT;
  }
  *len = recv(fd, buf, 8192, MSG_DONTWAIT);
  if (*len == -1)
    return errno;
  if (*len == 0)
    return -ECONNRESET;
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<YGParseValue>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rax
  movzbl (%rax),%eax
  mov    %al,-0x5(%rbp)
  movl   $0x0,-0x4(%rbp)
  cmpb   $0x1f,-0x5(%rbp)
  ja     L35
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rax
  lea    0x1(%rax),%rcx
  mov    -0x18(%rbp),%rdx
  mov    %rcx,(%rdx)
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  shl    $0x8,%eax
  mov    %eax,-0x4(%rbp)
L35:
  cmpb   $0x3f,-0x5(%rbp)
  ja     L46
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rax
  lea    0x1(%rax),%rcx
  mov    -0x18(%rbp),%rdx
  mov    %rcx,(%rdx)
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  shl    $0x8,%eax
  mov    %eax,-0x4(%rbp)
L46:
  movzbl -0x5(%rbp),%eax
  test   %al,%al
  js     L39
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rax
  lea    0x1(%rax),%rcx
  mov    -0x18(%rbp),%rdx
  mov    %rcx,(%rdx)
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  shl    $0x8,%eax
  mov    %eax,-0x4(%rbp)
L39:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rax
  lea    0x1(%rax),%rcx
  mov    -0x18(%rbp),%rdx
  mov    %rcx,(%rdx)
  movzbl (%rax),%eax
  movzbl %al,%eax
  add    %eax,-0x4(%rbp)
  movzbl -0x5(%rbp),%eax
  test   %al,%al
  jns    L107
  mov    -0x4(%rbp),%eax
  add    $0xffffff80,%eax
  jmp    L7
L107:
  cmpb   $0x3f,-0x5(%rbp)
  jbe    L41
  mov    -0x4(%rbp),%eax
  sub    $0x4000,%eax
  jmp    L7
L41:
  cmpb   $0x1f,-0x5(%rbp)
  jbe    L67
  mov    -0x4(%rbp),%eax
  sub    $0x200000,%eax
  jmp    L7
L67:
  cmpb   $0xf,-0x5(%rbp)
  jbe    L89
  mov    -0x4(%rbp),%eax
  sub    $0x10000000,%eax
  jmp    L7
L89:
  mov    $0x0,%eax
L7:
  pop    %rbp
  ret
```

assistant: ```c
int YGParseValue(const unsigned char **data) {
  unsigned char c = **data;
  int result = 0;
  if (c < 0x20)
    result = (result + *(*data)++) << 8;
  if (c < 0x40)
    result = (result + *(*data)++) << 8;
  if (c < 0x80)
    result = (result + *(*data)++) << 8;
  result += *(*data)++;
  if (c >= 0x80)
    return result - 0x80;
  if (c >= 0x40)
    return result - 0x4000;
  if (c >= 0x20)
    return result - 0x200000;
  if (c >= 0x10)
    return result - 0x10000000;
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<YGParseValue>:
  endbr64
  mov    %rdi,%rax
  mov    (%rdi),%rdx
  movzbl (%rdx),%ecx
  cmp    $0x1f,%cl
  ja     L15
  lea    0x1(%rdx),%rsi
  mov    %rsi,(%rdi)
  movzbl (%rdx),%esi
  shl    $0x8,%esi
L34:
  mov    (%rax),%rdx
  lea    0x1(%rdx),%r8
  mov    %r8,(%rax)
  movzbl (%rdx),%edi
  add    %esi,%edi
  lea    0x2(%rdx),%rsi
  mov    %rsi,(%rax)
  movzbl 0x1(%rdx),%esi
  shl    $0x8,%edi
  add    %edi,%esi
  shl    $0x8,%esi
  add    $0x3,%rdx
  mov    %rdx,(%rax)
  movzbl 0x1(%r8),%eax
  add    %esi,%eax
  cmp    $0x3f,%cl
  ja     L16
  cmp    $0x1f,%cl
  ja     L21
  sub    $0x10000000,%eax
  cmp    $0xf,%cl
  mov    $0x0,%edx
  cmovbe %edx,%eax
  ret
L15:
  cmp    $0x3f,%cl
  jbe    L1
  test   %cl,%cl
  jns    L54
  lea    0x1(%rdx),%rcx
  mov    %rcx,(%rdi)
  movzbl (%rdx),%eax
  add    $0xffffff80,%eax
  ret
L1:
  mov    $0x0,%esi
  jmp    L34
L21:
  sub    $0x200000,%eax
  ret
L54:
  mov    (%rdi),%rdx
  lea    0x1(%rdx),%rcx
  mov    %rcx,(%rdi)
  movzbl (%rdx),%ecx
  shl    $0x8,%ecx
  lea    0x2(%rdx),%rsi
  mov    %rsi,(%rdi)
  movzbl 0x1(%rdx),%eax
  add    %ecx,%eax
L16:
  sub    $0x4000,%eax
  ret
```

assistant: ```c
int YGParseValue(const unsigned char **data) {
  unsigned char c = **data;
  int result = 0;
  if (c < 0x20)
    result = (result + *(*data)++) << 8;
  if (c < 0x40)
    result = (result + *(*data)++) << 8;
  if (c < 0x80)
    result = (result + *(*data)++) << 8;
  result += *(*data)++;
  if (c >= 0x80)
    return result - 0x80;
  if (c >= 0x40)
    return result - 0x4000;
  if (c >= 0x20)
    return result - 0x200000;
  if (c >= 0x10)
    return result - 0x10000000;
  return 0;
}
```