ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请将以下的汇编代码转换成C语言代码：

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  movq   $0x0,-0x20(%rbp)
  movq   $0x0,-0x18(%rbp)
  cmpl   $0x3,-0x24(%rbp)
  je     L3
  lea    D28(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
L3:
  mov    -0x30(%rbp),%rax
  mov    0x8(%rax),%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x30(%rbp),%rax
  mov    0x10(%rax),%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x20(%rbp),%rax
  mov    $0x2e,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L11
  mov    -0x20(%rbp),%rax
  mov    %rax,%rsi
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xfffffffe,%edi
  call   <exit@plt>
L11:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <atoi@plt>
  mov    %eax,%ebx
  mov    -0x20(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <strtod@plt>
  mov    %ebx,%esi
  mov    %eax,%edi
  call   <dpow@plt>
  movq   %xmm0,%rax
  mov    -0x18(%rbp),%rdx
  mov    -0x20(%rbp),%rcx
  movq   %rax,%xmm0
  mov    %rcx,%rsi
  lea    D3(%rip),%rax
  mov    %rax,%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D28
data_type: string
name: disassemble_data
arguments: label: D19
data_type: string
name: disassemble_data
arguments: label: D3
data_type: string

tool: D28: usage: dpow <double/decimal number> <exponent>

tool: D19: First number entered %s is not a double/decimal number


tool: D3: %s ^ %s is : %g


assistant: ```c
int main(int argc, char **argv) {
  const char *dbl = NULL, *nbr = NULL;
  if (argc != 3) {
    printf("usage: dpow <double/decimal number> <exponent>\n");
    exit(-1);
  }
  dbl = argv[1];
  nbr = argv[2];
  if (strchr(dbl, '.') == NULL) {
    printf("First number entered %s is not a double/decimal number\n", dbl);
    exit(-2);
  }
  printf("%s ^ %s is : %g\n", dbl, nbr, dpow(strtod(dbl, NULL), atoi(nbr)));
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<main>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  cmp    $0x3,%edi
  jne    L19
L23:
  mov    0x8(%rbx),%rbp
  mov    0x10(%rbx),%rbx
  mov    $0x2e,%esi
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L9
L21:
  mov    %rbx,%rdi
  call   <atoi@plt>
  mov    %eax,%r12d
  mov    $0x0,%esi
  mov    %rbp,%rdi
  call   <strtod@plt>
  mov    %eax,%edi
  mov    %r12d,%esi
  call   <dpow@plt>
  mov    %rbx,%rdx
  mov    %rbp,%rsi
  lea    D19(%rip),%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L19:
  lea    D14(%rip),%rdi
  call   <puts@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
  jmp    L23
L9:
  mov    %rbp,%rsi
  lea    D3(%rip),%rdi
  call   <printf@plt>
  mov    $0xfffffffe,%edi
  call   <exit@plt>
  jmp    L21
```

tool_calls: name: disassemble_data
arguments: data_tag: D19
data_type: string
name: disassemble_data
arguments: data_tag: D14
data_type: string
name: disassemble_data
arguments: data_tag: D3
data_type: string

tool: D19: %s ^ %s is : %g


tool: D14: usage: dpow <double/decimal number> <exponent>

tool: D3: First number entered %s is not a double/decimal number


assistant: ```c
int main(int argc, char **argv) {
  const char *dbl = NULL, *nbr = NULL;
  if (argc != 3) {
    printf("usage: dpow <double/decimal number> <exponent>\n");
    exit(-1);
  }
  dbl = argv[1];
  nbr = argv[2];
  if (strchr(dbl, '.') == NULL) {
    printf("First number entered %s is not a double/decimal number\n", dbl);
    exit(-2);
  }
  printf("%s ^ %s is : %g\n", dbl, nbr, dpow(strtod(dbl, NULL), atoi(nbr)));
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x8,%rsp
  cmp    $0x3,%edi
  je     L24
  lea    D5(%rip),%rdi
  call   <puts@plt>
  or     $0xffffffff,%edi
  call   <exit@plt>
L24:
  mov    0x8(%rbx),%rbp
  mov    $0x2e,%esi
  mov    0x10(%rbx),%r13
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L13
L18:
  mov    %r13,%rdi
  call   <atoi@plt>
  mov    %rbp,%rdi
  xor    %esi,%esi
  mov    %eax,%r12d
  call   <strtod@plt>
  mov    %r12d,%esi
  mov    %eax,%edi
  call   <dpow@plt>
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    $0x1,%eax
  lea    D14(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L13:
  mov    %rbp,%rsi
  lea    D28(%rip),%rdi
  call   <printf@plt>
  mov    $0xfffffffe,%edi
  call   <exit@plt>
  jmp    L18
```

tool_calls: name: read_data
arguments: tag: D5
type: string
name: read_data
arguments: tag: D14
type: string
name: read_data
arguments: tag: D28
type: string

tool: D5: usage: dpow <double/decimal number> <exponent>

tool: D14: %s ^ %s is : %g


tool: D28: First number entered %s is not a double/decimal number


assistant: ```c
int main(int argc, char **argv) {
  const char *dbl = NULL, *nbr = NULL;
  if (argc != 3) {
    printf("usage: dpow <double/decimal number> <exponent>\n");
    exit(-1);
  }
  dbl = argv[1];
  nbr = argv[2];
  if (strchr(dbl, '.') == NULL) {
    printf("First number entered %s is not a double/decimal number\n", dbl);
    exit(-2);
  }
  printf("%s ^ %s is : %g\n", dbl, nbr, dpow(strtod(dbl, NULL), atoi(nbr)));
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x8,%rsp
  cmp    $0x3,%edi
  je     L22
  lea    D10(%rip),%rdi
  call   <puts@plt>
  or     $0xffffffff,%edi
  call   <exit@plt>
L22:
  mov    0x8(%rbx),%rbp
  mov    $0x2e,%esi
  mov    0x10(%rbx),%r13
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L23
L10:
  mov    %r13,%rdi
  call   <atoi@plt>
  mov    %rbp,%rdi
  xor    %esi,%esi
  mov    %eax,%r12d
  call   <strtod@plt>
  mov    %r12d,%esi
  mov    %eax,%edi
  call   <dpow@plt>
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    $0x1,%eax
  lea    D7(%rip),%rdi
  call   <printf@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L23:
  mov    %rbp,%rsi
  lea    D1(%rip),%rdi
  call   <printf@plt>
  mov    $0xfffffffe,%edi
  call   <exit@plt>
  jmp    L10
```

tool_calls: name: unpack_data
arguments: label: D10
type: string
name: unpack_data
arguments: label: D7
type: string
name: unpack_data
arguments: label: D1
type: string

tool: D10: usage: dpow <double/decimal number> <exponent>

tool: D7: %s ^ %s is : %g


tool: D1: First number entered %s is not a double/decimal number


assistant: ```c
int main(int argc, char **argv) {
  const char *dbl = NULL, *nbr = NULL;
  if (argc != 3) {
    printf("usage: dpow <double/decimal number> <exponent>\n");
    exit(-1);
  }
  dbl = argv[1];
  nbr = argv[2];
  if (strchr(dbl, '.') == NULL) {
    printf("First number entered %s is not a double/decimal number\n", dbl);
    exit(-2);
  }
  printf("%s ^ %s is : %g\n", dbl, nbr, dpow(strtod(dbl, NULL), atoi(nbr)));
  return 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x7e8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x7d8(%rsp)
  xor    %eax,%eax
  lea    0x30(%rsp),%rbx
  mov    %rbx,%rdi
  call   <genrb@plt>
  lea    0x40(%rsp),%r15
  mov    %r15,%rdi
  call   <genwb@plt>
  lea    0xd0(%rsp),%r14
  mov    %r14,%rdi
  call   <gendir@plt>
  lea    0x1d0(%rsp),%r13
  mov    %r13,%rdi
  call   <genconfig@plt>
  lea    0x2d0(%rsp),%r12
  mov    %r12,%rdi
  call   <genn0@plt>
  lea    0x3d0(%rsp),%rbp
  mov    %rbp,%rdi
  call   <genn1@plt>
  lea    0x4d0(%rsp),%rax
  mov    %rax,0x8(%rsp)
  mov    %rax,%rdi
  call   <genn2@plt>
  lea    0x5d0(%rsp),%rax
  mov    %rax,0x10(%rsp)
  mov    %rax,%rdi
  call   <gencmd@plt>
  lea    0x50(%rsp),%rax
  mov    %rax,0x18(%rsp)
  mov    %rax,%rdi
  call   <genend@plt>
  lea    0x90(%rsp),%rax
  mov    %rax,0x20(%rsp)
  mov    %rax,%rdi
  call   <genquit@plt>
  lea    0x6d0(%rsp),%rax
  mov    %rax,0x28(%rsp)
  mov    %rax,%rdi
  call   <gendumb@plt>
  mov    %rbx,%rsi
  lea    D8(%rip),%rbx
  mov    %rbx,%rdi
  call   <printf@plt>
  mov    %r15,%rsi
  mov    %rbx,%rdi
  call   <printf@plt>
  mov    %r14,%rsi
  mov    %rbx,%rdi
  call   <printf@plt>
  mov    %r13,%rsi
  mov    %rbx,%rdi
  call   <printf@plt>
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <printf@plt>
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <printf@plt>
  mov    0x8(%rsp),%rsi
  mov    %rbx,%rdi
  call   <printf@plt>
  mov    0x10(%rsp),%rsi
  mov    %rbx,%rdi
  call   <printf@plt>
  mov    0x18(%rsp),%rsi
  mov    %rbx,%rdi
  call   <printf@plt>
  mov    0x20(%rsp),%rsi
  mov    %rbx,%rdi
  call   <printf@plt>
  mov    0x28(%rsp),%rsi
  mov    %rbx,%rdi
  call   <printf@plt>
  mov    0x7d8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L2
  mov    $0x0,%eax
  add    $0x7e8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L2:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D8
type: string

tool: D8: %s


assistant: ```c
int main(int argc, char *argv[]) {
  char rb[16];
  char wb[16];
  char dir[256];
  char script_file[256];
  char input[256];
  char output[256];
  char errput[256];
  char cmd[256];
  char end[64];
  char quit[64];
  char dumb[256];
  char script[4096];
  int fid0;
  int fid1;
  int fid2;
  genrb(rb);
  genwb(wb);
  gendir(dir);
  genconfig(script_file);
  genn0(input);
  genn1(output);
  genn2(errput);
  gencmd(cmd);
  genend(end);
  genquit(quit);
  gendumb(dumb);
  printf("%s\n", rb);
  printf("%s\n", wb);
  printf("%s\n", dir);
  printf("%s\n", script_file);
  printf("%s\n", input);
  printf("%s\n", output);
  printf("%s\n", errput);
  printf("%s\n", cmd);
  printf("%s\n", end);
  printf("%s\n", quit);
  printf("%s\n", dumb);
  return 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x7e8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x7d8(%rsp)
  xor    %eax,%eax
  lea    0x30(%rsp),%rbp
  lea    0x4d0(%rsp),%rbx
  mov    %rbp,%rdi
  lea    0x5d0(%rsp),%r15
  lea    0x50(%rsp),%r14
  call   <genrb@plt>
  lea    0x40(%rsp),%rdx
  lea    0x90(%rsp),%r13
  mov    %rdx,%rdi
  mov    %rdx,0x28(%rsp)
  lea    0x6d0(%rsp),%r12
  call   <genwb@plt>
  lea    0xd0(%rsp),%r11
  mov    %r11,%rdi
  mov    %r11,0x20(%rsp)
  call   <gendir@plt>
  lea    0x1d0(%rsp),%r10
  mov    %r10,%rdi
  mov    %r10,0x18(%rsp)
  call   <genconfig@plt>
  lea    0x2d0(%rsp),%r9
  mov    %r9,%rdi
  mov    %r9,0x10(%rsp)
  call   <genn0@plt>
  lea    0x3d0(%rsp),%r8
  mov    %r8,%rdi
  mov    %r8,0x8(%rsp)
  call   <genn1@plt>
  mov    %rbx,%rdi
  call   <genn2@plt>
  mov    %r15,%rdi
  call   <gencmd@plt>
  mov    %r14,%rdi
  call   <genend@plt>
  mov    %r13,%rdi
  call   <genquit@plt>
  mov    %r12,%rdi
  call   <gendumb@plt>
  mov    %rbp,%rsi
  lea    D7(%rip),%rbp
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    0x28(%rsp),%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    0x20(%rsp),%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    0x18(%rsp),%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    0x10(%rsp),%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    0x8(%rsp),%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    %r14,%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    0x7d8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L4
  add    $0x7e8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L4:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D7
type_guessed: string

tool: D7: %s


assistant: ```c
int main(int argc, char *argv[]) {
  char rb[16];
  char wb[16];
  char dir[256];
  char script_file[256];
  char input[256];
  char output[256];
  char errput[256];
  char cmd[256];
  char end[64];
  char quit[64];
  char dumb[256];
  char script[4096];
  int fid0;
  int fid1;
  int fid2;
  genrb(rb);
  genwb(wb);
  gendir(dir);
  genconfig(script_file);
  genn0(input);
  genn1(output);
  genn2(errput);
  gencmd(cmd);
  genend(end);
  genquit(quit);
  gendumb(dumb);
  printf("%s\n", rb);
  printf("%s\n", wb);
  printf("%s\n", dir);
  printf("%s\n", script_file);
  printf("%s\n", input);
  printf("%s\n", output);
  printf("%s\n", errput);
  printf("%s\n", cmd);
  printf("%s\n", end);
  printf("%s\n", quit);
  printf("%s\n", dumb);
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x7e8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x7d8(%rsp)
  xor    %eax,%eax
  lea    0x30(%rsp),%rbp
  lea    0x4d0(%rsp),%rbx
  mov    %rbp,%rdi
  lea    0x5d0(%rsp),%r15
  lea    0x50(%rsp),%r14
  call   <genrb@plt>
  lea    0x40(%rsp),%rdx
  lea    0x90(%rsp),%r13
  mov    %rdx,%rdi
  mov    %rdx,0x28(%rsp)
  lea    0x6d0(%rsp),%r12
  call   <genwb@plt>
  lea    0xd0(%rsp),%r11
  mov    %r11,%rdi
  mov    %r11,0x20(%rsp)
  call   <gendir@plt>
  lea    0x1d0(%rsp),%r10
  mov    %r10,%rdi
  mov    %r10,0x18(%rsp)
  call   <genconfig@plt>
  lea    0x2d0(%rsp),%r9
  mov    %r9,%rdi
  mov    %r9,0x10(%rsp)
  call   <genn0@plt>
  lea    0x3d0(%rsp),%r8
  mov    %r8,%rdi
  mov    %r8,0x8(%rsp)
  call   <genn1@plt>
  mov    %rbx,%rdi
  call   <genn2@plt>
  mov    %r15,%rdi
  call   <gencmd@plt>
  mov    %r14,%rdi
  call   <genend@plt>
  mov    %r13,%rdi
  call   <genquit@plt>
  mov    %r12,%rdi
  call   <gendumb@plt>
  mov    %rbp,%rsi
  lea    D7(%rip),%rbp
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    0x28(%rsp),%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    0x20(%rsp),%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    0x18(%rsp),%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    0x10(%rsp),%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    0x8(%rsp),%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    %r14,%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <printf@plt>
  mov    0x7d8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  add    $0x7e8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L5:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D7
type_infered: string

tool: D7: %s


assistant: ```c
int main(int argc, char *argv[]) {
  char rb[16];
  char wb[16];
  char dir[256];
  char script_file[256];
  char input[256];
  char output[256];
  char errput[256];
  char cmd[256];
  char end[64];
  char quit[64];
  char dumb[256];
  char script[4096];
  int fid0;
  int fid1;
  int fid2;
  genrb(rb);
  genwb(wb);
  gendir(dir);
  genconfig(script_file);
  genn0(input);
  genn1(output);
  genn2(errput);
  gencmd(cmd);
  genend(end);
  genquit(quit);
  gendumb(dumb);
  printf("%s\n", rb);
  printf("%s\n", wb);
  printf("%s\n", dir);
  printf("%s\n", script_file);
  printf("%s\n", input);
  printf("%s\n", output);
  printf("%s\n", errput);
  printf("%s\n", cmd);
  printf("%s\n", end);
  printf("%s\n", quit);
  printf("%s\n", dumb);
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<shift_sh_offsets>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rcx,(%rsp)
  test   %rdi,%rdi
  je     L95
  mov    %rdi,%r12
  mov    %rsi,%r14
  mov    %rdx,%r15
  test   %rsi,%rsi
  je     L95
  mov    (%rsi),%rax
  mov    %rax,0x8(%rsp)
  mov    0x8(%rsi),%rbp
  call   <shdr_index@plt>
  mov    %eax,%ebx
  mov    $0x0,%r13d
  cmp    $0xffffffff,%eax
  je     L13
  add    0x8(%rsp),%rbp
  mov    (%rsp),%rdx
  mov    %r14,%rsi
  mov    %r12,%rdi
  call   <get_align_bias@plt>
  mov    %eax,%r13d
  cltq
  mov    %rax,(%rsp)
  jmp    L19
L14:
  mov    0x8(%rax),%rdx
  add    (%rax),%rdx
  cmp    %rdx,%rbp
  cmovb  %rdx,%rbp
  mov    %r14d,%ebx
L19:
  lea    0x1(%rbx),%r14d
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <get_s_header@plt>
  test   %rax,%rax
  je     L79
  add    %r13d,0x10(%rax)
  mov    (%rax),%rdx
  test   %rdx,%rdx
  je     L14
  add    (%rsp),%rdx
  mov    %rdx,(%rax)
  jmp    L14
L79:
  test   %r15,%r15
  je     L13
  mov    0x8(%rsp),%rdx
  test   %rdx,%rdx
  je     L13
  sub    %r13d,0x10(%r15)
  mov    %r13d,%r8d
  mov    %rbp,%rcx
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <rearrange_dynamic@plt>
  add    %r13d,0x10(%r15)
  jmp    L13
L95:
  mov    $0x0,%r13d
L13:
  mov    %r13d,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int shift_sh_offsets(char *elf, Elf64_Shdr *shdr, Elf64_Shdr *dyn_shdr, size_t n) {
  if (!elf || !shdr)
    return 0;
  unsigned long long base = shdr->sh_addr;
  unsigned long long top = base + shdr->sh_size;
  int i;
  i = shdr_index(elf, shdr);
  if (i == -1)
    return 0;
  int bias;
  bias = get_align_bias(elf, shdr, n);
  while ((shdr = get_s_header(elf, i++))) {
    shdr->sh_offset += bias;
    if (shdr->sh_addr)
      shdr->sh_addr += bias;
    if (top < shdr->sh_addr + shdr->sh_size)
      top = shdr->sh_addr + shdr->sh_size;
  }
  if (dyn_shdr && base > 0) {
    dyn_shdr->sh_offset -= bias;
    rearrange_dynamic(elf, dyn_shdr, (void *)base, (void *)top, bias);
    dyn_shdr->sh_offset += bias;
  }
  return bias;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<shift_sh_offsets>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  test   %rdi,%rdi
  je     L23
  mov    %rsi,%r12
  test   %rsi,%rsi
  je     L23
  mov    (%rsi),%rbx
  mov    0x8(%rsi),%r15
  mov    %rdi,%r14
  mov    %rdx,%rbp
  mov    %rcx,%r13
  mov    %rbx,0x8(%rsp)
  call   <shdr_index@plt>
  cmp    $0xffffffff,%eax
  mov    %eax,0x4(%rsp)
  je     L23
  mov    %r13,%rdx
  mov    %r12,%rsi
  mov    %r14,%rdi
  add    %rbx,%r15
  call   <get_align_bias@plt>
  mov    0x4(%rsp),%r8d
  movslq %eax,%r13
  mov    %r13,%r12
  jmp    L6
  nopl   0x0(%rax)
L64:
  mov    (%rax),%rdx
  add    %r12d,0x10(%rax)
  test   %rdx,%rdx
  je     L62
  add    %r13,%rdx
  mov    %rdx,(%rax)
L62:
  add    0x8(%rax),%rdx
  mov    %ebx,%r8d
  cmp    %rdx,%r15
  cmovb  %rdx,%r15
L6:
  mov    %r8d,%esi
  lea    0x1(%r8),%ebx
  mov    %r14,%rdi
  call   <get_s_header@plt>
  test   %rax,%rax
  jne    L64
  test   %rbp,%rbp
  je     L47
  mov    0x8(%rsp),%rax
  test   %rax,%rax
  je     L47
  sub    %r12d,0x10(%rbp)
  mov    %r12d,%r8d
  mov    %r15,%rcx
  mov    %rax,%rdx
  mov    %rbp,%rsi
  mov    %r14,%rdi
  call   <rearrange_dynamic@plt>
  add    %r12d,0x10(%rbp)
  jmp    L47
  nopl   0x0(%rax)
L23:
  xor    %r12d,%r12d
L47:
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int shift_sh_offsets(char *elf, Elf64_Shdr *shdr, Elf64_Shdr *dyn_shdr, size_t n) {
  if (!elf || !shdr)
    return 0;
  unsigned long long base = shdr->sh_addr;
  unsigned long long top = base + shdr->sh_size;
  int i;
  i = shdr_index(elf, shdr);
  if (i == -1)
    return 0;
  int bias;
  bias = get_align_bias(elf, shdr, n);
  while ((shdr = get_s_header(elf, i++))) {
    shdr->sh_offset += bias;
    if (shdr->sh_addr)
      shdr->sh_addr += bias;
    if (top < shdr->sh_addr + shdr->sh_size)
      top = shdr->sh_addr + shdr->sh_size;
  }
  if (dyn_shdr && base > 0) {
    dyn_shdr->sh_offset -= bias;
    rearrange_dynamic(elf, dyn_shdr, (void *)base, (void *)top, bias);
    dyn_shdr->sh_offset += bias;
  }
  return bias;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<shift_sh_offsets>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  test   %rdi,%rdi
  je     L80
  mov    %rsi,%r12
  test   %rsi,%rsi
  je     L80
  mov    (%rsi),%rbx
  mov    0x8(%rsi),%r15
  mov    %rdi,%r14
  mov    %rdx,%rbp
  mov    %rcx,%r13
  mov    %rbx,0x8(%rsp)
  call   <shdr_index@plt>
  cmp    $0xffffffff,%eax
  mov    %eax,0x4(%rsp)
  je     L80
  mov    %r13,%rdx
  mov    %r12,%rsi
  mov    %r14,%rdi
  add    %rbx,%r15
  call   <get_align_bias@plt>
  mov    0x4(%rsp),%r8d
  movslq %eax,%r13
  mov    %r13,%r12
  jmp    L60
  nopl   0x0(%rax)
L15:
  mov    (%rax),%rdx
  add    %r12d,0x10(%rax)
  test   %rdx,%rdx
  je     L76
  add    %r13,%rdx
  mov    %rdx,(%rax)
L76:
  add    0x8(%rax),%rdx
  mov    %ebx,%r8d
  cmp    %rdx,%r15
  cmovb  %rdx,%r15
L60:
  mov    %r8d,%esi
  lea    0x1(%r8),%ebx
  mov    %r14,%rdi
  call   <get_s_header@plt>
  test   %rax,%rax
  jne    L15
  test   %rbp,%rbp
  je     L18
  mov    0x8(%rsp),%rax
  test   %rax,%rax
  je     L18
  sub    %r12d,0x10(%rbp)
  mov    %r12d,%r8d
  mov    %r15,%rcx
  mov    %rax,%rdx
  mov    %rbp,%rsi
  mov    %r14,%rdi
  call   <rearrange_dynamic@plt>
  add    %r12d,0x10(%rbp)
  jmp    L18
  nopl   0x0(%rax)
L80:
  xor    %r12d,%r12d
L18:
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int shift_sh_offsets(char *elf, Elf64_Shdr *shdr, Elf64_Shdr *dyn_shdr, size_t n) {
  if (!elf || !shdr)
    return 0;
  unsigned long long base = shdr->sh_addr;
  unsigned long long top = base + shdr->sh_size;
  int i;
  i = shdr_index(elf, shdr);
  if (i == -1)
    return 0;
  int bias;
  bias = get_align_bias(elf, shdr, n);
  while ((shdr = get_s_header(elf, i++))) {
    shdr->sh_offset += bias;
    if (shdr->sh_addr)
      shdr->sh_addr += bias;
    if (top < shdr->sh_addr + shdr->sh_size)
      top = shdr->sh_addr + shdr->sh_size;
  }
  if (dyn_shdr && base > 0) {
    dyn_shdr->sh_offset -= bias;
    rearrange_dynamic(elf, dyn_shdr, (void *)base, (void *)top, bias);
    dyn_shdr->sh_offset += bias;
  }
  return bias;
}
```