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

```asm
<getXY>:
  endbr64
  push   %r15
  mov    %rdi,%r10
  mov    %edx,%r8d
  mov    $0x1,%r11d
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %ecx,%ecx
  jne    L4
  shl    $0x4,%r8d
  mov    $0xf,%r11d
  sub    %edx,%r8d
L4:
  movswl 0x0(%rbp),%esi
  cmp    $0x8,%ebx
  mov    $0x1e,%eax
  mov    $0x50,%r12d
  cmovne %eax,%r12d
  lea    D22(%rip),%rdi
  mov    %esi,%eax
  cltd
  mov    %r12d,%r13d
  idiv   %ebx
  sub    %ecx,%r13d
  imul   %ebx,%r13d
  mov    %r13d,%r9d
  add    %ecx,%eax
  test   %edx,%edx
  lea    D23(%rip),%rcx
  lea    D27(%rip),%rdx
  cmove  %rcx,%rdx
  sub    $0x8,%rsp
  mov    %r12d,%ecx
  push   %rsi
  mov    %r10,%rsi
  push   %rdx
  mov    %r11d,%edx
  push   %rax
  xor    %eax,%eax
  call   <printf@plt>
  add    $0x20,%rsp
  xor    %eax,%eax
  call   <getLine@plt>
  movslq %eax,%r12
  cmpb   $0x0,(%r12)
  jne    L76
  movzwl 0x0(%rbp),%r14d
L7:
  mov    %r14w,0x0(%rbp)
  mov    %r12,%rdi
  call   <free@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L81
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L76:
  lea    0x10(%rsp),%rsi
  xor    %edx,%edx
  mov    %r12,%rdi
  xor    %eax,%eax
  call   <strtol@plt>
  mov    %eax,%r14d
  mov    0x10(%rsp),%rax
  cmp    %r12,%rax
  je     L96
  movsbl (%rax),%r15d
  mov    %r15d,%edi
  mov    %r15b,0xf(%rsp)
  call   <toupper@plt>
  movzbl 0xf(%rsp),%edx
  test   %dl,%dl
  jne    L19
L84:
  mov    %r15d,%edi
  call   <toupper@plt>
  cmp    $0x50,%eax
  je     L74
  sub    $0x1,%r14d
  imul   %ebx,%r14d
L74:
  cmp    %r13d,%r14d
  jle    L7
  lea    D40(%rip),%rdi
  movzwl 0x0(%rbp),%r14d
  call   <puts@plt>
  jmp    L7
  nopl   0x0(%rax)
L19:
  cmp    $0x50,%eax
  je     L74
L96:
  lea    D8(%rip),%rdi
  movswl 0x0(%rbp),%r14d
  call   <puts@plt>
  mov    0x10(%rsp),%rax
  movsbl (%rax),%r15d
  jmp    L84
L81:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D22
data_type: string
name: parse_data
arguments: tag: D23
data_type: string
name: parse_data
arguments: tag: D27
data_type: string
name: parse_data
arguments: tag: D40
data_type: string
name: parse_data
arguments: tag: D8
data_type: string

tool: D22: %s (%d..%d) or (%dp..%dp) [%d%s or %dp]: 

tool: 

tool: D27: +

tool: D40: ???2

tool: D8: ???1

assistant: ```c
void getXY(char *what, short *locp, int scale, int abs) {
  char *line, *end;
  int val;
  int min = abs ? 1 : 15;
  int minp = min * scale;
  int max = scale == 8 ? 80 : 30;
  int maxp = (max - abs) * scale;
  int loc = *locp / scale + abs;
  char *plus = *locp % scale ? "+" : "";
  printf("%s (%d..%d) or (%dp..%dp) [%d%s or %dp]: ", what, min, max, minp, maxp, loc, plus, (int)*locp);
  line = getLine();
  if (!*line)
    val = *locp;
  else {
    val = strtol(line, &end, 0);
    if (line == end || (*end && toupper(*end) != 'P')) {
      val = *locp;
      printf("???1\n");
    }
    if (toupper(*end) != 'P')
      val = (val - 1) * scale;
    if (val > maxp) {
      val = *locp;
      printf("???2\n");
    }
  }
  *locp = val;
  free(line);
}
```