// File: /workspace/github_c_makefile_star2_O2/orangeduck[P]mpc/mpc.c
// Function: mpc_copy
mpc_parser_t *mpc_copy(mpc_parser_t *a) {
  int i = 0;
  mpc_parser_t *p;

  if (a->retained) { return a; }

  p = mpc_undefined();
  p->retained = a->retained;
  p->type = a->type;
  p->data = a->data;

  if (a->name) {
    p->name = malloc(strlen(a->name)+1);
    strcpy(p->name, a->name);
  }

  switch (a->type) {

    case MPC_TYPE_FAIL:
      p->data.fail.m = malloc(strlen(a->data.fail.m)+1);
      strcpy(p->data.fail.m, a->data.fail.m);
    break;

    case MPC_TYPE_ONEOF:
    case MPC_TYPE_NONEOF:
    case MPC_TYPE_STRING:
      p->data.string.x = malloc(strlen(a->data.string.x)+1);
      strcpy(p->data.string.x, a->data.string.x);
      break;

    case MPC_TYPE_APPLY:    p->data.apply.x    = mpc_copy(a->data.apply.x);    break;
    case MPC_TYPE_APPLY_TO: p->data.apply_to.x = mpc_copy(a->data.apply_to.x); break;
    case MPC_TYPE_PREDICT:  p->data.predict.x  = mpc_copy(a->data.predict.x);  break;

    case MPC_TYPE_MAYBE:
    case MPC_TYPE_NOT:
      p->data.not.x = mpc_copy(a->data.not.x);
      break;

    case MPC_TYPE_EXPECT:
      p->data.expect.x = mpc_copy(a->data.expect.x);
      p->data.expect.m = malloc(strlen(a->data.expect.m)+1);
      strcpy(p->data.expect.m, a->data.expect.m);
      break;

    case MPC_TYPE_MANY:
    case MPC_TYPE_MANY1:
    case MPC_TYPE_COUNT:
      p->data.repeat.x = mpc_copy(a->data.repeat.x);
      break;

    case MPC_TYPE_SEPBY1:
      p->data.sepby1.x   = mpc_copy(a->data.sepby1.x);
      p->data.sepby1.sep = mpc_copy(a->data.sepby1.sep);
      break;

    case MPC_TYPE_OR:
      p->data.or.xs = malloc(a->data.or.n * sizeof(mpc_parser_t*));
      for (i = 0; i < a->data.or.n; i++) {
        p->data.or.xs[i] = mpc_copy(a->data.or.xs[i]);
      }
    break;
    case MPC_TYPE_AND:
      p->data.and.xs = malloc(a->data.and.n * sizeof(mpc_parser_t*));
      for (i = 0; i < a->data.and.n; i++) {
        p->data.and.xs[i] = mpc_copy(a->data.and.xs[i]);
      }
      if (a->data.and.n > 0) {
          p->data.and.dxs = malloc((a->data.and.n-1) * sizeof(mpc_dtor_t));
          for (i = 0; i < a->data.and.n-1; i++) {
            p->data.and.dxs[i] = a->data.and.dxs[i];
          }
      }
    break;

    case MPC_TYPE_CHECK:
      p->data.check.x      = mpc_copy(a->data.check.x);
      p->data.check.e      = malloc(strlen(a->data.check.e)+1);
      strcpy(p->data.check.e, a->data.check.e);
      break;
    case MPC_TYPE_CHECK_WITH:
      p->data.check_with.x = mpc_copy(a->data.check_with.x);
      p->data.check_with.e = malloc(strlen(a->data.check_with.e)+1);
      strcpy(p->data.check_with.e, a->data.check_with.e);
      break;

    default: break;
  }


  return p;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r14
cmpb $0x0, 0x31(%rdi)
je 0x6173
movq %r14, %rbx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x6146
movq %rax, %r15
movq %rax, %rbx
movb $0x0, 0x31(%rax)
movzbl 0x30(%r14), %r13d
movb %r13b, 0x30(%rax)
movq 0x28(%r14), %rax
movq %rax, 0x28(%r15)
movups 0x8(%r14), %xmm0
movups 0x18(%r14), %xmm1
movups %xmm1, 0x18(%r15)
movups %xmm0, 0x8(%r15)
movq (%r14), %r12
testq %r12, %r12
je 0x61ce
movq %r12, %rdi
callq 0x41c0
leaq 0x1(%rax), %rdi
callq 0x45a0
movq %rax, (%rbx)
movq %rax, %rdi
movq %r12, %rsi
callq 0x40e0
addl $-0x2, %r13d
cmpl $0x1b, %r13d
ja 0x6166
addq $0x8, %r15
leaq 0x8(%r14), %rax
leaq 0x5f39(%rip), %rcx      # 0xc120
movslq (%rcx,%r13,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movq (%rax), %rdi
callq 0x4640
movq %rax, (%r15)
jmp 0x6166
movq (%rax), %r14
movq %r14, %rdi
callq 0x41c0
leaq 0x1(%rax), %rdi
callq 0x45a0
movq %rax, (%r15)
movq %rax, %rdi
movq %r14, %rsi
callq 0x40e0
jmp 0x6166
movq 0x18(%r14), %rdi
callq 0x4640
movq %rax, 0x18(%rbx)
jmp 0x6166
movslq 0x8(%r14), %r12
movq %r12, %rdi
shlq $0x3, %rdi
callq 0x45a0
movq %rax, %r15
movq %rax, 0x18(%rbx)
xorl %r13d, %r13d
movslq %r12d, %rax
cmpq %rax, %r13
jge 0x6275
movq 0x18(%r14), %rax
movq (%rax,%r13,8), %rdi
callq 0x4640
movq %rax, (%r15,%r13,8)
incq %r13
movl 0x8(%r14), %r12d
jmp 0x6253
testl %r12d, %r12d
jle 0x6166
decl %r12d
leaq (,%r12,8), %rdi
callq 0x45a0
movq %rax, 0x20(%rbx)
xorl %ecx, %ecx
cmpq %rcx, %r12
je 0x6166
movq 0x20(%r14), %rdx
movq (%rdx,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
incq %rcx
jmp 0x6294
movq 0x8(%r14), %rdi
callq 0x4640
movq %rax, 0x8(%rbx)
movq 0x20(%r14), %r14
movq %r14, %rdi
callq 0x41c0
leaq 0x1(%rax), %rdi
callq 0x45a0
movq %rax, 0x20(%rbx)
jmp 0x6217
movq 0x8(%r14), %rdi
callq 0x4640
movq %rax, 0x8(%rbx)
movq 0x10(%r14), %r14
movq %r14, %rdi
callq 0x41c0
leaq 0x1(%rax), %rdi
callq 0x45a0
movq %rax, 0x10(%rbx)
jmp 0x6217
movq 0x18(%r14), %rdi
callq 0x4640
movq %rax, 0x18(%rbx)
movq 0x20(%r14), %rdi
callq 0x4640
movq %rax, 0x20(%rbx)
jmp 0x6166
movq 0x8(%r14), %rdi
callq 0x4640
movq %rax, 0x8(%rbx)
movq 0x28(%r14), %r14
movq %r14, %rdi
callq 0x41c0
leaq 0x1(%rax), %rdi
callq 0x45a0
movq %rax, 0x28(%rbx)
jmp 0x6217
movslq 0x8(%r14), %r13
movq %r13, %rdi
shlq $0x3, %rdi
callq 0x45a0
movq %rax, %r15
movq %rax, 0x10(%rbx)
xorl %r12d, %r12d
movslq %r13d, %rax
cmpq %rax, %r12
jge 0x6166
movq 0x10(%r14), %rax
movq (%rax,%r12,8), %rdi
callq 0x4640
movq %rax, (%r15,%r12,8)
incq %r12
movl 0x8(%r14), %r13d
jmp 0x6368