user: 请从给定的汇编指令推导出C源代码:

```asm
<cb2006_ampf>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x258,%rsp
  mov    %rdi,0x38(%rsp)
  mov    %rsi,0x28(%rsp)
  mov    %edx,0x34(%rsp)
  mov    %rcx,%rbx
  mov    %r8,%r15
  mov    %r9,%rbp
  mov    0x290(%rsp),%r12
  mov    0x298(%rsp),%rax
  mov    %rax,0x40(%rsp)
  mov    0x2a0(%rsp),%rax
  mov    %rax,0x48(%rsp)
  mov    0x2a8(%rsp),%rax
  mov    %rax,0x50(%rsp)
  mov    0x2b0(%rsp),%rax
  mov    %rax,0x58(%rsp)
  mov    0x2b8(%rsp),%rax
  mov    %rax,0x60(%rsp)
  mov    0x2c0(%rsp),%rax
  mov    %rax,0x68(%rsp)
  mov    0x2c8(%rsp),%r13
  mov    %fs:0x28,%rax
  mov    %rax,0x248(%rsp)
  xor    %eax,%eax
  movl   $0x0,0x70(%rsp)
  movl   $0x3c23d70a,0x74(%rsp)
  movl   $0x3ca3d70a,0x78(%rsp)
  movl   $0x3cf5c28f,0x7c(%rsp)
  movl   $0x3d4ccccd,0x80(%rsp)
  movl   $0x3d99999a,0x84(%rsp)
  movl   $0x3dcccccd,0x88(%rsp)
  movl   $0x3e19999a,0x8c(%rsp)
  movl   $0x3e4ccccd,0x90(%rsp)
  movl   $0x3e800000,0x94(%rsp)
  movl   $0x3e99999a,0x98(%rsp)
  movl   $0x3ecccccd,0x9c(%rsp)
  movl   $0x3f000000,0xa0(%rsp)
  movl   $0x3f400000,0xa4(%rsp)
  movl   $0x3f800000,0xa8(%rsp)
  movl   $0x3fc00000,0xac(%rsp)
  movl   $0x40000000,0xb0(%rsp)
  movl   $0x40400000,0xb4(%rsp)
  movl   $0x40800000,0xb8(%rsp)
  movl   $0x40a00000,0xbc(%rsp)
  movl   $0x40f00000,0xc0(%rsp)
  movl   $0x41200000,0xc4(%rsp)
  movss  D115(%rip),%xmm0
  movss  %xmm0,0xd0(%rsp)
  movss  %xmm0,0xd4(%rsp)
  movl   $0x3f8d0e56,0xd8(%rsp)
  movl   $0x3f9645a2,0xdc(%rsp)
  movl   $0x3fa2d0e5,0xe0(%rsp)
  movl   $0x3fb81062,0xe4(%rsp)
  movl   $0x3fcd4fdf,0xe8(%rsp)
  movl   $0x3ff6c8b4,0xec(%rsp)
  movl   $0x400c6a7f,0xf0(%rsp)
  movl   $0x401676c9,0xf4(%rsp)
  movl   $0x401d70a4,0xf8(%rsp)
  movl   $0x40259168,0xfc(%rsp)
  movl   $0x4022d0e5,0x100(%rsp)
  movl   $0x40088312,0x104(%rsp)
  movl   $0x3fc91687,0x108(%rsp)
  movl   $0x3ecfdf3b,0x10c(%rsp)
  movl   $0xbee978d5,0x110(%rsp)
  movss  D279(%rip),%xmm0
  movss  %xmm0,0x114(%rsp)
  movss  %xmm0,0x118(%rsp)
  movss  %xmm0,0x11c(%rsp)
  movss  %xmm0,0x120(%rsp)
  movss  %xmm0,0x124(%rsp)
  mov    D52(%rip),%r14d
  mov    %r14d,0x130(%rsp)
  mov    %r14d,0x134(%rsp)
  mov    %r14d,0x138(%rsp)
  movl   $0x44630000,0x13c(%rsp)
  movl   $0x4483c000,0x140(%rsp)
  movl   $0x4487c000,0x144(%rsp)
  movl   $0x44810000,0x148(%rsp)
  movl   $0x445b8000,0x14c(%rsp)
  movl   $0x443b0000,0x150(%rsp)
  movl   $0x44238000,0x154(%rsp)
  movl   $0x4412c000,0x158(%rsp)
  movl   $0x43fb8000,0x15c(%rsp)
  movl   $0x43e48000,0x160(%rsp)
  movl   $0x43cd0000,0x164(%rsp)
  movss  D106(%rip),%xmm0
  movss  %xmm0,0x168(%rsp)
  movss  %xmm0,0x16c(%rsp)
  movss  %xmm0,0x170(%rsp)
  movss  %xmm0,0x174(%rsp)
  movss  %xmm0,0x178(%rsp)
  movss  %xmm0,0x17c(%rsp)
  movss  %xmm0,0x180(%rsp)
  movss  %xmm0,0x184(%rsp)
  movss  D252(%rip),%xmm0
  movss  %xmm0,0x190(%rsp)
  movss  %xmm0,0x194(%rsp)
  movl   $0xbf9c0831,0x198(%rsp)
  movl   $0xbfa2f1aa,0x19c(%rsp)
  movl   $0xbfac49ba,0x1a0(%rsp)
  movl   $0xbfbc49ba,0x1a4(%rsp)
  movl   $0xbfcfdf3b,0x1a8(%rsp)
  movl   $0xbff72b02,0x1ac(%rsp)
  movl   $0xc00c0831,0x1b0(%rsp)
  movl   $0xc018624e,0x1b4(%rsp)
  movl   $0xc02126e9,0x1b8(%rsp)
  movl   $0xc02a0c4a,0x1bc(%rsp)
  movl   $0xc02ad0e5,0x1c0(%rsp)
  movl   $0xc019a9fc,0x1c4(%rsp)
  movl   $0xbffa3d71,0x1c8(%rsp)
  movl   $0xbf833333,0x1cc(%rsp)
  movl   $0xbe991687,0x1d0(%rsp)
  movl   $0x0,0x1d4(%rsp)
  movl   $0x0,0x1d8(%rsp)
  movl   $0x0,0x1dc(%rsp)
  movl   $0x0,0x1e0(%rsp)
  movl   $0x0,0x1e4(%rsp)
  movss  D131(%rip),%xmm0
  call   <log@plt>
  mulss  D57(%rip),%xmm0
  movss  %xmm0,0xc(%rsp)
  movss  0x0(%rbp),%xmm0
  movd   %r14d,%xmm5
  comiss %xmm0,%xmm5
  jbe    L6
  divss  D52(%rip),%xmm0
  call   <log@plt>
  movss  %xmm0,0x10(%rsp)
  mov    (%r12),%r14d
  movss  0x0(%rbp),%xmm0
  divss  D52(%rip),%xmm0
  call   <log@plt>
  mulss  D107(%rip),%xmm0
  call   <exp@plt>
  movss  D32(%rip),%xmm1
  mulss  %xmm1,%xmm0
  movd   %r14d,%xmm2
  addss  %xmm2,%xmm0
  addss  (%r12),%xmm1
  divss  %xmm1,%xmm0
  call   <log@plt>
  movss  0x10(%rsp),%xmm1
  mulss  D115(%rip),%xmm1
  mulss  D252(%rip),%xmm0
  addss  %xmm0,%xmm1
L267:
  mov    (%r12),%ebp
  movss  0xc(%rsp),%xmm0
  subss  %xmm1,%xmm0
  call   <exp@plt>
  movd   %ebp,%xmm5
  mulss  %xmm0,%xmm5
  movss  %xmm5,0x14(%rsp)
  lea    0xd0(%rsp),%r12
  lea    0x190(%rsp),%r14
  lea    0x128(%rsp),%rax
  mov    %rax,0x18(%rsp)
  mov    $0x0,%ebp
  movss  D287(%rip),%xmm5
  movss  %xmm5,0x30(%rsp)
  jmp    L174
L6:
  divss  D52(%rip),%xmm0
  call   <log@plt>
  movaps %xmm0,%xmm1
  mulss  D57(%rip),%xmm1
  jmp    L267
L117:
  movss  (%r14),%xmm1
  mulss  D107(%rip),%xmm1
  addss  (%r12),%xmm1
  movss  %xmm1,0x10(%rsp)
  divss  0xc(%rsp),%xmm0
  call   <log@plt>
  mulss  0x10(%rsp),%xmm0
  movss  %xmm0,0x10(%rsp)
  jmp    L278
L238:
  movss  (%r14),%xmm1
  mulss  D107(%rip),%xmm1
  addss  (%r12),%xmm1
  movss  %xmm1,0x20(%rsp)
  divss  0xc(%rsp),%xmm0
  call   <log@plt>
  mulss  0x20(%rsp),%xmm0
  jmp    L223
L8:
  movss  %xmm6,0x1f0(%rsp,%rbp,1)
L57:
  add    $0x4,%r12
  add    $0x4,%r14
  add    $0x4,%rbp
  cmp    0x18(%rsp),%r12
  je     L133
L174:
  movss  (%r15),%xmm0
  movss  0x130(%rsp,%rbp,1),%xmm7
  movss  %xmm7,0xc(%rsp)
  comiss %xmm0,%xmm7
  jbe    L117
  movss  (%r12),%xmm4
  movss  %xmm4,0x10(%rsp)
  divss  %xmm7,%xmm0
  call   <log@plt>
  mulss  0x10(%rsp),%xmm0
  movss  %xmm0,0x10(%rsp)
  movss  (%r14),%xmm2
  movss  %xmm2,0x20(%rsp)
  movss  (%r15),%xmm0
  divss  0xc(%rsp),%xmm0
  call   <log@plt>
  mulss  D107(%rip),%xmm0
  call   <exp@plt>
  mulss  D32(%rip),%xmm0
  movss  0x14(%rsp),%xmm4
  addss  %xmm4,%xmm0
  addss  D32(%rip),%xmm4
  divss  %xmm4,%xmm0
  call   <log@plt>
  mulss  0x20(%rsp),%xmm0
  movaps %xmm0,%xmm3
  addss  0x10(%rsp),%xmm3
  movss  %xmm3,0x10(%rsp)
L278:
  movss  (%rbx),%xmm0
  movss  0xc(%rsp),%xmm5
  comiss %xmm0,%xmm5
  jbe    L238
  movss  (%r12),%xmm3
  movss  %xmm3,0x20(%rsp)
  divss  %xmm5,%xmm0
  call   <log@plt>
  mulss  0x20(%rsp),%xmm0
  movss  %xmm0,0x20(%rsp)
  movss  (%r14),%xmm4
  movss  %xmm4,0x24(%rsp)
  movss  (%rbx),%xmm0
  divss  0xc(%rsp),%xmm0
  call   <log@plt>
  mulss  D107(%rip),%xmm0
  call   <exp@plt>
  movss  D32(%rip),%xmm1
  mulss  %xmm1,%xmm0
  movss  0x14(%rsp),%xmm3
  addss  %xmm3,%xmm0
  addss  %xmm3,%xmm1
  divss  %xmm1,%xmm0
  call   <log@plt>
  mulss  0x24(%rsp),%xmm0
  addss  0x20(%rsp),%xmm0
L223:
  movss  0x10(%rsp),%xmm1
  subss  %xmm0,%xmm1
  movaps %xmm1,%xmm0
  call   <exp@plt>
  movss  %xmm0,0x1f0(%rsp,%rbp,1)
  pxor   %xmm2,%xmm2
  cvtss2sd 0x70(%rsp,%rbp,1),%xmm2
  movsd  D142(%rip),%xmm1
  divsd  %xmm2,%xmm1
  pxor   %xmm2,%xmm2
  cvtss2sd 0x0(%r13),%xmm2
  comisd %xmm1,%xmm2
  jb     L57
  pxor   %xmm1,%xmm1
  movss  0x30(%rsp),%xmm6
  comiss %xmm6,%xmm1
  jbe    L8
  movss  %xmm0,0x30(%rsp)
  jmp    L57
L133:
  movss  0x244(%rsp),%xmm6
  mov    0x34(%rsp),%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  mov    0x28(%rsp),%rsi
  mulss  (%rsi),%xmm0
  movss  D66(%rip),%xmm4
  divss  %xmm0,%xmm4
  mov    %eax,%ecx
  shr    $0x1f,%ecx
  add    %eax,%ecx
  sar    %ecx
  cmp    $0x3,%eax
  jle    L68
  movaps %xmm6,%xmm5
  mov    $0x1,%eax
  mov    $0x15,%edx
  pxor   %xmm3,%xmm3
  movss  D127(%rip),%xmm2
  movaps %xmm2,%xmm8
  movaps %xmm3,%xmm10
  movss  D66(%rip),%xmm12
  movaps %xmm3,%xmm11
  movaps %xmm12,%xmm7
  movsd  D142(%rip),%xmm9
  mov    0x38(%rsp),%rsi
  mov    0x40(%rsp),%rdi
  mov    0x48(%rsp),%r8
  mov    0x50(%rsp),%r9
  mov    0x58(%rsp),%r10
  jmp    L9
L235:
  movaps %xmm12,%xmm1
  divss  %xmm3,%xmm1
  jmp    L94
L292:
  movaps %xmm8,%xmm3
  subss  %xmm5,%xmm3
  movaps %xmm1,%xmm6
  subss  %xmm2,%xmm6
  divss  %xmm6,%xmm3
  movaps %xmm5,%xmm6
  movaps %xmm8,%xmm5
  movaps %xmm2,%xmm8
  movaps %xmm1,%xmm2
L195:
  movss  (%rdi),%xmm13
  movaps %xmm7,%xmm1
  comiss %xmm0,%xmm13
  ja     L66
  movaps %xmm0,%xmm1
  subss  %xmm8,%xmm1
  mulss  %xmm3,%xmm1
  addss  %xmm6,%xmm1
  movss  (%r8),%xmm14
  comiss %xmm0,%xmm14
  jbe    L0
  subss  %xmm13,%xmm0
  cvtss2sd %xmm0,%xmm0
  cvtss2sd %xmm1,%xmm1
  subsd  %xmm9,%xmm1
  mulsd  %xmm1,%xmm0
  subss  %xmm13,%xmm14
  cvtss2sd %xmm14,%xmm14
  divsd  %xmm14,%xmm0
  addsd  %xmm9,%xmm0
  pxor   %xmm1,%xmm1
  cvtsd2ss %xmm0,%xmm1
L66:
  movss  %xmm1,(%rsi,%rax,4)
  add    $0x1,%rax
  cmp    %eax,%ecx
  jle    L68
L9:
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  mulss  %xmm4,%xmm0
  comiss %xmm2,%xmm0
  jbe    L195
  test   %edx,%edx
  setg   %r11b
  movzbl %r11b,%r11d
  sub    %r11d,%edx
  movslq %edx,%r11
  movss  0x70(%rsp,%r11,4),%xmm3
  ucomiss %xmm10,%xmm3
  jp     L235
  ucomiss %xmm11,%xmm3
  movss  D43(%rip),%xmm1
  jne    L235
L94:
  movslq %edx,%r11
  movss  0x1f0(%rsp,%r11,4),%xmm8
  ucomiss %xmm2,%xmm1
  jp     L292
  jne    L292
  movaps %xmm5,%xmm6
  movaps %xmm8,%xmm5
  movaps %xmm2,%xmm8
  movaps %xmm1,%xmm2
  pxor   %xmm3,%xmm3
  jmp    L195
L0:
  movss  (%r9),%xmm13
  comiss %xmm0,%xmm13
  ja     L66
  movss  (%r10),%xmm13
  comiss %xmm0,%xmm13
  ja     L66
  mov    0x60(%rsp),%rbx
  movss  (%rbx),%xmm13
  comiss %xmm0,%xmm13
  ja     L66
  mov    0x68(%rsp),%rbx
  movss  (%rbx),%xmm14
  comiss %xmm0,%xmm14
  jbe    L207
  cvtss2sd %xmm1,%xmm1
  subss  %xmm13,%xmm0
  cvtss2sd %xmm0,%xmm0
  movsd  D142(%rip),%xmm15
  subsd  %xmm1,%xmm15
  mulsd  %xmm15,%xmm0
  subss  %xmm13,%xmm14
  pxor   %xmm13,%xmm13
  cvtss2sd %xmm14,%xmm13
  divsd  %xmm13,%xmm0
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsd2ss %xmm0,%xmm1
  jmp    L66
L207:
  movss  D66(%rip),%xmm1
  jmp    L66
L68:
  mov    0x248(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L240
  add    $0x258,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L240:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D115
type_guessed: f32
name: retrieve_data
arguments: data_tag: D279
type_guessed: byte[4]
name: retrieve_data
arguments: data_tag: D52
type_guessed: f32
name: retrieve_data
arguments: data_tag: D106
type_guessed: f32
name: retrieve_data
arguments: data_tag: D252
type_guessed: byte[4]
name: retrieve_data
arguments: data_tag: D131
type_guessed: byte[4]
name: retrieve_data
arguments: data_tag: D57
type_guessed: byte[4]
name: retrieve_data
arguments: data_tag: D107
type_guessed: f32
name: retrieve_data
arguments: data_tag: D32
type_guessed: f32
name: retrieve_data
arguments: data_tag: D287
type_guessed: byte[4]
name: retrieve_data
arguments: data_tag: D142
type_guessed: f64
name: retrieve_data
arguments: data_tag: D66
type_guessed: byte[4]
name: retrieve_data
arguments: data_tag: D127
type_guessed: f32
name: retrieve_data
arguments: data_tag: D43
type_guessed: f32

tool: D115: 1.058

tool: {"D279": [0x85,0xeb,0x51,0xbf]}

tool: D52: 865

tool: D106: 400

tool: {"D252": [0xd9,0xce,0x97,0xbf]}

tool: {"D131": [0x4a,0xc6,0xa2,0x3f]}

tool: {"D57": [0x74,0xd6,0xae,0xbe]}

tool: D107: 1.18

tool: D32: 1.88

tool: {"D287": [0x00,0x00,0x80,0xbf]}

tool: D142: 1

tool: {"D66": [0x00,0x00,0x80,0x3f]}

tool: D127: 0.1

tool: D43: 1000

assistant: ```c
void cb2006_ampf(float *ampf, float *dt, int n, float *vref, float *vsite, float *vpga, float *pga, float *fmin, float *fmidbot, float *fmid, float *fhigh, float *fhightop, float *fmax, float *flowcap) {
  float scon_c, scon_n, per[22], c10[22], c11[22], k1[22], k2[22], k3[22];
  float ampf0[22];
  float a_1100, fs_1100, fs_vpga, fs_vref, fsite;
  float df, ampv, afac, freq;
  float f0, f1, a0, a1, dadf, ampf_cap;
  int i, j;
  int nper = 22;
  scon_c = 1.88;
  scon_n = 1.18;
  per[0] = 0.0;
  per[1] = 0.01;
  per[2] = 0.02;
  per[3] = 0.03;
  per[4] = 0.05;
  per[5] = 0.075;
  per[6] = 0.10;
  per[7] = 0.15;
  per[8] = 0.20;
  per[9] = 0.25;
  per[10] = 0.30;
  per[11] = 0.40;
  per[12] = 0.50;
  per[13] = 0.75;
  per[14] = 1.00;
  per[15] = 1.50;
  per[16] = 2.00;
  per[17] = 3.00;
  per[18] = 4.00;
  per[19] = 5.00;
  per[20] = 7.50;
  per[21] = 10.0;
  c10[0] = 1.058;
  c10[1] = 1.058;
  c10[2] = 1.102;
  c10[3] = 1.174;
  c10[4] = 1.272;
  c10[5] = 1.438;
  c10[6] = 1.604;
  c10[7] = 1.928;
  c10[8] = 2.194;
  c10[9] = 2.351;
  c10[10] = 2.46;
  c10[11] = 2.587;
  c10[12] = 2.544;
  c10[13] = 2.133;
  c10[14] = 1.571;
  c10[15] = 0.406;
  c10[16] = -0.456;
  c10[17] = -0.82;
  c10[18] = -0.82;
  c10[19] = -0.82;
  c10[20] = -0.82;
  c10[21] = -0.82;
  c11[0] = 0.04;
  c11[1] = 0.04;
  c11[2] = 0.04;
  c11[3] = 0.04;
  c11[4] = 0.04;
  c11[5] = 0.04;
  c11[6] = 0.04;
  c11[7] = 0.04;
  c11[8] = 0.04;
  c11[9] = 0.04;
  c11[10] = 0.04;
  c11[11] = 0.04;
  c11[12] = 0.04;
  c11[13] = 0.077;
  c11[14] = 0.15;
  c11[15] = 0.253;
  c11[16] = 0.3;
  c11[17] = 0.3;
  c11[18] = 0.3;
  c11[19] = 0.3;
  c11[20] = 0.3;
  c11[21] = 0.3;
  k1[0] = 865.0;
  k1[1] = 865.0;
  k1[2] = 865.0;
  k1[3] = 908.0;
  k1[4] = 1054.0;
  k1[5] = 1086.0;
  k1[6] = 1032.0;
  k1[7] = 878.0;
  k1[8] = 748.0;
  k1[9] = 654.0;
  k1[10] = 587.0;
  k1[11] = 503.0;
  k1[12] = 457.0;
  k1[13] = 410.0;
  k1[14] = 400.0;
  k1[15] = 400.0;
  k1[16] = 400.0;
  k1[17] = 400.0;
  k1[18] = 400.0;
  k1[19] = 400.0;
  k1[20] = 400.0;
  k1[21] = 400.0;
  k2[0] = -1.186;
  k2[1] = -1.186;
  k2[2] = -1.219;
  k2[3] = -1.273;
  k2[4] = -1.346;
  k2[5] = -1.471;
  k2[6] = -1.624;
  k2[7] = -1.931;
  k2[8] = -2.188;
  k2[9] = -2.381;
  k2[10] = -2.518;
  k2[11] = -2.657;
  k2[12] = -2.669;
  k2[13] = -2.401;
  k2[14] = -1.955;
  k2[15] = -1.025;
  k2[16] = -0.299;
  k2[17] = 0.0;
  k2[18] = 0.0;
  k2[19] = 0.0;
  k2[20] = 0.0;
  k2[21] = 0.0;
  k3[0] = 1.839;
  k3[1] = 1.839;
  k3[2] = 1.84;
  k3[3] = 1.841;
  k3[4] = 1.843;
  k3[5] = 1.845;
  k3[6] = 1.847;
  k3[7] = 1.852;
  k3[8] = 1.856;
  k3[9] = 1.861;
  k3[10] = 1.865;
  k3[11] = 1.874;
  k3[12] = 1.883;
  k3[13] = 1.906;
  k3[14] = 1.929;
  k3[15] = 1.974;
  k3[16] = 2.019;
  k3[17] = 2.11;
  k3[18] = 2.2;
  k3[19] = 2.291;
  k3[20] = 2.517;
  k3[21] = 2.744;
  fs_1100 = (c10[0] + k2[0] * scon_n) * log(1100.0 / k1[0]);
  if ((*vpga) < k1[0]) {
    fs_vpga = c10[0] * log((*vpga) / k1[0]) + k2[0] * (log(((*pga) + scon_c * exp(scon_n * log((*vpga) / k1[0]))) / ((*pga) + scon_c)));
  } else
    fs_vpga = (c10[0] + k2[0] * scon_n) * log((*vpga) / k1[0]);
  a_1100 = (*pga) * exp(fs_1100 - fs_vpga);
  ampf_cap = -1.0;
  for (i = 0; i < nper; i++) {
    if ((*vsite) < k1[i]) {
      fsite = c10[i] * log((*vsite) / k1[i]) + k2[i] * (log((a_1100 + scon_c * exp(scon_n * log((*vsite) / k1[i]))) / (a_1100 + scon_c)));
    } else
      fsite = (c10[i] + k2[i] * scon_n) * log((*vsite) / k1[i]);
    if ((*vref) < k1[i]) {
      fs_vref = c10[i] * log((*vref) / k1[i]) + k2[i] * (log((a_1100 + scon_c * exp(scon_n * log((*vref) / k1[i]))) / (a_1100 + scon_c)));
    } else
      fs_vref = (c10[i] + k2[i] * scon_n) * log((*vref) / k1[i]);
    ampf0[i] = exp(fsite - fs_vref);
    if (1.0 / per[i] <= (*flowcap)) {
      if (ampf_cap < 0.0)
        ampf_cap = ampf0[i];
      else
        ampf0[i] = ampf_cap;
    }
  }
  j = nper - 1;
  f0 = 1.0 / per[j];
  a0 = ampf0[j];
  f1 = 1.0 / per[j];
  a1 = ampf0[j];
  dadf = 0.0;
  df = 1.0 / (n * (*dt));
  for (i = 1; i < n / 2; i++) {
    freq = i * df;
    if (freq > f1) {
      f0 = f1;
      a0 = a1;
      if (j > 0)
        j--;
      if (per[j] != 0.0)
        f1 = 1.0 / per[j];
      else
        f1 = 1000.0;
      a1 = ampf0[j];
      if (f1 != f0)
        dadf = (a1 - a0) / (f1 - f0);
      else
        dadf = 0.0;
    }
    ampv = a0 + dadf * (freq - f0);
    if (freq < *fmin)
      afac = 1.0;
    else if (freq < *fmidbot)
      afac = 1.0 + (freq - *fmin) * (ampv - 1.0) / (*fmidbot - *fmin);
    else if (freq < *fmid)
      afac = ampv;
    else if (freq < *fhigh)
      afac = ampv;
    else if (freq < *fhightop)
      afac = ampv;
    else if (freq < *fmax)
      afac = ampv + (freq - *fhightop) * (1.0 - ampv) / (*fmax - *fhightop);
    else
      afac = 1.0;
    ampf[i] = afac;
  }
}
```