// File: JRLamontagne[P]cdice_sa/CDICE.cpp
// Function: calcClim(DICE*, int)
void calcClim(DICE *dice, int t)
{

  Config *config = &dice->config;
  Econ *econ = &dice->econ;
  Carb *carb = &dice->carb;
  Clim *clim = &dice->clim;
  Dvars *dvars = &dice->dvars;
  Ctrl *ctrl = &dice->ctrl;
  Lims *lims = &dice->lims;

  clim->tatm[t] = clim->tatm[t-1]+clim->c1*((carb->forc[t]-((carb->fco22x/clim->t2xco2)*clim->tatm[t-1]))-(clim->c3*(clim->tatm[t-1]-clim->tocean[t-1])));
  if(clim->tatm[t] < lims->tatm_lo) {
    clim->tatm[t] = lims->tatm_lo;
  }
  if(clim->tatm[t] > lims->tatm_up) {
    clim->tatm[t] = lims->tatm_up;
  }

  clim->tocean[t] = clim->tocean[t-1]+clim->c4*(clim->tatm[t-1]-clim->tocean[t-1]);
  if(clim->tocean[t] < lims->tocean_lo) {
    clim->tocean[t] = lims->tocean_lo;
  }
  if(clim->tocean[t] > lims->tocean_up) {
    clim->tocean[t] = lims->tocean_up;
  }

  return;
}

// Assembly:
movq %rdi, -0x8(%rsp)
movl %esi, -0xc(%rsp)
movq -0x8(%rsp), %rax
movq %rax, -0x18(%rsp)
movq -0x8(%rsp), %rax
addq $0x190, %rax            # imm = 0x190
movq %rax, -0x20(%rsp)
movq -0x8(%rsp), %rax
addq $0x3e0, %rax            # imm = 0x3E0
movq %rax, -0x28(%rsp)
movq -0x8(%rsp), %rax
addq $0x60, %rax
movq %rax, -0x30(%rsp)
movq -0x8(%rsp), %rax
addq $0x38, %rax
movq %rax, -0x38(%rsp)
movq -0x8(%rsp), %rax
addq $0x58, %rax
movq %rax, -0x40(%rsp)
movq -0x8(%rsp), %rax
addq $0x4a8, %rax            # imm = 0x4A8
movq %rax, -0x48(%rsp)
movq -0x30(%rsp), %rax
movq 0xc8(%rax), %rax
movl -0xc(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x30(%rsp), %rax
movsd 0x18(%rax), %xmm0
movq -0x28(%rsp), %rax
movq 0x90(%rax), %rax
movslq -0xc(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x28(%rsp), %rax
movsd 0x68(%rax), %xmm3
movq -0x30(%rsp), %rax
divsd (%rax), %xmm3
movq -0x30(%rsp), %rax
movq 0xc8(%rax), %rax
movl -0xc(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm4
movq %xmm3, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm3
mulsd %xmm4, %xmm3
addsd %xmm2, %xmm3
movq -0x30(%rsp), %rax
movsd 0x20(%rax), %xmm2
movq -0x30(%rsp), %rax
movq 0xc8(%rax), %rax
movl -0xc(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm4
movq -0x30(%rsp), %rax
movq 0xd0(%rax), %rax
movl -0xc(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
subsd (%rax,%rcx,8), %xmm4
movq %xmm2, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm2
mulsd %xmm4, %xmm2
addsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x30(%rsp), %rax
movq 0xc8(%rax), %rax
movslq -0xc(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x30(%rsp), %rax
movq 0xc8(%rax), %rax
movslq -0xc(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x48(%rsp), %rax
movsd 0x40(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x16cd8
movq -0x48(%rsp), %rax
movsd 0x40(%rax), %xmm0
movq -0x30(%rsp), %rax
movq 0xc8(%rax), %rax
movslq -0xc(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x30(%rsp), %rax
movq 0xc8(%rax), %rax
movslq -0xc(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rsp), %rax
ucomisd 0x48(%rax), %xmm0
jbe 0x16d1a
movq -0x48(%rsp), %rax
movsd 0x48(%rax), %xmm0
movq -0x30(%rsp), %rax
movq 0xc8(%rax), %rax
movslq -0xc(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x30(%rsp), %rax
movq 0xd0(%rax), %rax
movl -0xc(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x30(%rsp), %rax
movsd 0x28(%rax), %xmm0
movq -0x30(%rsp), %rax
movq 0xc8(%rax), %rax
movl -0xc(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x30(%rsp), %rax
movq 0xd0(%rax), %rax
movl -0xc(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
subsd (%rax,%rcx,8), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x30(%rsp), %rax
movq 0xd0(%rax), %rax
movslq -0xc(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x30(%rsp), %rax
movq 0xd0(%rax), %rax
movslq -0xc(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x48(%rsp), %rax
movsd 0x38(%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x16dd9
movq -0x48(%rsp), %rax
movsd 0x38(%rax), %xmm0
movq -0x30(%rsp), %rax
movq 0xd0(%rax), %rax
movslq -0xc(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x30(%rsp), %rax
movq 0xd0(%rax), %rax
movslq -0xc(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rsp), %rax
ucomisd 0x30(%rax), %xmm0
jbe 0x16e1b
movq -0x48(%rsp), %rax
movsd 0x30(%rax), %xmm0
movq -0x30(%rsp), %rax
movq 0xd0(%rax), %rax
movslq -0xc(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
retq
nopl (%rax)