// File: /workspace/github_cpp_makefile_star2_O1/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:
cvtsi2sdl 0x20(%rdi), %xmm1
leal -0x1(%rsi), %eax
movd %esi, %xmm0
movd %eax, %xmm2
punpckldq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
cvtdq2pd %xmm2, %xmm2
movsd 0x8(%rdi), %xmm0
movapd %xmm0, %xmm3
unpcklpd %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0]
mulpd %xmm2, %xmm3
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
addpd %xmm3, %xmm1
cvttpd2dq %xmm1, %xmm1
movd %xmm1, %eax
pshufd $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
movd %xmm1, %ecx
cmpl %ecx, %eax
jge 0x7840
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
movq %rcx, %rdi
movslq %esi, %rcx
movq 0x470(%rbx), %rdx
movsd (%rdx,%rcx,8), %xmm1
subsd -0x8(%rdx,%rcx,8), %xmm1
decq %rcx
movq %rcx, 0x68(%rsp)
divsd %xmm0, %xmm1
movsd %xmm1, 0x70(%rsp)
movslq %eax, %rcx
movl %eax, %eax
shlq $0x3, %rcx
movq %rcx, 0x60(%rsp)
negl %edi
movq %rax, 0x58(%rsp)
addq %rax, %rdi
movq %rdi, 0x78(%rsp)
xorl %edi, %edi
leaq 0x1(%rdi), %rbp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movq 0x470(%rbx), %rax
mulsd 0x70(%rsp), %xmm0
movq 0x68(%rsp), %rcx
addsd (%rax,%rcx,8), %xmm0
movq 0xb0(%rbx), %r8
movq 0x60(%rsp), %rax
addq %r8, %rax
movsd %xmm0, (%rax,%rdi,8)
movl 0x24(%rbx), %esi
movl 0x28(%rbx), %edx
movsd 0xb8(%rbx), %xmm0
movsd 0xc0(%rbx), %xmm1
movsd 0xc8(%rbx), %xmm2
movsd 0xd0(%rbx), %xmm3
movsd 0xd8(%rbx), %xmm4
movsd 0xe0(%rbx), %xmm5
movsd 0xe8(%rbx), %xmm6
movsd 0xf0(%rbx), %xmm7
movsd 0xf8(%rbx), %xmm8
movq 0x100(%rbx), %rax
movq %rax, 0x80(%rsp)
movq 0x108(%rbx), %r9
movsd 0x110(%rbx), %xmm9
movsd 0x118(%rbx), %xmm10
movq 0x120(%rbx), %rcx
movq 0x140(%rbx), %r10
movq 0x148(%rbx), %r11
movq 0x150(%rbx), %r15
movq 0x158(%rbx), %r13
movq 0x160(%rbx), %r12
movq 0x168(%rbx), %r14
movq 0x170(%rbx), %rax
addl 0x58(%rsp), %edi
movq %rax, 0x50(%rsp)
movq %r14, 0x48(%rsp)
movq %r12, 0x40(%rsp)
movq %r13, 0x38(%rsp)
movq %r15, 0x30(%rsp)
movq %r11, 0x28(%rsp)
movq %r10, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
movsd %xmm10, 0x10(%rsp)
movsd %xmm9, 0x8(%rsp)
movsd %xmm8, (%rsp)
movq %r8, %rcx
movq 0x80(%rsp), %r8
callq 0x5e59
movq 0x78(%rsp), %rax
movq %rbp, %rdi
addl %ebp, %eax
jne 0x76ea
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq