ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 这段汇编代码用C语言表示是什么样的?

```asm
<GenReadCRegIndirect>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    $0x0,%r9d
  mov    $0x3,%r8d
  mov    $0x0,%ecx
  mov    $0x4,%edx
  mov    $0x0,%esi
  mov    $0x0,%edi
  call   <GenPrintInstr2Operands@plt>
  cmpl   $0xffffffff,-0x4(%rbp)
  jne    L30
  mov    $0x0,%r9d
  mov    $0x1b,%r8d
  mov    $0x0,%ecx
  mov    $0x5,%edx
  mov    $0x0,%esi
  mov    $0x1,%edi
  call   <GenPrintInstr2Operands@plt>
  jmp    L8
L30:
  cmpl   $0x1,-0x4(%rbp)
  jne    L2
  mov    $0x0,%r9d
  mov    $0x1b,%r8d
  mov    $0x0,%ecx
  mov    $0x5,%edx
  mov    $0x0,%esi
  mov    $0x2,%edi
  call   <GenPrintInstr2Operands@plt>
  jmp    L8
L2:
  mov    $0x0,%r9d
  mov    $0x1a,%r8d
  mov    $0x0,%ecx
  mov    $0x5,%edx
  mov    $0x0,%esi
  mov    $0x0,%edi
  call   <GenPrintInstr2Operands@plt>
L8:
  nop
  leave
  ret
```

assistant: ```c
void GenReadCRegIndirect(int opSz) {
  GenPrintInstr2Operands(0x00, 0, 0x04, 0, 0x03, 0);
  if (opSz == -1)
    GenPrintInstr2Operands(0x01, 0, 0x05, 0, 0x1B, 0);
  else if (opSz == 1)
    GenPrintInstr2Operands(0x02, 0, 0x05, 0, 0x1B, 0);
  else
    GenPrintInstr2Operands(0x00, 0, 0x05, 0, 0x1A, 0);
}
```
user: Translate the below assembly code into C programming language:

```asm
<GenReadCRegIndirect>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  mov    $0x0,%r9d
  mov    $0x3,%r8d
  mov    $0x0,%ecx
  mov    $0x4,%edx
  mov    $0x0,%esi
  mov    $0x0,%edi
  call   <GenPrintInstr2Operands@plt>
  cmp    $0xffffffff,%ebx
  je     L16
  cmp    $0x1,%ebx
  je     L18
  mov    $0x0,%r9d
  mov    $0x1a,%r8d
  mov    $0x0,%ecx
  mov    $0x5,%edx
  mov    $0x0,%esi
  mov    $0x0,%edi
  call   <GenPrintInstr2Operands@plt>
L39:
  pop    %rbx
  ret
L16:
  mov    $0x0,%r9d
  mov    $0x1b,%r8d
  mov    $0x0,%ecx
  mov    $0x5,%edx
  mov    $0x0,%esi
  mov    $0x1,%edi
  call   <GenPrintInstr2Operands@plt>
  jmp    L39
L18:
  mov    $0x0,%r9d
  mov    $0x1b,%r8d
  mov    $0x0,%ecx
  mov    $0x5,%edx
  mov    $0x0,%esi
  mov    $0x2,%edi
  call   <GenPrintInstr2Operands@plt>
  jmp    L39
```

