// File: giovifazi[P]knossos-bloodbath/Map.cpp
// Function: Map::addColumn(bool)
void Map::addColumn(bool onTop)
{
  // aumento la larghezza della mappa
  width++;

  // creo un iteratore per la listaY
  listaY *itery = origin;

  if (onTop)
  {
    // Aggiorna il valore mostLeft
    mostLeft--;

    // Fa un head insert per ogni nodo listaY
    while (itery != NULL)
    {
      listaX *old_head = itery->h;    // salvo la vecchia testa
      itery->h = new listaX;          // creo un nuovo nodo
      itery->h->val = 0;              // gli metto valore 0
	   itery->h->pres = 0;             // imposto 0 giocatori nel nodo
      itery->h->next = old_head;      // lo collego al resto della lista

      itery = itery->down;            // itero in avanti
    }
  }
  else  // If (onTop == false)
  {
    listaX *iterx;

    while (itery != NULL)
    {
      iterx = itery->h;

      // faccio scorrere iterx alla fine della listaX
      if (iterx->next != NULL)
        while (iterx->next != NULL)
          iterx = iterx->next;

      iterx->next = new listaX;
      iterx->next->val = 0;
      iterx->next->pres = 0;
      iterx->next->next = NULL;

      itery = itery->down;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movq (%rax), %rax
movq %rax, -0x18(%rbp)
testb $0x1, -0x9(%rbp)
je 0x4bcf
movq -0x40(%rbp), %rax
movl 0x10(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x10(%rax)
cmpq $0x0, -0x18(%rbp)
je 0x4bca
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x18, %edi
callq 0x21b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x48(%rbp)
callq 0x5140
jmp 0x4b65
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl $0x0, 0x8(%rax)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl $0x0, 0xc(%rax)
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x4b33
movq -0x48(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x18, %esi
callq 0x21c0
jmp 0x4c91
jmp 0x4c8b
jmp 0x4bd1
cmpq $0x0, -0x18(%rbp)
je 0x4c89
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
je 0x4c0d
jmp 0x4bf4
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
je 0x4c0b
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x4bf4
jmp 0x4c0d
movl $0x18, %edi
callq 0x21b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x50(%rbp)
callq 0x5140
jmp 0x4c28
movq -0x50(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl $0x0, 0x8(%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl $0x0, 0xc(%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq $0x0, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x4bd1
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x18, %esi
callq 0x21c0
jmp 0x4c91
jmp 0x4c8b
addq $0x50, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x2320
nopw (%rax,%rax)