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

```asm
<merge>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  mov    %ecx,-0x28(%rbp)
  mov    %r8d,-0x2c(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L6
  cmpq   $0x0,-0x20(%rbp)
  jne    L40
L6:
  lea    D1(%rip),%rax
  mov    %rax,%rsi
  lea    D8(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xffffffff,%eax
  jmp    L60
L40:
  movl   $0x0,-0x10(%rbp)
  mov    -0x24(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x28(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x2c(%rbp),%eax
  sub    -0x24(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L20
L135:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jg     L68
  mov    -0x24(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rax,%rdx
  mov    (%rcx),%eax
  mov    %eax,(%rdx)
  jmp    L20
L68:
  mov    -0x28(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x28(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rax,%rdx
  mov    (%rcx),%eax
  mov    %eax,(%rdx)
L20:
  mov    -0x24(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jg     L12
  mov    -0x28(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jle    L135
  jmp    L12
L76:
  mov    -0x24(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rax,%rdx
  mov    (%rcx),%eax
  mov    %eax,(%rdx)
L12:
  mov    -0x24(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jle    L76
  jmp    L52
L134:
  mov    -0x28(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x28(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rax,%rdx
  mov    (%rcx),%eax
  mov    %eax,(%rdx)
L52:
  mov    -0x28(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jle    L134
  movl   $0x0,-0x10(%rbp)
  jmp    L139
L80:
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    -0x2c(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x10(%rbp)
  subl   $0x1,-0x2c(%rbp)
L139:
  mov    -0x10(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jl     L80
  mov    $0x0,%eax
L60:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: label: D1
data_type: string
name: retrieve_data
arguments: label: D8
data_type: string

tool: D1: merge

tool: D8: You passed NULL in function %s()


assistant: ```c
int merge(int *array, int *tmp_array, int left_pos, int right_pos, int right_end) {
  if (!array || !tmp_array) {
    printf("You passed NULL in function %s()\n", __FUNCTION__);
    return -1;
  }
  int tmp = 0;
  int tmp_pos = left_pos;
  int left_end = right_pos - 1;
  int num_element = right_end - left_pos + 1;
  while (left_pos <= left_end && right_pos <= right_end) {
    if (array[left_pos] <= array[right_pos]) {
      tmp_array[tmp_pos++] = array[left_pos++];
    } else {
      tmp_array[tmp_pos++] = array[right_pos++];
    }
  }
  while (left_pos <= left_end) {
    tmp_array[tmp_pos++] = array[left_pos++];
  }
  while (right_pos <= right_end) {
    tmp_array[tmp_pos++] = array[right_pos++];
  }
  for (tmp = 0; tmp < num_element; tmp++, right_end--) {
    array[right_end] = tmp_array[right_end];
  }
  return 0;
}
```