user: 请将以下的汇编代码转换成C语言代码:

```asm
<encode_GDS_R4>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x10(%rbp)
  movl   $0x0,-0x14(%rbp)
  lea    -0x10(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  lea    D47(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sscanf@plt>
  movsd  -0x10(%rbp),%xmm1
  pxor   %xmm0,%xmm0
  comisd %xmm1,%xmm0
  seta   %al
  mov    %al,-0x19(%rbp)
  cmpb   $0x0,-0x19(%rbp)
  je     L48
  movsd  -0x10(%rbp),%xmm0
  movq   D25(%rip),%xmm1
  xorpd  %xmm1,%xmm0
  movsd  %xmm0,-0x10(%rbp)
L48:
  addl   $0x40,-0x14(%rbp)
  movsd  -0x10(%rbp),%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm1,%xmm0
  jp     L29
  pxor   %xmm1,%xmm1
  ucomisd %xmm1,%xmm0
  je     L79
L29:
  movsd  -0x10(%rbp),%xmm0
  movsd  D54(%rip),%xmm1
  comisd %xmm1,%xmm0
  jb     L92
  jmp    L96
L28:
  addl   $0x1,-0x14(%rbp)
  movsd  -0x10(%rbp),%xmm0
  movsd  D65(%rip),%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x10(%rbp)
L96:
  movsd  -0x10(%rbp),%xmm0
  movsd  D54(%rip),%xmm1
  comisd %xmm1,%xmm0
  jae    L28
  jmp    L79
L92:
  movsd  -0x10(%rbp),%xmm1
  movsd  D88(%rip),%xmm0
  comisd %xmm1,%xmm0
  jbe    L79
  jmp    L88
L9:
  subl   $0x1,-0x14(%rbp)
  movsd  -0x10(%rbp),%xmm1
  movsd  D65(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x10(%rbp)
L88:
  movsd  -0x10(%rbp),%xmm1
  movsd  D88(%rip),%xmm0
  comisd %xmm1,%xmm0
  ja     L9
L79:
  mov    -0x14(%rbp),%eax
  mov    %eax,%edx
  mov    -0x30(%rbp),%rax
  mov    %dl,(%rax)
  cmpb   $0x0,-0x19(%rbp)
  je     L43
  mov    -0x30(%rbp),%rax
  movzbl (%rax),%eax
  or     $0xffffff80,%eax
  mov    %eax,%edx
  mov    -0x30(%rbp),%rax
  mov    %dl,(%rax)
L43:
  movl   $0x1,-0x18(%rbp)
  jmp    L126
L36:
  movsd  -0x10(%rbp),%xmm1
  movsd  D74(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x10(%rbp)
  movsd  -0x10(%rbp),%xmm0
  cvttsd2si %xmm0,%edx
  mov    -0x18(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  movsd  -0x10(%rbp),%xmm0
  mov    -0x18(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,-0x10(%rbp)
  addl   $0x1,-0x18(%rbp)
L126:
  cmpl   $0x3,-0x18(%rbp)
  jle    L36
  mov    $0x4,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L76
  call   <__stack_chk_fail@plt>
L76:
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D47
type_infered: string
name: read_data
arguments: tag: D25
type_infered: f32[2]
name: read_data
arguments: tag: D54
type_infered: f64
name: read_data
arguments: tag: D65
type_infered: f64
name: read_data
arguments: tag: D88
type_infered: f32[2]
name: read_data
arguments: tag: D74
type_infered: f64

tool: D47: %lf

tool: {"D25": [0.0,-0.0]}

tool: D54: 1

tool: D65: 16

tool: {"D88": [0.0,1.375]}

tool: D74: 256

assistant: ```c
int encode_GDS_R4(buf, dchars, size)
char *buf;
unsigned char *dchars;
int size;
{
  double val = 0.0;
  int i;
  int exponent = 0;
  char isneg;
  sscanf(buf, "%lf", &val);
  if (isneg = (val < 0.0)) {
    val = -val;
  }
  exponent += 64;
  if (val == 0.0) {
  } else if (val >= 1.0) {
    while (val >= 1.0) {
      exponent++;
      val /= 16.0;
    }
  } else if (val < (1.0 / 16.0)) {
    while (val < (1.0 / 16.0)) {
      exponent--;
      val *= 16.0;
    }
  }
  dchars[0] = exponent;
  if (isneg)
    dchars[0] |= 0x80;
  for (i = 1; i < 4; i++) {
    val *= 256.0;
    dchars[i] = (int)val;
    val -= dchars[i];
  }
  return 4;
}
```