// File: harry830622[P]floorplanner/src/database.cpp
// Function: Database::ParseBlocks(std::istream&)
void Database::ParseBlocks(istream& block_input) {
  simple_parser::Parser block_parser(block_input, ":");
  int num_macros = 0;
  int num_terminals = 0;
  int nth_macro = 0;
  int nth_terminal = 0;
  block_parser.Parse([&](const simple_parser::Tokens& tokens) -> bool {
    if (!tokens.empty()) {
      string first_word = tokens[0];
      if (first_word == "Outline") {
        outline_width_ = stod(tokens[1]);
        outline_height_ = stod(tokens[2]);
      } else if (first_word == "NumBlocks") {
        num_macros = stoi(tokens[1]);
      } else if (first_word == "NumTerminals") {
        num_terminals = stoi(tokens[1]);
      } else {
        if (nth_macro < num_macros) {
          ++nth_macro;
          const string macro_name = tokens[0];
          double macro_width = stod(tokens[1]);
          double macro_height = stod(tokens[2]);
          bool is_macro_rotatable = true;
          if (macro_width > outline_width_ || macro_height > outline_height_) {
            swap(macro_width, macro_height);
            is_macro_rotatable = false;
          } else if (macro_width > outline_height_ ||
                     macro_height > outline_width_) {
            is_macro_rotatable = false;
          }
          macros_.push_back(
              Macro(macro_name, macro_width, macro_height, is_macro_rotatable));
          const int macro_id = macros_.size() - 1;
          macro_id_by_name_.insert({macro_name, macro_id});
        } else if (nth_terminal < num_terminals) {
          ++nth_terminal;
          const string terminal_name = tokens[0];
          const double terminal_x = stod(tokens[2]);
          const double terminal_y = stod(tokens[3]);
          terminals_.push_back(Terminal(terminal_name, terminal_x, terminal_y));
          const int terminal_id = terminals_.size() - 1;
          terminal_id_by_name_.insert({terminal_name, terminal_id});
        }
      }
    }
    return true;
  });
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x9910
movq -0xd0(%rbp), %rdx
leaq 0x3ec72(%rip), %rsi     # 0x4bf79
leaq -0x58(%rbp), %rdi
callq 0xfcf0
jmp 0xd312
movq -0xd8(%rbp), %rsi
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0xfda0
jmp 0xd328
leaq -0x58(%rbp), %rdi
callq 0x9a48
leaq -0x59(%rbp), %rdi
callq 0x9520
movq -0xe0(%rbp), %rax
movl $0x0, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movq %rax, -0xc8(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0x74(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0x78(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0x7c(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0xdf40
jmp 0xd3a5
leaq -0x38(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xfde0
jmp 0xd3b7
leaq -0xa0(%rbp), %rdi
callq 0xfef0
leaq -0x38(%rbp), %rdi
callq 0xff10
addq $0xe0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xd3f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x9a48
leaq -0x59(%rbp), %rdi
callq 0x9520
jmp 0xd432
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0xd429
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0xfef0
leaq -0x38(%rbp), %rdi
callq 0xff10
movq -0x68(%rbp), %rdi
callq 0x98f0
nopl (%rax,%rax)