// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x380, %rsp            # imm = 0x380
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x344(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x30ae
jmp 0x30cd
leaq 0x12e9(%rip), %rdi      # 0x439e
leaq 0xf58(%rip), %rsi       # 0x4014
movl $0x308, %edx            # imm = 0x308
leaq 0x12e2(%rip), %rcx      # 0x43aa
callq 0x1040
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x370(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x368(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x30ff
movq -0x28(%rbp), %rax
movq %rax, -0x378(%rbp)
jmp 0x310e
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x378(%rbp)
movq -0x368(%rbp), %rsi
movq -0x370(%rbp), %rdi
movq -0x378(%rbp), %rdx
callq 0x1190
movq %rax, -0x350(%rbp)
cmpq $0x0, -0x350(%rbp)
jne 0x3146
movq $0x0, -0x8(%rbp)
jmp 0x348b
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x350(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x350(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x3177
movq -0x350(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x348b
movq -0x10(%rbp), %rax
movq %rax, -0x358(%rbp)
movq -0x350(%rbp), %rax
movq %rax, -0x360(%rbp)
jmp 0x3192
movq -0x358(%rbp), %rax
cmpq $0x0, (%rax)
je 0x32cd
cmpl $0x62, -0x344(%rbp)
jge 0x31ae
jmp 0x31cd
leaq 0x1262(%rip), %rdi      # 0x4417
leaq 0xe58(%rip), %rsi       # 0x4014
movl $0x317, %edx            # imm = 0x317
leaq 0x11e2(%rip), %rcx      # 0x43aa
callq 0x1040
movq -0x350(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq -0x350(%rbp), %rcx
movq 0x18(%rcx), %rdi
movl $0x20, %esi
callq *%rax
movq %rax, %rcx
movq -0x360(%rbp), %rax
movq %rcx, (%rax)
movq -0x360(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x3262
movq -0x360(%rbp), %rax
movq -0x350(%rbp), %rcx
cmpq %rcx, %rax
je 0x3238
movq -0x360(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x360(%rbp), %rax
movq $0x0, 0x8(%rax)
leaq -0x340(%rbp), %rdi
movl -0x344(%rbp), %esi
movq -0x350(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x34a0
movq $0x0, -0x8(%rbp)
jmp 0x348b
movq -0x358(%rbp), %rcx
movl -0x344(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x344(%rbp)
cltq
movq %rcx, -0x340(%rbp,%rax,8)
movq -0x360(%rbp), %rcx
movl -0x344(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x344(%rbp)
cltq
movq %rcx, -0x340(%rbp,%rax,8)
movq -0x358(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x358(%rbp)
movq -0x360(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x360(%rbp)
jmp 0x3192
movq -0x360(%rbp), %rax
movq $0x0, (%rax)
movq -0x358(%rbp), %rax
movb 0x18(%rax), %cl
movq -0x360(%rbp), %rax
movb %cl, 0x18(%rax)
cmpq $0x0, -0x18(%rbp)
jne 0x330e
movq -0x358(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x360(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x337e
movq -0x18(%rbp), %rax
movq -0x358(%rbp), %rcx
movq 0x10(%rcx), %rdi
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rsi
callq *%rax
movq %rax, %rcx
movq -0x360(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x360(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x337c
movq -0x360(%rbp), %rax
movq $0x0, 0x8(%rax)
leaq -0x340(%rbp), %rdi
movl -0x344(%rbp), %esi
movq -0x350(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x34a0
movq $0x0, -0x8(%rbp)
jmp 0x348b
jmp 0x337e
movq -0x358(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x341c
movq -0x350(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq -0x350(%rbp), %rcx
movq 0x18(%rcx), %rdi
movl $0x20, %esi
callq *%rax
movq %rax, %rcx
movq -0x360(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x360(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x33f6
leaq -0x340(%rbp), %rdi
movl -0x344(%rbp), %esi
movq -0x350(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x34a0
movq $0x0, -0x8(%rbp)
jmp 0x348b
movq -0x358(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x358(%rbp)
movq -0x360(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x360(%rbp)
jmp 0x3486
movq -0x360(%rbp), %rax
movq $0x0, 0x8(%rax)
cmpl $0x2, -0x344(%rbp)
jg 0x3441
movq -0x350(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x348b
movl -0x344(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x344(%rbp)
cltq
movq -0x340(%rbp,%rax,8), %rax
movq %rax, -0x360(%rbp)
movl -0x344(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x344(%rbp)
cltq
movq -0x340(%rbp,%rax,8), %rax
movq %rax, -0x358(%rbp)
jmp 0x32db
jmp 0x3190
movq -0x8(%rbp), %rax
addq $0x380, %rsp            # imm = 0x380
popq %rbp
retq
nopl (%rax,%rax)