// File: /workspace/github_cpp_makefile_star2_O1/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 0x70e4
movl %eax, %ebp
callq 0x6100
cltq
imulq $0x55555556, %rax, %rcx # imm = 0x55555556
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rcx
addl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
cmpl $0x2, %eax
je 0xac85
cmpl $0x1, %eax
je 0xa9df
testl %eax, %eax
jne 0xb101
callq 0x6100
cltd
idivl %ebp
movl %edx, %r15d
movq %r14, %rdi
movl %edx, %esi
callq 0x8440
movq %rax, %rdi
callq 0x15956
testb %al, %al
je 0xa97f
movq %rbx, 0x90(%rsp)
leaq 0x58(%rbx), %r12
movslq %r15d, %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0xe07a
movq %rdx, %rbp
movq (%rax), %rbx
movq %r12, %rdi
movq %r13, %rsi
callq 0xe07a
testq %rbp, %rbx
je 0xaf3b
notq %rdx
andq (%rax), %rdx
jmp 0xaf3e
callq 0x6100
cltd
idivl %ebp
movl %edx, %r15d
callq 0x6100
cltd
idivl %ebp
cmpl %r15d, %edx
je 0xa9ea
movslq %r15d, %rsi
movq 0x40(%rbx), %r13
movq 0x48(%rbx), %rax
subq %r13, %rax
sarq $0x2, %rax
cmpq %rsi, %rax
jbe 0xb113
movslq %edx, %r15
cmpq %r15, %rax
jbe 0xb11c
movl (%r13,%rsi,4), %eax
movl (%r13,%r15,4), %ecx
movl %ecx, (%r13,%rsi,4)
movl %eax, (%r13,%r15,4)
cmpb $0x1, (%rbx)
jne 0xb101
movl (%r13,%rsi,4), %esi
movq %r14, %rdi
callq 0x8440
movq %rax, %rdi
callq 0x15946
movq %rax, %r12
movl (%r13,%r15,4), %esi
movq %r14, %rdi
callq 0x8440
movq %rax, %rdi
callq 0x15946
movq %rax, %r15
leaq 0x20(%rsp), %rbp
movb $0x0, (%rbp)
movq $0x0, 0x8(%rbp)
leaq 0x1687d(%rip), %rsi     # 0x21300
movq %rbp, %r13
movq %rbp, %rdi
callq 0xedfd
leaq 0x20(%rsp), %rdi
callq 0xe608
leaq 0x30(%rsp), %r13
movb $0x0, (%r13)
movq $0x0, 0x8(%r13)
leaq 0x16870(%rip), %rsi     # 0x21321
movq %r13, %rdi
callq 0xedfd
movq %r13, %rdi
callq 0xe608
leaq 0x40(%rsp), %r14
leaq 0x20(%rsp), %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe168
leaq 0x50(%rsp), %r14
movq %rsp, %rbp
movb $0x0, (%rbp)
movq $0x0, 0x8(%rbp)
leaq 0x16828(%rip), %rsi     # 0x21326
movq %rbp, %r13
movq %rbp, %rdi
callq 0xf9e6
movq %rsp, %rdi
callq 0xe608
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0xe284
movq %rsp, %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe168
leaq 0x60(%rsp), %r14
leaq 0x70(%rsp), %r13
movb $0x0, (%r13)
movq $0x0, 0x8(%r13)
leaq 0x167d3(%rip), %rsi     # 0x2132d
movq %r13, %r12
movq %r13, %rdi
callq 0xf9e6
leaq 0x70(%rsp), %rdi
callq 0xe608
leaq 0x80(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xe284
leaq 0x70(%rsp), %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe168
leaq 0xa8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movl $0x3, %edx
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe168
addq $0x98, %rbx
leaq 0x16745(%rip), %rsi     # 0x21314
movq %rbx, %rdi
callq 0xe2b0
movq %rax, %rbx
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
callq 0xe608
movb (%rbx), %al
movb (%r14), %cl
movb %cl, (%rbx)
movb %al, (%r14)
movq 0x8(%rbx), %rax
movq 0x8(%r14), %rcx
movq %rcx, 0x8(%rbx)
movq %rax, 0x8(%r14)
movq %rbx, %rdi
callq 0xe608
movq %r14, %rdi
callq 0xe0e0
movl $0x20, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x40, %rdi
callq 0xe0e0
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xac19
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x70, %rdi
callq 0xe0e0
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xac35
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
callq 0xe0e0
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xac51
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x20, %rdi
callq 0xe0e0
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xac69
jmp 0xb101
callq 0x6100
cltd
idivl %ebp
movl %edx, %r12d
callq 0x6100
cltd
idivl %ebp
cmpl %r12d, %edx
je 0xac90
movl %edx, %r13d
callq 0x6100
movl %eax, %ebp
callq 0x6100
shlq $0x20, %rax
movl %ebp, %ecx
orq %rax, %rcx
movq %r15, %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x7258
cmpb $0x1, (%rbx)
jne 0xb101
movslq %r12d, %rsi
movq 0x40(%rbx), %rcx
movq 0x48(%rbx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0xb12b
movslq %r13d, %rax
cmpq %rax, %rdx
jbe 0xb134
movl (%rcx,%rsi,4), %esi
movl (%rcx,%rax,4), %ebp
movq %r14, %rdi
callq 0x8440
movq %rax, %rdi
callq 0x15946
movq %rax, %r12
movq %r14, %rdi
movl %ebp, %esi
callq 0x8440
movq %rax, %rdi
callq 0x15946
movq %rax, %r15
leaq 0x20(%rsp), %rbp
movb $0x0, (%rbp)
movq $0x0, 0x8(%rbp)
leaq 0x165c7(%rip), %rsi     # 0x21300
movq %rbp, %r13
movq %rbp, %rdi
callq 0xedfd
leaq 0x20(%rsp), %rdi
callq 0xe608
leaq 0x30(%rsp), %r13
movb $0x0, (%r13)
movq $0x0, 0x8(%r13)
leaq 0x165cd(%rip), %rsi     # 0x21334
movq %r13, %rdi
callq 0xfa79
movq %r13, %rdi
callq 0xe608
leaq 0x40(%rsp), %r14
leaq 0x20(%rsp), %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe168
leaq 0x50(%rsp), %r14
movq %rsp, %rbp
movb $0x0, (%rbp)
movq $0x0, 0x8(%rbp)
leaq 0x16590(%rip), %rsi     # 0x21344
movq %rbp, %r13
movq %rbp, %rdi
callq 0xfb0c
movq %rsp, %rdi
callq 0xe608
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0xe284
movq %rsp, %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe168
leaq 0x60(%rsp), %r14
leaq 0x70(%rsp), %r13
movb $0x0, (%r13)
movq $0x0, 0x8(%r13)
leaq 0x16541(%rip), %rsi     # 0x21351
movq %r13, %r12
movq %r13, %rdi
callq 0xfb9f
leaq 0x70(%rsp), %rdi
callq 0xe608
leaq 0x80(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xe284
leaq 0x70(%rsp), %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe168
leaq 0x98(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movl $0x3, %edx
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe168
addq $0x98, %rbx
leaq 0x1648f(%rip), %rsi     # 0x21314
movq %rbx, %rdi
callq 0xe2b0
movq %rax, %rbx
leaq 0x98(%rsp), %r14
movq %r14, %rdi
callq 0xe608
movb (%rbx), %al
movb (%r14), %cl
movb %cl, (%rbx)
movb %al, (%r14)
movq 0x8(%rbx), %rax
movq 0x8(%r14), %rcx
movq %rcx, 0x8(%rbx)
movq %rax, 0x8(%r14)
movq %rbx, %rdi
callq 0xe608
movq %r14, %rdi
callq 0xe0e0
movl $0x20, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x40, %rdi
callq 0xe0e0
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xaecf
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x70, %rdi
callq 0xe0e0
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xaeeb
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
callq 0xe0e0
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xaf07
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x20, %rdi
callq 0xe0e0
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xaf1f
jmp 0xb101
orq (%rax), %rdx
movq %rdx, (%rax)
movq 0x90(%rsp), %rbx
cmpb $0x1, (%rbx)
jne 0xb101
movq %r14, %rdi
movl %r15d, %esi
callq 0x8440
movq %rax, %rdi
callq 0x15946
movq %rax, %r15
leaq 0x20(%rsp), %r13
movb $0x0, (%r13)
movq $0x0, 0x8(%r13)
leaq 0x1637f(%rip), %rsi     # 0x21300
movq %r13, %r12
movq %r13, %rdi
callq 0xedfd
leaq 0x20(%rsp), %rdi
callq 0xe608
leaq 0x30(%rsp), %r12
movb $0x0, (%r12)
movq $0x0, 0x8(%r12)
leaq 0x16355(%rip), %rsi     # 0x21305
movq %r12, %rdi
callq 0xeee0
movq %r12, %rdi
callq 0xe608
leaq 0x40(%rsp), %r14
leaq 0x20(%rsp), %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe168
leaq 0x50(%rsp), %r14
movq %rsp, %r13
movb $0x0, (%r13)
movq $0x0, 0x8(%r13)
leaq 0x16310(%rip), %rsi     # 0x2130e
movq %r13, %r12
movq %r13, %rdi
callq 0xf953
movq %rsp, %rdi
callq 0xe608
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xe284
movq %rsp, %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe168
leaq 0xb8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movl $0x2, %edx
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe168
addq $0x98, %rbx
leaq 0x162a8(%rip), %rsi     # 0x21314
movq %rbx, %rdi
callq 0xe2b0
movq %rax, %rbx
leaq 0xb8(%rsp), %r14
movq %r14, %rdi
callq 0xe608
movb (%rbx), %al
movb (%r14), %cl
movb %cl, (%rbx)
movb %al, (%r14)
movq 0x8(%rbx), %rax
movq 0x8(%r14), %rcx
movq %rcx, 0x8(%rbx)
movq %rax, 0x8(%r14)
movq %rbx, %rdi
callq 0xe608
movq %r14, %rdi
callq 0xe0e0
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x40, %rdi
callq 0xe0e0
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb0b6
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
callq 0xe0e0
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb0d2
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x20, %rdi
callq 0xe0e0
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb0ea
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15f6f(%rip), %rdi     # 0x21089
jmp 0xb126
leaq 0x15f66(%rip), %rdi     # 0x21089
movq %r15, %rsi
movq %rax, %rdx
jmp 0xb13e
leaq 0x15f57(%rip), %rdi     # 0x21089
jmp 0xb13e
leaq 0x15f4e(%rip), %rdi     # 0x21089
movq %rax, %rsi
xorl %eax, %eax
callq 0x6530
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0xe0e0
jmp 0xb16c
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0xe0e0
jmp 0xb191
movq %rax, %rbx
movl $0x20, %r15d
leaq (%rsp,%r15), %rdi
addq $0x40, %rdi
callq 0xe0e0
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb172
xorl %r15d, %r15d
jmp 0xb1b9
movq %rax, %rbx
movl $0x20, %r15d
leaq (%rsp,%r15), %rdi
addq $0x40, %rdi
callq 0xe0e0
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb197
xorl %r15d, %r15d
jmp 0xb1e1
movq %rax, %rbx
movb $0x1, %r15b
movl $0x10, %r12d
leaq (%rsp,%r12), %rdi
addq $0x70, %rdi
callq 0xe0e0
addq $-0x10, %r12
cmpq $-0x10, %r12
jne 0xb1bf
jmp 0xb2b2
movq %rax, %rbx
movb $0x1, %r15b
movl $0x10, %r12d
leaq (%rsp,%r12), %rdi
addq $0x70, %rdi
callq 0xe0e0
addq $-0x10, %r12
cmpq $-0x10, %r12
jne 0xb1e7
jmp 0xb33b
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0xe0e0
jmp 0xb22e
movq %rax, %rbx
movb $0x1, %r15b
jmp 0xb2b2
movq %rax, %rbx
movb $0x1, %r15b
jmp 0xb33b
movq %rax, %rbx
movl $0x10, %r15d
leaq (%rsp,%r15), %rdi
addq $0x40, %rdi
callq 0xe0e0
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb234
xorl %ebp, %ebp
jmp 0xb255
movq %rax, %rbx
movb $0x1, %bpl
movl $0x10, %r15d
leaq (%rsp,%r15), %rdi
callq 0xe0e0
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb25b
jmp 0xb412
movq %rax, %rbx
movb $0x1, %r15b
jmp 0xb2cb
movq %rax, %rbx
movb $0x1, %r15b
jmp 0xb354
movq %rax, %rbx
movb $0x1, %bpl
jmp 0xb412
movq %rax, %rbx
movb $0x1, %r15b
cmpq %r12, %r13
je 0xb2b2
leaq 0x70(%rsp), %r13
addq $-0x10, %r12
movq %r12, %rdi
callq 0xe0e0
cmpq %r13, %r12
jne 0xb2a1
movl $0x10, %r12d
leaq (%rsp,%r12), %rdi
callq 0xe0e0
addq $-0x10, %r12
cmpq $-0x10, %r12
jne 0xb2b8
movl $0x10, %r12d
leaq (%rsp,%r12), %rdi
addq $0x20, %rdi
callq 0xe0e0
addq $-0x10, %r12
cmpq $-0x10, %r12
jne 0xb2d1
leaq 0x40(%rsp), %r12
cmpq %r14, %r12
setne %al
testb %r15b, %r15b
je 0xb452
testb %al, %al
je 0xb452
addq $-0x10, %r14
movq %r14, %rdi
callq 0xe0e0
cmpq %r12, %r14
jne 0xb304
jmp 0xb452
movq %rax, %rbx
movb $0x1, %r15b
cmpq %r12, %r13
je 0xb33b
leaq 0x70(%rsp), %r13
addq $-0x10, %r12
movq %r12, %rdi
callq 0xe0e0
cmpq %r13, %r12
jne 0xb32a
movl $0x10, %r12d
leaq (%rsp,%r12), %rdi
callq 0xe0e0
addq $-0x10, %r12
cmpq $-0x10, %r12
jne 0xb341
movl $0x10, %r12d
leaq (%rsp,%r12), %rdi
addq $0x20, %rdi
callq 0xe0e0
addq $-0x10, %r12
cmpq $-0x10, %r12
jne 0xb35a
leaq 0x40(%rsp), %r12
cmpq %r14, %r12
setne %al
testb %r15b, %r15b
je 0xb452
testb %al, %al
je 0xb452
addq $-0x10, %r14
movq %r14, %rdi
callq 0xe0e0
cmpq %r12, %r14
jne 0xb38d
jmp 0xb452
movq %rax, %rbx
movb $0x1, %r15b
cmpq %r13, %rbp
je 0xb2cb
movq %rsp, %r12
addq $-0x10, %r13
movq %r13, %rdi
callq 0xe0e0
cmpq %r12, %r13
jne 0xb3b5
jmp 0xb2cb
movq %rax, %rbx
movb $0x1, %r15b
cmpq %r13, %rbp
je 0xb354
movq %rsp, %r12
addq $-0x10, %r13
movq %r13, %rdi
callq 0xe0e0
cmpq %r12, %r13
jne 0xb3dd
jmp 0xb354
movq %rax, %rbx
movb $0x1, %bpl
cmpq %r12, %r13
je 0xb412
movq %rsp, %r15
addq $-0x10, %r12
movq %r12, %rdi
callq 0xe0e0
cmpq %r15, %r12
jne 0xb401
movl $0x10, %r15d
leaq (%rsp,%r15), %rdi
addq $0x20, %rdi
callq 0xe0e0
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb418
leaq 0x40(%rsp), %r15
cmpq %r14, %r15
setne %al
andb %bpl, %al
cmpb $0x1, %al
jne 0xb452
addq $-0x10, %r14
movq %r14, %rdi
callq 0xe0e0
cmpq %r15, %r14
jne 0xb441
movq %rbx, %rdi
callq 0x6640
movq %rax, %rbx
movb $0x1, %r15b
leaq 0x40(%rsp), %r14
cmpq %r13, %rbp
je 0xb2e8
leaq 0x20(%rsp), %r12
addq $-0x10, %r13
movq %r13, %rdi
callq 0xe0e0
cmpq %r12, %r13
jne 0xb473
jmp 0xb2e8
movq %rax, %rbx
leaq 0x40(%rsp), %r14
movb $0x1, %r15b
cmpq %r13, %rbp
je 0xb371
leaq 0x20(%rsp), %r12
addq $-0x10, %r13
movq %r13, %rdi
callq 0xe0e0
cmpq %r12, %r13
jne 0xb4a2
jmp 0xb371
movq %rax, %rbx
leaq 0x40(%rsp), %r14
movb $0x1, %bpl
cmpq %r12, %r13
je 0xb42f
leaq 0x20(%rsp), %r15
addq $-0x10, %r12
movq %r12, %rdi
callq 0xe0e0
cmpq %r15, %r12
jne 0xb4d1
jmp 0xb42f
nop