ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<test3>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  movl   $0x5,-0xc(%rbp)
  movl   $0x3,-0x8(%rbp)
  mov    -0x8(%rbp),%edx
  mov    -0xc(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <resta_numeros@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0xc(%rbp),%eax
  sub    -0x8(%rbp),%eax
  cmp    %eax,-0x4(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x4(%rbp),%ecx
  mov    -0x8(%rbp),%edx
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  lea    D15(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    -0x8(%rbp),%edx
  mov    -0xc(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <multiplica_numeros@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0xc(%rbp),%eax
  imul   -0x8(%rbp),%eax
  cmp    %eax,-0x4(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x4(%rbp),%ecx
  mov    -0x8(%rbp),%edx
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  leave
  ret
```

tool_calls: name: unpack_data
arguments: tag: D15
data_type: string
name: unpack_data
arguments: tag: D19
data_type: string

tool: D15: %d - %d es igual a: %d


tool: D19: %d * %d es igual a %d


assistant: ```c
int test3(void) {
  int n = 5;
  int m = 3;
  int tmp = resta_numeros(n, m);
  assert(n - m == tmp);
  printf("%d - %d es igual a: %d\n", n, m, tmp);
  tmp = multiplica_numeros(n, m);
  assert(n * m == tmp);
  printf("%d * %d es igual a %d\n", n, m, tmp);
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<test3>:
  endbr64
  push   %rbx
  mov    $0x3,%esi
  mov    $0x5,%edi
  call   <resta_numeros@plt>
  mov    %eax,%ebx
  cmp    $0x2,%eax
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    %ebx,%ecx
  mov    $0x3,%edx
  mov    $0x5,%esi
  lea    D2(%rip),%rdi
  call   <printf@plt>
  mov    $0x3,%esi
  mov    $0x5,%edi
  call   <multiplica_numeros@plt>
  mov    %eax,%ebx
  cmp    $0xf,%eax
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    %ebx,%ecx
  mov    $0x3,%edx
  mov    $0x5,%esi
  lea    D5(%rip),%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  pop    %rbx
  ret
```

tool_calls: name: extract_symbolic_data
arguments: tag: D2
type_guessed: string
name: extract_symbolic_data
arguments: tag: D5
type_guessed: string

tool: D2: %d - %d es igual a: %d


tool: D5: %d * %d es igual a %d


assistant: ```c
int test3(void) {
  int n = 5;
  int m = 3;
  int tmp = resta_numeros(n, m);
  assert(n - m == tmp);
  printf("%d - %d es igual a: %d\n", n, m, tmp);
  tmp = multiplica_numeros(n, m);
  assert(n * m == tmp);
  printf("%d * %d es igual a %d\n", n, m, tmp);
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<test3>:
  endbr64
  push   %r12
  mov    $0x3,%esi
  mov    $0x5,%edi
  call   <resta_numeros@plt>
  xor    %edi,%edi
  cmp    $0x2,%eax
  mov    %eax,%r12d
  sete   %dil
  call   <assert@plt>
  mov    %r12d,%ecx
  mov    $0x3,%edx
  mov    $0x5,%esi
  lea    D11(%rip),%rdi
  call   <printf@plt>
  mov    $0x3,%esi
  mov    $0x5,%edi
  call   <multiplica_numeros@plt>
  xor    %edi,%edi
  cmp    $0xf,%eax
  mov    %eax,%r12d
  sete   %dil
  call   <assert@plt>
  mov    %r12d,%ecx
  mov    $0x3,%edx
  mov    $0x5,%esi
  lea    D19(%rip),%rdi
  call   <printf@plt>
  xor    %eax,%eax
  pop    %r12
  ret
```

tool_calls: name: read_data
arguments: data_tag: D11
type_infered: string
name: read_data
arguments: data_tag: D19
type_infered: string

tool: D11: %d - %d es igual a: %d


tool: D19: %d * %d es igual a %d


assistant: ```c
int test3(void) {
  int n = 5;
  int m = 3;
  int tmp = resta_numeros(n, m);
  assert(n - m == tmp);
  printf("%d - %d es igual a: %d\n", n, m, tmp);
  tmp = multiplica_numeros(n, m);
  assert(n * m == tmp);
  printf("%d * %d es igual a %d\n", n, m, tmp);
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<test3>:
  endbr64
  push   %r12
  mov    $0x3,%esi
  mov    $0x5,%edi
  call   <resta_numeros@plt>
  xor    %edi,%edi
  cmp    $0x2,%eax
  mov    %eax,%r12d
  sete   %dil
  call   <assert@plt>
  mov    %r12d,%ecx
  mov    $0x3,%edx
  mov    $0x5,%esi
  lea    D15(%rip),%rdi
  call   <printf@plt>
  mov    $0x3,%esi
  mov    $0x5,%edi
  call   <multiplica_numeros@plt>
  xor    %edi,%edi
  cmp    $0xf,%eax
  mov    %eax,%r12d
  sete   %dil
  call   <assert@plt>
  mov    %r12d,%ecx
  mov    $0x3,%edx
  mov    $0x5,%esi
  lea    D3(%rip),%rdi
  call   <printf@plt>
  xor    %eax,%eax
  pop    %r12
  ret
```

tool_calls: name: parse_data
arguments: tag: D15
datatype: string
name: parse_data
arguments: tag: D3
datatype: string

tool: D15: %d - %d es igual a: %d


tool: D3: %d * %d es igual a %d


assistant: ```c
int test3(void) {
  int n = 5;
  int m = 3;
  int tmp = resta_numeros(n, m);
  assert(n - m == tmp);
  printf("%d - %d es igual a: %d\n", n, m, tmp);
  tmp = multiplica_numeros(n, m);
  assert(n * m == tmp);
  printf("%d * %d es igual a %d\n", n, m, tmp);
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<f2_realloc_1>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    $0xc,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x8(%rbp)
  nop
  leave
  ret
```

assistant: ```c
void f2_realloc_1() {
  int *p = malloc(12);
  int *q = realloc(p, 0);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<f2_realloc_1>:
  endbr64
  sub    $0x8,%rsp
  mov    $0xc,%edi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    $0x0,%esi
  call   <realloc@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
void f2_realloc_1() {
  int *p = malloc(12);
  int *q = realloc(p, 0);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<f2_realloc_1>:
  endbr64
  sub    $0x8,%rsp
  mov    $0xc,%edi
  call   <malloc@plt>
  xor    %esi,%esi
  add    $0x8,%rsp
  mov    %rax,%rdi
  jmp    1070 <realloc@plt>
```

assistant: ```c
void f2_realloc_1() {
  int *p = malloc(12);
  int *q = realloc(p, 0);
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<f2_realloc_1>:
  endbr64
  sub    $0x8,%rsp
  mov    $0xc,%edi
  call   <malloc@plt>
  xor    %esi,%esi
  add    $0x8,%rsp
  mov    %rax,%rdi
  jmp    1070 <realloc@plt>
```

assistant: ```c
void f2_realloc_1() {
  int *p = malloc(12);
  int *q = realloc(p, 0);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    $0x0,%edi
  call   <foo@plt>
  cmp    $0xfffffffc,%eax
  je     L2
  mov    $0x0,%eax
  call   <abort@plt>
L2:
  mov    $0x0,%eax
  pop    %rbp
  ret
```

assistant: ```c
int main(void) {
  if (foo(0) != -4)
    abort();
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x0,%edi
  call   <foo@plt>
  cmp    $0xfffffffc,%eax
  jne    L13
L1:
  mov    $0x0,%eax
  add    $0x8,%rsp
  ret
L13:
  mov    $0x0,%eax
  call   <abort@plt>
  jmp    L1
```

assistant: ```c
int main(void) {
  if (foo(0) != -4)
    abort();
  return 0;
}
```
user: What is the c source code of the assembly code below:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  xor    %edi,%edi
  call   <foo@plt>
  cmp    $0xfffffffc,%eax
  je     L9
  xor    %eax,%eax
  call   <abort@plt>
L9:
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int main(void) {
  if (foo(0) != -4)
    abort();
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  xor    %edi,%edi
  call   <foo@plt>
  cmp    $0xfffffffc,%eax
  je     L0
  xor    %eax,%eax
  call   <abort@plt>
L0:
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int main(void) {
  if (foo(0) != -4)
    abort();
  return 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<nthUglyNumber>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %edi,-0x54(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x0,-0x54(%rbp)
  jns    L48
  mov    $0x0,%eax
  jmp    L73
L48:
  cmpl   $0x1,-0x54(%rbp)
  jne    L129
  mov    $0x1,%eax
  jmp    L73
L129:
  mov    -0x54(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x38(%rbp)
  mov    -0x38(%rbp),%rax
  movl   $0x1,(%rax)
  movl   $0x2,-0x2c(%rbp)
  movl   $0x3,-0x28(%rbp)
  movl   $0x5,-0x24(%rbp)
  movl   $0x0,-0x20(%rbp)
  movl   $0x0,-0x1c(%rbp)
  movl   $0x0,-0x18(%rbp)
  movl   $0x0,-0x14(%rbp)
  movl   $0x0,-0x10(%rbp)
  movl   $0x0,-0xc(%rbp)
  movl   $0x1,-0x48(%rbp)
  jmp    L74
L104:
  mov    D5(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x44(%rbp)
  movl   $0x0,-0x40(%rbp)
  jmp    L71
L23:
  mov    -0x40(%rbp),%eax
  cltq
  mov    -0x20(%rbp,%rax,4),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x40(%rbp),%eax
  cltq
  mov    -0x2c(%rbp,%rax,4),%eax
  imul   %eax,%edx
  mov    -0x40(%rbp),%eax
  cltq
  mov    %edx,-0x14(%rbp,%rax,4)
  mov    -0x40(%rbp),%eax
  cltq
  mov    -0x14(%rbp,%rax,4),%eax
  cmp    %eax,-0x44(%rbp)
  jle    L105
  mov    -0x40(%rbp),%eax
  cltq
  mov    -0x14(%rbp,%rax,4),%eax
  mov    %eax,-0x44(%rbp)
L105:
  addl   $0x1,-0x40(%rbp)
L71:
  mov    -0x40(%rbp),%eax
  cmp    $0x2,%eax
  jbe    L23
  mov    -0x48(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    -0x44(%rbp),%eax
  mov    %eax,(%rdx)
  movl   $0x0,-0x3c(%rbp)
  jmp    L44
L118:
  mov    -0x3c(%rbp),%eax
  cltq
  mov    -0x14(%rbp,%rax,4),%eax
  cmp    %eax,-0x44(%rbp)
  jne    L85
  mov    -0x3c(%rbp),%eax
  cltq
  mov    -0x20(%rbp,%rax,4),%eax
  lea    0x1(%rax),%edx
  mov    -0x3c(%rbp),%eax
  cltq
  mov    %edx,-0x20(%rbp,%rax,4)
L85:
  addl   $0x1,-0x3c(%rbp)
L44:
  mov    -0x3c(%rbp),%eax
  cmp    $0x2,%eax
  jbe    L118
  addl   $0x1,-0x48(%rbp)
L74:
  mov    -0x48(%rbp),%eax
  cmp    -0x54(%rbp),%eax
  jl     L104
  mov    -0x54(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
L73:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L111
  call   <__stack_chk_fail@plt>
L111:
  leave
  ret
```

assistant: ```c
int nthUglyNumber(int n) {
  if (n < 0)
    return 0;
  if (n == 1)
    return 1;
  int *arr = (int *)malloc(sizeof(int) * n);
  arr[0] = 1;
  int factors[] = {2, 3, 5};
  int indexes[] = {0, 0, 0};
  int t[] = {0, 0, 0};
  for (int i = 1; i < n; i++) {
    int min = INT_MAX;
    for (int j = 0; j < sizeof(factors) / sizeof(int); j++)
      if ((t[j] = arr[indexes[j]] * factors[j]) < min)
        min = t[j];
    arr[i] = min;
    for (int j = 0; j < sizeof(factors) / sizeof(int); j++)
      if (t[j] == min)
        indexes[j]++;
  }
  return arr[n - 1];
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<nthUglyNumber>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  js     L20
  mov    %edi,%ebp
  mov    %edi,%eax
  cmp    $0x1,%edi
  je     L20
  movslq %edi,%rbx
  lea    0x0(,%rdi,4),%edi
  call   <malloc@plt>
  mov    %rax,%rdi
  movl   $0x1,(%rax)
  movl   $0x2,0x4(%rsp)
  movl   $0x3,0x8(%rsp)
  movl   $0x5,0xc(%rsp)
  movl   $0x0,0x10(%rsp)
  movl   $0x0,0x14(%rsp)
  movl   $0x0,0x18(%rsp)
  movl   $0x0,0x1c(%rsp)
  movl   $0x0,0x20(%rsp)
  movl   $0x0,0x24(%rsp)
  cmp    $0x1,%ebp
  jle    L64
  lea    0x4(%rax),%rsi
  lea    -0x2(%rbp),%eax
  lea    0x8(%rdi,%rax,4),%r11
  mov    D1(%rip),%r10
  lea    0x4(%rsp),%r9
  lea    0x28(%rsp),%r8
  jmp    L57
L65:
  add    $0x4,%rax
  add    $0x4,%rdx
  cmp    %r8,%rax
  je     L59
L11:
  cmp    (%rax),%ecx
  jne    L65
  addl   $0x1,(%rdx)
  jmp    L65
L59:
  add    $0x4,%rsi
  cmp    %r11,%rsi
  je     L64
L57:
  mov    (%r10),%ecx
  mov    $0x0,%eax
L14:
  movslq 0x10(%rsp,%rax,1),%rdx
  mov    (%rdi,%rdx,4),%edx
  imul   (%rax,%r9,1),%edx
  mov    %edx,0x1c(%rsp,%rax,1)
  cmp    %edx,%ecx
  cmovg  %edx,%ecx
  add    $0x4,%rax
  cmp    $0xc,%rax
  jne    L14
  mov    %ecx,(%rsi)
  lea    0x1c(%rsp),%rax
  lea    0x10(%rsp),%rdx
  jmp    L11
L64:
  mov    -0x4(%rdi,%rbx,4),%eax
L20:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L43
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  ret
L43:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int nthUglyNumber(int n) {
  if (n < 0)
    return 0;
  if (n == 1)
    return 1;
  int *arr = (int *)malloc(sizeof(int) * n);
  arr[0] = 1;
  int factors[] = {2, 3, 5};
  int indexes[] = {0, 0, 0};
  int t[] = {0, 0, 0};
  for (int i = 1; i < n; i++) {
    int min = INT_MAX;
    for (int j = 0; j < sizeof(factors) / sizeof(int); j++)
      if ((t[j] = arr[indexes[j]] * factors[j]) < min)
        min = t[j];
    arr[i] = min;
    for (int j = 0; j < sizeof(factors) / sizeof(int); j++)
      if (t[j] == min)
        indexes[j]++;
  }
  return arr[n - 1];
}
```
user: Translate the below assembly code into C programming language:

```asm
<nthUglyNumber>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  js     L2
  mov    %edi,%ebp
  mov    $0x1,%eax
  cmp    $0x1,%edi
  je     L2
  movslq %edi,%rbx
  lea    0x0(,%rdi,4),%edi
  call   <malloc@plt>
  movq   $0x0,(%rsp)
  movl   $0x1,(%rax)
  mov    %rax,%rdi
  movl   $0x0,0x8(%rsp)
  movq   $0x0,0xc(%rsp)
  movl   $0x0,0x14(%rsp)
  cmp    $0x1,%ebp
  jle    L47
  lea    0x4(%rax),%rsi
  lea    -0x2(%rbp),%eax
  mov    $0x1,%edx
  mov    %rsp,%r9
  mov    D7(%rip),%r11
  lea    0x8(%rdi,%rax,4),%rbp
  lea    0xc(%rsp),%r10
  lea    0x18(%rsp),%r8
  nopl   0x0(%rax)
L22:
  movslq 0x4(%rsp),%rax
  add    %edx,%edx
  mov    %edx,0xc(%rsp)
  mov    (%rdi,%rax,4),%eax
  lea    (%rax,%rax,2),%ecx
  movslq 0x8(%rsp),%rax
  mov    %ecx,0x10(%rsp)
  mov    (%rdi,%rax,4),%eax
  lea    (%rax,%rax,4),%eax
  cmp    %ecx,%eax
  mov    %eax,0x14(%rsp)
  cmovg  %ecx,%eax
  mov    (%r11),%ecx
  cmp    %ecx,%eax
  cmovg  %ecx,%eax
  mov    %r9,%rcx
  cmp    %edx,%eax
  cmovg  %edx,%eax
  mov    %r10,%rdx
  mov    %eax,(%rsi)
L20:
  cmp    (%rdx),%eax
  jne    L65
  addl   $0x1,(%rcx)
L65:
  add    $0x4,%rdx
  add    $0x4,%rcx
  cmp    %r8,%rdx
  jne    L20
  add    $0x4,%rsi
  cmp    %rsi,%rbp
  je     L47
  movslq (%rsp),%rax
  mov    (%rdi,%rax,4),%edx
  jmp    L22
  nopl   0x0(%rax)
L47:
  mov    -0x4(%rdi,%rbx,4),%eax
L2:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L21
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  ret
L21:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int nthUglyNumber(int n) {
  if (n < 0)
    return 0;
  if (n == 1)
    return 1;
  int *arr = (int *)malloc(sizeof(int) * n);
  arr[0] = 1;
  int factors[] = {2, 3, 5};
  int indexes[] = {0, 0, 0};
  int t[] = {0, 0, 0};
  for (int i = 1; i < n; i++) {
    int min = INT_MAX;
    for (int j = 0; j < sizeof(factors) / sizeof(int); j++)
      if ((t[j] = arr[indexes[j]] * factors[j]) < min)
        min = t[j];
    arr[i] = min;
    for (int j = 0; j < sizeof(factors) / sizeof(int); j++)
      if (t[j] == min)
        indexes[j]++;
  }
  return arr[n - 1];
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<nthUglyNumber>:
  endbr64
  xor    %eax,%eax
  test   %edi,%edi
  js     L7
  push   %r13
  mov    $0x1,%eax
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  sub    $0x8,%rsp
  cmp    $0x1,%edi
  je     L11
  movslq %edi,%rbx
  lea    0x0(,%rdi,4),%edi
  call   <malloc@plt>
  movl   $0x1,(%rax)
  mov    %rax,%r8
  cmp    $0x1,%ebp
  jle    L30
  lea    0x4(%rax),%rcx
  lea    -0x2(%rbp),%eax
  mov    $0x1,%esi
  xor    %r11d,%r11d
  lea    0x8(%r8,%rax,4),%r12
  mov    $0x1,%edx
  xor    %r10d,%r10d
  xor    %r9d,%r9d
  mov    D0(%rip),%rbp
  mov    $0x1,%eax
  jmp    L17
  cs nopw 0x0(%rax,%rax,1)
L42:
  movslq %r9d,%rax
  movslq %r11d,%rsi
  mov    (%r8,%rax,4),%edx
  movslq %r10d,%rax
  mov    (%r8,%rsi,4),%esi
  mov    (%r8,%rax,4),%eax
L17:
  lea    (%rax,%rax,2),%r13d
  mov    0x0(%rbp),%eax
  add    %edx,%edx
  lea    (%rsi,%rsi,4),%esi
  mov    %esi,%edi
  cmp    %eax,%edx
  cmovle %edx,%eax
  cmp    %r13d,%eax
  cmovg  %r13d,%eax
  cmp    %esi,%eax
  cmovle %eax,%edi
  cmp    %edi,%edx
  mov    %edi,(%rcx)
  sete   %dl
  movzbl %dl,%edx
  add    %edx,%r9d
  xor    %edx,%edx
  cmp    %edi,%r13d
  sete   %dl
  add    %edx,%r10d
  cmp    %esi,%eax
  setge  %al
  add    $0x4,%rcx
  movzbl %al,%eax
  add    %eax,%r11d
  cmp    %r12,%rcx
  jne    L42
L30:
  mov    -0x4(%r8,%rbx,4),%eax
L11:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L7:
  ret
```

assistant: ```c
int nthUglyNumber(int n) {
  if (n < 0)
    return 0;
  if (n == 1)
    return 1;
  int *arr = (int *)malloc(sizeof(int) * n);
  arr[0] = 1;
  int factors[] = {2, 3, 5};
  int indexes[] = {0, 0, 0};
  int t[] = {0, 0, 0};
  for (int i = 1; i < n; i++) {
    int min = INT_MAX;
    for (int j = 0; j < sizeof(factors) / sizeof(int); j++)
      if ((t[j] = arr[indexes[j]] * factors[j]) < min)
        min = t[j];
    arr[i] = min;
    for (int j = 0; j < sizeof(factors) / sizeof(int); j++)
      if (t[j] == min)
        indexes[j]++;
  }
  return arr[n - 1];
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<read_line>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  movq   $0x0,-0x8(%rbp)
  movl   $0x0,-0x14(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <getc@plt>
  mov    %eax,-0xc(%rbp)
  mov    D28(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0xc(%rbp)
  je     L0
  mov    $0x51,%edi
  call   <malloc_or_die@plt>
  mov    %rax,-0x8(%rbp)
  movl   $0x50,-0x10(%rbp)
  jmp    L39
L24:
  mov    -0x14(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jne    L17
  mov    -0x10(%rbp),%eax
  lea    0x15(%rax),%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc_or_die@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L59
  mov    $0x0,%eax
  jmp    L12
L59:
  addl   $0x14,-0x10(%rbp)
L17:
  mov    -0x14(%rbp),%edx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0xc(%rbp),%edx
  mov    %dl,(%rax)
  addl   $0x1,-0x14(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <getc@plt>
  mov    %eax,-0xc(%rbp)
L39:
  cmpl   $0xa,-0xc(%rbp)
  je     L42
  cmpl   $0xd,-0xc(%rbp)
  je     L42
  mov    D28(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0xc(%rbp)
  jne    L24
L42:
  mov    -0x14(%rbp),%edx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  cmpl   $0xd,-0xc(%rbp)
  jne    L0
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <getc@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0xa,-0xc(%rbp)
  je     L0
  mov    D28(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0xc(%rbp)
  je     L0
  mov    -0x28(%rbp),%rdx
  mov    -0xc(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <ungetc@plt>
L0:
  mov    -0x8(%rbp),%rax
L12:
  leave
  ret
```

assistant: ```c
char *read_line(FILE *fpin) {
  char *line = NULL;
  unsigned len = 0;
  unsigned max_length;
  int ch;
  ch = getc(fpin);
  if (ch != EOF) {
    line = (char *)malloc_or_die(80 + 1);
    max_length = 80;
    while ((ch != '\n') && (ch != '\r') && (ch != EOF)) {
      if (len == max_length) {
        line = (char *)realloc_or_die((void *)line, max_length + 20 + 1);
        if (line == NULL) {
          return NULL;
        }
        max_length += 20;
      }
      line[len] = ch;
      len++;
      ch = getc(fpin);
    }
    line[len] = '\0';
    if (ch == '\r') {
      ch = getc(fpin);
      if (ch != '\n' && ch != EOF) {
        ungetc(ch, fpin);
      }
    }
  }
  return line;
}
```
user: What is the c source code of the assembly code below?

```asm
<read_line>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r14
  call   <getc@plt>
  mov    %eax,%ebx
  mov    $0x0,%r12d
  mov    D22(%rip),%rax
  cmp    %ebx,(%rax)
  je     L114
  mov    $0x51,%edi
  call   <malloc_or_die@plt>
  mov    %rax,%r12
  cmp    $0xa,%ebx
  je     L22
  cmp    $0xd,%ebx
  je     L22
  mov    $0x50,%r13d
  mov    $0x0,%ebp
  mov    D22(%rip),%r15
  jmp    L50
L22:
  mov    $0x0,%ebp
L26:
  mov    %ebp,%ebp
  movb   $0x0,(%r12,%rbp,1)
  cmp    $0xd,%ebx
  je     L123
L114:
  mov    %r12,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L120:
  mov    %ebp,%eax
  mov    %bl,(%r12,%rax,1)
  add    $0x1,%ebp
  mov    %r14,%rdi
  call   <getc@plt>
  mov    %eax,%ebx
  cmp    $0xa,%eax
  je     L26
  cmp    $0xd,%eax
  je     L26
L50:
  cmp    %ebx,(%r15)
  je     L26
  cmp    %r13d,%ebp
  jne    L120
  lea    0x15(%r13),%esi
  mov    %r12,%rdi
  call   <realloc_or_die@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L44
  add    $0x14,%r13d
  jmp    L120
L123:
  mov    %r14,%rdi
  call   <getc@plt>
  cmp    $0xa,%eax
  je     L114
  mov    D22(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L114
  mov    %r14,%rsi
  mov    %eax,%edi
  call   <ungetc@plt>
  jmp    L114
L44:
  mov    $0x0,%r12d
  jmp    L114
```

assistant: ```c
char *read_line(FILE *fpin) {
  char *line = NULL;
  unsigned len = 0;
  unsigned max_length;
  int ch;
  ch = getc(fpin);
  if (ch != EOF) {
    line = (char *)malloc_or_die(80 + 1);
    max_length = 80;
    while ((ch != '\n') && (ch != '\r') && (ch != EOF)) {
      if (len == max_length) {
        line = (char *)realloc_or_die((void *)line, max_length + 20 + 1);
        if (line == NULL) {
          return NULL;
        }
        max_length += 20;
      }
      line[len] = ch;
      len++;
      ch = getc(fpin);
    }
    line[len] = '\0';
    if (ch == '\r') {
      ch = getc(fpin);
      if (ch != '\n' && ch != EOF) {
        ungetc(ch, fpin);
      }
    }
  }
  return line;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<read_line>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  call   <getc@plt>
  mov    D2(%rip),%r13
  cmp    %eax,0x0(%r13)
  je     L21
  mov    $0x51,%edi
  mov    %eax,%ebx
  call   <malloc_or_die@plt>
  mov    %rax,%r14
  cmp    $0xd,%ebx
  je     L44
  cmp    $0xa,%ebx
  je     L44
  mov    $0x50,%r15d
  xor    %ebp,%ebp
  jmp    L156
  cs nopw 0x0(%rax,%rax,1)
L126:
  mov    %ebp,%eax
  mov    %r12,%rdi
  add    $0x1,%ebp
  mov    %bl,(%r14,%rax,1)
  call   <getc@plt>
  mov    %eax,%ebx
  cmp    $0xa,%eax
  je     L76
  cmp    $0xd,%eax
  je     L76
L156:
  cmp    %ebx,0x0(%r13)
  je     L76
  cmp    %r15d,%ebp
  jne    L126
  mov    %r14,%rdi
  lea    0x15(%rbp),%esi
  call   <realloc_or_die@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L21
  lea    0x14(%rbp),%r15d
  jmp    L126
  nopl   0x0(%rax)
L76:
  add    %r14,%rbp
L115:
  movb   $0x0,0x0(%rbp)
  cmp    $0xd,%ebx
  je     L81
L87:
  add    $0x8,%rsp
  mov    %r14,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L21:
  xor    %r14d,%r14d
  jmp    L87
  nopl   (%rax)
L81:
  mov    %r12,%rdi
  call   <getc@plt>
  cmp    $0xa,%eax
  je     L87
  cmp    %eax,0x0(%r13)
  je     L87
  mov    %r12,%rsi
  mov    %eax,%edi
  call   <ungetc@plt>
  jmp    L87
L44:
  mov    %r14,%rbp
  jmp    L115
```

assistant: ```c
char *read_line(FILE *fpin) {
  char *line = NULL;
  unsigned len = 0;
  unsigned max_length;
  int ch;
  ch = getc(fpin);
  if (ch != EOF) {
    line = (char *)malloc_or_die(80 + 1);
    max_length = 80;
    while ((ch != '\n') && (ch != '\r') && (ch != EOF)) {
      if (len == max_length) {
        line = (char *)realloc_or_die((void *)line, max_length + 20 + 1);
        if (line == NULL) {
          return NULL;
        }
        max_length += 20;
      }
      line[len] = ch;
      len++;
      ch = getc(fpin);
    }
    line[len] = '\0';
    if (ch == '\r') {
      ch = getc(fpin);
      if (ch != '\n' && ch != EOF) {
        ungetc(ch, fpin);
      }
    }
  }
  return line;
}
```