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

```asm
<position_near>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %esi,-0x28(%rbp)
  mov    %edx,-0x2c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    D23(%rip),%rax
  mov    (%rax),%r9d
  mov    D32(%rip),%rax
  mov    (%rax),%ecx
  mov    D18(%rip),%rax
  mov    (%rax),%esi
  lea    -0x1c(%rbp),%r8
  lea    -0x20(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  push   $0x0
  lea    -0x18(%rbp),%rdi
  push   %rdi
  mov    %eax,%edi
  call   <XtVaGetValues@plt>
  add    $0x10,%rsp
  mov    -0x18(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x18(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x1c(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <XtScreen@plt>
  mov    %eax,%edi
  call   <WidthOfScreen@plt>
  mov    %eax,-0x10(%rbp)
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <XtScreen@plt>
  mov    %eax,%edi
  call   <HeightOfScreen@plt>
  mov    %eax,-0xc(%rbp)
  movl   $0x1,-0x14(%rbp)
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  imul   $0x55555556,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  cmp    %eax,-0x28(%rbp)
  jle    L41
  addl   $0x1,-0x14(%rbp)
L41:
  mov    -0x10(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdx
  imul   $0x55555556,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  cmp    %eax,-0x28(%rbp)
  jle    L12
  addl   $0x1,-0x14(%rbp)
L12:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  imul   $0x55555556,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  cmp    %eax,-0x2c(%rbp)
  jle    L47
  addl   $0x3,-0x14(%rbp)
L47:
  mov    -0xc(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdx
  imul   $0x55555556,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  cmp    %eax,-0x2c(%rbp)
  jle    L34
  addl   $0x3,-0x14(%rbp)
L34:
  mov    -0x20(%rbp),%eax
  sub    %eax,-0x10(%rbp)
  mov    -0x1c(%rbp),%eax
  sub    %eax,-0xc(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  neg    %eax
  add    %eax,-0x28(%rbp)
  cmpl   $0x0,-0x28(%rbp)
  jns    L56
  movl   $0x0,-0x28(%rbp)
L56:
  mov    -0x28(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jle    L35
  mov    -0x10(%rbp),%eax
  mov    %eax,-0x28(%rbp)
L35:
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  neg    %eax
  add    %eax,-0x2c(%rbp)
  cmpl   $0x0,-0x2c(%rbp)
  jns    L78
  movl   $0x0,-0x2c(%rbp)
L78:
  mov    -0x2c(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jle    L32
  mov    -0xc(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
L32:
  mov    D50(%rip),%rax
  mov    (%rax),%r9d
  mov    D41(%rip),%rax
  mov    (%rax),%ecx
  mov    D28(%rip),%rax
  mov    (%rax),%esi
  mov    -0x2c(%rbp),%r8d
  mov    -0x28(%rbp),%edx
  mov    -0x24(%rbp),%eax
  push   $0x0
  mov    -0x14(%rbp),%edi
  push   %rdi
  mov    %eax,%edi
  call   <XtVaSetValues@plt>
  add    $0x10,%rsp
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L49
  call   <__stack_chk_fail@plt>
L49:
  leave
  ret
```

assistant: ```c
void position_near(Widget shell, int x, int y) {
  int max_x, max_y;
  Dimension width, height, border;
  int gravity;
  XtVaGetValues(shell, XtNwidth, &width, XtNheight, &height, XtNborderWidth, &border, NULL);
  width += 2 * border;
  height += 2 * border;
  max_x = WidthOfScreen(XtScreen(shell));
  max_y = HeightOfScreen(XtScreen(shell));
  gravity = 1;
  if (x > max_x / 3)
    gravity += 1;
  if (x > max_x * 2 / 3)
    gravity += 1;
  if (y > max_y / 3)
    gravity += 3;
  if (y > max_y * 2 / 3)
    gravity += 3;
  max_x -= width;
  max_y -= height;
  x -= ((Position)width / 2);
  if (x < 0)
    x = 0;
  if (x > max_x)
    x = max_x;
  y -= ((Position)height / 2);
  if (y < 0)
    y = 0;
  if (y > max_y)
    y = max_y;
  XtVaSetValues(shell, XtNx, (Position)x, XtNy, (Position)y, XtNwinGravity, gravity, NULL);
}
```