assistant: ```c
void GenReadCRegIndirect(int opSz) {
  GenPrintInstr2Operands(0x00, 0, 0x04, 0, 0x03, 0);
  if (opSz == -1)
    GenPrintInstr2Operands(0x01, 0, 0x05, 0, 0x1B, 0);
  else if (opSz == 1)
    GenPrintInstr2Operands(0x02, 0, 0x05, 0, 0x1B, 0);
  else
    GenPrintInstr2Operands(0x00, 0, 0x05, 0, 0x1A, 0);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<GenReadCRegIndirect>:
  endbr64
  push   %rbx
  xor    %r9d,%r9d
  mov    %edi,%ebx
  mov    $0x3,%r8d
  xor    %ecx,%ecx
  mov    $0x4,%edx
  xor    %esi,%esi
  xor    %edi,%edi
  call   <GenPrintInstr2Operands@plt>
  xor    %r9d,%r9d
  cmp    $0xffffffff,%ebx
  je     L8
  cmp    $0x1,%ebx
  je     L4
  mov    $0x1a,%r8d
  xor    %ecx,%ecx
  mov    $0x5,%edx
  xor    %esi,%esi
  xor    %edi,%edi
  pop    %rbx
  jmp    1050 <GenPrintInstr2Operands@plt>
  nopl   0x0(%rax)
L4:
  mov    $0x1b,%r8d
  xor    %ecx,%ecx
  mov    $0x5,%edx
  xor    %esi,%esi
  mov    $0x2,%edi
  pop    %rbx
  jmp    1050 <GenPrintInstr2Operands@plt>
  nopw   0x0(%rax,%rax,1)
L8:
  mov    $0x1b,%r8d
  xor    %ecx,%ecx
  mov    $0x5,%edx
  xor    %esi,%esi
  mov    $0x1,%edi
  pop    %rbx
  jmp    1050 <GenPrintInstr2Operands@plt>
```

assistant: ```c
void GenReadCRegIndirect(int opSz) {
  GenPrintInstr2Operands(0x00, 0, 0x04, 0, 0x03, 0);
  if (opSz == -1)
    GenPrintInstr2Operands(0x01, 0, 0x05, 0, 0x1B, 0);
  else if (opSz == 1)
    GenPrintInstr2Operands(0x02, 0, 0x05, 0, 0x1B, 0);
  else
    GenPrintInstr2Operands(0x00, 0, 0x05, 0, 0x1A, 0);
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<GenReadCRegIndirect>:
  endbr64
  push   %rbx
  xor    %r9d,%r9d
  mov    %edi,%ebx
  mov    $0x3,%r8d
  xor    %ecx,%ecx
  mov    $0x4,%edx
  xor    %esi,%esi
  xor    %edi,%edi
  call   <GenPrintInstr2Operands@plt>
  xor    %r9d,%r9d
  cmp    $0xffffffff,%ebx
  je     L13
  cmp    $0x1,%ebx
  je     L14
  mov    $0x1a,%r8d
  xor    %ecx,%ecx
  mov    $0x5,%edx
  xor    %esi,%esi
  xor    %edi,%edi
  pop    %rbx
  jmp    1050 <GenPrintInstr2Operands@plt>
  nopl   0x0(%rax)
L14:
  mov    $0x1b,%r8d
  xor    %ecx,%ecx
  mov    $0x5,%edx
  xor    %esi,%esi
  mov    $0x2,%edi
  pop    %rbx
  jmp    1050 <GenPrintInstr2Operands@plt>
  nopw   0x0(%rax,%rax,1)
L13:
  mov    $0x1b,%r8d
  xor    %ecx,%ecx
  mov    $0x5,%edx
  xor    %esi,%esi
  mov    $0x1,%edi
  pop    %rbx
  jmp    1050 <GenPrintInstr2Operands@plt>
```

assistant: ```c
void GenReadCRegIndirect(int opSz) {
  GenPrintInstr2Operands(0x00, 0, 0x04, 0, 0x03, 0);
  if (opSz == -1)
    GenPrintInstr2Operands(0x01, 0, 0x05, 0, 0x1B, 0);
  else if (opSz == 1)
    GenPrintInstr2Operands(0x02, 0, 0x05, 0, 0x1B, 0);
  else
    GenPrintInstr2Operands(0x00, 0, 0x05, 0, 0x1A, 0);
}
```
user: What is the c source code of the assembly code below?

```asm
<bitswap>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  movl   $0x0,-0x4(%rbp)
  movl   $0x0,-0x8(%rbp)
  jmp    L14
L3:
  mov    -0x8(%rbp),%eax
  mov    -0x14(%rbp),%edx
  mov    %eax,%ecx
  shr    %cl,%edx
  mov    %edx,%eax
  and    $0x1,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%eax
  sub    -0x8(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  or     %eax,-0x4(%rbp)
  addl   $0x1,-0x8(%rbp)
L14:
  mov    -0x8(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jb     L3
  mov    -0x4(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
unsigned bitswap(unsigned x, unsigned size_log2) {
  unsigned i;
  unsigned ret = 0;
  for (i = 0; i < size_log2; i++)
    ret |= ((x >> i) & 1) << (size_log2 - i - 1);
  return ret;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<bitswap>:
  endbr64
  test   %esi,%esi
  je     L25
  mov    $0x0,%r8d
  mov    $0x0,%edx
  lea    -0x1(%rsi),%r9d
L19:
  mov    %edi,%eax
  mov    %edx,%ecx
  shr    %cl,%eax
  and    $0x1,%eax
  mov    %r9d,%ecx
  sub    %edx,%ecx
  shl    %cl,%eax
  or     %eax,%r8d
  add    $0x1,%edx
  cmp    %edx,%esi
  jne    L19
L16:
  mov    %r8d,%eax
  ret
L25:
  mov    %esi,%r8d
  jmp    L16
```

