// File: JRLamontagne[P]cdice_sa/CDICE_doeclim.cpp
// Function: doeclim_dice_ts(DICE*, int)
void doeclim_dice_ts(DICE *dice, int ts)
{

  Clim *clim = &dice->clim;
  Carb *carb = &dice->carb;
  Config *config = &dice->config;

  // Get the range of doeclim time steps associated with this
  // DICE time step.
  int start = config->hind_ns + ((ts-1) * config->tstep);
  int finish = config->hind_ns + (ts * config->tstep);

  // Get a linear interpolation of the forcing for this time step
  double dforc = (carb->forc[ts] - carb->forc[ts-1]) / double(config->tstep);

  for(int i=start; i<finish; i++) {
    
    // Calculate the forcing needed for this doeclim time step
    clim->forc[i] = carb->forc[ts-1] + (double(i-start+1) * dforc);
    
    // Run doeclim for this doeclim time step using the interpolated forcing.
    doeclim_ts(i, config->dt, config->ns, clim->forc, 
	       clim->flnd, clim->powtoheat, clim->cal, clim->cas,
	       clim->taucfl, clim->taukls, clim->taucfs, clim->tauksl,
	       clim->bsi, clim->IB, clim->A, clim->fso,
	       clim->taudif, clim->Ker, clim->temp, clim->temp_landair, clim->temp_sst, 
	       clim->heat_mixed, clim->heat_interior, 
	       clim->heatflux_mixed, clim->heatflux_interior);
  }

}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa0, %rsp
movq %rdi, 0x98(%rsp)
movl %esi, 0x94(%rsp)
movq 0x98(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x88(%rsp)
movq 0x98(%rsp), %rax
addq $0x3e0, %rax            # imm = 0x3E0
movq %rax, 0x80(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rax
cvtsi2sdl 0x20(%rax), %xmm1
movl 0x94(%rsp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm0
movq 0x78(%rsp), %rax
movsd 0x8(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x74(%rsp)
movq 0x78(%rsp), %rax
cvtsi2sdl 0x20(%rax), %xmm1
cvtsi2sdl 0x94(%rsp), %xmm0
movq 0x78(%rsp), %rax
movsd 0x8(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x70(%rsp)
movq 0x80(%rsp), %rax
movq 0x90(%rax), %rax
movslq 0x94(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x80(%rsp), %rax
movq 0x90(%rax), %rax
movl 0x94(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
subsd (%rax,%rcx,8), %xmm0
movq 0x78(%rsp), %rax
divsd 0x8(%rax), %xmm0
movsd %xmm0, 0x68(%rsp)
movl 0x74(%rsp), %eax
movl %eax, 0x64(%rsp)
movl 0x64(%rsp), %eax
cmpl 0x70(%rsp), %eax
jge 0x1af37
movq 0x80(%rsp), %rax
movq 0x90(%rax), %rax
movl 0x94(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movl 0x64(%rsp), %eax
subl 0x74(%rsp), %eax
addl $0x1, %eax
cvtsi2sd %eax, %xmm0
movsd 0x68(%rsp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x88(%rsp), %rax
movq 0x50(%rax), %rax
movslq 0x64(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x64(%rsp), %edi
movq 0x78(%rsp), %rax
movl 0x24(%rax), %esi
movq 0x78(%rsp), %rax
movl 0x28(%rax), %edx
movq 0x88(%rsp), %rax
movq 0x50(%rax), %rcx
movq 0x88(%rsp), %rax
movsd 0x58(%rax), %xmm0
movq 0x88(%rsp), %rax
movsd 0x60(%rax), %xmm1
movq 0x88(%rsp), %rax
movsd 0x68(%rax), %xmm2
movq 0x88(%rsp), %rax
movsd 0x70(%rax), %xmm3
movq 0x88(%rsp), %rax
movsd 0x78(%rax), %xmm4
movq 0x88(%rsp), %rax
movsd 0x80(%rax), %xmm5
movq 0x88(%rsp), %rax
movsd 0x88(%rax), %xmm6
movq 0x88(%rsp), %rax
movsd 0x90(%rax), %xmm7
movq 0x88(%rsp), %rax
movsd 0x98(%rax), %xmm10
movq 0x88(%rsp), %rax
movq 0xa0(%rax), %r8
movq 0x88(%rsp), %rax
movq 0xa8(%rax), %r9
movq 0x88(%rsp), %rax
movsd 0xb0(%rax), %xmm9
movq 0x88(%rsp), %rax
movsd 0xb8(%rax), %xmm8
movq 0x88(%rsp), %rax
movq 0xc0(%rax), %r13
movq 0x88(%rsp), %rax
movq 0xe0(%rax), %r12
movq 0x88(%rsp), %rax
movq 0xe8(%rax), %r15
movq 0x88(%rsp), %rax
movq 0xf0(%rax), %r14
movq 0x88(%rsp), %rax
movq 0xf8(%rax), %rbx
movq 0x88(%rsp), %rax
movq 0x100(%rax), %r11
movq 0x88(%rsp), %rax
movq 0x108(%rax), %r10
movq 0x88(%rsp), %rax
movq 0x110(%rax), %rax
movsd %xmm10, (%rsp)
movsd %xmm9, 0x8(%rsp)
movsd %xmm8, 0x10(%rsp)
movq %r13, 0x18(%rsp)
movq %r12, 0x20(%rsp)
movq %r15, 0x28(%rsp)
movq %r14, 0x30(%rsp)
movq %rbx, 0x38(%rsp)
movq %r11, 0x40(%rsp)
movq %r10, 0x48(%rsp)
movq %rax, 0x50(%rsp)
callq 0x18230
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x1ad2a
addq $0xa0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nopl (%rax,%rax)