// File: /workspace/github_cpp_makefile_star2_O2/harry830622[P]floorplanner/src/floorplan.cpp
// Function: Floorplan::Perturb(Database const&)
void Floorplan::Perturb(const Database& database) {
  const int num_nodes = b_star_tree_.num_nodes();
  const int num_macros = num_nodes;
  const int op = rand() % 3;
  switch (op) {
    case 0: {
      const int macro_id = [&]() {
        int id = rand() % num_macros;
        while (!database.macro(id).is_rotatable()) {
          id = rand() % num_macros;
        }
        return id;
      }();
      is_macro_rotated_by_id_.at(macro_id) =
          !is_macro_rotated_by_id_.at(macro_id);

      if (is_drawing_) {
        const string& macro_name = database.macro(macro_id).name();
        drawing_["perturbation"] = {{"type", "rotation"},
                                    {"macro", macro_name}};
      }

      break;
    }
    case 1: {
      const int node_a_id = rand() % num_nodes;
      const int node_b_id = [&]() {
        int node_id = rand() % num_nodes;
        while (node_id == node_a_id) {
          node_id = rand() % num_nodes;
        }
        return node_id;
      }();
      int& node_a_macro_id = macro_id_by_node_id_.at(node_a_id);
      int& node_b_macro_id = macro_id_by_node_id_.at(node_b_id);
      swap(node_a_macro_id, node_b_macro_id);

      if (is_drawing_) {
        const string& macro_a_name = database.macro(node_a_macro_id).name();
        const string& macro_b_name = database.macro(node_b_macro_id).name();
        drawing_["perturbation"] = {{"type", "swap"},
                                    {"macroA", macro_a_name},
                                    {"macroB", macro_b_name}};
      }

      break;
    }
    case 2: {
      const int node_a_id = rand() % num_nodes;
      const int node_b_id = [&]() {
        int node_id = rand() % num_nodes;
        while (node_id == node_a_id) {
          node_id = rand() % num_nodes;
        }
        return node_id;
      }();
      auto inserted_positions = make_pair(rand(), rand());
      b_star_tree_.DeleteAndInsert(node_a_id, node_b_id, inserted_positions);

      if (is_drawing_) {
        const int node_a_macro_id = macro_id_by_node_id_.at(node_a_id);
        const int node_b_macro_id = macro_id_by_node_id_.at(node_b_id);
        const string& macro_a_name = database.macro(node_a_macro_id).name();
        const string& macro_b_name = database.macro(node_b_macro_id).name();
        drawing_["perturbation"] = {{"type", "deleteAndInsert"},
                                    {"deletedMacro", macro_a_name},
                                    {"targetMacro", macro_b_name}};
      }

      break;
    }
    default:
      break;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x20(%rdi), %r15
movq %r15, %rdi
callq 0x7d2e
movl %eax, %ebp
callq 0x7120
pushq $0x3
popq %rcx
cltd
idivl %ecx
cmpl $0x2, %edx
je 0xaf82
cmpl $0x1, %edx
je 0xad9c
testl %edx, %edx
jne 0xb2b2
callq 0x7120
cltd
idivl %ebp
movl %edx, %r15d
movq %r14, %rdi
movl %edx, %esi
callq 0x8d72
movq %rax, %rdi
callq 0x12e6c
testb %al, %al
je 0xad3c
movq %rbx, 0x90(%rsp)
leaq 0x58(%rbx), %r12
movslq %r15d, %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0xd23a
movq %rdx, %rbp
movq (%rax), %rbx
movq %r12, %rdi
movq %r13, %rsi
callq 0xd23a
testq %rbp, %rbx
je 0xb17a
notq %rdx
andq (%rax), %rdx
jmp 0xb17d
callq 0x7120
cltd
idivl %ebp
movl %edx, %r15d
callq 0x7120
cltd
idivl %ebp
cmpl %r15d, %edx
je 0xada7
movl %edx, %r13d
leaq 0x40(%rbx), %rbp
movslq %r15d, %rsi
movq %rbp, %rdi
callq 0xd53c
movq %rax, %r12
movslq %r13d, %rsi
movq %rbp, %rdi
callq 0xd53c
movq %rax, %r15
movl (%r12), %eax
movl (%r15), %ecx
movl %ecx, (%r12)
movl %eax, (%r15)
cmpb $0x1, (%rbx)
jne 0xb2b2
movl (%r12), %esi
movq %r14, %rdi
callq 0x8d72
movq %rax, %rdi
callq 0x12e5c
movq %rax, %r12
movl (%r15), %esi
movq %r14, %rdi
callq 0x8d72
movq %rax, %rdi
callq 0x12e5c
movq %rax, %r15
leaq 0x104ea(%rip), %rsi     # 0x1b30c
leaq 0x20(%rsp), %rdi
callq 0xd25c
leaq 0x30(%rsp), %rdi
leaq 0x104f5(%rip), %rsi     # 0x1b32d
callq 0xd25c
leaq 0x40(%rsp), %r14
leaq 0x20(%rsp), %rsi
pushq $0x2
popq %rdx
pushq $0x1
popq %rcx
pushq $0x2
popq %r8
movq %r14, %rdi
callq 0xd2e8
leaq 0x50(%rsp), %r14
leaq 0x104cd(%rip), %rsi     # 0x1b332
movq %rsp, %rdi
callq 0xd55e
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0xd3e0
movq %rsp, %rsi
pushq $0x2
popq %rdx
pushq $0x1
popq %rcx
pushq $0x2
popq %r8
movq %r14, %rdi
callq 0xd2e8
leaq 0x60(%rsp), %r14
leaq 0x1049e(%rip), %rsi     # 0x1b339
leaq 0x70(%rsp), %rdi
callq 0xd55e
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
callq 0xd3e0
leaq 0x70(%rsp), %rsi
pushq $0x2
popq %rdx
pushq $0x1
popq %rcx
pushq $0x2
popq %r8
movq %r14, %rdi
callq 0xd2e8
leaq 0xa8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
pushq $0x3
popq %rdx
pushq $0x1
popq %rcx
pushq $0x2
popq %r8
callq 0xd2e8
addq $0x98, %rbx
leaq 0x1042a(%rip), %rsi     # 0x1b320
movq %rbx, %rdi
callq 0xd3fa
leaq 0xa8(%rsp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0xd4fc
movq %rbx, %rdi
callq 0xd290
pushq $0x20
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x40, %rdi
callq 0xd290
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xaf1c
pushq $0x10
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x70, %rdi
callq 0xd290
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xaf36
pushq $0x10
popq %rbx
leaq (%rsp,%rbx), %rdi
callq 0xd290
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xaf50
pushq $0x10
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x20, %rdi
callq 0xd290
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xaf66
jmp 0xb2b2
callq 0x7120
cltd
idivl %ebp
movl %edx, %r12d
callq 0x7120
cltd
idivl %ebp
cmpl %r12d, %edx
je 0xaf8d
movl %edx, %r13d
callq 0x7120
movl %eax, %ebp
callq 0x7120
shlq $0x20, %rax
movl %ebp, %ecx
orq %rax, %rcx
movq %r15, %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x7daa
cmpb $0x1, (%rbx)
jne 0xb2b2
leaq 0x40(%rbx), %r15
movslq %r12d, %rsi
movq %r15, %rdi
callq 0xd53c
movl (%rax), %ebp
movslq %r13d, %rsi
movq %r15, %rdi
callq 0xd53c
movl (%rax), %r15d
movq %r14, %rdi
movl %ebp, %esi
callq 0x8d72
movq %rax, %rdi
callq 0x12e5c
movq %rax, %r12
movq %r14, %rdi
movl %r15d, %esi
callq 0x8d72
movq %rax, %rdi
callq 0x12e5c
movq %rax, %r15
leaq 0x102f2(%rip), %rsi     # 0x1b30c
leaq 0x20(%rsp), %rdi
callq 0xd25c
leaq 0x30(%rsp), %rdi
leaq 0x10310(%rip), %rsi     # 0x1b340
callq 0xd578
leaq 0x40(%rsp), %r14
leaq 0x20(%rsp), %rsi
pushq $0x2
popq %rdx
pushq $0x1
popq %rcx
pushq $0x2
popq %r8
movq %r14, %rdi
callq 0xd2e8
leaq 0x50(%rsp), %r14
leaq 0x102f3(%rip), %rsi     # 0x1b350
movq %rsp, %rdi
callq 0xd592
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0xd3e0
movq %rsp, %rsi
pushq $0x2
popq %rdx
pushq $0x1
popq %rcx
pushq $0x2
popq %r8
movq %r14, %rdi
callq 0xd2e8
leaq 0x60(%rsp), %r14
leaq 0x102ca(%rip), %rsi     # 0x1b35d
leaq 0x70(%rsp), %rdi
callq 0xd5ac
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
callq 0xd3e0
leaq 0x70(%rsp), %rsi
pushq $0x2
popq %rdx
pushq $0x1
popq %rcx
pushq $0x2
popq %r8
movq %r14, %rdi
callq 0xd2e8
leaq 0x98(%rsp), %rdi
leaq 0x40(%rsp), %rsi
pushq $0x3
popq %rdx
pushq $0x1
popq %rcx
pushq $0x2
popq %r8
callq 0xd2e8
addq $0x98, %rbx
leaq 0x10232(%rip), %rsi     # 0x1b320
movq %rbx, %rdi
callq 0xd3fa
leaq 0x98(%rsp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0xd4fc
movq %rbx, %rdi
callq 0xd290
pushq $0x20
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x40, %rdi
callq 0xd290
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb114
pushq $0x10
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x70, %rdi
callq 0xd290
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb12e
pushq $0x10
popq %rbx
leaq (%rsp,%rbx), %rdi
callq 0xd290
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb148
pushq $0x10
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x20, %rdi
callq 0xd290
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb15e
jmp 0xb2b2
orq (%rax), %rdx
movq %rdx, (%rax)
movq 0x90(%rsp), %rbx
cmpb $0x1, (%rbx)
jne 0xb2b2
movq %r14, %rdi
movl %r15d, %esi
callq 0x8d72
movq %rax, %rdi
callq 0x12e5c
movq %rax, %r15
leaq 0x1015e(%rip), %rsi     # 0x1b30c
leaq 0x20(%rsp), %rdi
callq 0xd25c
leaq 0x30(%rsp), %rdi
leaq 0x1014d(%rip), %rsi     # 0x1b311
callq 0xd276
leaq 0x40(%rsp), %r14
leaq 0x20(%rsp), %rsi
pushq $0x2
popq %rdx
pushq $0x1
popq %rcx
pushq $0x2
popq %r8
movq %r14, %rdi
callq 0xd2e8
leaq 0x50(%rsp), %r14
leaq 0x10129(%rip), %rsi     # 0x1b31a
movq %rsp, %rdi
callq 0xd3c6
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xd3e0
movq %rsp, %rsi
pushq $0x2
popq %rdx
pushq $0x1
popq %rcx
pushq $0x2
popq %r8
movq %r14, %rdi
callq 0xd2e8
leaq 0xb8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
pushq $0x2
popq %rdx
pushq $0x1
popq %rcx
pushq $0x2
popq %r8
callq 0xd2e8
addq $0x98, %rbx
leaq 0x100db(%rip), %rsi     # 0x1b320
movq %rbx, %rdi
callq 0xd3fa
leaq 0xb8(%rsp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0xd4fc
movq %rbx, %rdi
callq 0xd290
pushq $0x10
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x40, %rdi
callq 0xd290
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb26b
pushq $0x10
popq %rbx
leaq (%rsp,%rbx), %rdi
callq 0xd290
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb285
pushq $0x10
popq %rbx
leaq (%rsp,%rbx), %rdi
addq $0x20, %rdi
callq 0xd290
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb29b
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0xd290
jmp 0xb2eb
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0xd290
jmp 0xb30d
movq %rax, %rbx
pushq $0x20
popq %r15
leaq (%rsp,%r15), %rdi
addq $0x40, %rdi
callq 0xd290
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb2ef
xorl %ebp, %ebp
jmp 0xb332
movq %rax, %rbx
pushq $0x20
popq %r15
leaq (%rsp,%r15), %rdi
addq $0x40, %rdi
callq 0xd290
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb311
xorl %ebp, %ebp
jmp 0xb358
movq %rax, %rbx
movb $0x1, %bpl
pushq $0x10
popq %r15
leaq (%rsp,%r15), %rdi
addq $0x70, %rdi
callq 0xd290
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb336
jmp 0xb3f3
movq %rax, %rbx
movb $0x1, %bpl
pushq $0x10
popq %r15
leaq (%rsp,%r15), %rdi
addq $0x70, %rdi
callq 0xd290
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb35c
jmp 0xb415
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0xd290
jmp 0xb3ab
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xd290
jmp 0xb3f0
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xd290
jmp 0xb412
movq %rax, %rbx
pushq $0x10
popq %r15
leaq (%rsp,%r15), %rdi
addq $0x40, %rdi
callq 0xd290
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb3af
xorl %ebp, %ebp
jmp 0xb3d4
jmp 0xb3ed
jmp 0xb40f
movq %rax, %rbx
movb $0x1, %bpl
pushq $0x10
popq %r15
leaq (%rsp,%r15), %rdi
callq 0xd290
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb3d8
jmp 0xb46a
movq %rax, %rbx
movb $0x1, %bpl
pushq $0x10
popq %r15
leaq (%rsp,%r15), %rdi
callq 0xd290
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb3f7
jmp 0xb4b9
movq %rax, %rbx
movb $0x1, %bpl
pushq $0x10
popq %r15
leaq (%rsp,%r15), %rdi
callq 0xd290
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb419
jmp 0xb501
movq %rax, %rbx
movq %rsp, %rdi
callq 0xd290
jmp 0xb467
movq %rax, %rbx
movq %rsp, %rdi
callq 0xd290
jmp 0xb4b6
movq %rax, %rbx
movq %rsp, %rdi
callq 0xd290
jmp 0xb4fe
jmp 0xb464
jmp 0xb4b3
jmp 0xb4fb
movq %rax, %rbx
movb $0x1, %bpl
pushq $0x10
popq %r15
leaq (%rsp,%r15), %rdi
addq $0x20, %rdi
callq 0xd290
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb46e
leaq 0x40(%rsp), %r15
cmpq %r14, %r15
setne %al
andb %al, %bpl
cmpb $0x1, %bpl
jne 0xb55d
addq $-0x10, %r14
movq %r14, %rdi
callq 0xd290
cmpq %r15, %r14
jne 0xb49d
jmp 0xb55d
movq %rax, %rbx
movb $0x1, %bpl
pushq $0x10
popq %r15
leaq (%rsp,%r15), %rdi
addq $0x20, %rdi
callq 0xd290
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb4bd
leaq 0x40(%rsp), %r15
cmpq %r14, %r15
setne %al
andb %al, %bpl
cmpb $0x1, %bpl
jne 0xb55d
addq $-0x10, %r14
movq %r14, %rdi
callq 0xd290
cmpq %r15, %r14
jne 0xb4e8
jmp 0xb55d
movq %rax, %rbx
movb $0x1, %bpl
pushq $0x10
popq %r15
leaq (%rsp,%r15), %rdi
addq $0x20, %rdi
callq 0xd290
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb505
leaq 0x40(%rsp), %r15
cmpq %r14, %r15
setne %al
andb %al, %bpl
cmpb $0x1, %bpl
jne 0xb55d
addq $-0x10, %r14
movq %r14, %rdi
callq 0xd290
cmpq %r15, %r14
jne 0xb530
jmp 0xb55d
jmp 0xb547
jmp 0xb547
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xd290
jmp 0xb55d
jmp 0xb55a
jmp 0xb55a
movq %rax, %rbx
movq %rbx, %rdi
callq 0x7660
nop