// File: /workspace/github_c_makefile_star2_O3/attractivechaos[P]rb-eval/rb.c
// Function: rb_copy
struct rb_table *
rb_copy (const struct rb_table *org, rb_copy_func *copy,
          rb_item_func *destroy, struct libavl_allocator *allocator)
{
  struct rb_node *stack[2 * (RB_MAX_HEIGHT + 1)];
  int height = 0;

  struct rb_table *new;
  const struct rb_node *x;
  struct rb_node *y;

  assert (org != NULL);
  new = rb_create (org->rb_compare, org->rb_param,
                    allocator != NULL ? allocator : org->rb_alloc);
  if (new == NULL)
    return NULL;
  new->rb_count = org->rb_count;
  if (new->rb_count == 0)
    return new;

  x = (const struct rb_node *) &org->rb_root;
  y = (struct rb_node *) &new->rb_root;
  for (;;)
    {
      while (x->rb_link[0] != NULL)
        {
          assert (height < 2 * (RB_MAX_HEIGHT + 1));

          y->rb_link[0] =
            new->rb_alloc->libavl_malloc (new->rb_alloc,
                                           sizeof *y->rb_link[0]);
          if (y->rb_link[0] == NULL)
            {
              if (y != (struct rb_node *) &new->rb_root)
                {
                  y->rb_data = NULL;
                  y->rb_link[1] = NULL;
                }

              copy_error_recovery (stack, height, new, destroy);
              return NULL;
            }

          stack[height++] = (struct rb_node *) x;
          stack[height++] = y;
          x = x->rb_link[0];
          y = y->rb_link[0];
        }
      y->rb_link[0] = NULL;

      for (;;)
        {
          y->rb_color = x->rb_color;
          if (copy == NULL)
            y->rb_data = x->rb_data;
          else
            {
              y->rb_data = copy (x->rb_data, org->rb_param);
              if (y->rb_data == NULL)
                {
                  y->rb_link[1] = NULL;
                  copy_error_recovery (stack, height, new, destroy);
                  return NULL;
                }
            }

          if (x->rb_link[1] != NULL)
            {
              y->rb_link[1] =
                new->rb_alloc->libavl_malloc (new->rb_alloc,
                                               sizeof *y->rb_link[1]);
              if (y->rb_link[1] == NULL)
                {
                  copy_error_recovery (stack, height, new, destroy);
                  return NULL;
                }

              x = x->rb_link[1];
              y = y->rb_link[1];
              break;
            }
          else
            y->rb_link[1] = NULL;

          if (height <= 2)
            return new;

          y = stack[--height];
          x = stack[--height];
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x328, %rsp            # imm = 0x328
testq %rdi, %rdi
je 0x20f7
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movq 0x8(%rdi), %rdi
movq 0x10(%r12), %rsi
testq %rcx, %rcx
jne 0x1fa5
movq 0x18(%r12), %rcx
movq %rcx, %rdx
callq 0x11cc
testq %rax, %rax
je 0x20c1
movq %rax, %rbx
movq 0x20(%r12), %rax
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0x20c3
movq %r14, 0x8(%rsp)
xorl %r13d, %r13d
movq %r12, %rbp
movq %rbx, %r14
cmpq $0x0, (%rbp)
je 0x2020
movslq %r13d, %r13
cmpq $0x62, %r13
jge 0x20d8
movq 0x18(%rbx), %rdi
movl $0x20, %esi
callq *(%rdi)
movq %rax, (%r14)
testq %rax, %rax
je 0x2095
movq %rbp, 0x10(%rsp,%r13,8)
movq %r14, 0x18(%rsp,%r13,8)
addq $0x2, %r13
movq (%rbp), %rbp
movq (%r14), %r14
cmpq $0x0, (%rbp)
jne 0x1fe3
movq $0x0, (%r14)
movl %r13d, %r13d
movb 0x18(%rbp), %al
movb %al, 0x18(%r14)
movq 0x10(%rbp), %rdi
testq %r15, %r15
je 0x204d
movq 0x10(%r12), %rsi
callq *%r15
movq %rax, 0x10(%r14)
testq %rax, %rax
jne 0x2051
jmp 0x20a4
movq %rdi, 0x10(%r14)
cmpq $0x0, 0x8(%rbp)
jne 0x2075
movq $0x0, 0x8(%r14)
cmpl $0x3, %r13d
jl 0x20c3
movq (%rsp,%r13,8), %rbp
movq 0x8(%rsp,%r13,8), %r14
addq $-0x2, %r13
jmp 0x202a
movq 0x18(%rbx), %rdi
movl $0x20, %esi
callq *(%rdi)
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0x20ac
movq 0x8(%rbp), %rbp
movq %rax, %r14
jmp 0x1fd9
cmpq %rbx, %r14
je 0x20ac
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r14)
jmp 0x20ac
movq $0x0, 0x8(%r14)
movq 0x8(%rsp), %rcx
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
movq %rbx, %rdx
callq 0x2116
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1354(%rip), %rdi      # 0x3433
leaq 0xf4a(%rip), %rsi       # 0x3030
leaq 0x12d9(%rip), %rcx      # 0x33c6
movl $0x317, %edx            # imm = 0x317
callq 0x1040
leaq 0x12bc(%rip), %rdi      # 0x33ba
leaq 0xf2b(%rip), %rsi       # 0x3030
leaq 0x12ba(%rip), %rcx      # 0x33c6
movl $0x308, %edx            # imm = 0x308
callq 0x1040