// File: /workspace/github_c_makefile_star2_O3/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 0x61df
movq %r14, %rbx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movl $0x1, %edi
movl $0x38, %esi
callq 0x4280
movq %rax, %r15
movq %rax, %rbx
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 0x6240
movq %r12, %rdi
callq 0x4130
leaq 0x1(%rax), %rdi
callq 0x43a0
movq %rax, (%rbx)
movq %rax, %rdi
movq %r12, %rsi
callq 0x40b0
addl $-0x2, %r13d
cmpl $0x1b, %r13d
ja 0x61d2
addq $0x8, %r15
leaq 0x8(%r14), %rax
leaq 0x7ec7(%rip), %rcx      # 0xe120
movslq (%rcx,%r13,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movq (%rax), %rdi
callq 0x4420
movq %rax, (%r15)
jmp 0x61d2
movq (%rax), %r14
movq %r14, %rdi
callq 0x4130
leaq 0x1(%rax), %rdi
callq 0x43a0
movq %rax, (%r15)
movq %rax, %rdi
movq %r14, %rsi
callq 0x40b0
jmp 0x61d2
movq 0x18(%r14), %rdi
callq 0x4420
movq %rax, 0x18(%rbx)
jmp 0x61d2
movslq (%rax), %r12
leaq (,%r12,8), %rdi
callq 0x43a0
movq %rax, 0x18(%rbx)
testq %r12, %r12
jle 0x61d2
movq %rax, %r15
xorl %r13d, %r13d
movq 0x18(%r14), %rax
movq (%rax,%r13,8), %rdi
callq 0x4420
movq %rax, (%r15,%r13,8)
incq %r13
movslq 0x8(%r14), %r12
cmpq %r12, %r13
jl 0x62ce
testl %r12d, %r12d
jle 0x61d2
leal -0x1(%r12), %r15d
leaq (,%r15,8), %rdi
callq 0x43a0
movq %rax, 0x20(%rbx)
cmpl $0x1, %r12d
je 0x61d2
movq 0x20(%r14), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movq %rsi, (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %r15
jne 0x631a
jmp 0x61d2
movq 0x8(%r14), %rdi
callq 0x4420
movq %rax, 0x8(%rbx)
movq 0x20(%r14), %r14
movq %r14, %rdi
callq 0x4130
leaq 0x1(%rax), %rdi
callq 0x43a0
movq %rax, 0x20(%rbx)
jmp 0x6289
movq 0x8(%r14), %rdi
callq 0x4420
movq %rax, 0x8(%rbx)
movq 0x10(%r14), %r14
movq %r14, %rdi
callq 0x4130
leaq 0x1(%rax), %rdi
callq 0x43a0
movq %rax, 0x10(%rbx)
jmp 0x6289
movq 0x18(%r14), %rdi
callq 0x4420
movq %rax, 0x18(%rbx)
movq 0x20(%r14), %rdi
callq 0x4420
movq %rax, 0x20(%rbx)
jmp 0x61d2
movq 0x8(%r14), %rdi
callq 0x4420
movq %rax, 0x8(%rbx)
movq 0x28(%r14), %r14
movq %r14, %rdi
callq 0x4130
leaq 0x1(%rax), %rdi
callq 0x43a0
movq %rax, 0x28(%rbx)
jmp 0x6289
movslq (%rax), %r12
leaq (,%r12,8), %rdi
callq 0x43a0
movq %rax, 0x10(%rbx)
testq %r12, %r12
jle 0x61d2
movq %rax, %r15
xorl %r12d, %r12d
movq 0x10(%r14), %rax
movq (%rax,%r12,8), %rdi
callq 0x4420
movq %rax, (%r15,%r12,8)
incq %r12
movslq 0x8(%r14), %rax
cmpq %rax, %r12
jl 0x63f2
jmp 0x61d2