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

```asm
<get_max_def_res>:
  endbr64
  push   %r15
  mov    %esi,%edi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x48,%rsp
  mov    %rcx,0x28(%rsp)
  mov    %r8,0x30(%rsp)
  call   <GET_ELEM_N1@plt>
  mov    %ebx,%edi
  mov    %eax,%r12d
  call   <GET_ELEM_N2@plt>
  mov    %r12d,%edi
  mov    %eax,%r15d
  call   <GET_NODE_X@plt>
  mov    %r12d,%edi
  movsd  %xmm0,(%rsp)
  call   <GET_NODE_Y@plt>
  mov    %r15d,%edi
  movsd  %xmm0,0x8(%rsp)
  call   <GET_NODE_X@plt>
  mov    %r15d,%edi
  movq   %xmm0,%r12
  call   <GET_NODE_Y@plt>
  movq   %r12,%xmm7
  subsd  (%rsp),%xmm7
  movapd %xmm0,%xmm1
  subsd  0x8(%rsp),%xmm1
  movapd %xmm7,%xmm0
  mulsd  %xmm1,%xmm1
  mulsd  %xmm7,%xmm0
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L41
  sqrtsd %xmm0,%xmm0
  movsd  %xmm0,(%rsp)
L59:
  test   %ebp,%ebp
  js     L40
  pxor   %xmm7,%xmm7
  mov    $0xffffffff,%r12d
  movsd  %xmm1,0x18(%rsp)
  xor    %r15d,%r15d
  cvtsi2sd %ebp,%xmm7
  movsd  %xmm7,0x20(%rsp)
  movsd  %xmm7,0x38(%rsp)
  nopw   0x0(%rax,%rax,1)
L36:
  mov    %ebx,%edi
  call   <GET_ELEM_E@plt>
  mov    %ebx,%edi
  movsd  %xmm0,0x8(%rsp)
  call   <GET_ELEM_I@plt>
  movsd  0x8(%rsp),%xmm2
  pxor   %xmm1,%xmm1
  mov    %ebx,%edi
  cvtsi2sd %r15d,%xmm1
  divsd  0x20(%rsp),%xmm1
  mulsd  (%rsp),%xmm1
  mulsd  %xmm0,%xmm2
  movsd  %xmm1,0x10(%rsp)
  movsd  %xmm2,0x8(%rsp)
  call   <GET_ELEM_VB@plt>
  mov    %ebx,%edi
  mov    %eax,%r14d
  call   <GET_ELEM_VA@plt>
  mov    %ebx,%edi
  mov    %eax,%r13d
  call   <GET_ELEM_TYPE@plt>
  movsd  (%rsp),%xmm0
  mov    %r14d,%edx
  mov    %r13d,%esi
  movsd  0x10(%rsp),%xmm1
  mov    %eax,%edi
  call   <md_compute_e_def_y@plt>
  divsd  0x8(%rsp),%xmm0
  movapd %xmm0,%xmm1
  andpd  D15(%rip),%xmm1
  comisd 0x18(%rsp),%xmm1
  jbe    L32
  mov    %r15d,%r12d
  movsd  %xmm0,0x18(%rsp)
L32:
  add    $0x1,%r15d
  cmp    %r15d,%ebp
  jge    L36
  pxor   %xmm0,%xmm0
  cvtsi2sd %r12d,%xmm0
L55:
  divsd  0x38(%rsp),%xmm0
  mulsd  (%rsp),%xmm0
  mov    0x28(%rsp),%rax
  mov    %r12d,(%rax)
  mov    0x30(%rsp),%rax
  movsd  %xmm0,(%rax)
  movsd  0x18(%rsp),%xmm0
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L40:
  pxor   %xmm7,%xmm7
  movsd  D8(%rip),%xmm0
  mov    $0xffffffff,%r12d
  movsd  %xmm1,0x18(%rsp)
  cvtsi2sd %ebp,%xmm7
  movsd  %xmm7,0x38(%rsp)
  jmp    L55
L41:
  call   <sqrt@plt>
  pxor   %xmm1,%xmm1
  movsd  %xmm0,(%rsp)
  jmp    L59
```

tool_calls: name: unpack_data
arguments: label: D15
type: qword[2]
name: unpack_data
arguments: label: D8
type: f32[2]

tool: {"D15": [0x7fffffffffffffff,0x0000000000000000]}

tool: {"D8": [0.0,-1.875]}

assistant: ```c
double get_max_def_res(int type, int epos, int div, int *ppos, double *x) {
  int i, n1, n2;
  double val, EI, L, x1, y1, x2, y2;
  double xx = 0.0;
  double max = 0.0;
  int pos = -1;
  n1 = GET_ELEM_N1(epos);
  n2 = GET_ELEM_N2(epos);
  x1 = (GET_NODE_X(n1));
  y1 = (GET_NODE_Y(n1));
  x2 = (GET_NODE_X(n2));
  y2 = (GET_NODE_Y(n2));
  L = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  for (i = 0; i <= div; i++) {
    EI = GET_ELEM_E(epos) * GET_ELEM_I(epos);
    xx = ((double)i / (double)div) * L;
    val = ((md_compute_e_def_y(GET_ELEM_TYPE(epos), L, GET_ELEM_VA(epos), GET_ELEM_VB(epos), xx) / EI));
    if (fabs(val) > max) {
      max = val;
      pos = i;
    }
  }
  *ppos = pos;
  *x = ((double)pos / (double)div) * L;
  return (max);
}
```