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

```asm
<position_near>:
  endbr64
  push   %r13
  mov    %edi,%r13d
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%rdx
  push   $0x0
  lea    0x1c(%rsp),%rax
  push   %rax
  mov    D30(%rip),%rax
  mov    (%rax),%r9d
  mov    D11(%rip),%rax
  lea    0x20(%rsp),%r8
  mov    (%rax),%ecx
  mov    D28(%rip),%rax
  mov    (%rax),%esi
  call   <XtVaGetValues@plt>
  mov    0x24(%rsp),%eax
  mov    %r13d,%edi
  add    %eax,%eax
  add    %eax,0x1c(%rsp)
  add    %eax,0x20(%rsp)
  call   <XtScreen@plt>
  mov    %eax,%edi
  call   <WidthOfScreen@plt>
  mov    %r13d,%edi
  mov    %eax,%r12d
  call   <XtScreen@plt>
  mov    %eax,%edi
  call   <HeightOfScreen@plt>
  movslq %r12d,%rdx
  mov    %r12d,%ecx
  lea    (%r12,%r12,1),%r11d
  imul   $0x55555556,%rdx,%rdx
  sar    $0x1f,%ecx
  shr    $0x20,%rdx
  sub    %ecx,%edx
  pop    %rcx
  pop    %rsi
  cmp    %ebx,%edx
  setl   %dl
  setl   %r9b
  movzbl %dl,%r8d
  movzbl %dl,%ecx
  movzbl %dl,%esi
  movzbl %dl,%edi
  movzbl %dl,%r10d
  movslq %r11d,%rdx
  sar    $0x1f,%r11d
  movzbl %r9b,%r9d
  imul   $0x55555556,%rdx,%rdx
  add    $0x8,%ecx
  add    $0x5,%esi
  add    $0x2,%edi
  add    $0x4,%r8d
  add    $0x7,%r9d
  add    $0x1,%r10d
  shr    $0x20,%rdx
  sub    %r11d,%edx
  cmp    %ebx,%edx
  movslq %eax,%rdx
  cmovge %r8d,%esi
  cmovge %r9d,%ecx
  cmovge %r10d,%edi
  mov    %eax,%r8d
  sar    $0x1f,%r8d
  imul   $0x55555556,%rdx,%rdx
  shr    $0x20,%rdx
  sub    %r8d,%edx
  cmp    %ebp,%edx
  jl     L1
  mov    %esi,%ecx
  mov    %edi,%esi
L1:
  lea    (%rax,%rax,1),%edi
  movslq %edi,%rdx
  sar    $0x1f,%edi
  imul   $0x55555556,%rdx,%rdx
  shr    $0x20,%rdx
  sub    %edi,%edx
  mov    0xc(%rsp),%edi
  cmp    %ebp,%edx
  cmovge %esi,%ecx
  mov    0x10(%rsp),%esi
  push   $0x0
  mov    %esi,%edx
  push   %rcx
  mov    D17(%rip),%rcx
  shr    $0x1f,%edx
  add    %esi,%edx
  mov    (%rcx),%r9d
  sar    %edx
  sub    %edx,%ebp
  mov    $0x0,%edx
  cmovs  %edx,%ebp
  sub    %esi,%eax
  mov    %edi,%esi
  shr    $0x1f,%esi
  add    %edi,%esi
  sar    %esi
  sub    %esi,%ebx
  mov    $0x0,%esi
  mov    %ebx,%edx
  cmovs  %esi,%edx
  sub    %edi,%r12d
  mov    %r13d,%edi
  cmp    %r12d,%edx
  cmovg  %r12d,%edx
  cmp    %eax,%ebp
  cmovle %ebp,%eax
  mov    %eax,%r8d
  mov    D32(%rip),%rax
  mov    (%rax),%ecx
  mov    D7(%rip),%rax
  mov    (%rax),%esi
  call   <XtVaSetValues@plt>
  pop    %rax
  pop    %rdx
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L4
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L4:
  call   <__stack_chk_fail@plt>
```

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);
}
```