user: 请将以下的汇编代码转换成C语言代码：

```asm
<build_string>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x18,%rsp
  test   %rdi,%rdi
  je     L477
  movzbl (%rdi),%eax
  mov    %rdi,%rbp
  xor    %r13d,%r13d
  test   %al,%al
  je     L610
  cmpb   $0x0,(%rcx)
  jne    L52
  test   %rsi,%rsi
  je     L316
  test   %rdx,%rdx
  setne  %cl
  cmp    %rdx,%rsi
  jb     L518
  test   %cl,%cl
  jne    L378
L518:
  mov    $0x1,%edx
  nopl   0x0(%rax)
L366:
  mov    %al,(%rbx)
  movzbl 0x0(%rbp,%rdx,1),%eax
  add    $0x1,%rbx
  mov    %edx,%r13d
  test   %al,%al
  je     L35
  add    $0x1,%rdx
  cmp    %rbx,%r12
  ja     L366
  test   %cl,%cl
  je     L366
L378:
  lea    D15(%rip),%rdi
  mov    $0xffffffff,%r13d
  call   <puts@plt>
L610:
  add    $0x18,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L477:
  test   %rsi,%rsi
  je     L678
  test   %rdx,%rdx
  setne  %cl
  cmp    %rdx,%rsi
  jb     L62
  test   %cl,%cl
  jne    L378
L62:
  lea    D7(%rip),%rdx
  mov    $0x4e,%eax
  nopl   0x0(%rax)
L406:
  add    $0x1,%rdx
  mov    %al,(%rbx)
  add    $0x1,%rbx
  movzbl (%rdx),%eax
  test   %al,%al
  je     L69
  cmp    %rbx,%r12
  ja     L406
  test   %cl,%cl
  je     L406
  jmp    L378
L316:
  xor    %r13d,%r13d
  nopl   0x0(%rax,%rax,1)
L465:
  add    $0x1,%rbp
  movsbl %al,%edi
  add    $0x1,%r13d
  call   <putchar@plt>
  movzbl 0x0(%rbp),%eax
  test   %al,%al
  jne    L465
  nopl   0x0(%rax,%rax,1)
L35:
  movswl %r13w,%r13d
  jmp    L610
  nopl   0x0(%rax)
L52:
  mov    %rcx,%rdi
  mov    %r8d,0xc(%rsp)
  call   <atoi@plt>
  movzbl 0x0(%rbp),%ecx
  mov    0xc(%rsp),%r8d
  mov    %eax,%r15d
  test   %cl,%cl
  je     L642
  mov    $0x1,%esi
  mov    %rbp,%rdx
  sub    %ebp,%esi
  mov    %esi,%r13d
  xchg   %ax,%ax
L55:
  lea    0x0(%r13,%rdx,1),%r14d
  add    $0x1,%rdx
  cmpb   $0x0,(%rdx)
  jne    L55
  cmp    %r14w,%ax
  jg     L206
  test   %rbx,%rbx
  je     L365
  test   %r12,%r12
  setne  %dl
  cmp    %r12,%rbx
  jb     L201
  test   %dl,%dl
  jne    L378
L201:
  mov    $0x1,%eax
  nopl   (%rax)
L662:
  mov    %cl,(%rbx)
  movzbl 0x0(%rbp,%rax,1),%ecx
  add    $0x1,%rbx
  movswl %ax,%r13d
  test   %cl,%cl
  je     L610
  add    $0x1,%rax
  cmp    %rbx,%r12
  ja     L662
  test   %dl,%dl
  je     L662
  jmp    L378
  nopl   0x0(%rax)
L365:
  lea    0x0(%r13,%rbp,1),%ebx
  movsbl %cl,%edi
  add    $0x1,%rbp
  call   <putchar@plt>
  movzbl 0x0(%rbp),%ecx
  test   %cl,%cl
  jne    L365
  movswl %bx,%r13d
  jmp    L610
L678:
  lea    D7(%rip),%rbx
  mov    $0x4e,%edi
  cs nopw 0x0(%rax,%rax,1)
L30:
  call   <putchar@plt>
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  jne    L30
  nopw   0x0(%rax,%rax,1)
L69:
  mov    $0xc,%r13d
  jmp    L610
  nopl   0x0(%rax,%rax,1)
L206:
  cmp    $0x2,%r8d
  je     L540
  test   %rbx,%rbx
  je     L420
  test   %r12,%r12
  setne  %dil
  cmp    %r12,%rbx
  jb     L140
  test   %dil,%dil
  jne    L378
L140:
  mov    $0x1,%edx
  nopl   0x0(%rax)
L493:
  mov    %cl,(%rbx)
  movzbl 0x0(%rbp,%rdx,1),%ecx
  add    $0x1,%rbx
  mov    %edx,%esi
  test   %cl,%cl
  je     L354
  add    $0x1,%rdx
  cmp    %rbx,%r12
  ja     L493
  test   %dil,%dil
  je     L493
  jmp    L378
L642:
  test   %ax,%ax
  jle    L610
  xor    %r14d,%r14d
  xor    %esi,%esi
  cmp    $0x2,%r8d
  jne    L354
L540:
  xor    %r13d,%r13d
  nopl   0x0(%rax,%rax,1)
L416:
  mov    %r13d,%eax
  lea    0x1(%rax),%edx
  mov    %edx,%r13d
  test   %rbx,%rbx
  je     L412
  test   %r12,%r12
  setne  %cl
  cmp    %r12,%rbx
  jb     L284
  test   %cl,%cl
  jne    L378
L284:
  sub    $0x1,%r15d
  add    $0x1,%rbx
  movb   $0x20,-0x1(%rbx)
  cmp    %r14w,%r15w
  jg     L416
  movzbl 0x0(%rbp),%esi
  test   %sil,%sil
  je     L310
  add    $0x2,%eax
  cmp    %rbx,%r12
  ja     L135
  test   %cl,%cl
  jne    L378
L135:
  sub    %ebx,%eax
  cs nopw 0x0(%rax,%rax,1)
L589:
  lea    (%rax,%rbx,1),%r13d
  add    $0x1,%rbp
  add    $0x1,%rbx
  mov    %sil,-0x1(%rbx)
  movzbl 0x0(%rbp),%esi
  test   %sil,%sil
  je     L35
  cmp    %rbx,%r12
  ja     L589
  test   %cl,%cl
  je     L589
  jmp    L378
L354:
  lea    0x1(%rsi,%rax,1),%esi
  nop
L362:
  mov    %esi,%r13d
  sub    %r15d,%r13d
  test   %rbx,%rbx
  je     L191
  test   %r12,%r12
  je     L417
  cmp    %r12,%rbx
  jae    L378
L417:
  sub    $0x1,%r15d
  add    $0x1,%rbx
  movb   $0x20,-0x1(%rbx)
  cmp    %r14w,%r15w
  jg     L362
  jmp    L35
L420:
  mov    %rbp,%rbx
  nopl   0x0(%rax,%rax,1)
L217:
  add    $0x1,%rbx
  movsbl %cl,%edi
  call   <putchar@plt>
  movzbl (%rbx),%ecx
  lea    0x1(%rbx),%r13d
  sub    %ebp,%r13d
  test   %cl,%cl
  jne    L217
L191:
  lea    -0x1(%r15,%r13,1),%r15d
  jmp    L312
  nopl   0x0(%rax)
L363:
  add    $0x1,%r13d
L312:
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    %r15d,%eax
  sub    %r13d,%eax
  cmp    %r14w,%ax
  jg     L363
  jmp    L35
L412:
  lea    -0x1(%r15,%r13,1),%r15d
  jmp    L184
  cs nopw 0x0(%rax,%rax,1)
L327:
  add    $0x1,%r13d
L184:
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    %r15d,%eax
  sub    %r13d,%eax
  cmp    %r14w,%ax
  jg     L327
  movzbl 0x0(%rbp),%eax
  test   %al,%al
  je     L35
  sub    %ebp,%r13d
  lea    0x1(%r13),%ebx
L643:
  lea    (%rbx,%rbp,1),%r13d
  movsbl %al,%edi
  add    $0x1,%rbp
  call   <putchar@plt>
  movzbl 0x0(%rbp),%eax
  test   %al,%al
  jne    L643
  jmp    L35
L310:
  movswl %dx,%r13d
  jmp    L610
```

