// File: /workspace/github_c_makefile_star2_O2/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 0x2075
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq 0x10(%rbx), %rsi
testq %rcx, %rcx
jne 0x1f32
movq 0x18(%rbx), %rcx
movq %rcx, %rdx
callq 0x118c
testq %rax, %rax
je 0x203f
movq %rax, %rbp
movq 0x20(%rbx), %rax
movq %rax, 0x20(%rbp)
testq %rax, %rax
je 0x2041
movq %r14, 0x8(%rsp)
xorl %r13d, %r13d
movq %rbx, %r12
movq %rbp, %r14
movslq %r13d, %r13
cmpq $0x0, (%r12)
je 0x1fa5
cmpq $0x62, %r13
jge 0x2056
movq 0x18(%rbp), %rdi
pushq $0x20
popq %rsi
callq *(%rdi)
movq %rax, (%r14)
testq %rax, %rax
je 0x2016
movq %r12, 0x10(%rsp,%r13,8)
movq %r14, 0x18(%rsp,%r13,8)
addq $0x2, %r13
movq (%r12), %r12
movq (%r14), %r14
jmp 0x1f68
andq $0x0, (%r14)
movl %r13d, %r13d
movb 0x18(%r12), %al
movb %al, 0x18(%r14)
movq 0x10(%r12), %rdi
testq %r15, %r15
je 0x1fd1
movq 0x10(%rbx), %rsi
callq *%r15
movq %rax, 0x10(%r14)
testq %rax, %rax
jne 0x1fd5
jmp 0x2025
movq %rdi, 0x10(%r14)
cmpq $0x0, 0x8(%r12)
jne 0x1ff7
andq $0x0, 0x8(%r14)
cmpl $0x3, %r13d
jl 0x2041
movq (%rsp,%r13,8), %r12
movq 0x8(%rsp,%r13,8), %r14
addq $-0x2, %r13
jmp 0x1fac
movq 0x18(%rbp), %rdi
pushq $0x20
popq %rsi
callq *(%rdi)
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0x202a
movq 0x8(%r12), %r12
movq %rax, %r14
jmp 0x1f65
cmpq %rbp, %r14
je 0x202a
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r14)
jmp 0x202a
andq $0x0, 0x8(%r14)
movq 0x8(%rsp), %rcx
leaq 0x10(%rsp), %rdi
movl %r13d, %esi
movq %rbp, %rdx
callq 0x2094
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13d6(%rip), %rdi      # 0x3433
leaq 0xfcc(%rip), %rsi       # 0x3030
leaq 0x135b(%rip), %rcx      # 0x33c6
movl $0x317, %edx            # imm = 0x317
callq 0x1040
leaq 0x133e(%rip), %rdi      # 0x33ba
leaq 0xfad(%rip), %rsi       # 0x3030
leaq 0x133c(%rip), %rcx      # 0x33c6
movl $0x308, %edx            # imm = 0x308
callq 0x1040