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

```asm
<UI_CalcWeight>:
  endbr64
  push   %r15
  mov    $0x400,%edx
  lea    D71(%rip),%rdi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x418,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x408(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbp
  mov    %rbp,%rsi
  call   <trap_Cvar_VariableStringBuffer@plt>
  mov    %rbp,%rdi
  call   <atoi@plt>
  mov    $0x400,%edx
  mov    %rbp,%rsi
  lea    D43(%rip),%rdi
  mov    %eax,%r13d
  call   <trap_Cvar_VariableStringBuffer@plt>
  mov    %rbp,%rdi
  call   <atoi@plt>
  mov    $0x400,%edx
  mov    %rbp,%rsi
  lea    D88(%rip),%rdi
  mov    %eax,%r14d
  call   <trap_Cvar_VariableStringBuffer@plt>
  mov    %rbp,%rdi
  call   <atoi@plt>
  mov    $0x400,%edx
  mov    %rbp,%rsi
  lea    D62(%rip),%rdi
  mov    %eax,%r15d
  call   <trap_Cvar_VariableStringBuffer@plt>
  mov    %rbp,%rdi
  call   <atoi@plt>
  mov    $0x400,%edx
  mov    %rbp,%rsi
  lea    D60(%rip),%rdi
  mov    %eax,%ebx
  call   <trap_Cvar_VariableStringBuffer@plt>
  mov    %rbp,%rdi
  call   <atoi@plt>
  mov    $0x400,%edx
  mov    %rbp,%rsi
  lea    D46(%rip),%rdi
  mov    %eax,%r12d
  call   <trap_Cvar_VariableStringBuffer@plt>
  mov    %rbp,%rdi
  call   <atoi@plt>
  lea    -0xc(%r15),%edx
  movss  D104(%rip),%xmm1
  cmp    $0xc,%edx
  ja     L13
  lea    D22(%rip),%rcx
  pxor   %xmm1,%xmm1
  addss  (%rcx,%rdx,4),%xmm1
L13:
  lea    -0x6(%rbx),%edx
  movss  D52(%rip),%xmm0
  cmp    $0x5,%edx
  ja     L51
  lea    D25(%rip),%rcx
  movss  (%rcx,%rdx,4),%xmm0
L51:
  add    %eax,%r12d
  addss  %xmm0,%xmm1
  pxor   %xmm0,%xmm0
  mov    %r12d,%eax
  shr    $0x1f,%eax
  add    %r12d,%eax
  sar    %eax
  cvtsi2ss %eax,%xmm0
  addss  %xmm1,%xmm0
  test   %r14d,%r14d
  je     L6
  addss  D21(%rip),%xmm0
L6:
  test   %r13d,%r13d
  je     L40
  addss  D52(%rip),%xmm0
L40:
  comiss D77(%rip),%xmm0
  jbe    L29
  movss  D77(%rip),%xmm0
L29:
  mov    0x408(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L7
  add    $0x418,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L7:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D71
datatype: string
name: retrieve_data
arguments: label: D43
datatype: string
name: retrieve_data
arguments: label: D88
datatype: string
name: retrieve_data
arguments: label: D62
datatype: string
name: retrieve_data
arguments: label: D60
datatype: string
name: retrieve_data
arguments: label: D46
datatype: string
name: retrieve_data
arguments: label: D104
datatype: byte[4]
name: retrieve_data
arguments: label: D22
datatype: string
name: retrieve_data
arguments: label: D52
datatype: byte[4]
name: retrieve_data
arguments: label: D25
datatype: string
name: retrieve_data
arguments: label: D21
datatype: f32
name: retrieve_data
arguments: label: D77
datatype: byte[4]

tool: D71: inven_helmet

tool: D43: inven_kevlar

tool: D88: inven_primary

tool: D62: inven_secondary

tool: D60: inven_ammo_primary

tool: D46: inven_ammo_secondary

tool: {"D104": [0x00,0x00,0x70,0x41]}

tool: 

tool: {"D52": [0x00,0x00,0xc0,0x40]}

tool: 

tool: D21: 6.5

tool: {"D77": [0x00,0x00,0x48,0x43]}

assistant: ```c
float UI_CalcWeight(void) {
  float weight = 0;
  float weapon_weight = 0;
  int primary;
  int secondary;
  int priammo;
  int secammo;
  int kevlar;
  int helmet;
  char var[1024];
  trap_Cvar_VariableStringBuffer("inven_helmet", var, sizeof(var));
  helmet = atoi(var);
  trap_Cvar_VariableStringBuffer("inven_kevlar", var, sizeof(var));
  kevlar = atoi(var);
  trap_Cvar_VariableStringBuffer("inven_primary", var, sizeof(var));
  primary = atoi(var);
  trap_Cvar_VariableStringBuffer("inven_secondary", var, sizeof(var));
  secondary = atoi(var);
  trap_Cvar_VariableStringBuffer("inven_ammo_primary", var, sizeof(var));
  priammo = atoi(var);
  trap_Cvar_VariableStringBuffer("inven_ammo_secondary", var, sizeof(var));
  secammo = atoi(var);
  switch (primary) {
  case 15:
    weapon_weight = 19;
    break;
  case 16:
    weapon_weight = 20;
    break;
  case 14:
    weapon_weight = 15;
    break;
  case 12:
    weapon_weight = 20;
    break;
  case 22:
    weapon_weight = 32;
    break;
  case 21:
    weapon_weight = 24;
    break;
  case 19:
    weapon_weight = 20;
    break;
  case 23:
    weapon_weight = 21;
    break;
  case 20:
    weapon_weight = 16;
    break;
  case 24:
    weapon_weight = 17;
    break;
  case 17:
    weapon_weight = 18;
    break;
  case 18:
    weapon_weight = 15;
    break;
  default:
    weapon_weight = 15;
    break;
  }
  weight += weapon_weight;
  switch (secondary) {
  case 11:
  case 10:
    weapon_weight = 9;
    break;
  case 8:
    weapon_weight = 7;
    break;
  case 6:
    weapon_weight = 6;
    break;
  case 7:
    weapon_weight = 6;
    break;
  case 9:
    weapon_weight = 5;
    break;
  default:
    weapon_weight = 6;
    break;
  }
  weight += weapon_weight;
  weight += (priammo + secammo) / 2;
  if (kevlar) {
    weight += 6.5;
  }
  if (helmet) {
    weight += 6;
  }
  if (weight > 200) {
    weight = 200;
  }
  return weight;
}
```