user: Converte this assembly snippet into its equivalent C code:

```asm
<InsertInString>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,-0x68(%rbp)
  mov    %rsi,-0x70(%rbp)
  mov    %rdx,-0x78(%rbp)
  mov    %ecx,-0x7c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%rbx
  cmpl   $0x0,-0x7c(%rbp)
  jns    L22
  mov    -0x68(%rbp),%rax
  mov    %rax,%rdi
  call   <ReturnNullMallocStack@plt>
  jmp    L101
L22:
  mov    -0x70(%rbp),%rax
  mov    %rax,%rdi
  call   <GetStringLength@plt>
  mov    %eax,-0x54(%rbp)
  mov    -0x78(%rbp),%rax
  mov    %rax,%rdi
  call   <GetStringLength@plt>
  mov    %eax,-0x50(%rbp)
  cmpl   $0x0,-0x54(%rbp)
  jle    L120
  cmpl   $0x0,-0x50(%rbp)
  jle    L120
  mov    -0x54(%rbp),%eax
  cmp    -0x7c(%rbp),%eax
  jg     L57
L120:
  mov    -0x68(%rbp),%rax
  mov    %rax,%rdi
  call   <ReturnNullMallocStack@plt>
  jmp    L101
L57:
  mov    -0x54(%rbp),%edx
  mov    -0x50(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x4c(%rbp)
  mov    -0x4c(%rbp),%eax
  lea    D5(%rip),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <GetStackSize@plt>
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x48(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r14
  mov    $0x0,%r15d
  movslq %eax,%rdx
  mov    %rdx,%r12
  mov    $0x0,%r13d
  cltq
  mov    $0x10,%edx
  sub    $0x1,%rdx
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L137:
  cmp    %rdx,%rsp
  je     L148
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L137
L148:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L119
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L119:
  mov    %rsp,%rax
  add    $0x0,%rax
  mov    %rax,-0x40(%rbp)
  movl   $0xffffffff,-0x60(%rbp)
  movl   $0x0,-0x5c(%rbp)
  movl   $0x0,-0x5c(%rbp)
  jmp    L26
L131:
  mov    -0x5c(%rbp),%eax
  cmp    -0x7c(%rbp),%eax
  jne    L104
  movl   $0x0,-0x58(%rbp)
  movl   $0x0,-0x58(%rbp)
  jmp    L71
L129:
  addl   $0x1,-0x60(%rbp)
  mov    -0x58(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x78(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%ecx
  mov    -0x40(%rbp),%rdx
  mov    -0x60(%rbp),%eax
  cltq
  mov    %cl,(%rdx,%rax,1)
  addl   $0x1,-0x58(%rbp)
L71:
  mov    -0x58(%rbp),%eax
  cmp    -0x50(%rbp),%eax
  jl     L129
L104:
  addl   $0x1,-0x60(%rbp)
  mov    -0x5c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%ecx
  mov    -0x40(%rbp),%rdx
  mov    -0x60(%rbp),%eax
  cltq
  mov    %cl,(%rdx,%rax,1)
  addl   $0x1,-0x5c(%rbp)
L26:
  mov    -0x5c(%rbp),%eax
  cmp    -0x54(%rbp),%eax
  jl     L131
  addl   $0x1,-0x60(%rbp)
  mov    -0x40(%rbp),%rdx
  mov    -0x60(%rbp),%eax
  cltq
  movb   $0x0,(%rdx,%rax,1)
  mov    -0x60(%rbp),%edx
  mov    -0x40(%rbp),%rcx
  mov    -0x68(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <ReturnOutputMallocStack@plt>
L101:
  mov    %rbx,%rsp
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L39
  call   <__stack_chk_fail@plt>
L39:
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D5
data_type: string

tool: D5: char

assistant: ```c
char *InsertInString(char *output, char *input, char *addition, const int index) {
  if (index < 0)
    return ReturnNullMallocStack(output);
  int length1 = GetStringLength(input);
  int length2 = GetStringLength(addition);
  if (length1 < 1 || length2 < 1 || index > length1 - 1) {
    return ReturnNullMallocStack(output);
  }
  int length0 = length1 + length2;
  char output2[GetStackSize(length0, "char")];
  int i0 = -1;
  int i = 0;
  for (i = 0; i < length1; i++) {
    if (i == index) {
      int i2 = 0;
      for (i2 = 0; i2 < length2; i2++) {
        i0++;
        output2[i0] = addition[i2];
      }
    }
    i0++;
    output2[i0] = input[i];
  }
  i0++;
  output2[i0] = '\0';
  return ReturnOutputMallocStack(output, output2, i0);
}
```