user: Translate the below assembly code into C programming language:

```asm
<loadmap>:
  endbr64
  push   %r15
  push   %r14
  mov    %r8,%r14
  push   %r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  mov    %ecx,%ebp
  push   %rbx
  imul   %ebp,%r12d
  mov    %edi,%ebx
  mov    %rsi,%rdi
  lea    D5(%rip),%rsi
  sub    $0x38,%rsp
  movslq %r12d,%r15
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  lea    D8(%rip),%rsi
  mov    %r14,%rdi
  mov    %rax,%r13
  call   <fopen@plt>
  lea    0x0(,%r12,8),%edi
  mov    %r15,0x18(%rsp)
  mov    %rax,0x8(%rsp)
  call   <malloc@plt>
  movl   $0x0,0x24(%rsp)
  mov    %rax,%rbp
  test   %r12d,%r12d
  jle    L75
  mov    %rax,%r14
  test   %ebx,%ebx
  je     L22
  cmp    $0x1,%ebx
  je     L86
  add    %rax,%r15
  lea    D53(%rip),%rbx
  nopl   (%rax)
L72:
  mov    %rbx,%rdi
  xor    %eax,%eax
  add    $0x1,%r14
  call   <printf@plt>
  mov    0x24(%rsp),%eax
  mov    %al,-0x1(%r14)
  cmp    %r15,%r14
  jne    L72
L91:
  lea    D54(%rip),%rbx
L66:
  mov    0x8(%rsp),%rcx
  mov    %r12d,%edx
  mov    $0x1,%esi
  mov    %rbp,%rdi
  call   <fwrite@plt>
  mov    0x18(%rsp),%r12
  add    %rbp,%r12
  nop
L28:
  movsbl 0x0(%rbp),%esi
  mov    %rbx,%rdi
  xor    %eax,%eax
  add    $0x1,%rbp
  call   <printf@plt>
  cmp    %rbp,%r12
  jne    L28
L83:
  mov    %r13,%rdi
  call   <fclose@plt>
  mov    0x8(%rsp),%rdi
  call   <fclose@plt>
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L107
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L86:
  mov    0x18(%rsp),%rax
  lea    0x24(%rsp),%r15
  lea    D54(%rip),%rbx
  add    %rbp,%rax
  mov    %rax,0x10(%rsp)
  nopl   0x0(%rax)
L45:
  mov    %r15,%rdx
  mov    %rbx,%rsi
  mov    %r13,%rdi
  add    $0x1,%r14
  call   <fscanf@plt>
  mov    0x24(%rsp),%eax
  mov    %al,-0x1(%r14)
  cmp    0x10(%rsp),%r14
  jne    L45
  jmp    L66
  cs nopw 0x0(%rax,%rax,1)
L22:
  mov    0x18(%rsp),%rax
  lea    0x24(%rsp),%r15
  lea    D46(%rip),%rbx
  add    %rbp,%rax
  mov    %rax,0x10(%rsp)
  nopl   0x0(%rax)
L65:
  mov    %r15,%rdx
  mov    %rbx,%rsi
  mov    %r13,%rdi
  add    $0x1,%r14
  call   <fscanf@plt>
  mov    0x24(%rsp),%eax
  mov    %al,-0x1(%r14)
  cmp    0x10(%rsp),%r14
  jne    L65
  jmp    L91
  cs nopw 0x0(%rax,%rax,1)
L75:
  mov    0x8(%rsp),%rcx
  mov    %r12d,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fwrite@plt>
  jmp    L83
L107:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D5
type_infered: string
name: unpack_data
arguments: tag: D8
type_infered: string
name: unpack_data
arguments: tag: D53
type_infered: string
name: unpack_data
arguments: tag: D54
type_infered: string
name: unpack_data
arguments: tag: D46
type_infered: string

tool: D5: r

tool: D8: wb

tool: D53: error,tipo no soportado

tool: D54: %d

tool: D46: %d%*c

assistant: ```c
void loadmap(int type, char *path_old, int numtilex, int numtiley, char *path_new) {
  FILE *old;
  FILE *new;
  old = fopen(path_old, "r");
  new = fopen(path_new, "wb");
  int numtiles = numtilex * numtiley;
  char *temparray = (char *)malloc(numtiles * sizeof(char *));
  int i = 0;
  int v = 0;
  for (i = 0; i < (numtilex * numtiley); i++) {
    if (type == 0) {
      fscanf(old, "%d%*c", &v);
    } else if (type == 1) {
      fscanf(old, "%d", &v);
    } else {
      printf("error,tipo no soportado");
    }
    temparray[i] = v;
  }
  fwrite(temparray, sizeof(char), numtiles, new);
  for (i = 0; i < (numtilex * numtiley); i++) {
    printf("%d", temparray[i]);
  }
  fclose(old);
  fclose(new);
}
```