ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Translate the below assembly code into C programming language:

```asm
<test_wr3_1>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsp)
  mov    $0x1,%esi
  mov    $0x0,%edi
  call   <signed_range@plt>
  mov    %eax,%edi
  mov    $0x0,%edx
  mov    $0x0,%esi
  call   <wr3_1@plt>
  mov    $0x1,%esi
  mov    $0x1,%edi
  call   <signed_range@plt>
  mov    %eax,%edi
  mov    %rsp,%rdx
  mov    $0x0,%esi
  call   <wr3_1@plt>
  mov    $0x2,%esi
  mov    $0x1,%edi
  call   <signed_range@plt>
  mov    %eax,%edi
  mov    $0x0,%edx
  mov    $0x1,%esi
  call   <wr3_1@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L0
  add    $0x18,%rsp
  ret
L0:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void test_wr3_1(void) {
  {
    void *null = 0;
    void *p = &null;
    wr3_1(signed_range((0), (1)), 0, null);
    wr3_1(signed_range((1), (1)), 0, p);
  }
  void *null = 0;
  wr3_1(signed_range((1), (2)), 1, null);
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<test_wr3_1>:
  endbr64
  sub    $0x18,%rsp
  mov    $0x1,%esi
  xor    %edi,%edi
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsp)
  call   <signed_range@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %eax,%edi
  call   <wr3_1@plt>
  mov    $0x1,%esi
  mov    $0x1,%edi
  call   <signed_range@plt>
  mov    %rsp,%rdx
  xor    %esi,%esi
  mov    %eax,%edi
  call   <wr3_1@plt>
  mov    $0x1,%edi
  mov    $0x2,%esi
  call   <signed_range@plt>
  mov    %eax,%edi
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  xor    %edx,%edx
  mov    $0x1,%esi
  add    $0x18,%rsp
  jmp    1080 <wr3_1@plt>
L5:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void test_wr3_1(void) {
  {
    void *null = 0;
    void *p = &null;
    wr3_1(signed_range((0), (1)), 0, null);
    wr3_1(signed_range((1), (1)), 0, p);
  }
  void *null = 0;
  wr3_1(signed_range((1), (2)), 1, null);
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<test_wr3_1>:
  endbr64
  sub    $0x18,%rsp
  mov    $0x1,%esi
  xor    %edi,%edi
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsp)
  call   <signed_range@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %eax,%edi
  call   <wr3_1@plt>
  mov    $0x1,%esi
  mov    $0x1,%edi
  call   <signed_range@plt>
  mov    %rsp,%rdx
  xor    %esi,%esi
  mov    %eax,%edi
  call   <wr3_1@plt>
  mov    $0x1,%edi
  mov    $0x2,%esi
  call   <signed_range@plt>
  mov    %eax,%edi
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L1
  xor    %edx,%edx
  mov    $0x1,%esi
  add    $0x18,%rsp
  jmp    1080 <wr3_1@plt>
L1:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void test_wr3_1(void) {
  {
    void *null = 0;
    void *p = &null;
    wr3_1(signed_range((0), (1)), 0, null);
    wr3_1(signed_range((1), (1)), 0, p);
  }
  void *null = 0;
  wr3_1(signed_range((1), (2)), 1, null);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<division_of_zero_Good>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  shl    $0x2,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int division_of_zero_Good(int x) {
  int i = 4 * x;
  i /= 2;
  i /= 2;
  return i;
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<division_of_zero_Good>:
  endbr64
  mov    %edi,%eax
  ret
```

assistant: ```c
int division_of_zero_Good(int x) {
  int i = 4 * x;
  i /= 2;
  i /= 2;
  return i;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<division_of_zero_Good>:
  endbr64
  mov    %edi,%eax
  ret
```

assistant: ```c
int division_of_zero_Good(int x) {
  int i = 4 * x;
  i /= 2;
  i /= 2;
  return i;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<division_of_zero_Good>:
  endbr64
  mov    %edi,%eax
  ret
```

assistant: ```c
int division_of_zero_Good(int x) {
  int i = 4 * x;
  i /= 2;
  i /= 2;
  return i;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<help_load>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %rsi,-0x10(%rbp)
  lea    D8(%rip),%rax
  mov    %rax,%rdi
  call   <esc_prn@plt>
  mov    $0x1,%eax
  leave
  ret
```

