// File: /workspace/github_cpp_makefile_star2_O3/jenniferdr[P]proyectoIAI/basepatrones.cc
// Function: generarBD()
void generarBD() {
  // Llena la base de datos inicialmente con 'infinito'
  for (int i = 0; i < (16*16*16*16*16*16); i++) {
    bd1[i] = 255;
    bd2[i] = 255;
    bd3[i] = 255;
  }

  // Si un archivo con nombre 'patrones.bd' ya existe, se carga de allí en vez
  // de generarla. Sino, se genera y se escribe en disco.
  std::ifstream entrada("patrones.bd", std::ios::in | std::ios::binary);
  if (!entrada) {
    std::cout << "No existe la base de datos de patrones, se generará" << std::endl;
    llenarBDPat(set1, estado_inicial1, bd1);
    llenarBDPat(set2, estado_inicial2, bd2);
    llenarBDPat(set3, estado_inicial3, bd3);

    std::ofstream salida;
    salida.open("patrones.bd", std::ios::out | std::ios::binary);
    salida.write((char*) bd1, 16*16*16*16*16*16*sizeof(unsigned char));
    salida.write((char*) bd2, 16*16*16*16*16*16*sizeof(unsigned char));
    salida.write((char*) bd3, 16*16*16*16*16*16*sizeof(unsigned char));
    salida.close();

  } else {
    entrada.read((char*) bd1, 16*16*16*16*16*16*sizeof(unsigned char));
    entrada.read((char*) bd2, 16*16*16*16*16*16*sizeof(unsigned char));
    entrada.read((char*) bd3, 16*16*16*16*16*16*sizeof(unsigned char));
    entrada.close();
  }
}

// Assembly:
pushq %rbx
subq $0x410, %rsp            # imm = 0x410
leaq 0x58ae(%rip), %rdi      # 0x9330
movl $0x1000000, %edx        # imm = 0x1000000
movl $0xff, %esi
callq 0x2100
leaq 0x1005898(%rip), %rdi   # 0x1009330
movl $0x1000000, %edx        # imm = 0x1000000
movl $0xff, %esi
callq 0x2100
leaq 0x2005882(%rip), %rdi   # 0x2009330
movl $0x1000000, %edx        # imm = 0x1000000
movl $0xff, %esi
callq 0x2100
leaq 0x25b3(%rip), %rsi      # 0x6077
leaq 0x208(%rsp), %rbx
movq %rbx, %rdi
movl $0xc, %edx
callq 0x22d0
movq (%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x228(%rsp,%rax)
je 0x3c22
movq 0x54e3(%rip), %rbx      # 0x8fd8
leaq 0x2587(%rip), %rsi      # 0x6083
movl $0x34, %edx
movq %rbx, %rdi
callq 0x21a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %esi
movq 0x54b1(%rip), %rdi      # 0x8fd8
callq 0x2030
movq %rax, %rdi
callq 0x2110
leaq 0x5775(%rip), %rdi      # 0x92b0
leaq 0x579e(%rip), %rsi      # 0x92e0
leaq 0x57e7(%rip), %rdx      # 0x9330
callq 0x37f3
leaq 0x576b(%rip), %rdi      # 0x92c0
leaq 0x5794(%rip), %rsi      # 0x92f0
leaq 0x10057cd(%rip), %rdx   # 0x1009330
callq 0x37f3
leaq 0x5761(%rip), %rdi      # 0x92d0
leaq 0x578a(%rip), %rsi      # 0x9300
leaq 0x20057b3(%rip), %rdx   # 0x2009330
callq 0x37f3
leaq 0x8(%rsp), %rdi
callq 0x2280
leaq 0x24e4(%rip), %rsi      # 0x6077
leaq 0x8(%rsp), %rdi
movl $0x14, %edx
callq 0x2040
leaq 0x5787(%rip), %rsi      # 0x9330
leaq 0x8(%rsp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
callq 0x21c0
leaq 0x1005771(%rip), %rsi   # 0x1009330
leaq 0x8(%rsp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
callq 0x21c0
leaq 0x200575b(%rip), %rsi   # 0x2009330
leaq 0x8(%rsp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
callq 0x21c0
leaq 0x8(%rsp), %rdi
callq 0x21e0
movq 0x53d3(%rip), %rax      # 0x8fc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x10(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x8(%rsp,%rcx)
callq 0x2150
leaq 0x100(%rsp), %rdi
callq 0x20a0
jmp 0x3c7a
leaq 0x5707(%rip), %rsi      # 0x9330
leaq 0x208(%rsp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
callq 0x21b0
leaq 0x10056ee(%rip), %rsi   # 0x1009330
leaq 0x208(%rsp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
callq 0x21b0
leaq 0x20056d5(%rip), %rsi   # 0x2009330
leaq 0x208(%rsp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
callq 0x21b0
leaq 0x208(%rsp), %rdi
callq 0x2060
leaq 0x208(%rsp), %rdi
callq 0x2070
addq $0x410, %rsp            # imm = 0x410
popq %rbx
retq
jmp 0x3ca1
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2210
jmp 0x3ca4
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x22b0