ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 下面的汇编指令对应的C源代码是什么：

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <pipe@plt>
  call   <fork@plt>
  test   %eax,%eax
  jne    L18
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    -0x34(%rbp),%eax
  mov    $0x5,%edx
  lea    D3(%rip),%rcx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  lea    D49(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  jmp    L22
L18:
  lea    D26(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    -0x38(%rbp),%eax
  lea    -0x30(%rbp),%rcx
  mov    $0x5,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  lea    -0x30(%rbp),%rax
  mov    %rax,%rsi
  lea    D48(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%edi
  call   <wait@plt>
L22:
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L0
  call   <__stack_chk_fail@plt>
L0:
  leave
  ret
```

tool_calls: name: read_data
arguments: data_label: D19
data_type: string
name: read_data
arguments: data_label: D3
data_type: string
name: read_data
arguments: data_label: D49
data_type: string
name: read_data
arguments: data_label: D26
data_type: string
name: read_data
arguments: data_label: D48
data_type: string

tool: D19:  CHILD: writing to the pipe

tool: D3: test

tool: D49:  CHILD: exiting

tool: D26: PARENT: reading from pipe

tool: D48: PARENT: read "%s"


assistant: ```c
int main(void) {
  int pfds[2];
  char buf[30];
  pipe(pfds);
  if (!fork()) {
    printf(" CHILD: writing to the pipe\n");
    write(pfds[1], "test", 5);
    printf(" CHILD: exiting\n");
    exit(0);
  } else {
    printf("PARENT: reading from pipe\n");
    read(pfds[0], buf, 5);
    printf("PARENT: read \"%s\"\n", buf);
    wait(NULL);
  }
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<main>:
  endbr64
  push   %rbx
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0x8(%rsp),%rdi
  call   <pipe@plt>
  call   <fork@plt>
  test   %eax,%eax
  jne    L8
  lea    D1(%rip),%rdi
  call   <puts@plt>
  mov    $0x5,%edx
  lea    D21(%rip),%rsi
  mov    0xc(%rsp),%edi
  call   <write@plt>
  lea    D11(%rip),%rdi
  call   <puts@plt>
  mov    $0x0,%edi
  call   <exit@plt>
L16:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L24
  mov    $0x0,%eax
  add    $0x40,%rsp
  pop    %rbx
  ret
L8:
  lea    D26(%rip),%rdi
  call   <puts@plt>
  lea    0x10(%rsp),%rbx
  mov    $0x5,%edx
  mov    %rbx,%rsi
  mov    0x8(%rsp),%edi
  call   <read@plt>
  mov    %rbx,%rsi
  lea    D37(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%edi
  call   <wait@plt>
  jmp    L16
L24:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D1
data_type: string
name: retrieve_data
arguments: tag: D21
data_type: string
name: retrieve_data
arguments: tag: D11
data_type: string
name: retrieve_data
arguments: tag: D26
data_type: string
name: retrieve_data
arguments: tag: D37
data_type: string

tool: D1:  CHILD: writing to the pipe

tool: D21: test

tool: D11:  CHILD: exiting

tool: D26: PARENT: reading from pipe

tool: D37: PARENT: read "%s"


assistant: ```c
int main(void) {
  int pfds[2];
  char buf[30];
  pipe(pfds);
  if (!fork()) {
    printf(" CHILD: writing to the pipe\n");
    write(pfds[1], "test", 5);
    printf(" CHILD: exiting\n");
    exit(0);
  } else {
    printf("PARENT: reading from pipe\n");
    read(pfds[0], buf, 5);
    printf("PARENT: read \"%s\"\n", buf);
    wait(NULL);
  }
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<main>:
  endbr64
  push   %rbp
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0x8(%rsp),%rdi
  call   <pipe@plt>
  call   <fork@plt>
  test   %eax,%eax
  jne    L3
  lea    D17(%rip),%rdi
  call   <puts@plt>
  mov    0xc(%rsp),%edi
  mov    $0x5,%edx
  lea    D2(%rip),%rsi
  call   <write@plt>
  lea    D27(%rip),%rdi
  call   <puts@plt>
  xor    %edi,%edi
  call   <exit@plt>
L26:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L12
  add    $0x40,%rsp
  xor    %eax,%eax
  pop    %rbp
  ret
L3:
  lea    D5(%rip),%rdi
  lea    0x10(%rsp),%rbp
  call   <puts@plt>
  mov    0x8(%rsp),%edi
  mov    $0x5,%edx
  mov    %rbp,%rsi
  call   <read@plt>
  mov    %rbp,%rsi
  lea    D12(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  xor    %edi,%edi
  call   <wait@plt>
  jmp    L26
L12:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D17
type: string
name: unpack_data
arguments: tag: D2
type: string
name: unpack_data
arguments: tag: D27
type: string
name: unpack_data
arguments: tag: D5
type: string
name: unpack_data
arguments: tag: D12
type: string

tool: D17:  CHILD: writing to the pipe

tool: D2: test

tool: D27:  CHILD: exiting

tool: D5: PARENT: reading from pipe

tool: D12: PARENT: read "%s"


assistant: ```c
int main(void) {
  int pfds[2];
  char buf[30];
  pipe(pfds);
  if (!fork()) {
    printf(" CHILD: writing to the pipe\n");
    write(pfds[1], "test", 5);
    printf(" CHILD: exiting\n");
    exit(0);
  } else {
    printf("PARENT: reading from pipe\n");
    read(pfds[0], buf, 5);
    printf("PARENT: read \"%s\"\n", buf);
    wait(NULL);
  }
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<main>:
  endbr64
  push   %rbp
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0x8(%rsp),%rdi
  call   <pipe@plt>
  call   <fork@plt>
  test   %eax,%eax
  jne    L2
  lea    D14(%rip),%rdi
  call   <puts@plt>
  mov    0xc(%rsp),%edi
  mov    $0x5,%edx
  lea    D26(%rip),%rsi
  call   <write@plt>
  lea    D36(%rip),%rdi
  call   <puts@plt>
  xor    %edi,%edi
  call   <exit@plt>
L6:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L27
  add    $0x40,%rsp
  xor    %eax,%eax
  pop    %rbp
  ret
L2:
  lea    D22(%rip),%rdi
  lea    0x10(%rsp),%rbp
  call   <puts@plt>
  mov    0x8(%rsp),%edi
  mov    $0x5,%edx
  mov    %rbp,%rsi
  call   <read@plt>
  mov    %rbp,%rsi
  lea    D25(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  xor    %edi,%edi
  call   <wait@plt>
  jmp    L6
L27:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D14
data_type: string
name: retrieve_data
arguments: tag: D26
data_type: string
name: retrieve_data
arguments: tag: D36
data_type: string
name: retrieve_data
arguments: tag: D22
data_type: string
name: retrieve_data
arguments: tag: D25
data_type: string

tool: D14:  CHILD: writing to the pipe

tool: D26: test

tool: D36:  CHILD: exiting

tool: D22: PARENT: reading from pipe

tool: D25: PARENT: read "%s"


assistant: ```c
int main(void) {
  int pfds[2];
  char buf[30];
  pipe(pfds);
  if (!fork()) {
    printf(" CHILD: writing to the pipe\n");
    write(pfds[1], "test", 5);
    printf(" CHILD: exiting\n");
    exit(0);
  } else {
    printf("PARENT: reading from pipe\n");
    read(pfds[0], buf, 5);
    printf("PARENT: read \"%s\"\n", buf);
    wait(NULL);
  }
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<fourcc_is_ivf>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    $0x4,%edx
  lea    D6(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcmp@plt>
  test   %rax,%rax
  jne    L17
  mov    $0x1,%eax
  jmp    L6
L17:
  mov    $0x0,%eax
L6:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D6
type_infered: string

tool: D6: DKIF

assistant: ```c
int fourcc_is_ivf(const char detect[4]) {
  if (memcmp(detect, "DKIF", 4) == 0) {
    return 1;
  }
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<fourcc_is_ivf>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x4,%edx
  lea    D6(%rip),%rsi
  call   <memcmp@plt>
  test   %rax,%rax
  sete   %al
  movzbl %al,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D6
datatype: string

tool: D6: DKIF

assistant: ```c
int fourcc_is_ivf(const char detect[4]) {
  if (memcmp(detect, "DKIF", 4) == 0) {
    return 1;
  }
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<fourcc_is_ivf>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x4,%edx
  lea    D0(%rip),%rsi
  call   <memcmp@plt>
  test   %rax,%rax
  sete   %al
  add    $0x8,%rsp
  movzbl %al,%eax
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D0
data_type: string

tool: D0: DKIF

assistant: ```c
int fourcc_is_ivf(const char detect[4]) {
  if (memcmp(detect, "DKIF", 4) == 0) {
    return 1;
  }
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<fourcc_is_ivf>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x4,%edx
  lea    D1(%rip),%rsi
  call   <memcmp@plt>
  test   %rax,%rax
  sete   %al
  add    $0x8,%rsp
  movzbl %al,%eax
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D1
data_type: string

tool: D1: DKIF

assistant: ```c
int fourcc_is_ivf(const char detect[4]) {
  if (memcmp(detect, "DKIF", 4) == 0) {
    return 1;
  }
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<teste>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %esi,-0x8(%rbp)
  mov    %edx,-0xc(%rbp)
  mov    %ecx,-0x10(%rbp)
  cmpl   $0x1,-0x10(%rbp)
  jne    L58
  jmp    L66
L61:
  mov    -0x4(%rbp),%eax
  mov    -0x8(%rbp),%ecx
  mov    -0xc(%rbp),%edx
  mov    %eax,%esi
  lea    D10(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    -0x4(%rbp),%rax
  mov    %rax,%rsi
  lea    D1(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
L66:
  mov    -0x4(%rbp),%eax
  cmp    %eax,-0x8(%rbp)
  je     L27
  mov    -0x4(%rbp),%eax
  cmp    %eax,-0xc(%rbp)
  jne    L61
  jmp    L27
L58:
  cmpl   $0x2,-0x10(%rbp)
  jne    L27
  jmp    L9
L21:
  mov    -0x4(%rbp),%eax
  mov    -0xc(%rbp),%ecx
  mov    -0x8(%rbp),%edx
  mov    %eax,%esi
  lea    D18(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    -0x4(%rbp),%rax
  mov    %rax,%rsi
  lea    D1(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
L9:
  mov    -0x4(%rbp),%eax
  cmp    %eax,-0x8(%rbp)
  jg     L21
  mov    -0x4(%rbp),%eax
  cmp    %eax,-0xc(%rbp)
  jl     L21
L27:
  mov    -0x4(%rbp),%eax
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D10
datatype: string
name: extract_symbolic_data
arguments: data_tag: D1
datatype: string
name: extract_symbolic_data
arguments: data_tag: D18
datatype: string

tool: D10: Sua entrada %i eh invalida. Digite %i para sim ou %i para nao:


tool: D1: %i

tool: D18: Sua entrada %i eh invalida. Digite um valor entre %i e %i


assistant: ```c
int teste(int var, int isso, int aquilo, int tipo) {
  if (tipo == 1) {
    while (var != isso && var != aquilo) {
      printf("Sua entrada %i eh invalida. Digite %i para sim ou %i para nao:\n", var, aquilo, isso);
      scanf("%i", &var);
    }
  } else if (tipo == 2) {
    while (var < isso || var > aquilo) {
      printf("Sua entrada %i eh invalida. Digite um valor entre %i e %i\n", var, isso, aquilo);
      scanf("%i", &var);
    }
  }
  return (var);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<teste>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %edi,0xc(%rsp)
  mov    %esi,%ebp
  mov    %edx,%ebx
  cmp    $0x1,%ecx
  je     L46
  cmp    $0x2,%ecx
  je     L28
L27:
  mov    0xc(%rsp),%eax
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L46:
  mov    %edi,%esi
  cmp    %edi,%ebp
  je     L27
  cmp    %edi,%edx
  je     L27
  lea    D17(%rip),%r14
  lea    0xc(%rsp),%r13
  lea    D8(%rip),%r12
L83:
  mov    %ebp,%ecx
  mov    %ebx,%edx
  mov    %r14,%rdi
  call   <printf@plt>
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  mov    0xc(%rsp),%esi
  cmp    %ebp,%esi
  je     L27
  cmp    %ebx,%esi
  jne    L83
  jmp    L27
L28:
  mov    0xc(%rsp),%esi
  cmp    %esi,%edx
  jl     L86
  cmp    %esi,%ebp
  jle    L27
L86:
  lea    D18(%rip),%r14
  lea    0xc(%rsp),%r13
  lea    D8(%rip),%r12
L96:
  mov    %ebx,%ecx
  mov    %ebp,%edx
  mov    %r14,%rdi
  call   <printf@plt>
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  mov    0xc(%rsp),%esi
  cmp    %ebx,%esi
  jg     L96
  cmp    %ebp,%esi
  jl     L96
  jmp    L27
```

tool_calls: name: read_data
arguments: label: D17
type_infered: string
name: read_data
arguments: label: D8
type_infered: string
name: read_data
arguments: label: D18
type_infered: string

tool: D17: Sua entrada %i eh invalida. Digite %i para sim ou %i para nao:


tool: D8: %i

tool: D18: Sua entrada %i eh invalida. Digite um valor entre %i e %i


assistant: ```c
int teste(int var, int isso, int aquilo, int tipo) {
  if (tipo == 1) {
    while (var != isso && var != aquilo) {
      printf("Sua entrada %i eh invalida. Digite %i para sim ou %i para nao:\n", var, aquilo, isso);
      scanf("%i", &var);
    }
  } else if (tipo == 2) {
    while (var < isso || var > aquilo) {
      printf("Sua entrada %i eh invalida. Digite um valor entre %i e %i\n", var, isso, aquilo);
      scanf("%i", &var);
    }
  }
  return (var);
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<teste>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %esi,%ebx
  mov    %edi,%esi
  sub    $0x10,%rsp
  mov    %edi,0xc(%rsp)
  cmp    $0x1,%ecx
  je     L79
  cmp    $0x2,%ecx
  je     L99
L81:
  add    $0x10,%rsp
  mov    %esi,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax,%rax,1)
L99:
  cmp    %edx,%edi
  jg     L60
  cmp    %ebx,%edi
  jge    L81
L60:
  lea    0xc(%rsp),%r13
  lea    D19(%rip),%r12
  lea    D27(%rip),%r14
  nopl   0x0(%rax,%rax,1)
L97:
  mov    %ebp,%ecx
  mov    %ebx,%edx
  mov    %r14,%rdi
  call   <printf@plt>
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  mov    0xc(%rsp),%esi
  cmp    %ebx,%esi
  jl     L97
  cmp    %ebp,%esi
  jg     L97
  add    $0x10,%rsp
  mov    %esi,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopw   0x0(%rax,%rax,1)
L79:
  cmp    %ebx,%edi
  je     L81
  cmp    %edx,%edi
  je     L81
  lea    D2(%rip),%r14
  lea    0xc(%rsp),%r13
  lea    D19(%rip),%r12
  nopl   0x0(%rax,%rax,1)
L87:
  mov    %ebx,%ecx
  mov    %ebp,%edx
  mov    %r14,%rdi
  call   <printf@plt>
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  mov    0xc(%rsp),%esi
  cmp    %ebx,%esi
  je     L81
  cmp    %ebp,%esi
  jne    L87
  add    $0x10,%rsp
  mov    %esi,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D19
type_guessed: string
name: unpack_data
arguments: data_label: D27
type_guessed: string
name: unpack_data
arguments: data_label: D2
type_guessed: string

tool: D19: %i

tool: D27: Sua entrada %i eh invalida. Digite um valor entre %i e %i


tool: D2: Sua entrada %i eh invalida. Digite %i para sim ou %i para nao:


assistant: ```c
int teste(int var, int isso, int aquilo, int tipo) {
  if (tipo == 1) {
    while (var != isso && var != aquilo) {
      printf("Sua entrada %i eh invalida. Digite %i para sim ou %i para nao:\n", var, aquilo, isso);
      scanf("%i", &var);
    }
  } else if (tipo == 2) {
    while (var < isso || var > aquilo) {
      printf("Sua entrada %i eh invalida. Digite um valor entre %i e %i\n", var, isso, aquilo);
      scanf("%i", &var);
    }
  }
  return (var);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<teste>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %esi,%ebx
  mov    %edi,%esi
  sub    $0x10,%rsp
  mov    %edi,0xc(%rsp)
  cmp    $0x1,%ecx
  je     L9
  cmp    $0x2,%ecx
  je     L51
L26:
  add    $0x10,%rsp
  mov    %esi,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax,%rax,1)
L51:
  cmp    %edx,%edi
  jg     L25
  cmp    %ebx,%edi
  jge    L26
L25:
  lea    0xc(%rsp),%r13
  lea    D26(%rip),%r12
  lea    D14(%rip),%r14
  nopl   0x0(%rax,%rax,1)
L22:
  mov    %ebp,%ecx
  mov    %ebx,%edx
  mov    %r14,%rdi
  call   <printf@plt>
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  mov    0xc(%rsp),%esi
  cmp    %ebx,%esi
  jl     L22
  cmp    %ebp,%esi
  jg     L22
  add    $0x10,%rsp
  mov    %esi,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopw   0x0(%rax,%rax,1)
L9:
  cmp    %ebx,%edi
  je     L26
  cmp    %edx,%edi
  je     L26
  lea    D4(%rip),%r14
  lea    0xc(%rsp),%r13
  lea    D26(%rip),%r12
  nopl   0x0(%rax,%rax,1)
L44:
  mov    %ebx,%ecx
  mov    %ebp,%edx
  mov    %r14,%rdi
  call   <printf@plt>
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  mov    0xc(%rsp),%esi
  cmp    %ebx,%esi
  je     L26
  cmp    %ebp,%esi
  jne    L44
  add    $0x10,%rsp
  mov    %esi,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D26
type: string
name: retrieve_data
arguments: data_label: D14
type: string
name: retrieve_data
arguments: data_label: D4
type: string

tool: D26: %i

tool: D14: Sua entrada %i eh invalida. Digite um valor entre %i e %i


tool: D4: Sua entrada %i eh invalida. Digite %i para sim ou %i para nao:


assistant: ```c
int teste(int var, int isso, int aquilo, int tipo) {
  if (tipo == 1) {
    while (var != isso && var != aquilo) {
      printf("Sua entrada %i eh invalida. Digite %i para sim ou %i para nao:\n", var, aquilo, isso);
      scanf("%i", &var);
    }
  } else if (tipo == 2) {
    while (var < isso || var > aquilo) {
      printf("Sua entrada %i eh invalida. Digite um valor entre %i e %i\n", var, isso, aquilo);
      scanf("%i", &var);
    }
  }
  return (var);
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<sock_send>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %edx,-0x44(%rbp)
  mov    %ecx,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x40(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x44(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
  movl   $0x0,-0x28(%rbp)
  lea    -0x18(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <gettimeofday@plt>
  jmp    L16
L24:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  mov    -0x2c(%rbp),%edx
  mov    -0x20(%rbp),%rsi
  mov    $0x0,%ecx
  mov    %eax,%edi
  call   <send@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0xffffffff,-0x24(%rbp)
  jne    L49
  mov    D7(%rip),%rax
  mov    (%rax),%rdx
  mov    D11(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L27
  lea    -0x10(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <gettimeofday@plt>
  mov    -0x10(%rbp),%eax
  mov    -0x18(%rbp),%edx
  sub    %edx,%eax
  movslq %eax,%rdx
  imul   $0x10624dd3,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x6,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0xc(%rbp),%eax
  mov    -0x14(%rbp),%edx
  sub    %edx,%eax
  imul   $0x3e8,%eax,%eax
  add    %eax,-0x28(%rbp)
  mov    -0x48(%rbp),%eax
  imul   $0x3e8,%eax,%eax
  cmp    %eax,-0x28(%rbp)
  jle    L16
  jmp    L0
L49:
  mov    -0x24(%rbp),%eax
  cltq
  add    %rax,-0x20(%rbp)
  mov    -0x24(%rbp),%eax
  sub    %eax,-0x2c(%rbp)
L16:
  cmpl   $0x0,-0x2c(%rbp)
  jg     L24
  jmp    L0
L27:
  nop
L0:
  movq   $0x0,-0x20(%rbp)
  mov    -0x44(%rbp),%eax
  sub    -0x2c(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L52
  call   <__stack_chk_fail@plt>
L52:
  leave
  ret
```

assistant: ```c
int sock_send(int *fd, void *buf, int len, int timeout_secs) {
  char *p = (char *)buf;
  int n, rem = len, elapsed_ms = 0;
  struct timeval start, now;
  gettimeofday(&start, 0);
  while (rem > 0) {
    n = send((*fd), p, rem, 0);
    if (n == -1) {
      if (errno != EWOULDBLOCK)
        break;
      gettimeofday(&now, 0);
      elapsed_ms = ((now.tv_usec - start.tv_usec) / 1000);
      elapsed_ms += ((now.tv_sec - start.tv_sec) * 1000);
      if (elapsed_ms > (timeout_secs * 1000))
        break;
    } else {
      p += n;
      rem -= n;
    }
  }
  p = NULL;
  return (len - rem);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<sock_send>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%r12
  mov    %rsi,%rbp
  mov    %edx,%r14d
  mov    %ecx,%r13d
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0x8(%rsp),%rdi
  mov    $0x0,%esi
  call   <gettimeofday@plt>
  test   %r14d,%r14d
  jle    L34
  imul   $0x3e8,%r13d,%r13d
  mov    %r14d,%ebx
  lea    0x10(%rsp),%r15
  jmp    L50
L15:
  movslq %eax,%rdx
  add    %rdx,%rbp
  sub    %eax,%ebx
L8:
  test   %ebx,%ebx
  jle    L42
L50:
  mov    $0x0,%ecx
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    (%r12),%edi
  call   <send@plt>
  cmp    $0xffffffff,%eax
  jne    L15
  mov    D7(%rip),%rdx
  mov    D18(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  jne    L42
  mov    $0x0,%esi
  mov    %r15,%rdi
  call   <gettimeofday@plt>
  mov    0x10(%rsp),%eax
  sub    0x8(%rsp),%eax
  movslq %eax,%rdx
  imul   $0x10624dd3,%rdx,%rdx
  sar    $0x26,%rdx
  sar    $0x1f,%eax
  sub    %eax,%edx
  mov    0x14(%rsp),%eax
  sub    0xc(%rsp),%eax
  imul   $0x3e8,%eax,%eax
  add    %edx,%eax
  cmp    %eax,%r13d
  jge    L8
L42:
  mov    %r14d,%eax
  sub    %ebx,%eax
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L77
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L34:
  mov    %r14d,%ebx
  jmp    L42
L77:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int sock_send(int *fd, void *buf, int len, int timeout_secs) {
  char *p = (char *)buf;
  int n, rem = len, elapsed_ms = 0;
  struct timeval start, now;
  gettimeofday(&start, 0);
  while (rem > 0) {
    n = send((*fd), p, rem, 0);
    if (n == -1) {
      if (errno != EWOULDBLOCK)
        break;
      gettimeofday(&now, 0);
      elapsed_ms = ((now.tv_usec - start.tv_usec) / 1000);
      elapsed_ms += ((now.tv_sec - start.tv_sec) * 1000);
      if (elapsed_ms > (timeout_secs * 1000))
        break;
    } else {
      p += n;
      rem -= n;
    }
  }
  p = NULL;
  return (len - rem);
}
```