ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Demonstrate the C code that generates the assembly output below:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x1,%edi
  call   <assume@plt>
  xor    %edi,%edi
  call   <assert@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int main() {
  int i;
  int j;
  int k;
  int l;
  i = j;
  assume(i < 200);
  while (i < 500) {
    i = i + 1;
    j = j + 1;
    k = 0;
    l = 0;
    while (k < 200) {
      k = k + 1;
      l = l + 1;
    }
    i = i + k;
    j = j + l;
  }
  assert(i == j + 1);
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<ft_putnbr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  jns    L39
  mov    $0x2d,%edi
  call   <ft_putchar@plt>
  cmpl   $0x80000000,-0x4(%rbp)
  jne    L35
  mov    $0x32,%edi
  call   <ft_putchar@plt>
  movl   $0x8ca6c00,-0x4(%rbp)
  jmp    L39
L35:
  negl   -0x4(%rbp)
L39:
  cmpl   $0x9,-0x4(%rbp)
  jg     L10
  mov    -0x4(%rbp),%eax
  add    $0x30,%eax
  mov    %eax,%edi
  call   <ft_putchar@plt>
  jmp    L20
L10:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  imul   $0x66666667,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x2,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %eax,%edi
  call   <ft_putnbr>
  mov    -0x4(%rbp),%ecx
  movslq %ecx,%rax
  imul   $0x66666667,%rax,%rax
  shr    $0x20,%rax
  sar    $0x2,%eax
  mov    %ecx,%esi
  sar    $0x1f,%esi
  sub    %esi,%eax
  mov    %eax,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  sub    %eax,%ecx
  mov    %ecx,%edx
  lea    0x30(%rdx),%eax
  mov    %eax,%edi
  call   <ft_putchar@plt>
L20:
  nop
  leave
  ret
```

assistant: ```c
void ft_putnbr(int n) {
  if (n < 0) {
    ft_putchar('-');
    if (n == -2147483648) {
      ft_putchar('2');
      n = 147483648;
    } else
      n *= -1;
  }
  if (n <= 9)
    ft_putchar('0' + n);
  else {
    ft_putnbr(n / 10);
    ft_putchar('0' + n % 10);
  }
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<ft_putnbr>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %edi,%ebx
  test   %edi,%edi
  js     L35
L20:
  cmp    $0x9,%ebx
  jle    L34
L3:
  movslq %ebx,%rbp
  imul   $0x66666667,%rbp,%rbp
  sar    $0x22,%rbp
  mov    %ebx,%eax
  sar    $0x1f,%eax
  sub    %eax,%ebp
  mov    %ebp,%edi
  call   <ft_putnbr>
  lea    0x0(%rbp,%rbp,4),%eax
  add    %eax,%eax
  sub    %eax,%ebx
  lea    0x30(%rbx),%edi
  call   <ft_putchar@plt>
L26:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L35:
  mov    $0x2d,%edi
  call   <ft_putchar@plt>
  cmp    $0x80000000,%ebx
  je     L29
  neg    %ebx
  jmp    L20
L29:
  mov    $0x32,%edi
  call   <ft_putchar@plt>
  mov    $0x8ca6c00,%ebx
  jmp    L3
L34:
  lea    0x30(%rbx),%edi
  call   <ft_putchar@plt>
  jmp    L26
```

assistant: ```c
void ft_putnbr(int n) {
  if (n < 0) {
    ft_putchar('-');
    if (n == -2147483648) {
      ft_putchar('2');
      n = 147483648;
    } else
      n *= -1;
  }
  if (n <= 9)
    ft_putchar('0' + n);
  else {
    ft_putnbr(n / 10);
    ft_putchar('0' + n % 10);
  }
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<ft_putnbr>:
  endbr64
  push   %rbp
  push   %rbx
  mov    %edi,%ebx
  sub    $0x8,%rsp
  test   %edi,%edi
  js     L44
L9:
  cmp    $0x9,%ebx
  jle    L43
  mov    %ebx,%edi
  mov    $0xcccccccd,%eax
  imul   %rax,%rdi
  shr    $0x23,%rdi
  lea    (%rdi,%rdi,4),%eax
  add    %eax,%eax
  sub    %eax,%ebx
  lea    0x30(%rbx),%ebp
L35:
  call   <ft_putnbr>
  add    $0x8,%rsp
  mov    %ebp,%edi
  pop    %rbx
  pop    %rbp
  jmp    1050 <ft_putchar@plt>
L43:
  add    $0x8,%rsp
  lea    0x30(%rbx),%edi
  pop    %rbx
  pop    %rbp
  jmp    1050 <ft_putchar@plt>
  xchg   %ax,%ax
L44:
  mov    $0x2d,%edi
  call   <ft_putchar@plt>
  cmp    $0x80000000,%ebx
  je     L0
  neg    %ebx
  jmp    L9
  cs nopw 0x0(%rax,%rax,1)
L0:
  mov    $0x32,%edi
  mov    $0x38,%ebp
  call   <ft_putchar@plt>
  mov    $0xe10acc,%edi
  jmp    L35
```

assistant: ```c
void ft_putnbr(int n) {
  if (n < 0) {
    ft_putchar('-');
    if (n == -2147483648) {
      ft_putchar('2');
      n = 147483648;
    } else
      n *= -1;
  }
  if (n <= 9)
    ft_putchar('0' + n);
  else {
    ft_putnbr(n / 10);
    ft_putchar('0' + n % 10);
  }
}
```
user: What is the c source code of the assembly code below:

```asm
<dot_matrix_3x_generic_output>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x8(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    %rdx,-0x18(%rbp)
  mov    %ecx,-0x1c(%rbp)
  mov    %r8d,-0x20(%rbp)
  mov    -0x1c(%rbp),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x20(%rbp),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,(%rax)
  nop
  pop    %rbp
  ret
```

assistant: ```c
void dot_matrix_3x_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) {
  *out_width = width * 3;
  *out_height = height * 3;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<dot_matrix_3x_generic_output>:
  endbr64
  lea    (%rcx,%rcx,2),%eax
  mov    %eax,(%rsi)
  lea    (%r8,%r8,2),%eax
  mov    %eax,(%rdx)
  ret
```

assistant: ```c
void dot_matrix_3x_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) {
  *out_width = width * 3;
  *out_height = height * 3;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<dot_matrix_3x_generic_output>:
  endbr64
  lea    (%rcx,%rcx,2),%eax
  mov    %eax,(%rsi)
  lea    (%r8,%r8,2),%eax
  mov    %eax,(%rdx)
  ret
```

assistant: ```c
void dot_matrix_3x_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) {
  *out_width = width * 3;
  *out_height = height * 3;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<dot_matrix_3x_generic_output>:
  endbr64
  lea    (%rcx,%rcx,2),%eax
  mov    %eax,(%rsi)
  lea    (%r8,%r8,2),%eax
  mov    %eax,(%rdx)
  ret
```

assistant: ```c
void dot_matrix_3x_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) {
  *out_width = width * 3;
  *out_height = height * 3;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<chld_handler>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  nop
L12:
  mov    D8(%rip),%rax
  mov    (%rax),%edx
  lea    -0xc(%rbp),%rax
  mov    %rax,%rsi
  mov    $0xffffffff,%edi
  call   <waitpid@plt>
  test   %rax,%rax
  jg     L12
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L3
  call   <__stack_chk_fail@plt>
L3:
  leave
  ret
```

assistant: ```c
void chld_handler() {
  int st;
  while ((waitpid(-1, &st, WNOHANG)) > 0)
    ;
}
```
user: What is the c source code of the assembly code below?

```asm
<chld_handler>:
  endbr64
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    D2(%rip),%rbx
L4:
  lea    0x4(%rsp),%rsi
  mov    (%rbx),%edx
  mov    $0xffffffff,%edi
  call   <waitpid@plt>
  test   %rax,%rax
  jg     L4
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L12
  add    $0x10,%rsp
  pop    %rbx
  ret
L12:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void chld_handler() {
  int st;
  while ((waitpid(-1, &st, WNOHANG)) > 0)
    ;
}
```
user: What is the c source code of the assembly code below?

```asm
<chld_handler>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    D5(%rip),%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rbx
  cs nopw 0x0(%rax,%rax,1)
L12:
  mov    0x0(%rbp),%edx
  mov    %rbx,%rsi
  mov    $0xffffffff,%edi
  call   <waitpid@plt>
  test   %rax,%rax
  jg     L12
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L17
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L17:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void chld_handler() {
  int st;
  while ((waitpid(-1, &st, WNOHANG)) > 0)
    ;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<chld_handler>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    D4(%rip),%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rbx
  cs nopw 0x0(%rax,%rax,1)
L8:
  mov    0x0(%rbp),%edx
  mov    %rbx,%rsi
  mov    $0xffffffff,%edi
  call   <waitpid@plt>
  test   %rax,%rax
  jg     L8
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L16
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L16:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void chld_handler() {
  int st;
  while ((waitpid(-1, &st, WNOHANG)) > 0)
    ;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<query_B>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x820,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D59(%rip),%rax
  mov    %rax,-0x818(%rbp)
  mov    -0x818(%rbp),%rdx
  lea    -0x810(%rbp),%rax
  mov    $0x138a,%ecx
  lea    D110(%rip),%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    $0x3e9,%edi
  call   <WSQ_BeginTransaction@plt>
  mov    $0x65,%edi
  call   <WSQ_BeginSubgraph@plt>
  lea    -0x810(%rbp),%rax
  mov    %rax,%r8
  lea    D39(%rip),%rax
  mov    %rax,%rcx
  lea    D97(%rip),%rax
  mov    %rax,%rdx
  lea    D62(%rip),%rax
  mov    %rax,%rsi
  mov    $0x14,%edi
  call   <WSQ_AddOp@plt>
  lea    D118(%rip),%r8
  lea    D74(%rip),%rax
  mov    %rax,%rcx
  lea    D39(%rip),%rax
  mov    %rax,%rdx
  lea    D56(%rip),%rax
  mov    %rax,%rsi
  mov    $0x2,%edi
  call   <WSQ_AddOp@plt>
  lea    D30(%rip),%r8
  lea    D97(%rip),%rax
  mov    %rax,%rcx
  lea    D74(%rip),%rax
  mov    %rax,%rdx
  lea    D83(%rip),%rax
  mov    %rax,%rsi
  mov    $0x3,%edi
  call   <WSQ_AddOp@plt>
  mov    $0x0,%eax
  call   <WSQ_EndSubgraph@plt>
  mov    $0x0,%eax
  call   <WSQ_EndTransaction@plt>
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L3
  call   <__stack_chk_fail@plt>
L3:
  leave
  ret
```

tool_calls: name: read_data
arguments: data_tag: D59
type_infered: string
name: read_data
arguments: data_tag: D110
type_infered: string
name: read_data
arguments: data_tag: D39
type_infered: string
name: read_data
arguments: data_tag: D97
type_infered: string
name: read_data
arguments: data_tag: D62
type_infered: string
name: read_data
arguments: data_tag: D118
type_infered: string
name: read_data
arguments: data_tag: D74
type_infered: string
name: read_data
arguments: data_tag: D56
type_infered: string
name: read_data
arguments: data_tag: D30
type_infered: string
name: read_data
arguments: data_tag: D83
type_infered: string

tool: D59: localhost

tool: D110: %s | %d | bigint TIMESTAMP, string SYMBOL, bigint EXCHTIMESTAMP, bigint RECEIVEDTIME, double BID, double BIDSIZE, double ASK, double ASKSIZE 

tool: D39: 100

tool: 

tool: D62: ConnectRemoteIn

tool: D118: output_timer.ws | output_timer | 1.0 

tool: D74: 200

tool: D56: UDF

tool: D30:  Should never see this.. 

tool: D83: Printer

assistant: ```c
void query_B() {
  char strargs[2048];
  char *machine = "localhost";
  sprintf(strargs, "%s | %d | bigint TIMESTAMP, string SYMBOL, bigint EXCHTIMESTAMP, bigint RECEIVEDTIME, double BID, double BIDSIZE, double ASK, double ASKSIZE ", machine, 5002);
  WSQ_BeginTransaction(1001);
  WSQ_BeginSubgraph(101);
  WSQ_AddOp(20, "ConnectRemoteIn", "", "100", strargs);
  WSQ_AddOp(2, "UDF", "100", "200", "output_timer.ws | output_timer | 1.0 ");
  WSQ_AddOp(3, "Printer", "200", "", " Should never see this.. ");
  WSQ_EndSubgraph();
  WSQ_EndTransaction();
}
```
user: Translate the below assembly code into C programming language:

```asm
<query_B>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x810,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x808(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbx
  mov    $0x138a,%ecx
  lea    D98(%rip),%rdx
  lea    D74(%rip),%rsi
  mov    %rbx,%rdi
  call   <sprintf@plt>
  mov    $0x3e9,%edi
  call   <WSQ_BeginTransaction@plt>
  mov    $0x65,%edi
  call   <WSQ_BeginSubgraph@plt>
  mov    %rbx,%r8
  lea    D47(%rip),%r12
  mov    %r12,%rcx
  lea    D99(%rip),%rbp
  mov    %rbp,%rdx
  lea    D50(%rip),%rsi
  mov    $0x14,%edi
  call   <WSQ_AddOp@plt>
  lea    D36(%rip),%r8
  lea    D56(%rip),%rbx
  mov    %rbx,%rcx
  mov    %r12,%rdx
  lea    D44(%rip),%rsi
  mov    $0x2,%edi
  call   <WSQ_AddOp@plt>
  lea    D29(%rip),%r8
  mov    %rbp,%rcx
  mov    %rbx,%rdx
  lea    D27(%rip),%rsi
  mov    $0x3,%edi
  call   <WSQ_AddOp@plt>
  mov    $0x0,%eax
  call   <WSQ_EndSubgraph@plt>
  mov    $0x0,%eax
  call   <WSQ_EndTransaction@plt>
  mov    0x808(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L4
  add    $0x810,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L4:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D98
data_type: string
name: read_data
arguments: label: D74
data_type: string
name: read_data
arguments: label: D47
data_type: string
name: read_data
arguments: label: D99
data_type: string
name: read_data
arguments: label: D50
data_type: string
name: read_data
arguments: label: D36
data_type: string
name: read_data
arguments: label: D56
data_type: string
name: read_data
arguments: label: D44
data_type: string
name: read_data
arguments: label: D29
data_type: string
name: read_data
arguments: label: D27
data_type: string

tool: D98: localhost

tool: D74: %s | %d | bigint TIMESTAMP, string SYMBOL, bigint EXCHTIMESTAMP, bigint RECEIVEDTIME, double BID, double BIDSIZE, double ASK, double ASKSIZE 

tool: D47: 100

tool: 

tool: D50: ConnectRemoteIn

tool: D36: output_timer.ws | output_timer | 1.0 

tool: D56: 200

tool: D44: UDF

tool: D29:  Should never see this.. 

tool: D27: Printer

assistant: ```c
void query_B() {
  char strargs[2048];
  char *machine = "localhost";
  sprintf(strargs, "%s | %d | bigint TIMESTAMP, string SYMBOL, bigint EXCHTIMESTAMP, bigint RECEIVEDTIME, double BID, double BIDSIZE, double ASK, double ASKSIZE ", machine, 5002);
  WSQ_BeginTransaction(1001);
  WSQ_BeginSubgraph(101);
  WSQ_AddOp(20, "ConnectRemoteIn", "", "100", strargs);
  WSQ_AddOp(2, "UDF", "100", "200", "output_timer.ws | output_timer | 1.0 ");
  WSQ_AddOp(3, "Printer", "200", "", " Should never see this.. ");
  WSQ_EndSubgraph();
  WSQ_EndTransaction();
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<query_B>:
  endbr64
  push   %r14
  mov    $0x138a,%ecx
  lea    D16(%rip),%rdx
  lea    D13(%rip),%rsi
  push   %r13
  lea    D89(%rip),%r14
  lea    D90(%rip),%r13
  push   %r12
  sub    $0x810,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x808(%rsp)
  xor    %eax,%eax
  mov    %rsp,%r12
  mov    %r12,%rdi
  call   <sprintf@plt>
  mov    $0x3e9,%edi
  call   <WSQ_BeginTransaction@plt>
  mov    $0x65,%edi
  call   <WSQ_BeginSubgraph@plt>
  mov    %r12,%r8
  mov    %r14,%rcx
  mov    %r13,%rdx
  lea    D31(%rip),%rsi
  mov    $0x14,%edi
  lea    D43(%rip),%r12
  call   <WSQ_AddOp@plt>
  mov    %r12,%rcx
  mov    %r14,%rdx
  mov    $0x2,%edi
  lea    D99(%rip),%r8
  lea    D29(%rip),%rsi
  call   <WSQ_AddOp@plt>
  mov    %r13,%rcx
  mov    %r12,%rdx
  mov    $0x3,%edi
  lea    D80(%rip),%r8
  lea    D68(%rip),%rsi
  call   <WSQ_AddOp@plt>
  xor    %eax,%eax
  call   <WSQ_EndSubgraph@plt>
  xor    %eax,%eax
  call   <WSQ_EndTransaction@plt>
  mov    0x808(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L2
  add    $0x810,%rsp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L2:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D16
datatype: string
name: unpack_data
arguments: tag: D13
datatype: string
name: unpack_data
arguments: tag: D89
datatype: string
name: unpack_data
arguments: tag: D90
datatype: string
name: unpack_data
arguments: tag: D31
datatype: string
name: unpack_data
arguments: tag: D43
datatype: string
name: unpack_data
arguments: tag: D99
datatype: string
name: unpack_data
arguments: tag: D29
datatype: string
name: unpack_data
arguments: tag: D80
datatype: string
name: unpack_data
arguments: tag: D68
datatype: string

tool: D16: localhost

tool: D13: %s | %d | bigint TIMESTAMP, string SYMBOL, bigint EXCHTIMESTAMP, bigint RECEIVEDTIME, double BID, double BIDSIZE, double ASK, double ASKSIZE 

tool: D89: 100

tool: 

tool: D31: ConnectRemoteIn

tool: D43: 200

tool: D99: output_timer.ws | output_timer | 1.0 

tool: D29: UDF

tool: D80:  Should never see this.. 

tool: D68: Printer

assistant: ```c
void query_B() {
  char strargs[2048];
  char *machine = "localhost";
  sprintf(strargs, "%s | %d | bigint TIMESTAMP, string SYMBOL, bigint EXCHTIMESTAMP, bigint RECEIVEDTIME, double BID, double BIDSIZE, double ASK, double ASKSIZE ", machine, 5002);
  WSQ_BeginTransaction(1001);
  WSQ_BeginSubgraph(101);
  WSQ_AddOp(20, "ConnectRemoteIn", "", "100", strargs);
  WSQ_AddOp(2, "UDF", "100", "200", "output_timer.ws | output_timer | 1.0 ");
  WSQ_AddOp(3, "Printer", "200", "", " Should never see this.. ");
  WSQ_EndSubgraph();
  WSQ_EndTransaction();
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<query_B>:
  endbr64
  push   %r14
  mov    $0x138a,%ecx
  lea    D62(%rip),%rdx
  lea    D31(%rip),%rsi
  push   %r13
  lea    D37(%rip),%r14
  lea    D7(%rip),%r13
  push   %r12
  sub    $0x810,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x808(%rsp)
  xor    %eax,%eax
  mov    %rsp,%r12
  mov    %r12,%rdi
  call   <sprintf@plt>
  mov    $0x3e9,%edi
  call   <WSQ_BeginTransaction@plt>
  mov    $0x65,%edi
  call   <WSQ_BeginSubgraph@plt>
  mov    %r12,%r8
  mov    %r14,%rcx
  mov    %r13,%rdx
  lea    D87(%rip),%rsi
  mov    $0x14,%edi
  lea    D68(%rip),%r12
  call   <WSQ_AddOp@plt>
  mov    %r12,%rcx
  mov    %r14,%rdx
  mov    $0x2,%edi
  lea    D65(%rip),%r8
  lea    D9(%rip),%rsi
  call   <WSQ_AddOp@plt>
  mov    %r13,%rcx
  mov    %r12,%rdx
  mov    $0x3,%edi
  lea    D1(%rip),%r8
  lea    D24(%rip),%rsi
  call   <WSQ_AddOp@plt>
  xor    %eax,%eax
  call   <WSQ_EndSubgraph@plt>
  xor    %eax,%eax
  call   <WSQ_EndTransaction@plt>
  mov    0x808(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L4
  add    $0x810,%rsp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L4:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D62
datatype: string
name: parse_data
arguments: tag: D31
datatype: string
name: parse_data
arguments: tag: D37
datatype: string
name: parse_data
arguments: tag: D7
datatype: string
name: parse_data
arguments: tag: D87
datatype: string
name: parse_data
arguments: tag: D68
datatype: string
name: parse_data
arguments: tag: D65
datatype: string
name: parse_data
arguments: tag: D9
datatype: string
name: parse_data
arguments: tag: D1
datatype: string
name: parse_data
arguments: tag: D24
datatype: string

tool: D62: localhost

tool: D31: %s | %d | bigint TIMESTAMP, string SYMBOL, bigint EXCHTIMESTAMP, bigint RECEIVEDTIME, double BID, double BIDSIZE, double ASK, double ASKSIZE 

tool: D37: 100

tool: 

tool: D87: ConnectRemoteIn

tool: D68: 200

tool: D65: output_timer.ws | output_timer | 1.0 

tool: D9: UDF

tool: D1:  Should never see this.. 

tool: D24: Printer

assistant: ```c
void query_B() {
  char strargs[2048];
  char *machine = "localhost";
  sprintf(strargs, "%s | %d | bigint TIMESTAMP, string SYMBOL, bigint EXCHTIMESTAMP, bigint RECEIVEDTIME, double BID, double BIDSIZE, double ASK, double ASKSIZE ", machine, 5002);
  WSQ_BeginTransaction(1001);
  WSQ_BeginSubgraph(101);
  WSQ_AddOp(20, "ConnectRemoteIn", "", "100", strargs);
  WSQ_AddOp(2, "UDF", "100", "200", "output_timer.ws | output_timer | 1.0 ");
  WSQ_AddOp(3, "Printer", "200", "", " Should never see this.. ");
  WSQ_EndSubgraph();
  WSQ_EndTransaction();
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<scgi_env_add_uwsgi>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %rcx,-0x30(%rbp)
  mov    %r8,-0x38(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  je     L30
  cmpq   $0x0,-0x30(%rbp)
  jne    L13
  cmpq   $0x0,-0x38(%rbp)
  je     L13
L30:
  mov    $0xffffffff,%eax
  jmp    L36
L13:
  mov    D9(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,-0x28(%rbp)
  ja     L37
  mov    D9(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,-0x38(%rbp)
  jbe    L25
L37:
  mov    $0xffffffff,%eax
  jmp    L36
L25:
  mov    -0x28(%rbp),%rax
  mov    %eax,%edx
  mov    -0x38(%rbp),%rax
  add    %edx,%eax
  add    $0x4,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <buffer_extend@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x28(%rbp),%rax
  shr    $0x8,%rax
  mov    %rax,%rdx
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  mov    %dl,(%rax)
  mov    -0x8(%rbp),%rax
  lea    0x2(%rax),%rcx
  mov    -0x28(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x28(%rbp),%rax
  add    $0x2,%rax
  add    %rax,-0x8(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x38(%rbp),%rax
  shr    $0x8,%rax
  mov    %rax,%rdx
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  mov    %dl,(%rax)
  mov    -0x8(%rbp),%rax
  lea    0x2(%rax),%rcx
  mov    -0x38(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    $0x0,%eax
L36:
  leave
  ret
```

assistant: ```c
int scgi_env_add_uwsgi(void *venv, const char *key, size_t key_len, const char *val, size_t val_len) {
  if (!key || (!val && val_len))
    return -1;
  if (key_len > USHRT_MAX || val_len > USHRT_MAX)
    return -1;
  char *dst = buffer_extend(venv, 2 + key_len + 2 + val_len);
  dst[0] = key_len & 0xff;
  dst[1] = (key_len >> 8) & 0xff;
  memcpy(dst + 2, key, key_len);
  dst += 2 + key_len;
  dst[0] = val_len & 0xff;
  dst[1] = (val_len >> 8) & 0xff;
  memcpy(dst + 2, val, val_len);
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<scgi_env_add_uwsgi>:
  endbr64
  test   %rsi,%rsi
  je     L51
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%r14
  mov    %rdx,%rbx
  mov    %rcx,%r13
  mov    %r8,%rbp
  test   %rcx,%rcx
  jne    L16
  test   %r8,%r8
  jne    L50
L16:
  cmp    %rbx,%rbp
  mov    %rbx,%rax
  cmovae %rbp,%rax
  mov    D7(%rip),%rdx
  cmp    %rax,(%rdx)
  jb     L13
  lea    0x4(%rbx,%rbp,1),%esi
  call   <buffer_extend@plt>
  mov    %rax,%r12
  mov    %bl,(%rax)
  movzbl %bh,%eax
  mov    %al,0x1(%r12)
  lea    0x2(%r12),%rdi
  mov    %rbx,%rdx
  mov    %r14,%rsi
  call   <memcpy@plt>
  lea    0x2(%r12,%rbx,1),%rdi
  mov    %bpl,(%rdi)
  mov    %rbp,%rax
  movzbl %ah,%eax
  mov    %al,0x1(%rdi)
  add    $0x2,%rdi
  mov    %rbp,%rdx
  mov    %r13,%rsi
  call   <memcpy@plt>
  mov    $0x0,%eax
L53:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L51:
  mov    $0xffffffff,%eax
  ret
L50:
  mov    $0xffffffff,%eax
  jmp    L53
L13:
  mov    $0xffffffff,%eax
  jmp    L53
```

assistant: ```c
int scgi_env_add_uwsgi(void *venv, const char *key, size_t key_len, const char *val, size_t val_len) {
  if (!key || (!val && val_len))
    return -1;
  if (key_len > USHRT_MAX || val_len > USHRT_MAX)
    return -1;
  char *dst = buffer_extend(venv, 2 + key_len + 2 + val_len);
  dst[0] = key_len & 0xff;
  dst[1] = (key_len >> 8) & 0xff;
  memcpy(dst + 2, key, key_len);
  dst += 2 + key_len;
  dst[0] = val_len & 0xff;
  dst[1] = (val_len >> 8) & 0xff;
  memcpy(dst + 2, val, val_len);
  return 0;
}
```