assistant: ```c
unsigned bitswap(unsigned x, unsigned size_log2) {
  unsigned i;
  unsigned ret = 0;
  for (i = 0; i < size_log2; i++)
    ret |= ((x >> i) & 1) << (size_log2 - i - 1);
  return ret;
}
```
user: What is the c source code of the assembly code below:

```asm
<bitswap>:
  endbr64
  test   %esi,%esi
  je     L13
  lea    -0x1(%rsi),%r9d
  xor    %r8d,%r8d
  xor    %edx,%edx
  nopl   0x0(%rax)
L8:
  mov    %edx,%ecx
  mov    %edi,%eax
  shr    %cl,%eax
  mov    %r9d,%ecx
  sub    %edx,%ecx
  and    $0x1,%eax
  add    $0x1,%edx
  shl    %cl,%eax
  or     %eax,%r8d
  cmp    %edx,%esi
  jne    L8
  mov    %r8d,%eax
  ret
  cs nopw 0x0(%rax,%rax,1)
L13:
  xor    %r8d,%r8d
  mov    %r8d,%eax
  ret
```

assistant: ```c
unsigned bitswap(unsigned x, unsigned size_log2) {
  unsigned i;
  unsigned ret = 0;
  for (i = 0; i < size_log2; i++)
    ret |= ((x >> i) & 1) << (size_log2 - i - 1);
  return ret;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<bitswap>:
  endbr64
  test   %esi,%esi
  je     L4
  lea    -0x1(%rsi),%r9d
  xor    %r8d,%r8d
  xor    %edx,%edx
  nopl   0x0(%rax)
L19:
  mov    %edx,%ecx
  mov    %edi,%eax
  shr    %cl,%eax
  mov    %r9d,%ecx
  sub    %edx,%ecx
  and    $0x1,%eax
  add    $0x1,%edx
  shl    %cl,%eax
  or     %eax,%r8d
  cmp    %edx,%esi
  jne    L19
  mov    %r8d,%eax
  ret
  cs nopw 0x0(%rax,%rax,1)
L4:
  xor    %r8d,%r8d
  mov    %r8d,%eax
  ret
```

assistant: ```c
unsigned bitswap(unsigned x, unsigned size_log2) {
  unsigned i;
  unsigned ret = 0;
  for (i = 0; i < size_log2; i++)
    ret |= ((x >> i) & 1) << (size_log2 - i - 1);
  return ret;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<atol>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  movq   $0x0,-0x8(%rbp)
  movl   $0x1,-0xc(%rbp)
  jmp    L65
L3:
  addq   $0x1,-0x18(%rbp)
L65:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L3
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2d,%al
  jne    L10
  movl   $0xffffffff,-0xc(%rbp)
  addq   $0x1,-0x18(%rbp)
  jmp    L34
L10:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2b,%al
  jne    L34
  addq   $0x1,-0x18(%rbp)
  jmp    L34
L32:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L24
  mov    -0x8(%rbp),%rdx
  mov    %rdx,%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  add    %rax,%rax
  mov    %rax,%rdx
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  sub    $0x30,%eax
  cltq
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  jmp    L21
L24:
  mov    -0x8(%rbp),%rax
  jmp    L20
L21:
  addq   $0x1,-0x18(%rbp)
L34:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L32
  mov    -0x8(%rbp),%rax
L20:
  leave
  ret
```