tool_calls: name: retrieve_data
arguments: data_label: D15
type_infered: string
name: retrieve_data
arguments: data_label: D7
type_infered: string

tool: D15: s_printf buffer overflow

tool: D7: NULL_POINTER

assistant: ```c
int build_string(char *src, char *dest, char *bufend, char *hdr, int sign) {
  char *cp1;
  short minsize, i, j;
  if (!src) {
    cp1 = "NULL_POINTER";
    while (*cp1) {
      if (dest) {
        if (bufend && (dest >= bufend)) {
          puts("s_printf buffer overflow");
          return (-1);
        }
        *dest++ = *cp1++;
      } else {
        putchar(*cp1++);
      };
    }
    return (12);
  }
  if (!*src) {
    return (0);
  }
  if (!hdr[0]) {
    j = 0;
    while (*src) {
      if (dest) {
        if (bufend && (dest >= bufend)) {
          puts("s_printf buffer overflow");
          return (-1);
        }
        *dest++ = *src++;
      } else {
        putchar(*src++);
      };
      j++;
    }
    return (j);
  }
  minsize = (short)atoi(hdr);
  i = 0;
  cp1 = (char *)src;
  while (*cp1) {
    i++;
    cp1++;
  }
  cp1 = (char *)src;
  j = 0;
  if (minsize > i) {
    if (sign == 2) {
      while (minsize > i) {
        j++;
        if (dest) {
          if (bufend && (dest >= bufend)) {
            puts("s_printf buffer overflow");
            return (-1);
          }
          *dest++ = ' ';
        } else {
          if (' ')
            putchar(' ');
        };
        minsize--;
      }
      while (*cp1) {
        j++;
        if (dest) {
          if (bufend && (dest >= bufend)) {
            puts("s_printf buffer overflow");
            return (-1);
          }
          *dest++ = *cp1++;
        } else {
          putchar(*cp1++);
        };
      }
    } else {
      while (*cp1) {
        j++;
        if (dest) {
          if (bufend && (dest >= bufend)) {
            puts("s_printf buffer overflow");
            return (-1);
          }
          *dest++ = *cp1++;
        } else {
          putchar(*cp1++);
        };
      }
      while (minsize > i) {
        j++;
        if (dest) {
          if (bufend && (dest >= bufend)) {
            puts("s_printf buffer overflow");
            return (-1);
          }
          *dest++ = ' ';
        } else {
          if (' ')
            putchar(' ');
        };
        minsize--;
      }
    }
  } else {
    while (*cp1) {
      j++;
      if (dest) {
        if (bufend && (dest >= bufend)) {
          puts("s_printf buffer overflow");
          return (-1);
        }
        *dest++ = *cp1++;
      } else {
        putchar(*cp1++);
      };
    }
  }
  return (j);
}
```