// File: /workspace/github_cpp_makefile_star2_O1/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 0x583e(%rip), %rdi      # 0x9330
movl $0x1000000, %edx        # imm = 0x1000000
movl $0xff, %esi
callq 0x2100
leaq 0x1005828(%rip), %rdi   # 0x1009330
movl $0x1000000, %edx        # imm = 0x1000000
movl $0xff, %esi
callq 0x2100
leaq 0x2005812(%rip), %rdi   # 0x2009330
movl $0x1000000, %edx        # imm = 0x1000000
movl $0xff, %esi
callq 0x2100
leaq 0x2543(%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 0x3c92
movq 0x5473(%rip), %rbx      # 0x8fd8
leaq 0x2517(%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 0x5441(%rip), %rdi      # 0x8fd8
callq 0x2030
movq %rax, %rdi
callq 0x2110
leaq 0x5705(%rip), %rdi      # 0x92b0
leaq 0x572e(%rip), %rsi      # 0x92e0
leaq 0x5777(%rip), %rdx      # 0x9330
callq 0x387b
leaq 0x56fb(%rip), %rdi      # 0x92c0
leaq 0x5724(%rip), %rsi      # 0x92f0
leaq 0x100575d(%rip), %rdx   # 0x1009330
callq 0x387b
leaq 0x56f1(%rip), %rdi      # 0x92d0
leaq 0x571a(%rip), %rsi      # 0x9300
leaq 0x2005743(%rip), %rdx   # 0x2009330
callq 0x387b
leaq 0x8(%rsp), %rdi
callq 0x2280
leaq 0x2474(%rip), %rsi      # 0x6077
leaq 0x8(%rsp), %rdi
movl $0x14, %edx
callq 0x2040
leaq 0x5717(%rip), %rsi      # 0x9330
leaq 0x8(%rsp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
callq 0x21c0
leaq 0x1005701(%rip), %rsi   # 0x1009330
leaq 0x8(%rsp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
callq 0x21c0
leaq 0x20056eb(%rip), %rsi   # 0x2009330
leaq 0x8(%rsp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
callq 0x21c0
leaq 0x8(%rsp), %rdi
callq 0x21e0
movq 0x5363(%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 0x3cea
leaq 0x5697(%rip), %rsi      # 0x9330
leaq 0x208(%rsp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
callq 0x21b0
leaq 0x100567e(%rip), %rsi   # 0x1009330
leaq 0x208(%rsp), %rdi
movl $0x1000000, %edx        # imm = 0x1000000
callq 0x21b0
leaq 0x2005665(%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 0x3d11
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2210
jmp 0x3d14
movq %rax, %rbx
leaq 0x208(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x22b0