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

```asm
<main>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    D29(%rip),%rdi
  call   <printf@plt>
  lea    0x4(%rsp),%rsi
  lea    D9(%rip),%rdi
  call   <scanf@plt>
  cmpl   $0x1,0x4(%rsp)
  jle    L19
  lea    D38(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x4(%rsp),%edi
  call   <sqrt@plt>
  mov    %eax,%ebp
  cmp    $0x1,%eax
  jle    L63
  mov    $0x2,%ebx
  lea    D36(%rip),%r12
  jmp    L40
L19:
  lea    D10(%rip),%rdi
  call   <puts@plt>
  mov    $0xffffffff,%eax
  jmp    L9
L42:
  add    $0x1,%ebx
  cmp    %ebx,%ebp
  jl     L63
L40:
  mov    0x4(%rsp),%ecx
  mov    %ecx,%eax
  cltd
  idiv   %ebx
  test   %edx,%edx
  jne    L42
  mov    %ecx,%eax
  cltd
  idiv   %ebx
  mov    %eax,%edx
  mov    %ebx,%esi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L42
L63:
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    $0x0,%eax
L9:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L54
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L54:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D29
type_infered: string
name: retrieve_data
arguments: tag: D9
type_infered: string
name: retrieve_data
arguments: tag: D38
type_infered: string
name: retrieve_data
arguments: tag: D36
type_infered: string
name: retrieve_data
arguments: tag: D10
type_infered: string

tool: D29: Input a number: 

tool: D9: %d

tool: D38: Factors: 

tool: D36:  %d %d

tool: D10: Input a number greater than two.

assistant: ```c
int main() {
  int number;
  int sqrt_n;
  int i;
  printf("Input a number: ");
  scanf("%d", &number);
  if (number < 2) {
    printf("Input a number greater than two.\n");
    return -1;
  }
  printf("Factors: ");
  sqrt_n = (int)sqrt(number);
  for (i = 2; i <= sqrt_n; i++) {
    if ((number % i) == 0) {
      printf(" %d %d", i, number / i);
    }
  }
  printf("\n");
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<main>:
  endbr64
  push   %r12
  lea    D30(%rip),%rdi
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <printf@plt>
  lea    0x4(%rsp),%rsi
  lea    D33(%rip),%rdi
  call   <scanf@plt>
  cmpl   $0x1,0x4(%rsp)
  jle    L59
  lea    D37(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x4(%rsp),%edi
  call   <sqrt@plt>
  mov    %eax,%ebp
  cmp    $0x1,%eax
  jle    L43
  mov    $0x2,%ebx
  lea    D24(%rip),%r12
  jmp    L72
  nopl   0x0(%rax)
L17:
  add    $0x1,%ebx
  cmp    %ebx,%ebp
  jl     L43
L72:
  mov    0x4(%rsp),%eax
  cltd
  idiv   %ebx
  test   %edx,%edx
  jne    L17
  mov    %eax,%edx
  mov    %ebx,%esi
  mov    %r12,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  add    $0x1,%ebx
  cmp    %ebx,%ebp
  jge    L72
L43:
  mov    $0xa,%edi
  call   <putchar@plt>
  xor    %eax,%eax
L32:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L24
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L59:
  lea    D42(%rip),%rdi
  call   <puts@plt>
  or     $0xffffffff,%eax
  jmp    L32
L24:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D30
type_infered: string
name: unpack_data
arguments: tag: D33
type_infered: string
name: unpack_data
arguments: tag: D37
type_infered: string
name: unpack_data
arguments: tag: D24
type_infered: string
name: unpack_data
arguments: tag: D42
type_infered: string

tool: D30: Input a number: 

tool: D33: %d

tool: D37: Factors: 

tool: D24:  %d %d

tool: D42: Input a number greater than two.

assistant: ```c
int main() {
  int number;
  int sqrt_n;
  int i;
  printf("Input a number: ");
  scanf("%d", &number);
  if (number < 2) {
    printf("Input a number greater than two.\n");
    return -1;
  }
  printf("Factors: ");
  sqrt_n = (int)sqrt(number);
  for (i = 2; i <= sqrt_n; i++) {
    if ((number % i) == 0) {
      printf(" %d %d", i, number / i);
    }
  }
  printf("\n");
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<main>:
  endbr64
  push   %r12
  lea    D49(%rip),%rdi
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <printf@plt>
  lea    0x4(%rsp),%rsi
  lea    D12(%rip),%rdi
  call   <scanf@plt>
  cmpl   $0x1,0x4(%rsp)
  jle    L65
  lea    D30(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x4(%rsp),%edi
  call   <sqrt@plt>
  mov    %eax,%ebp
  cmp    $0x1,%eax
  jle    L55
  mov    $0x2,%ebx
  lea    D27(%rip),%r12
  jmp    L3
  nopl   0x0(%rax)
L31:
  add    $0x1,%ebx
  cmp    %ebx,%ebp
  jl     L55
L3:
  mov    0x4(%rsp),%eax
  cltd
  idiv   %ebx
  test   %edx,%edx
  jne    L31
  mov    %eax,%edx
  mov    %ebx,%esi
  mov    %r12,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  add    $0x1,%ebx
  cmp    %ebx,%ebp
  jge    L3
L55:
  mov    $0xa,%edi
  call   <putchar@plt>
  xor    %eax,%eax
L74:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L5
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L65:
  lea    D26(%rip),%rdi
  call   <puts@plt>
  or     $0xffffffff,%eax
  jmp    L74
L5:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D49
type: string
name: read_data
arguments: tag: D12
type: string
name: read_data
arguments: tag: D30
type: string
name: read_data
arguments: tag: D27
type: string
name: read_data
arguments: tag: D26
type: string

tool: D49: Input a number: 

tool: D12: %d

tool: D30: Factors: 

tool: D27:  %d %d

tool: D26: Input a number greater than two.

assistant: ```c
int main() {
  int number;
  int sqrt_n;
  int i;
  printf("Input a number: ");
  scanf("%d", &number);
  if (number < 2) {
    printf("Input a number greater than two.\n");
    return -1;
  }
  printf("Factors: ");
  sqrt_n = (int)sqrt(number);
  for (i = 2; i <= sqrt_n; i++) {
    if ((number % i) == 0) {
      printf(" %d %d", i, number / i);
    }
  }
  printf("\n");
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<vectorFPSum>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %ecx,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x4(%rbp)
  jmp    L7
L0:
  mov    -0x18(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movsd  (%rax),%xmm1
  mov    -0x20(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  movsd  (%rax),%xmm0
  mov    -0x28(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  subl   $0x1,-0x4(%rbp)
L7:
  cmpl   $0x0,-0x4(%rbp)
  jg     L0
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void vectorFPSum(double *a, double *b, double *c, int nsize) {
  int j;
  for (j = nsize; j > 0; j--)
    *(c++) = *(a++) + *(b++);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<vectorFPSum>:
  endbr64
  test   %ecx,%ecx
  jle    L11
  mov    %ecx,%ecx
  mov    $0x0,%eax
L6:
  movsd  (%rdi,%rax,8),%xmm0
  addsd  (%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L6
L11:
  ret
```

assistant: ```c
void vectorFPSum(double *a, double *b, double *c, int nsize) {
  int j;
  for (j = nsize; j > 0; j--)
    *(c++) = *(a++) + *(b++);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<vectorFPSum>:
  endbr64
  test   %ecx,%ecx
  jle    L16
  movslq %ecx,%rcx
  xor    %eax,%eax
  nopl   (%rax)
L8:
  movsd  (%rdi,%rax,8),%xmm0
  addsd  (%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L8
L16:
  ret
```

assistant: ```c
void vectorFPSum(double *a, double *b, double *c, int nsize) {
  int j;
  for (j = nsize; j > 0; j--)
    *(c++) = *(a++) + *(b++);
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<vectorFPSum>:
  endbr64
  mov    %rdx,%r8
  movslq %ecx,%rdx
  test   %edx,%edx
  jle    L3
  lea    0x8(%rsi),%rax
  cmp    %rax,%r8
  lea    0x8(%rdi),%rax
  setne  %cl
  cmp    %rax,%r8
  setne  %al
  test   %al,%cl
  je     L24
  lea    -0x1(%rdx),%eax
  cmp    $0x1,%eax
  jbe    L24
  mov    %edx,%ecx
  xor    %eax,%eax
  shr    %ecx
  shl    $0x4,%rcx
  nopl   0x0(%rax)
L42:
  movupd (%rdi,%rax,1),%xmm0
  movupd (%rsi,%rax,1),%xmm1
  addpd  %xmm1,%xmm0
  movups %xmm0,(%r8,%rax,1)
  add    $0x10,%rax
  cmp    %rax,%rcx
  jne    L42
  mov    %edx,%ecx
  and    $0xfffffffe,%ecx
  mov    %ecx,%eax
  shl    $0x3,%rax
  add    %rax,%rdi
  add    %rax,%rsi
  add    %r8,%rax
  cmp    %ecx,%edx
  je     L3
  movsd  (%rdi),%xmm0
  addsd  (%rsi),%xmm0
  movsd  %xmm0,(%rax)
  ret
  nopl   0x0(%rax)
L24:
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L52:
  movsd  (%rdi,%rax,8),%xmm0
  addsd  (%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%r8,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%rdx
  jne    L52
L3:
  ret
```

assistant: ```c
void vectorFPSum(double *a, double *b, double *c, int nsize) {
  int j;
  for (j = nsize; j > 0; j--)
    *(c++) = *(a++) + *(b++);
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<test6>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %esi,-0x8(%rbp)
  mov    -0x4(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jle    L7
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jl     L7
  mov    $0x0,%eax
  call   <link_error1@plt>
L7:
  nop
  leave
  ret
```

assistant: ```c
void test6(int x, int y) {
  if ((x <= y) || (y < x)) {
  } else
    link_error1();
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<test6>:
  endbr64
  ret
```

assistant: ```c
void test6(int x, int y) {
  if ((x <= y) || (y < x)) {
  } else
    link_error1();
}
```
user: Translate the below assembly code into C programming language:

```asm
<test6>:
  endbr64
  ret
```

assistant: ```c
void test6(int x, int y) {
  if ((x <= y) || (y < x)) {
  } else
    link_error1();
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<test6>:
  endbr64
  ret
```

assistant: ```c
void test6(int x, int y) {
  if ((x <= y) || (y < x)) {
  } else
    link_error1();
}
```
user: 下面的汇编指令对应的C源代码是什么:

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

assistant: ```c
void copy(char *left, char *right, int count) {
  int i;
  for (i = 0; i <= count; i++) {
    left[i] = right[i];
  }
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<copy>:
  endbr64
  test   %edx,%edx
  js     L9
  lea    0x1(%rdx),%ecx
  mov    $0x0,%eax
L19:
  movzbl (%rsi,%rax,1),%edx
  mov    %dl,(%rdi,%rax,1)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L19
L9:
  ret
```

assistant: ```c
void copy(char *left, char *right, int count) {
  int i;
  for (i = 0; i <= count; i++) {
    left[i] = right[i];
  }
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<copy>:
  endbr64
  test   %edx,%edx
  js     L18
  movslq %edx,%rdx
  xor    %eax,%eax
  nopl   (%rax)
L5:
  movzbl (%rsi,%rax,1),%ecx
  mov    %cl,(%rdi,%rax,1)
  mov    %rax,%rcx
  add    $0x1,%rax
  cmp    %rcx,%rdx
  jne    L5
L18:
  ret
```

assistant: ```c
void copy(char *left, char *right, int count) {
  int i;
  for (i = 0; i <= count; i++) {
    left[i] = right[i];
  }
}
```
user: What is the c source code of the assembly code below:

```asm
<copy>:
  endbr64
  mov    %rdi,%rcx
  test   %edx,%edx
  js     L37
  lea    0x1(%rsi),%rdi
  mov    %rcx,%rax
  sub    %rdi,%rax
  cmp    $0xe,%rax
  jbe    L32
  cmp    $0x6,%edx
  jbe    L32
  lea    0x1(%rdx),%r8d
  cmp    $0xe,%edx
  jbe    L1
  mov    %r8d,%edi
  xor    %eax,%eax
  shr    $0x4,%edi
  shl    $0x4,%rdi
  nopl   (%rax)
L31:
  movdqu (%rsi,%rax,1),%xmm0
  movups %xmm0,(%rcx,%rax,1)
  add    $0x10,%rax
  cmp    %rdi,%rax
  jne    L31
  mov    %r8d,%edi
  and    $0xfffffff0,%edi
  mov    %edi,%eax
  cmp    %edi,%r8d
  je     L37
  mov    %edx,%r9d
  sub    %edi,%r9d
  lea    0x1(%r9),%r8d
  cmp    $0x6,%r9d
  jbe    L23
L9:
  mov    (%rsi,%rdi,1),%r9
  mov    %r9,(%rcx,%rdi,1)
  mov    %r8d,%edi
  and    $0xfffffff8,%edi
  add    %edi,%eax
  cmp    %edi,%r8d
  je     L37
L23:
  movslq %eax,%rdi
  movzbl (%rsi,%rdi,1),%r8d
  mov    %r8b,(%rcx,%rdi,1)
  lea    0x1(%rax),%edi
  cmp    %edi,%edx
  jl     L37
  movslq %edi,%rdi
  movzbl (%rsi,%rdi,1),%r8d
  mov    %r8b,(%rcx,%rdi,1)
  lea    0x2(%rax),%edi
  cmp    %edi,%edx
  jl     L37
  movslq %edi,%rdi
  movzbl (%rsi,%rdi,1),%r8d
  mov    %r8b,(%rcx,%rdi,1)
  lea    0x3(%rax),%edi
  cmp    %edi,%edx
  jl     L37
  movslq %edi,%rdi
  movzbl (%rsi,%rdi,1),%r8d
  mov    %r8b,(%rcx,%rdi,1)
  lea    0x4(%rax),%edi
  cmp    %edi,%edx
  jl     L37
  movslq %edi,%rdi
  movzbl (%rsi,%rdi,1),%r8d
  mov    %r8b,(%rcx,%rdi,1)
  lea    0x5(%rax),%edi
  cmp    %edi,%edx
  jl     L37
  movslq %edi,%rdi
  add    $0x6,%eax
  movzbl (%rsi,%rdi,1),%r8d
  mov    %r8b,(%rcx,%rdi,1)
  cmp    %eax,%edx
  jl     L37
  cltq
  movzbl (%rsi,%rax,1),%edx
  mov    %dl,(%rcx,%rax,1)
  ret
L37:
  ret
  nopl   0x0(%rax)
L32:
  movslq %edx,%rdx
  xor    %eax,%eax
  nopl   (%rax)
L83:
  movzbl (%rsi,%rax,1),%edi
  mov    %dil,(%rcx,%rax,1)
  mov    %rax,%rdi
  add    $0x1,%rax
  cmp    %rdx,%rdi
  jne    L83
  ret
L1:
  xor    %edi,%edi
  xor    %eax,%eax
  jmp    L9
```

assistant: ```c
void copy(char *left, char *right, int count) {
  int i;
  for (i = 0; i <= count; i++) {
    left[i] = right[i];
  }
}
```
user: Translate the below assembly code into C programming language:

```asm
<absMathInteger>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  js     L0
  mov    -0x4(%rbp),%eax
  jmp    L13
L0:
  mov    -0x4(%rbp),%eax
  neg    %eax
L13:
  pop    %rbp
  ret
```

assistant: ```c
int absMathInteger(int i) {
  if (i >= 0) {
    return i;
  } else {
    return -i;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<absMathInteger>:
  endbr64
  mov    %edi,%eax
  neg    %eax
  cmovs  %edi,%eax
  ret
```

assistant: ```c
int absMathInteger(int i) {
  if (i >= 0) {
    return i;
  } else {
    return -i;
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<absMathInteger>:
  endbr64
  mov    %edi,%eax
  neg    %eax
  cmovs  %edi,%eax
  ret
```

assistant: ```c
int absMathInteger(int i) {
  if (i >= 0) {
    return i;
  } else {
    return -i;
  }
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<naive_clz>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  setne  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  movl   $0x80000000,-0x8(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L5
L8:
  addl   $0x1,-0x4(%rbp)
  sarl   -0x8(%rbp)
L5:
  mov    -0x14(%rbp),%eax
  and    -0x8(%rbp),%eax
  test   %eax,%eax
  je     L8
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
uint32_t naive_clz(uint32_t x) {
  uint32_t m, i;
  assert(x != 0);
  m = 0x80000000u;
  i = 0;
  while ((x & m) == 0) {
    i++;
    m >>= 1;
  }
  return i;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<naive_clz>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  test   %edi,%edi
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  test   %ebx,%ebx
  js     L13
  mov    $0x0,%edx
  mov    $0x80000000,%eax
L7:
  add    $0x1,%edx
  sar    %eax
  test   %eax,%ebx
  je     L7
L21:
  mov    %edx,%eax
  pop    %rbx
  ret
L13:
  mov    $0x0,%edx
  jmp    L21
```

assistant: ```c
uint32_t naive_clz(uint32_t x) {
  uint32_t m, i;
  assert(x != 0);
  m = 0x80000000u;
  i = 0;
  while ((x & m) == 0) {
    i++;
    m >>= 1;
  }
  return i;
}
```
user: What is the c source code of the assembly code below?

```asm
<naive_clz>:
  endbr64
  test   %edi,%edi
  push   %rbx
  mov    %edi,%ebx
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  xor    %r8d,%r8d
  test   %ebx,%ebx
  js     L9
  mov    $0x80000000,%eax
  nopw   0x0(%rax,%rax,1)
L8:
  sar    %eax
  add    $0x1,%r8d
  test   %eax,%ebx
  je     L8
L9:
  mov    %r8d,%eax
  pop    %rbx
  ret
```

assistant: ```c
uint32_t naive_clz(uint32_t x) {
  uint32_t m, i;
  assert(x != 0);
  m = 0x80000000u;
  i = 0;
  while ((x & m) == 0) {
    i++;
    m >>= 1;
  }
  return i;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<naive_clz>:
  endbr64
  test   %edi,%edi
  push   %rbx
  mov    %edi,%ebx
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  xor    %r8d,%r8d
  test   %ebx,%ebx
  js     L14
  mov    $0x80000000,%eax
  nopw   0x0(%rax,%rax,1)
L7:
  sar    %eax
  add    $0x1,%r8d
  test   %eax,%ebx
  je     L7
L14:
  mov    %r8d,%eax
  pop    %rbx
  ret
```

assistant: ```c
uint32_t naive_clz(uint32_t x) {
  uint32_t m, i;
  assert(x != 0);
  m = 0x80000000u;
  i = 0;
  while ((x & m) == 0) {
    i++;
    m >>= 1;
  }
  return i;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<compute_revents>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x50,%rsp
  mov    %edi,%ebx
  mov    %esi,%r12d
  mov    %rdx,%rsi
  mov    %rcx,%r14
  mov    %r8,%r13
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  call   <FD_ISSET@plt>
  mov    $0x0,%ebp
  test   %rax,%rax
  jne    L68
L150:
  mov    %r14,%rsi
  mov    %ebx,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L131
  mov    D25(%rip),%rax
  mov    (%rax),%eax
  mov    D98(%rip),%rdx
  or     (%rdx),%eax
  mov    D13(%rip),%rdx
  or     (%rdx),%eax
  and    %r12d,%eax
  or     %eax,%ebp
L131:
  mov    %r13,%rsi
  mov    %ebx,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L140
  mov    D112(%rip),%rax
  mov    (%rax),%eax
  mov    D120(%rip),%rdx
  or     (%rdx),%eax
  and    %r12d,%eax
  or     %eax,%ebp
L140:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L86
  mov    %ebp,%eax
  add    $0x50,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L68:
  mov    %rsp,%rsi
  mov    $0x0,%ecx
  mov    $0x40,%edx
  mov    %ebx,%edi
  call   <recv@plt>
  test   %eax,%eax
  js     L168
  jne    L148
  mov    D168(%rip),%rax
  mov    (%rax),%ebp
  jmp    L150
L168:
  mov    D1(%rip),%rax
  mov    (%rax),%eax
  mov    D0(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L148
  mov    D149(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L29
  mov    D69(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L29
  mov    D60(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L29
  mov    D81(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L29
  mov    D126(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L144
  mov    D134(%rip),%rax
  mov    (%rax),%ebp
  jmp    L150
L148:
  mov    D136(%rip),%rax
  mov    (%rax),%ebp
  mov    D19(%rip),%rax
  or     (%rax),%ebp
  and    %r12d,%ebp
  jmp    L150
L29:
  mov    D168(%rip),%rax
  mov    (%rax),%ebp
  jmp    L150
L144:
  mov    D136(%rip),%rax
  mov    (%rax),%ebp
  mov    D19(%rip),%rax
  or     (%rax),%ebp
  and    %r12d,%ebp
  jmp    L150
L86:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int compute_revents(int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds) {
  int happened = 0;
  if (FD_ISSET(fd, rfds)) {
    int r;
    int socket_errno;
    char data[64];
    r = recv(fd, data, sizeof(data), 0);
    socket_errno = (r < 0) ? errno : 0;
    if (r == 0)
      happened |= POLLHUP;
    else if (r > 0 || (socket_errno == ENOTCONN))
      happened |= (POLLIN | POLLRDNORM) & sought;
    else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET || socket_errno == ECONNABORTED || socket_errno == ENETRESET)
      happened |= POLLHUP;
    else if (socket_errno == ENOTSOCK)
      happened |= (POLLIN | POLLRDNORM) & sought;
    else
      happened |= POLLERR;
  }
  if (FD_ISSET(fd, wfds))
    happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought;
  if (FD_ISSET(fd, efds))
    happened |= (POLLPRI | POLLRDBAND) & sought;
  return happened;
}
```
user: What is the c source code of the assembly code below?

```asm
<compute_revents>:
  endbr64
  push   %r14
  mov    %rcx,%r14
  push   %r13
  mov    %r8,%r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %esi,%ebx
  mov    %rdx,%rsi
  sub    $0x50,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  call   <FD_ISSET@plt>
  test   %rax,%rax
  jne    L5
L41:
  mov    %r14,%rsi
  mov    %ebp,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L44
  mov    D148(%rip),%rdx
  mov    D24(%rip),%rax
  mov    (%rax),%eax
  or     (%rdx),%eax
  mov    D16(%rip),%rdx
  or     (%rdx),%eax
  and    %ebx,%eax
  or     %eax,%r12d
L44:
  mov    %r13,%rsi
  mov    %ebp,%edi
  call   <FD_ISSET@plt>
  test   %rax,%rax
  je     L59
  mov    D20(%rip),%rax
  mov    D32(%rip),%rdx
  mov    (%rax),%eax
  or     (%rdx),%eax
  and    %ebx,%eax
  or     %eax,%r12d
L59:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L27
  add    $0x50,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax,%rax,1)
L5:
  xor    %ecx,%ecx
  mov    %rsp,%rsi
  mov    $0x40,%edx
  mov    %ebp,%edi
  call   <recv@plt>
  test   %eax,%eax
  js     L105
  jne    L21
L56:
  mov    D39(%rip),%rax
  mov    (%rax),%r12d
  jmp    L41
  xchg   %ax,%ax
L105:
  mov    D45(%rip),%rax
  mov    D112(%rip),%rdx
  mov    (%rax),%eax
  cmp    %eax,(%rdx)
  je     L21
  mov    D8(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L56
  mov    D153(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L56
  mov    D17(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L56
  mov    D21(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L56
  mov    D156(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L21
  mov    D31(%rip),%rax
  mov    (%rax),%r12d
  jmp    L41
  nopw   0x0(%rax,%rax,1)
L21:
  mov    D9(%rip),%rax
  mov    (%rax),%r12d
  mov    D97(%rip),%rax
  or     (%rax),%r12d
  and    %ebx,%r12d
  jmp    L41
L27:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int compute_revents(int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds) {
  int happened = 0;
  if (FD_ISSET(fd, rfds)) {
    int r;
    int socket_errno;
    char data[64];
    r = recv(fd, data, sizeof(data), 0);
    socket_errno = (r < 0) ? errno : 0;
    if (r == 0)
      happened |= POLLHUP;
    else if (r > 0 || (socket_errno == ENOTCONN))
      happened |= (POLLIN | POLLRDNORM) & sought;
    else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET || socket_errno == ECONNABORTED || socket_errno == ENETRESET)
      happened |= POLLHUP;
    else if (socket_errno == ENOTSOCK)
      happened |= (POLLIN | POLLRDNORM) & sought;
    else
      happened |= POLLERR;
  }
  if (FD_ISSET(fd, wfds))
    happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought;
  if (FD_ISSET(fd, efds))
    happened |= (POLLPRI | POLLRDBAND) & sought;
  return happened;
}
```