// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
movq %rdi, %rbx
movl (%rdi), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x3d58
cvtsi2sdl 0x10(%rbx), %xmm0
cvtsi2sd %ecx, %xmm1
mulsd 0x8(%rbx), %xmm1
addsd %xmm0, %xmm1
movq 0x18(%rbx), %rdx
movsd %xmm1, (%rdx,%rcx,8)
movq 0x288(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x290(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x2f0(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x2c8(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x2d0(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x468(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x2d8(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x2e0(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x2e8(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x2f8(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x300(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x298(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x2a8(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x2b0(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x2b8(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x2c0(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x470(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x478(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x480(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x488(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x490(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x498(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x4a0(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x3b8(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x3c0(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x308(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x310(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x318(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x320(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x328(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x330(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x338(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x340(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x348(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x350(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x358(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x360(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x3c8(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x3d0(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x368(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x370(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x378(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x388(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x390(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x398(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x3a0(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x3a8(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
cmpl $0x0, 0x58(%rbx)
jne 0x3d50
movq 0x128(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x130(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
incq %rcx
jmp 0x3ada
cmpl $0x1, 0x58(%rbx)
jne 0x3dc6
movl 0x28(%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x3dc6
movq 0x140(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x148(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x150(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x158(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x160(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x168(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
movq 0x170(%rbx), %rdx
andq $0x0, (%rdx,%rcx,8)
incq %rcx
jmp 0x3d68
movq %rbx, %rdi
callq 0x4650
movl (%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movsd 0x4229(%rip), %xmm0     # 0x8008
cmpq %rcx, %rax
je 0x3e04
movapd %xmm0, %xmm1
cmpq $0x1d, %rcx
jb 0x3df3
movsd 0x38(%rbx), %xmm1
movq 0x528(%rbx), %rdx
movsd %xmm1, (%rdx,%rcx,8)
incq %rcx
jmp 0x3ddf
popq %rbx
retq