// File: /workspace/github_cpp_makefile_star2_O1/JRLamontagne[P]cdice_sa/CDICEInit.cpp
// Function: initTS(DICE*)
void initTS(DICE *dice)
{

  for (int i=0; i<dice->config.nPeriods; i++) {
    
    dice->config.dateSeries[i] = dice->config.startYear + (dice->config.tstep * i);
    dice->econ.l[i] = 0.0;
    dice->econ.al[i] = 0.0;		
    dice->econ.sigma[i] = 0.0;	 
    dice->econ.rr[i] = 0.0;		
    dice->econ.ga[i] = 0.0;		
    dice->carb.forcoth[i] = 0.0;
    dice->econ.gl[i] = 0.0;		
    dice->econ.gcost[i] = 0.0;
    dice->econ.gsig[i] = 0.0;		
    dice->econ.etree[i] = 0.0;
    dice->econ.cumetree[i] = 0.0;
    dice->econ.cost1[i] = 0.0;
    //dice->econ.gfacpop[i] = 0.0;	// Appears in GAMS version, but is never used
    dice->econ.pbacktime[i] = 0.0;
    dice->econ.scc[i] = 0.0;
    dice->econ.cpricebase[i] = 0.0;
    dice->econ.photel[i] = 0.0;

    //dice->dvars.miu[i] = dice->dvars.miu0;
    dice->carb.forc[i] = 0.0;
    dice->carb.mat[i] = 0.0;
    dice->carb.mu[i] = 0.0;
    dice->carb.ml[i] = 0.0;
    dice->carb.atfrac[i] = 0.0;
    dice->carb.atfrac2010[i] = 0.0;
    dice->carb.ppm[i] = 0.0;
    dice->econ.e[i] = 0.0;
    dice->econ.eind[i] = 0.0;
    dice->econ.c[i] = 0.0;
    dice->econ.k[i] = 0.0;
    dice->econ.cpc[i] = 0.0;
    dice->econ.i[i] = 0.0;
    dice->econ.ri[i] = 0.0;
    dice->econ.y[i] = 0.0;
    dice->econ.ygross[i] = 0.0;
    dice->econ.ynet[i] = 0.0;
    dice->econ.damages[i] = 0.0;
    dice->econ.damfrac[i] = 0.0;
    dice->econ.abatecost[i] = 0.0;
    dice->econ.mcabate[i] = 0.0;
    dice->econ.cca[i] = 0.0;
    dice->econ.ccatot[i] = 0.0;
    dice->econ.periodu[i] = 0.0;
    dice->econ.cprice[i] = 0.0;
    dice->econ.cemutotper[i] = 0.0;

    dice->econ.ri_disc[i] = 0.0;
    dice->econ.pv_damages[i] = 0.0;
    dice->econ.pv_abatecost[i] = 0.0;
    dice->econ.totalcost[i] = 0.0;
    dice->econ.pv_totalcost[i] = 0.0;

    // If not using DOEclim, then initialize DICE clim time series
    if(dice->ctrl.use_doeclim == 0) {
      dice->clim.tatm[i] = 0.0;
      dice->clim.tocean[i] = 0.0;
    }
    
  }
	
	// If using DOEclim...
	if(dice->ctrl.use_doeclim == 1) {

		// Initialize the appropriate time series
		for(int i=0; i<dice->config.ns; i++) {
  	  dice->clim.temp[i] = 0.0;
    	dice->clim.temp_landair[i] = 0.0;
	    dice->clim.temp_sst[i] = 0.0;
  	  dice->clim.heat_mixed[i] = 0.0;
    	dice->clim.heat_interior[i] = 0.0;
	    dice->clim.heatflux_mixed[i] = 0.0;
 	   dice->clim.heatflux_interior[i] = 0.0;
  	}

  
  }

  // Calculate values for the exogenous variables -------------------------
  // dice->econ.partfract is used to determine the upper limit of the
  // control policy 'miu'
  calcExog(dice);
  for(int i=0; i<dice->config.nPeriods; i++) {
    if (i < 29) {
      dice->lims.miu_up[i] = 1.0;
    }
    else	{
      dice->lims.miu_up[i] = dice->dvars.limmiu;
    }
  }
  
  return;

}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movslq (%rdi), %rax
testq %rax, %rax
jle 0x3fee
cvtsi2sdl 0x10(%rbx), %xmm0
movq 0x18(%rbx), %rcx
movq 0x288(%rbx), %rdx
xorl %esi, %esi
xorl %edi, %edi
cvtsi2sd %edi, %xmm1
mulsd 0x8(%rbx), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rdi,8)
movq %rsi, (%rdx,%rdi,8)
movq 0x290(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x2f0(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x2c8(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x2d0(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x468(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x2d8(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x2e0(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x2e8(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x2f8(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x300(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x298(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x2a8(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x2b0(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x2b8(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x2c0(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x470(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x478(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x480(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x488(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x490(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x498(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x4a0(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x3b8(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x3c0(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x308(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x310(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x318(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x320(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x328(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x330(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x338(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x340(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x348(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x350(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x358(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x360(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x3c8(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x3d0(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x368(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x370(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x378(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x388(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x390(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x398(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x3a0(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x3a8(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
cmpl $0x0, 0x58(%rbx)
jne 0x3fe2
movq 0x128(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
movq 0x130(%rbx), %r8
movq %rsi, (%r8,%rdi,8)
incq %rdi
cmpq %rdi, %rax
jne 0x3db6
cmpl $0x1, 0x58(%rbx)
jne 0x4058
movslq 0x28(%rbx), %rax
testq %rax, %rax
jle 0x4058
movq 0x140(%rbx), %rcx
movq 0x148(%rbx), %rdx
movq 0x150(%rbx), %rsi
movq 0x158(%rbx), %rdi
movq 0x160(%rbx), %r8
movq 0x168(%rbx), %r9
movq 0x170(%rbx), %r10
xorl %r11d, %r11d
xorl %r14d, %r14d
movq %r11, (%rcx,%r14,8)
movq %r11, (%rdx,%r14,8)
movq %r11, (%rsi,%r14,8)
movq %r11, (%rdi,%r14,8)
movq %r11, (%r8,%r14,8)
movq %r11, (%r9,%r14,8)
movq %r11, (%r10,%r14,8)
incq %r14
cmpq %r14, %rax
jne 0x4034
movq %rbx, %rdi
callq 0x4ad0
movslq (%rbx), %rax
testq %rax, %rax
jle 0x4095
movq 0x528(%rbx), %rcx
xorl %edx, %edx
movsd 0x3f8f(%rip), %xmm0     # 0x8008
movapd %xmm0, %xmm1
cmpq $0x1d, %rdx
jb 0x4088
movsd 0x38(%rbx), %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x4079
addq $0x8, %rsp
popq %rbx
popq %r14
retq