assistant: ```c
long atol(const char *str) {
  long res = 0;
  int sign = 1;
  while (isspace(*str))
    str++;
  if (*str == '-') {
    sign = -1;
    str++;
  } else if (*str == '+') {
    str++;
  }
  for (; *str; str++) {
    if (isdigit(*str))
      res = res * 10 + (*str - '0');
    else
      return res;
  }
  return res;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<atol>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  jmp    L5
L49:
  add    $0x1,%rbx
L5:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  jne    L49
  movzbl (%rbx),%eax
  cmp    $0x2d,%al
  je     L32
  cmp    $0x2b,%al
  sete   %al
  movzbl %al,%eax
  add    %rax,%rbx
L31:
  movzbl (%rbx),%edi
  test   %dil,%dil
  je     L15
L45:
  movsbl %dil,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L15
  lea    0x0(%rbp,%rbp,4),%rdx
  movsbl (%rbx),%eax
  sub    $0x30,%eax
  cltq
  lea    (%rax,%rdx,2),%rbp
  add    $0x1,%rbx
  movzbl (%rbx),%edi
  test   %dil,%dil
  jne    L45
L15:
  mov    %rbp,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L32:
  add    $0x1,%rbx
  jmp    L31
```

assistant: ```c
long atol(const char *str) {
  long res = 0;
  int sign = 1;
  while (isspace(*str))
    str++;
  if (*str == '-') {
    sign = -1;
    str++;
  } else if (*str == '+') {
    str++;
  }
  for (; *str; str++) {
    if (isdigit(*str))
      res = res * 10 + (*str - '0');
    else
      return res;
  }
  return res;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<atol>:
  endbr64
  push   %r12
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  jmp    L26
L50:
  add    $0x1,%rbx
L26:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  mov    %rax,%r12
  test   %rax,%rax
  jne    L50
  movsbl (%rbx),%edi
  cmp    $0x2d,%dil
  je     L0
  cmp    $0x2b,%dil
  jne    L49
L0:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  je     L62
L11:
  call   <isdigit@plt>
  test   %rax,%rax
  je     L62
  movsbl (%rbx),%eax
  lea    (%r12,%r12,4),%rdx
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  sub    $0x30,%eax
  cltq
  lea    (%rax,%rdx,2),%r12
L49:
  test   %dil,%dil
  jne    L11
L62:
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %r12
  ret
```

assistant: ```c
long atol(const char *str) {
  long res = 0;
  int sign = 1;
  while (isspace(*str))
    str++;
  if (*str == '-') {
    sign = -1;
    str++;
  } else if (*str == '+') {
    str++;
  }
  for (; *str; str++) {
    if (isdigit(*str))
      res = res * 10 + (*str - '0');
    else
      return res;
  }
  return res;
}
```
user: What is the c source code of the assembly code below:

```asm
<atol>:
  endbr64
  push   %r12
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  jmp    L4
L21:
  add    $0x1,%rbx
L4:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  mov    %rax,%r12
  test   %rax,%rax
  jne    L21
  movsbl (%rbx),%edi
  cmp    $0x2d,%dil
  je     L55
  cmp    $0x2b,%dil
  jne    L24
L55:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  je     L45
L22:
  call   <isdigit@plt>
  test   %rax,%rax
  je     L45
  movsbl (%rbx),%eax
  lea    (%r12,%r12,4),%rdx
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  sub    $0x30,%eax
  cltq
  lea    (%rax,%rdx,2),%r12
L24:
  test   %dil,%dil
  jne    L22
L45:
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %r12
  ret
```

assistant: ```c
long atol(const char *str) {
  long res = 0;
  int sign = 1;
  while (isspace(*str))
    str++;
  if (*str == '-') {
    sign = -1;
    str++;
  } else if (*str == '+') {
    str++;
  }
  for (; *str; str++) {
    if (isdigit(*str))
      res = res * 10 + (*str - '0');
    else
      return res;
  }
  return res;
}
```
user: Translate the below assembly code into C programming language:

```asm
<tbh_read>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x18(%rbp)
  mov    -0x20(%rbp),%rcx
  mov    -0x14(%rbp),%eax
  mov    $0x2,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read_at_least@plt>
  cmp    $0x2,%eax
  je     L31
  mov    $0x0,%eax
  jmp    L21
L31:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <get_tbh_size@plt>
  mov    %eax,-0x8(%rbp)
  mov    -0x18(%rbp),%eax
  lea    -0x2(%rax),%edx
  mov    -0x8(%rbp),%eax
  cmp    %eax,%edx
  cmovg  %eax,%edx
  mov    -0x20(%rbp),%rax
  lea    0x2(%rax),%rcx
  mov    -0x14(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read_at_least@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  jne    L15
  mov    $0x0,%eax
  jmp    L21
L15:
  mov    -0x4(%rbp),%eax
  add    $0x2,%eax
L21:
  leave
  ret
```

assistant: ```c
int tbh_read(int fd, char buf[], int buffsize) {
  int remaining, msgsize;
  if (read_at_least(fd, buf, 2) != 2)
    return 0;
  remaining = get_tbh_size(buf);
  ;
  msgsize = read_at_least(fd, &buf[2], (((remaining) < ((buffsize - 2))) ? (remaining) : ((buffsize - 2))));
  if (msgsize == 0)
    return 0;
  else
    return msgsize + 2;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<tbh_read>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,%r12d
  mov    %rsi,%rbx
  mov    %edx,%ebp
  mov    $0x2,%edx
  call   <read_at_least@plt>
  mov    %eax,%edx
  mov    $0x0,%eax
  cmp    $0x2,%edx
  je     L1
L16:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L1:
  mov    %rbx,%rdi
  call   <get_tbh_size@plt>
  lea    -0x2(%rbp),%edx
  cmp    %eax,%edx
  cmovg  %eax,%edx
  lea    0x2(%rbx),%rsi
  mov    %r12d,%edi
  call   <read_at_least@plt>
  lea    0x2(%rax),%edx
  test   %eax,%eax
  cmovne %edx,%eax
  jmp    L16
```

assistant: ```c
int tbh_read(int fd, char buf[], int buffsize) {
  int remaining, msgsize;
  if (read_at_least(fd, buf, 2) != 2)
    return 0;
  remaining = get_tbh_size(buf);
  ;
  msgsize = read_at_least(fd, &buf[2], (((remaining) < ((buffsize - 2))) ? (remaining) : ((buffsize - 2))));
  if (msgsize == 0)
    return 0;
  else
    return msgsize + 2;
}
```
user: Translate the below assembly code into C programming language:

```asm
<tbh_read>:
  endbr64
  push   %r12
  mov    %edi,%r12d
  push   %rbp
  mov    %edx,%ebp
  mov    $0x2,%edx
  push   %rbx
  mov    %rsi,%rbx
  call   <read_at_least@plt>
  cmp    $0x2,%eax
  je     L13
L9:
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
  cs nopw 0x0(%rax,%rax,1)
L13:
  mov    %rbx,%rdi
  call   <get_tbh_size@plt>
  lea    -0x2(%rbp),%edx
  lea    0x2(%rbx),%rsi
  mov    %r12d,%edi
  cmp    %eax,%edx
  cmovg  %eax,%edx
  call   <read_at_least@plt>
  test   %eax,%eax
  je     L9
  pop    %rbx
  add    $0x2,%eax
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int tbh_read(int fd, char buf[], int buffsize) {
  int remaining, msgsize;
  if (read_at_least(fd, buf, 2) != 2)
    return 0;
  remaining = get_tbh_size(buf);
  ;
  msgsize = read_at_least(fd, &buf[2], (((remaining) < ((buffsize - 2))) ? (remaining) : ((buffsize - 2))));
  if (msgsize == 0)
    return 0;
  else
    return msgsize + 2;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<tbh_read>:
  endbr64
  push   %r12
  mov    %edi,%r12d
  push   %rbp
  mov    %edx,%ebp
  mov    $0x2,%edx
  push   %rbx
  mov    %rsi,%rbx
  call   <read_at_least@plt>
  cmp    $0x2,%eax
  je     L10
L1:
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
  cs nopw 0x0(%rax,%rax,1)
L10:
  mov    %rbx,%rdi
  call   <get_tbh_size@plt>
  lea    -0x2(%rbp),%edx
  lea    0x2(%rbx),%rsi
  mov    %r12d,%edi
  cmp    %eax,%edx
  cmovg  %eax,%edx
  call   <read_at_least@plt>
  test   %eax,%eax
  je     L1
  pop    %rbx
  add    $0x2,%eax
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int tbh_read(int fd, char buf[], int buffsize) {
  int remaining, msgsize;
  if (read_at_least(fd, buf, 2) != 2)
    return 0;
  remaining = get_tbh_size(buf);
  ;
  msgsize = read_at_least(fd, &buf[2], (((remaining) < ((buffsize - 2))) ? (remaining) : ((buffsize - 2))));
  if (msgsize == 0)
    return 0;
  else
    return msgsize + 2;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<getline_wrapped>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  movl   $0x100,-0x14(%rbp)
  movl   $0x0,-0x10(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L83
  mov    $0x0,%eax
  jmp    L110
L83:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <getc_unlocked@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x80,-0xc(%rbp)
  je     L160
  cmpl   $0x80,-0xc(%rbp)
  jg     L143
  cmpl   $0xa,-0xc(%rbp)
  je     L37
  cmpl   $0x5c,-0xc(%rbp)
  je     L177
  jmp    L143
L160:
  cmpl   $0x0,-0x10(%rbp)
  jne    L37
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  jmp    L110
L37:
  cmpq   $0x0,-0x30(%rbp)
  je     L157
  mov    -0x30(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x30(%rbp),%rax
  mov    %edx,(%rax)
L157:
  mov    -0x10(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jne    L144
  mov    -0x14(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x8(%rbp)
L144:
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x8(%rbp),%rax
  jmp    L110
L177:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <getc_unlocked@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0xa,-0xc(%rbp)
  jne    L143
  cmpq   $0x0,-0x30(%rbp)
  je     L163
  mov    -0x30(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x30(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L163
L143:
  mov    -0x10(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x10(%rbp)
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0xc(%rbp),%edx
  mov    %dl,(%rax)
  mov    -0x10(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jne    L83
  shll   -0x14(%rbp)
  mov    -0x14(%rbp),%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x8(%rbp)
  jmp    L83
L163:
  nop
  jmp    L83
L110:
  leave
  ret
```

assistant: ```c
char *getline_wrapped(FILE *fp, unsigned int *linenum) {
  int size = 256;
  int i = 0;
  char *buf = malloc(size);
  if (buf == NULL)
    return NULL;
  for (;;) {
    int ch = getc_unlocked(fp);
    switch (ch) {
    case EOF:
      if (i == 0) {
        free(buf);
        return NULL;
      }
    case '\n':
      if (linenum)
        (*linenum)++;
      if (i == size)
        buf = realloc(buf, size + 1);
      buf[i] = '\0';
      return buf;
    case '\\':
      ch = getc_unlocked(fp);
      if (ch == '\n') {
        if (linenum)
          (*linenum)++;
        continue;
      }
    default:
      buf[i++] = ch;
      if (i == size) {
        size *= 2;
        buf = realloc(buf, size);
      }
    }
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<getline_wrapped>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r13
  mov    %rsi,%r12
  mov    $0x100,%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L5
  mov    $0x0,%ebx
  mov    $0x100,%r14d
L4:
  mov    %r13,%rdi
  call   <getc_unlocked@plt>
  cmp    $0x5c,%eax
  je     L105
  cmp    $0x80,%eax
  je     L143
  cmp    $0xa,%eax
  je     L36
L1:
  lea    0x1(%rbx),%r15d
  movslq %ebx,%rbx
  mov    %al,0x0(%rbp,%rbx,1)
  cmp    %r15d,%r14d
  je     L75
L30:
  mov    %r15d,%ebx
  jmp    L4
L143:
  test   %ebx,%ebx
  je     L95
L36:
  test   %r12,%r12
  je     L111
  addl   $0x1,(%r12)
L111:
  cmp    %ebx,%r14d
  je     L46
L137:
  movslq %ebx,%rbx
  movb   $0x0,0x0(%rbp,%rbx,1)
L5:
  mov    %rbp,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L95:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    $0x0,%ebp
  jmp    L5
L46:
  lea    0x1(%r14),%esi
  mov    %rbp,%rdi
  call   <realloc@plt>
  mov    %rax,%rbp
  jmp    L137
L105:
  mov    %r13,%rdi
  call   <getc_unlocked@plt>
  cmp    $0xa,%eax
  jne    L1
  mov    %ebx,%r15d
  test   %r12,%r12
  je     L30
  addl   $0x1,(%r12)
  jmp    L30
L75:
  add    %r14d,%r14d
  mov    %r14d,%esi
  mov    %rbp,%rdi
  call   <realloc@plt>
  mov    %rax,%rbp
  jmp    L30
```

assistant: ```c
char *getline_wrapped(FILE *fp, unsigned int *linenum) {
  int size = 256;
  int i = 0;
  char *buf = malloc(size);
  if (buf == NULL)
    return NULL;
  for (;;) {
    int ch = getc_unlocked(fp);
    switch (ch) {
    case EOF:
      if (i == 0) {
        free(buf);
        return NULL;
      }
    case '\n':
      if (linenum)
        (*linenum)++;
      if (i == size)
        buf = realloc(buf, size + 1);
      buf[i] = '\0';
      return buf;
    case '\\':
      ch = getc_unlocked(fp);
      if (ch == '\n') {
        if (linenum)
          (*linenum)++;
        continue;
      }
    default:
      buf[i++] = ch;
      if (i == size) {
        size *= 2;
        buf = realloc(buf, size);
      }
    }
  }
}
```
user: What is the c source code of the assembly code below:

```asm
<getline_wrapped>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  mov    $0x100,%edi
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x8,%rsp
  call   <malloc@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L144
  mov    %rbp,%rdi
  xor    %r13d,%r13d
  mov    $0x100,%r12d
  call   <getc_unlocked@plt>
  cmp    $0x5c,%eax
  je     L88
L122:
  cmp    $0x80,%eax
  je     L99
  cmp    $0xa,%eax
  je     L38
L130:
  lea    0x1(%r13),%r15d
  mov    %al,(%r14,%r13,1)
  cmp    %r15d,%r12d
  je     L79
L55:
  mov    %rbp,%rdi
  movslq %r15d,%r13
  call   <getc_unlocked@plt>
  cmp    $0x5c,%eax
  jne    L122
L88:
  mov    %rbp,%rdi
  call   <getc_unlocked@plt>
  cmp    $0xa,%eax
  jne    L130
  mov    %r13d,%r15d
  test   %rbx,%rbx
  je     L55
  addl   $0x1,(%rbx)
  jmp    L55
  nopl   0x0(%rax,%rax,1)
L99:
  test   %r13d,%r13d
  je     L64
L38:
  test   %rbx,%rbx
  je     L23
  addl   $0x1,(%rbx)
L23:
  cmp    %r13d,%r12d
  je     L31
L59:
  movb   $0x0,(%r14,%r13,1)
L144:
  add    $0x8,%rsp
  mov    %r14,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L31:
  mov    %r14,%rdi
  lea    0x1(%r13),%esi
  call   <realloc@plt>
  mov    %rax,%r14
  jmp    L59
  nopl   0x0(%rax)
L79:
  add    %r12d,%r12d
  mov    %r14,%rdi
  mov    %r12d,%esi
  call   <realloc@plt>
  mov    %rax,%r14
  jmp    L55
  cs nopw 0x0(%rax,%rax,1)
L64:
  mov    %r14,%rdi
  xor    %r14d,%r14d
  call   <free@plt>
  jmp    L144
```

assistant: ```c
char *getline_wrapped(FILE *fp, unsigned int *linenum) {
  int size = 256;
  int i = 0;
  char *buf = malloc(size);
  if (buf == NULL)
    return NULL;
  for (;;) {
    int ch = getc_unlocked(fp);
    switch (ch) {
    case EOF:
      if (i == 0) {
        free(buf);
        return NULL;
      }
    case '\n':
      if (linenum)
        (*linenum)++;
      if (i == size)
        buf = realloc(buf, size + 1);
      buf[i] = '\0';
      return buf;
    case '\\':
      ch = getc_unlocked(fp);
      if (ch == '\n') {
        if (linenum)
          (*linenum)++;
        continue;
      }
    default:
      buf[i++] = ch;
      if (i == size) {
        size *= 2;
        buf = realloc(buf, size);
      }
    }
  }
}
```