tool_calls: name: read_data
arguments: data_tag: D8
data_type: string

tool: D8: 
{Hload} [{UFILENAME}[.vpc]]
  Load the configuration/script from the file {UFILENAME}. If {UFILENAME} ends with
  '.vpc', then the '.vpc' can be omitted. If {UFILENAME} is omitted then 
  {Ustartup.vpc} will be loaded if it exists. When the file is loaded, each
  line of the file is executed as a VPCS command. If the state of the echo flag
  is on, the command will be echoed to the console before execution, except: 
  * If the command is prefixed with a '@' symbol (eg {H@set echo color red});
  * If the command is an echo command;
  * If the command is a sleep command 
    Note: The command {Hsleep 0} will be echoed if the echo flag is on
  See {Hset echo} and {Hshow echo}

  Note: Press Ctrl+C to interrupt the running script.


assistant: ```c
int help_load(int argc, char **argv) {
  esc_prn("\n{Hload} [{UFILENAME}[.vpc]]\n"
          "  Load the configuration/script from the file {UFILENAME}. If {UFILENAME} ends with\n"
          "  '.vpc', then the '.vpc' can be omitted. If {UFILENAME} is omitted then \n"
          "  {Ustartup.vpc} will be loaded if it exists. When the file is loaded, each\n"
          "  line of the file is executed as a VPCS command. If the state of the echo flag\n"
          "  is on, the command will be echoed to the console before execution, except: \n"
          "  * If the command is prefixed with a '@' symbol (eg {H@set echo color red});\n"
          "  * If the command is an echo command;\n"
          "  * If the command is a sleep command \n"
          "    Note: The command {Hsleep 0} will be echoed if the echo flag is on\n"
          "  See {Hset echo} and {Hshow echo}\n\n"
          "  Note: Press Ctrl+C to interrupt the running script.\n");
  return 1;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<help_load>:
  endbr64
  sub    $0x8,%rsp
  lea    D8(%rip),%rdi
  call   <esc_prn@plt>
  mov    $0x1,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D8
datatype: string

tool: D8: 
{Hload} [{UFILENAME}[.vpc]]
  Load the configuration/script from the file {UFILENAME}. If {UFILENAME} ends with
  '.vpc', then the '.vpc' can be omitted. If {UFILENAME} is omitted then 
  {Ustartup.vpc} will be loaded if it exists. When the file is loaded, each
  line of the file is executed as a VPCS command. If the state of the echo flag
  is on, the command will be echoed to the console before execution, except: 
  * If the command is prefixed with a '@' symbol (eg {H@set echo color red});
  * If the command is an echo command;
  * If the command is a sleep command 
    Note: The command {Hsleep 0} will be echoed if the echo flag is on
  See {Hset echo} and {Hshow echo}

  Note: Press Ctrl+C to interrupt the running script.


assistant: ```c
int help_load(int argc, char **argv) {
  esc_prn("\n{Hload} [{UFILENAME}[.vpc]]\n"
          "  Load the configuration/script from the file {UFILENAME}. If {UFILENAME} ends with\n"
          "  '.vpc', then the '.vpc' can be omitted. If {UFILENAME} is omitted then \n"
          "  {Ustartup.vpc} will be loaded if it exists. When the file is loaded, each\n"
          "  line of the file is executed as a VPCS command. If the state of the echo flag\n"
          "  is on, the command will be echoed to the console before execution, except: \n"
          "  * If the command is prefixed with a '@' symbol (eg {H@set echo color red});\n"
          "  * If the command is an echo command;\n"
          "  * If the command is a sleep command \n"
          "    Note: The command {Hsleep 0} will be echoed if the echo flag is on\n"
          "  See {Hset echo} and {Hshow echo}\n\n"
          "  Note: Press Ctrl+C to interrupt the running script.\n");
  return 1;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<help_load>:
  endbr64
  sub    $0x8,%rsp
  lea    D2(%rip),%rdi
  call   <esc_prn@plt>
  mov    $0x1,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: read_data
arguments: data_label: D2
type_infered: string

tool: D2: 
{Hload} [{UFILENAME}[.vpc]]
  Load the configuration/script from the file {UFILENAME}. If {UFILENAME} ends with
  '.vpc', then the '.vpc' can be omitted. If {UFILENAME} is omitted then 
  {Ustartup.vpc} will be loaded if it exists. When the file is loaded, each
  line of the file is executed as a VPCS command. If the state of the echo flag
  is on, the command will be echoed to the console before execution, except: 
  * If the command is prefixed with a '@' symbol (eg {H@set echo color red});
  * If the command is an echo command;
  * If the command is a sleep command 
    Note: The command {Hsleep 0} will be echoed if the echo flag is on
  See {Hset echo} and {Hshow echo}

  Note: Press Ctrl+C to interrupt the running script.


assistant: ```c
int help_load(int argc, char **argv) {
  esc_prn("\n{Hload} [{UFILENAME}[.vpc]]\n"
          "  Load the configuration/script from the file {UFILENAME}. If {UFILENAME} ends with\n"
          "  '.vpc', then the '.vpc' can be omitted. If {UFILENAME} is omitted then \n"
          "  {Ustartup.vpc} will be loaded if it exists. When the file is loaded, each\n"
          "  line of the file is executed as a VPCS command. If the state of the echo flag\n"
          "  is on, the command will be echoed to the console before execution, except: \n"
          "  * If the command is prefixed with a '@' symbol (eg {H@set echo color red});\n"
          "  * If the command is an echo command;\n"
          "  * If the command is a sleep command \n"
          "    Note: The command {Hsleep 0} will be echoed if the echo flag is on\n"
          "  See {Hset echo} and {Hshow echo}\n\n"
          "  Note: Press Ctrl+C to interrupt the running script.\n");
  return 1;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<help_load>:
  endbr64
  sub    $0x8,%rsp
  lea    D1(%rip),%rdi
  call   <esc_prn@plt>
  mov    $0x1,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: extract_symbolic_data
arguments: tag: D1
datatype: string

tool: D1: 
{Hload} [{UFILENAME}[.vpc]]
  Load the configuration/script from the file {UFILENAME}. If {UFILENAME} ends with
  '.vpc', then the '.vpc' can be omitted. If {UFILENAME} is omitted then 
  {Ustartup.vpc} will be loaded if it exists. When the file is loaded, each
  line of the file is executed as a VPCS command. If the state of the echo flag
  is on, the command will be echoed to the console before execution, except: 
  * If the command is prefixed with a '@' symbol (eg {H@set echo color red});
  * If the command is an echo command;
  * If the command is a sleep command 
    Note: The command {Hsleep 0} will be echoed if the echo flag is on
  See {Hset echo} and {Hshow echo}

  Note: Press Ctrl+C to interrupt the running script.


assistant: ```c
int help_load(int argc, char **argv) {
  esc_prn("\n{Hload} [{UFILENAME}[.vpc]]\n"
          "  Load the configuration/script from the file {UFILENAME}. If {UFILENAME} ends with\n"
          "  '.vpc', then the '.vpc' can be omitted. If {UFILENAME} is omitted then \n"
          "  {Ustartup.vpc} will be loaded if it exists. When the file is loaded, each\n"
          "  line of the file is executed as a VPCS command. If the state of the echo flag\n"
          "  is on, the command will be echoed to the console before execution, except: \n"
          "  * If the command is prefixed with a '@' symbol (eg {H@set echo color red});\n"
          "  * If the command is an echo command;\n"
          "  * If the command is a sleep command \n"
          "    Note: The command {Hsleep 0} will be echoed if the echo flag is on\n"
          "  See {Hset echo} and {Hshow echo}\n\n"
          "  Note: Press Ctrl+C to interrupt the running script.\n");
  return 1;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<prog_action>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x20(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <action_pointer@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L3
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  jmp    L4
L3:
  mov    $0x0,%eax
L4:
  leave
  ret
```

assistant: ```c
struct action *prog_action(struct program *prog, char *name) {
  struct action **ptr = action_pointer(prog, name);
  return (ptr) ? *ptr : NULL;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<prog_action>:
  endbr64
  sub    $0x8,%rsp
  call   <action_pointer@plt>
  test   %rax,%rax
  je     L4
  mov    (%rax),%rax
L4:
  add    $0x8,%rsp
  ret
```

assistant: ```c
struct action *prog_action(struct program *prog, char *name) {
  struct action **ptr = action_pointer(prog, name);
  return (ptr) ? *ptr : NULL;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<prog_action>:
  endbr64
  sub    $0x8,%rsp
  call   <action_pointer@plt>
  test   %rax,%rax
  je     L1
  mov    (%rax),%rax
L1:
  add    $0x8,%rsp
  ret
```

assistant: ```c
struct action *prog_action(struct program *prog, char *name) {
  struct action **ptr = action_pointer(prog, name);
  return (ptr) ? *ptr : NULL;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<prog_action>:
  endbr64
  sub    $0x8,%rsp
  call   <action_pointer@plt>
  test   %rax,%rax
  je     L1
  mov    (%rax),%rax
L1:
  add    $0x8,%rsp
  ret
```

assistant: ```c
struct action *prog_action(struct program *prog, char *name) {
  struct action **ptr = action_pointer(prog, name);
  return (ptr) ? *ptr : NULL;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<stbhw__weighted>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  movl   $0x0,-0x8(%rbp)
  movl   $0x0,-0xc(%rbp)
  jmp    L11
L15:
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  add    %eax,-0x8(%rbp)
  addl   $0x1,-0xc(%rbp)
L11:
  mov    -0xc(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L15
  mov    $0x0,%eax
  call   <rand@plt>
  sar    $0x4,%eax
  cltd
  idivl  -0x8(%rbp)
  mov    %edx,-0x4(%rbp)
  movl   $0x0,-0x8(%rbp)
  movl   $0x0,-0xc(%rbp)
  jmp    L9
L32:
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  add    %eax,-0x8(%rbp)
  mov    -0x4(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jl     L8
  addl   $0x1,-0xc(%rbp)
L9:
  mov    -0xc(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L32
  jmp    L59
L8:
  nop
L59:
  mov    -0xc(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  setl   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0xc(%rbp),%eax
  leave
  ret
```

assistant: ```c
int stbhw__weighted(int num_options, int *weights) {
  int k, total, choice;
  total = 0;
  for (k = 0; k < num_options; ++k)
    total += weights[k];
  choice = (rand() >> 4) % total;
  total = 0;
  for (k = 0; k < num_options; ++k) {
    total += weights[k];
    if (choice < total)
      break;
  }
  assert(k < num_options);
  return k;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<stbhw__weighted>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,%r12d
  test   %edi,%edi
  jle    L13
  mov    %rsi,%rbp
  mov    %rsi,%rax
  lea    -0x1(%rdi),%edx
  lea    0x4(%rsi,%rdx,4),%rdx
  mov    $0x0,%ebx
L14:
  add    (%rax),%ebx
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L14
  mov    $0x0,%eax
  call   <rand@plt>
  sar    $0x4,%eax
  cltd
  idiv   %ebx
  mov    0x0(%rbp),%esi
  cmp    %esi,%edx
  jl     L61
  mov    %r12d,%edi
  mov    $0x1,%eax
L24:
  mov    %eax,%ebx
  cmp    %rax,%rdi
  je     L67
  add    0x0(%rbp,%rax,4),%esi
  add    $0x1,%rax
  cmp    %edx,%esi
  jle    L24
L67:
  cmp    %ebx,%r12d
  setg   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    %ebx,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L61:
  mov    $0x0,%ebx
  jmp    L67
L13:
  mov    $0x0,%eax
  call   <rand@plt>
  mov    $0x0,%ebx
  jmp    L67
```

assistant: ```c
int stbhw__weighted(int num_options, int *weights) {
  int k, total, choice;
  total = 0;
  for (k = 0; k < num_options; ++k)
    total += weights[k];
  choice = (rand() >> 4) % total;
  total = 0;
  for (k = 0; k < num_options; ++k) {
    total += weights[k];
    if (choice < total)
      break;
  }
  assert(k < num_options);
  return k;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<stbhw__weighted>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %edi,%edi
  jle    L53
  lea    -0x1(%rdi),%edx
  mov    %edi,%r13d
  mov    %rsi,%rbp
  mov    %rsi,%rax
  lea    0x4(%rsi,%rdx,4),%rdx
  xor    %ebx,%ebx
  nopl   (%rax)
L15:
  add    (%rax),%ebx
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L15
  xor    %eax,%eax
  call   <rand@plt>
  mov    0x0(%rbp),%ecx
  sar    $0x4,%eax
  cltd
  idiv   %ebx
  cmp    %ecx,%edx
  jl     L10
  mov    %r13d,%esi
  mov    $0x1,%eax
  jmp    L39
  nopl   0x0(%rax)
L31:
  add    0x0(%rbp,%rax,4),%ecx
  add    $0x1,%rax
  cmp    %edx,%ecx
  jg     L37
L39:
  mov    %eax,%r12d
  cmp    %rax,%rsi
  jne    L31
L37:
  xor    %edi,%edi
  cmp    %r12d,%r13d
  setg   %dil
  call   <assert@plt>
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax,%rax,1)
L53:
  xor    %eax,%eax
  call   <rand@plt>
  ud2
L10:
  xor    %r12d,%r12d
  jmp    L37
```

assistant: ```c
int stbhw__weighted(int num_options, int *weights) {
  int k, total, choice;
  total = 0;
  for (k = 0; k < num_options; ++k)
    total += weights[k];
  choice = (rand() >> 4) % total;
  total = 0;
  for (k = 0; k < num_options; ++k) {
    total += weights[k];
    if (choice < total)
      break;
  }
  assert(k < num_options);
  return k;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<stbhw__weighted>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %edi,%edi
  jle    L81
  lea    -0x1(%rdi),%eax
  mov    %edi,%r12d
  mov    %rsi,%rbp
  cmp    $0x2,%eax
  jbe    L7
  mov    %edi,%edx
  mov    %rsi,%rax
  pxor   %xmm0,%xmm0
  shr    $0x2,%edx
  sub    $0x1,%edx
  shl    $0x4,%rdx
  lea    0x10(%rsi,%rdx,1),%rdx
L67:
  movdqu (%rax),%xmm2
  add    $0x10,%rax
  paddd  %xmm2,%xmm0
  cmp    %rdx,%rax
  jne    L67
  movdqa %xmm0,%xmm1
  mov    %r12d,%eax
  psrldq $0x8,%xmm1
  and    $0xfffffffc,%eax
  paddd  %xmm1,%xmm0
  movdqa %xmm0,%xmm1
  psrldq $0x4,%xmm1
  paddd  %xmm1,%xmm0
  movd   %xmm0,%ebx
  test   $0x3,%r12b
  je     L42
L99:
  movslq %eax,%rdx
  lea    0x0(,%rdx,4),%rcx
  add    0x0(%rbp,%rdx,4),%ebx
  lea    0x1(%rax),%edx
  cmp    %edx,%r12d
  jle    L42
  add    $0x2,%eax
  add    0x4(%rbp,%rcx,1),%ebx
  cmp    %eax,%r12d
  jle    L42
  add    0x8(%rbp,%rcx,1),%ebx
L42:
  xor    %eax,%eax
  call   <rand@plt>
  mov    0x0(%rbp),%ecx
  sar    $0x4,%eax
  cltd
  idiv   %ebx
  cmp    %ecx,%edx
  jl     L35
  mov    %r12d,%esi
  mov    $0x1,%eax
  jmp    L85
L113:
  add    0x0(%rbp,%rax,4),%ecx
  add    $0x1,%rax
  cmp    %edx,%ecx
  jg     L90
L85:
  mov    %eax,%r13d
  cmp    %rsi,%rax
  jne    L113
L90:
  xor    %edi,%edi
  cmp    %r13d,%r12d
  setg   %dil
  call   <assert@plt>
  add    $0x8,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L7:
  xor    %ebx,%ebx
  xor    %eax,%eax
  jmp    L99
  cs nopw 0x0(%rax,%rax,1)
L81:
  xor    %eax,%eax
  call   <rand@plt>
  ud2
L35:
  xor    %r13d,%r13d
  jmp    L90
```

assistant: ```c
int stbhw__weighted(int num_options, int *weights) {
  int k, total, choice;
  total = 0;
  for (k = 0; k < num_options; ++k)
    total += weights[k];
  choice = (rand() >> 4) % total;
  total = 0;
  for (k = 0; k < num_options; ++k) {
    total += weights[k];
    if (choice < total)
      break;
  }
  assert(k < num_options);
  return k;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<strpbrk>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %rsi,-0x60(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x58(%rbp),%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x60(%rbp),%rax
  mov    %rax,-0x38(%rbp)
  movl   $0x0,-0x44(%rbp)
  jmp    L87
L60:
  mov    -0x44(%rbp),%eax
  cltq
  movb   $0x0,-0x30(%rbp,%rax,1)
  addl   $0x1,-0x44(%rbp)
L87:
  cmpl   $0x1f,-0x44(%rbp)
  jle    L60
  jmp    L45
L13:
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  sar    $0x3,%al
  movsbl %al,%eax
  cltq
  movzbl -0x30(%rbp,%rax,1),%edx
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  and    $0x7,%eax
  mov    $0x1,%esi
  mov    %eax,%ecx
  shl    %cl,%esi
  mov    %esi,%eax
  mov    %eax,%ecx
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  sar    $0x3,%al
  movsbl %al,%eax
  or     %ecx,%edx
  cltq
  mov    %dl,-0x30(%rbp,%rax,1)
  addq   $0x1,-0x38(%rbp)
L45:
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L13
  jmp    L74
L84:
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%eax
  sar    $0x3,%al
  movsbl %al,%eax
  cltq
  movzbl -0x30(%rbp,%rax,1),%eax
  movsbl %al,%edx
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  and    $0x7,%eax
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L28
  mov    -0x40(%rbp),%rax
  jmp    L3
L28:
  addq   $0x1,-0x40(%rbp)
L74:
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L84
  mov    $0x0,%eax
L3:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L43
  call   <__stack_chk_fail@plt>
L43:
  leave
  ret
```

assistant: ```c
char *strpbrk(const char *string, const char *control) {
  const char *str = string;
  const char *ctrl = control;
  char map[32];
  int n;
  for (n = 0; n < 32; n++)
    map[n] = 0;
  while (*ctrl) {
    map[*ctrl >> 3] |= (1 << (*ctrl & 7));
    ctrl++;
  }
  while (*str) {
    if (map[*str >> 3] & (1 << (*str & 7)))
      return (char *)str;
    str++;
  }
  return NULL;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<strpbrk>:
  endbr64
  sub    $0x38,%rsp
  mov    %rdi,%rax
  mov    %fs:0x28,%rdx
  mov    %rdx,0x28(%rsp)
  xor    %edx,%edx
  mov    %rsp,%rdx
  lea    0x20(%rsp),%rcx
L53:
  movb   $0x0,(%rdx)
  add    $0x1,%rdx
  cmp    %rcx,%rdx
  jne    L53
  movzbl (%rsi),%ecx
  test   %cl,%cl
  je     L33
  mov    $0x1,%edi
L41:
  mov    %ecx,%edx
  sar    $0x3,%dl
  movsbq %dl,%rdx
  and    $0x7,%ecx
  mov    %edi,%r8d
  shl    %cl,%r8d
  or     %r8b,(%rsp,%rdx,1)
  add    $0x1,%rsi
  movzbl (%rsi),%ecx
  test   %cl,%cl
  jne    L41
L33:
  movzbl (%rax),%edx
  test   %dl,%dl
  je     L70
L67:
  mov    %edx,%ecx
  sar    $0x3,%cl
  movsbq %cl,%rcx
  movsbl (%rsp,%rcx,1),%ecx
  and    $0x7,%edx
  bt     %edx,%ecx
  jb     L68
  add    $0x1,%rax
  movzbl (%rax),%edx
  test   %dl,%dl
  jne    L67
  mov    $0x0,%eax
L68:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L42
  add    $0x38,%rsp
  ret
L70:
  mov    $0x0,%eax
  jmp    L68
L42:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *strpbrk(const char *string, const char *control) {
  const char *str = string;
  const char *ctrl = control;
  char map[32];
  int n;
  for (n = 0; n < 32; n++)
    map[n] = 0;
  while (*ctrl) {
    map[*ctrl >> 3] |= (1 << (*ctrl & 7));
    ctrl++;
  }
  while (*str) {
    if (map[*str >> 3] & (1 << (*str & 7)))
      return (char *)str;
    str++;
  }
  return NULL;
}
```