// File: /workspace/github_c_makefile_star2_O0/felipelouza[P]egap/./blocks.h
// Function: merge_sls
static void merge_sls(solidBlock *s, liquidBlock *b, solidBlock *z, solidBlockFile *sf) {
  // showBlock(s,NULL,0); showBlock(z,NULL,0); showLiquid(b);
  assert(s && z && b && !b->empty);
  assert(s->endsAt==b->beginsAt && b->endsAt==z->beginsAt);
  customInt ssize = s->endsAt - s->beginsAt;
  customInt zsize = z->endsAt - z->beginsAt;
  bool zreduced = false;
  // --- merge occs 
  if(ssize + zsize + (b->endsAt - b->beginsAt) <= SMALLSOLID_LIMIT){
    for (int c = 0; c < b->occ_size; ++c) // all blocks are small 
      s->smallOcc[c] += z->smallOcc[c] + (smallSolidInt) b->occ[c];
  } 
  else if(ssize>SMALLSOLID_LIMIT && zsize>SMALLSOLID_LIMIT) {
      for (int c = 0; c < b->occ_size; ++c) // all blocks are large  
        s->occ[c] += z->occ[c] + b->occ[c];
  }
  else { // mixed small/large blocks
    if(zsize>SMALLSOLID_LIMIT) {// s must be  small, swap with z
      customInt *tmp = z->occ; z->smallOcc = s->smallOcc; s->occ = tmp; zreduced=true;
    }
    else {  // z is small, s can be small or large 
      if(ssize<=SMALLSOLID_LIMIT)  // if s is small enlarge it
        block_inflate(s,sf);
    }
    // now s is large and z is small
    for (int c = 0; c < b->occ_size; ++c) 
        s->occ[c] += z->smallOcc[c] + b->occ[c];
  }
  // ----  update endpoints and nextBlock
  s->endsAt = z->endsAt;
  s->nextBlock = z->nextBlock;
  // --- clear b and free z
  b->empty = true;
  memset(b->occ, 0, (b->occ_size) * sizeof(customInt));
  if(zreduced) z->endsAt = z->beginsAt; // a large z got a smallocc from s, make it appear small 
  block_free(z,sf);
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq %rdx, 0x40(%rsp)
movq %rcx, 0x38(%rsp)
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x50(%rsp), %rcx
subq (%rcx), %rax
movq %rax, 0x30(%rsp)
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x40(%rsp), %rcx
subq (%rcx), %rax
movq %rax, 0x28(%rsp)
movb $0x0, 0x27(%rsp)
movq 0x30(%rsp), %rax
addq 0x28(%rsp), %rax
movq 0x48(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq 0x48(%rsp), %rdx
subq (%rdx), %rcx
addq %rcx, %rax
cmpq $0xffff, %rax           # imm = 0xFFFF
ja 0x10f08
movl $0x0, 0x20(%rsp)
movl 0x20(%rsp), %eax
movq 0x48(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x10f03
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x20(%rsp), %rcx
movzwl (%rax,%rcx,2), %esi
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0x20(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movzwl %ax, %eax
addl %eax, %esi
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x20(%rsp), %rcx
movzwl (%rax,%rcx,2), %edx
addl %esi, %edx
movw %dx, (%rax,%rcx,2)
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x10ea7
jmp 0x1103f
cmpq $0xffff, 0x30(%rsp)     # imm = 0xFFFF
jbe 0x10f80
cmpq $0xffff, 0x28(%rsp)     # imm = 0xFFFF
jbe 0x10f80
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movq 0x48(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x10f7b
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x1c(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0x1c(%rsp), %rcx
addq (%rax,%rcx,8), %rdx
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x1c(%rsp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0x10f26
jmp 0x1103d
cmpq $0xffff, 0x28(%rsp)     # imm = 0xFFFF
jbe 0x10fc0
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rcx
movq 0x50(%rsp), %rax
movq %rcx, 0x10(%rax)
movb $0x1, 0x27(%rsp)
jmp 0x10fdc
cmpq $0xffff, 0x30(%rsp)     # imm = 0xFFFF
ja 0x10fda
movq 0x50(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x10580
jmp 0x10fdc
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
movq 0x48(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x1103b
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0xc(%rsp), %rcx
movzwl (%rax,%rcx,2), %eax
movl %eax, %edx
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rax
movslq 0xc(%rsp), %rcx
addq (%rax,%rcx,8), %rdx
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0xc(%rsp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x10fe4
jmp 0x1103d
jmp 0x1103f
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x50(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x50(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x48(%rsp), %rax
movb $0x1, 0x2c(%rax)
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x48(%rsp), %rax
movslq 0x18(%rax), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x2140
testb $0x1, 0x27(%rsp)
je 0x110a1
movq 0x40(%rsp), %rax
movq (%rax), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x8990
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)