// File: /workspace/github_cpp_makefile_star2_O3/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 0x71ee
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 0xb2fe
cmpl $0x1, %eax
je 0xb075
testl %eax, %eax
jne 0xb748
callq 0x6100
cltd
idivl %ebp
movl %edx, %r15d
movq %r14, %rdi
movl %edx, %esi
callq 0x8a80
movq %rax, %rdi
callq 0x158ae
testb %al, %al
je 0xb015
movq %rbx, 0x90(%rsp)
leaq 0x58(%rbx), %r12
movslq %r15d, %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0xe044
movq %rdx, %rbp
movq (%rax), %rbx
movq %r12, %rdi
movq %r13, %rsi
callq 0xe044
testq %rbp, %rbx
je 0xb597
notq %rdx
andq (%rax), %rdx
jmp 0xb59a
callq 0x6100
cltd
idivl %ebp
movl %edx, %r15d
callq 0x6100
cltd
idivl %ebp
cmpl %r15d, %edx
je 0xb080
movslq %r15d, %rsi
movq 0x40(%rbx), %r13
movq 0x48(%rbx), %rax
subq %r13, %rax
sarq $0x2, %rax
cmpq %rsi, %rax
jbe 0xb75a
movslq %edx, %r15
cmpq %r15, %rax
jbe 0xb763
movl (%r13,%rsi,4), %eax
movl (%r13,%r15,4), %ecx
movl %ecx, (%r13,%rsi,4)
movl %eax, (%r13,%r15,4)
cmpb $0x1, (%rbx)
jne 0xb748
movl (%r13,%rsi,4), %esi
movq %r14, %rdi
callq 0x8a80
movq %rax, %rdi
callq 0x1589e
movq %rax, %r12
movl (%r13,%r15,4), %esi
movq %r14, %rdi
callq 0x8a80
movq %rax, %rdi
callq 0x1589e
movq %rax, %r15
leaq 0x20(%rsp), %rdi
movb $0x0, (%rdi)
movq $0x0, 0x8(%rdi)
leaq 0x16298(%rip), %rsi     # 0x213b0
callq 0xedc3
leaq 0x20(%rsp), %rdi
callq 0xe5c8
leaq 0x30(%rsp), %r14
movb $0x0, (%r14)
movq $0x0, 0x8(%r14)
leaq 0x16292(%rip), %rsi     # 0x213d1
movq %r14, %rdi
callq 0xedc3
movq %r14, %rdi
callq 0xe5c8
leaq 0x60(%rsp), %r14
leaq 0x20(%rsp), %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe11c
leaq 0x70(%rsp), %r14
movq %rsp, %rdi
movb $0x0, (%rdi)
movq $0x0, 0x8(%rdi)
leaq 0x1624b(%rip), %rsi     # 0x213d6
callq 0xf9b0
movq %rsp, %rdi
callq 0xe5c8
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0xe22c
movq %rsp, %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe11c
leaq 0x80(%rsp), %r14
leaq 0x40(%rsp), %rdi
movb $0x0, (%rdi)
movq $0x0, 0x8(%rdi)
leaq 0x161fe(%rip), %rsi     # 0x213dd
callq 0xf9b0
leaq 0x40(%rsp), %rdi
callq 0xe5c8
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0xe22c
leaq 0x40(%rsp), %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe11c
leaq 0xa8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movl $0x3, %edx
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe11c
addq $0x98, %rbx
leaq 0x1617c(%rip), %rsi     # 0x213c4
movq %rbx, %rdi
callq 0xe258
movq %rax, %rbx
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
callq 0xe5c8
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 0xe5c8
movq %r14, %rdi
callq 0xe0aa
movl $0x20, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x60, %rdi
callq 0xe0aa
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb292
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x40, %rdi
callq 0xe0aa
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb2ae
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
callq 0xe0aa
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb2ca
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x20, %rdi
callq 0xe0aa
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb2e2
jmp 0xb748
callq 0x6100
cltd
idivl %ebp
movl %edx, %r12d
callq 0x6100
cltd
idivl %ebp
cmpl %r12d, %edx
je 0xb309
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 0x78ae
cmpb $0x1, (%rbx)
jne 0xb748
movslq %r12d, %rsi
movq 0x40(%rbx), %rcx
movq 0x48(%rbx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0xb772
movslq %r13d, %rax
cmpq %rax, %rdx
jbe 0xb77b
movl (%rcx,%rsi,4), %esi
movl (%rcx,%rax,4), %ebp
movq %r14, %rdi
callq 0x8a80
movq %rax, %rdi
callq 0x1589e
movq %rax, %r12
movq %r14, %rdi
movl %ebp, %esi
callq 0x8a80
movq %rax, %rdi
callq 0x1589e
movq %rax, %r15
leaq 0x20(%rsp), %rdi
movb $0x0, (%rdi)
movq $0x0, 0x8(%rdi)
leaq 0x15fff(%rip), %rsi     # 0x213b0
callq 0xedc3
leaq 0x20(%rsp), %rdi
callq 0xe5c8
leaq 0x30(%rsp), %r14
movb $0x0, (%r14)
movq $0x0, 0x8(%r14)
leaq 0x1600c(%rip), %rsi     # 0x213e4
movq %r14, %rdi
callq 0xfa43
movq %r14, %rdi
callq 0xe5c8
leaq 0x60(%rsp), %r14
leaq 0x20(%rsp), %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe11c
leaq 0x70(%rsp), %r14
movq %rsp, %rdi
movb $0x0, (%rdi)
movq $0x0, 0x8(%rdi)
leaq 0x15fd0(%rip), %rsi     # 0x213f4
callq 0xfad6
movq %rsp, %rdi
callq 0xe5c8
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0xe22c
movq %rsp, %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe11c
leaq 0x80(%rsp), %r14
leaq 0x40(%rsp), %rdi
movb $0x0, (%rdi)
movq $0x0, 0x8(%rdi)
leaq 0x15f89(%rip), %rsi     # 0x21401
callq 0xfb69
leaq 0x40(%rsp), %rdi
callq 0xe5c8
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0xe22c
leaq 0x40(%rsp), %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe11c
leaq 0x98(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movl $0x3, %edx
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe11c
addq $0x98, %rbx
leaq 0x15ee3(%rip), %rsi     # 0x213c4
movq %rbx, %rdi
callq 0xe258
movq %rax, %rbx
leaq 0x98(%rsp), %r14
movq %r14, %rdi
callq 0xe5c8
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 0xe5c8
movq %r14, %rdi
callq 0xe0aa
movl $0x20, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x60, %rdi
callq 0xe0aa
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb52b
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x40, %rdi
callq 0xe0aa
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb547
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
callq 0xe0aa
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb563
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x20, %rdi
callq 0xe0aa
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb57b
jmp 0xb748
orq (%rax), %rdx
movq %rdx, (%rax)
movq 0x90(%rsp), %rbx
cmpb $0x1, (%rbx)
jne 0xb748
movq %r14, %rdi
movl %r15d, %esi
callq 0x8a80
movq %rax, %rdi
callq 0x1589e
movq %rax, %r15
leaq 0x20(%rsp), %rdi
movb $0x0, (%rdi)
movq $0x0, 0x8(%rdi)
leaq 0x15dd5(%rip), %rsi     # 0x213b0
callq 0xedc3
leaq 0x20(%rsp), %rdi
callq 0xe5c8
leaq 0x30(%rsp), %r14
movb $0x0, (%r14)
movq $0x0, 0x8(%r14)
leaq 0x15db3(%rip), %rsi     # 0x213b5
movq %r14, %rdi
callq 0xeea6
movq %r14, %rdi
callq 0xe5c8
leaq 0x60(%rsp), %r14
leaq 0x20(%rsp), %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe11c
leaq 0x70(%rsp), %r14
movq %rsp, %rdi
movb $0x0, (%rdi)
movq $0x0, 0x8(%rdi)
leaq 0x15d70(%rip), %rsi     # 0x213be
callq 0xf91d
movq %rsp, %rdi
callq 0xe5c8
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xe22c
movq %rsp, %rsi
movl $0x2, %edx
movq %r14, %rdi
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe11c
leaq 0xb8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movl $0x2, %edx
movl $0x1, %ecx
movl $0x2, %r8d
callq 0xe11c
addq $0x98, %rbx
leaq 0x15d11(%rip), %rsi     # 0x213c4
movq %rbx, %rdi
callq 0xe258
movq %rax, %rbx
leaq 0xb8(%rsp), %r14
movq %r14, %rdi
callq 0xe5c8
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 0xe5c8
movq %r14, %rdi
callq 0xe0aa
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x60, %rdi
callq 0xe0aa
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb6fd
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
callq 0xe0aa
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb719
movl $0x10, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x20, %rdi
callq 0xe0aa
addq $-0x10, %rbx
cmpq $-0x10, %rbx
jne 0xb731
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x159d4(%rip), %rdi     # 0x21135
jmp 0xb76d
leaq 0x159cb(%rip), %rdi     # 0x21135
movq %r15, %rsi
movq %rax, %rdx
jmp 0xb785
leaq 0x159bc(%rip), %rdi     # 0x21135
jmp 0xb785
leaq 0x159b3(%rip), %rdi     # 0x21135
movq %rax, %rsi
xorl %eax, %eax
callq 0x6530
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0xe0aa
jmp 0xb7b3
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0xe0aa
jmp 0xb7d7
movq %rax, %rbx
movl $0x20, %r15d
leaq (%rsp,%r15), %rdi
addq $0x60, %rdi
callq 0xe0aa
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb7b9
xorl %ebp, %ebp
jmp 0xb7fe
movq %rax, %rbx
movl $0x20, %r15d
leaq (%rsp,%r15), %rdi
addq $0x60, %rdi
callq 0xe0aa
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb7dd
xorl %ebp, %ebp
jmp 0xb823
movq %rax, %rbx
movb $0x1, %bpl
movl $0x10, %r15d
leaq (%rsp,%r15), %rdi
addq $0x40, %rdi
callq 0xe0aa
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb804
jmp 0xb87c
movq %rax, %rbx
movb $0x1, %bpl
movl $0x10, %r15d
leaq (%rsp,%r15), %rdi
addq $0x40, %rdi
callq 0xe0aa
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb829
jmp 0xb8a0
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xe0aa
jmp 0xb879
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xe0aa
jmp 0xb89d
jmp 0xb876
jmp 0xb89a
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0xe0aa
jmp 0xb8c1
movq %rax, %rbx
movb $0x1, %bpl
movl $0x10, %r15d
leaq (%rsp,%r15), %rdi
callq 0xe0aa
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb882
jmp 0xb93d
movq %rax, %rbx
movb $0x1, %bpl
movl $0x10, %r15d
leaq (%rsp,%r15), %rdi
callq 0xe0aa
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb8a6
jmp 0xb98e
movq %rax, %rbx
movl $0x10, %r15d
leaq (%rsp,%r15), %rdi
addq $0x60, %rdi
callq 0xe0aa
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb8c7
xorl %ebp, %ebp
jmp 0xb905
movq %rax, %rbx
movq %rsp, %rdi
callq 0xe0aa
jmp 0xb93a
movq %rax, %rbx
movq %rsp, %rdi
callq 0xe0aa
jmp 0xb98b
movq %rax, %rbx
movb $0x1, %bpl
movl $0x10, %r15d
leaq (%rsp,%r15), %rdi
callq 0xe0aa
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb90b
jmp 0xb9de
jmp 0xb937
jmp 0xb988
movq %rax, %rbx
movq %rsp, %rdi
callq 0xe0aa
jmp 0xb9db
movq %rax, %rbx
movb $0x1, %bpl
movl $0x10, %r15d
leaq (%rsp,%r15), %rdi
addq $0x20, %rdi
callq 0xe0aa
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb943
leaq 0x60(%rsp), %r15
cmpq %r14, %r15
setne %al
andb %al, %bpl
cmpb $0x1, %bpl
jne 0xba38
addq $-0x10, %r14
movq %r14, %rdi
callq 0xe0aa
cmpq %r15, %r14
jne 0xb972
jmp 0xba38
movq %rax, %rbx
movb $0x1, %bpl
movl $0x10, %r15d
leaq (%rsp,%r15), %rdi
addq $0x20, %rdi
callq 0xe0aa
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb994
leaq 0x60(%rsp), %r15
cmpq %r14, %r15
setne %al
andb %al, %bpl
cmpb $0x1, %bpl
jne 0xba38
addq $-0x10, %r14
movq %r14, %rdi
callq 0xe0aa
cmpq %r15, %r14
jne 0xb9bf
jmp 0xba38
jmp 0xb9d8
jmp 0xba26
jmp 0xba26
movq %rax, %rbx
movb $0x1, %bpl
movl $0x10, %r15d
leaq (%rsp,%r15), %rdi
addq $0x20, %rdi
callq 0xe0aa
addq $-0x10, %r15
cmpq $-0x10, %r15
jne 0xb9e4
leaq 0x60(%rsp), %r15
cmpq %r14, %r15
setne %al
andb %al, %bpl
cmpb $0x1, %bpl
jne 0xba38
addq $-0x10, %r14
movq %r14, %rdi
callq 0xe0aa
cmpq %r15, %r14
jne 0xba0f
jmp 0xba38
jmp 0xba35
jmp 0xba35
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xe0aa
jmp 0xba38
movq %rax, %rbx
movq %rbx, %rdi
callq 0x6640