// File: /workspace/github_cpp_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
movslq (%rdi), %rdi
testq %rdi, %rdi
jle 0x4132
cvtsi2sdl 0x10(%rbx), %xmm0
movq 0x18(%rbx), %rax
movq 0x288(%rbx), %r8
movq 0x2c0(%rbx), %r9
movq 0x470(%rbx), %r10
movq 0x478(%rbx), %r11
movq 0x480(%rbx), %r14
movq 0x488(%rbx), %r15
movq 0x490(%rbx), %r12
movq 0x498(%rbx), %r13
movq 0x4a0(%rbx), %rbp
movq 0x3b8(%rbx), %rcx
movq %rcx, 0x90(%rsp)
movq 0x3c0(%rbx), %rcx
movq %rcx, 0x88(%rsp)
movq 0x308(%rbx), %rcx
movq %rcx, 0x80(%rsp)
movq 0x310(%rbx), %rcx
movq %rcx, 0x78(%rsp)
movq 0x318(%rbx), %rcx
movq %rcx, 0x70(%rsp)
movq 0x320(%rbx), %rcx
movq %rcx, 0x68(%rsp)
movq 0x328(%rbx), %rcx
movq %rcx, 0x60(%rsp)
movq 0x330(%rbx), %rcx
movq %rcx, 0x58(%rsp)
movq 0x338(%rbx), %rcx
movq %rcx, 0x50(%rsp)
movq 0x340(%rbx), %rcx
movq %rcx, 0x48(%rsp)
movq 0x348(%rbx), %rcx
movq %rcx, 0x40(%rsp)
movq 0x350(%rbx), %rcx
movq %rcx, 0x38(%rsp)
movq 0x358(%rbx), %rcx
movq %rcx, 0x30(%rsp)
movq 0x360(%rbx), %rcx
movq %rcx, 0x28(%rsp)
movq 0x3c8(%rbx), %rcx
movq %rcx, 0x18(%rsp)
movq 0x3d0(%rbx), %rcx
movq %rcx, 0x20(%rsp)
movq 0x368(%rbx), %rcx
movq %rcx, 0x10(%rsp)
xorl %ecx, %ecx
xorl %edx, %edx
movq %rbp, 0x8(%rsp)
cvtsi2sd %edx, %xmm1
mulsd 0x8(%rbx), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rdx,8)
movq %rcx, (%r8,%rdx,8)
movq 0x290(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x2f0(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x2c8(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x2d0(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x468(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x2d8(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x2e0(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x2e8(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x2f8(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x300(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x298(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x2a8(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x2b0(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x2b8(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq %rcx, (%r9,%rdx,8)
movq %rcx, (%r10,%rdx,8)
movq %rcx, (%r11,%rdx,8)
movq %rcx, (%r14,%rdx,8)
movq %rcx, (%r15,%rdx,8)
movq %rcx, (%r12,%rdx,8)
movq %rcx, (%r13,%rdx,8)
movq %rcx, (%rbp,%rdx,8)
movq 0x90(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x88(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x80(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x78(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x70(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x68(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x60(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x58(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x50(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x48(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x40(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x38(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x30(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x28(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x18(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x20(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x10(%rsp), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x370(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x378(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x388(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x390(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x398(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x3a0(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movq 0x3a8(%rbx), %rsi
movq %rcx, (%rsi,%rdx,8)
movl 0x58(%rbx), %esi
testl %esi, %esi
jne 0x4124
movq %r13, %rbp
movq %r12, %r13
movq %r15, %r12
movq %r14, %r15
movq %r11, %r14
movq %r10, %r11
movq %r9, %r10
movq %r8, %r9
movq %rax, %r8
movq %rdi, %rax
movq 0x128(%rbx), %rdi
movq %rcx, (%rdi,%rdx,8)
movq 0x130(%rbx), %rdi
movq %rcx, (%rdi,%rdx,8)
movq %rax, %rdi
movq %r8, %rax
movq %r9, %r8
movq %r10, %r9
movq %r11, %r10
movq %r14, %r11
movq %r15, %r14
movq %r12, %r15
movq %r13, %r12
movq %rbp, %r13
movq 0x8(%rsp), %rbp
incq %rdx
cmpq %rdx, %rdi
jne 0x3f05
jmp 0x4135
movl 0x58(%rbx), %esi
cmpl $0x1, %esi
jne 0x419e
movslq 0x28(%rbx), %rax
testq %rax, %rax
jle 0x419e
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 0x417a
movq %rbx, %rdi
callq 0x4ae8
movslq (%rbx), %rax
testq %rax, %rax
jle 0x41db
movq 0x528(%rbx), %rcx
xorl %edx, %edx
movsd 0x3e49(%rip), %xmm0     # 0x8008
movapd %xmm0, %xmm1
cmpq $0x1d, %rdx
jb 0x41ce
movsd 0x38(%rbx), %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x41bf
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq