// File: /workspace/github_c_makefile_star2_O3/orangeduck[P]mpc/mpc.c
// Function: mpcf_fold_ast
mpc_val_t *mpcf_fold_ast(int n, mpc_val_t **xs) {

  int i, j;
  mpc_ast_t** as = (mpc_ast_t**)xs;
  mpc_ast_t *r;

  if (n == 0) { return NULL; }
  if (n == 1) { return xs[0]; }
  if (n == 2 && xs[1] == NULL) { return xs[0]; }
  if (n == 2 && xs[0] == NULL) { return xs[1]; }

  r = mpc_ast_new(">", "");

  for (i = 0; i < n; i++) {

    if (as[i] == NULL) { continue; }

    if        (as[i] && as[i]->children_num == 0) {
      mpc_ast_add_child(r, as[i]);
    } else if (as[i] && as[i]->children_num == 1) {
      mpc_ast_add_child(r, mpc_ast_add_root_tag(as[i]->children[0], as[i]->tag));
      mpc_ast_delete_no_children(as[i]);
    } else if (as[i] && as[i]->children_num >= 2) {
      for (j = 0; j < as[i]->children_num; j++) {
        mpc_ast_add_child(r, as[i]->children[j]);
      }
      mpc_ast_delete_no_children(as[i]);
    }

  }

  if (r->children_num) {
    r->state = r->children[0]->state;
  }

  return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testl %edi, %edi
je 0xa1d0
movq %rsi, %rbx
movl %edi, %ebp
cmpl $0x2, %edi
je 0xa19f
cmpl $0x1, %ebp
jne 0xa1d8
movq (%rbx), %r12
jmp 0xa341
movq (%rbx), %rax
movq 0x8(%rbx), %r12
testq %r12, %r12
je 0xa33e
testq %rax, %rax
je 0xa341
leaq 0x4605(%rip), %rdi      # 0xe7c4
leaq 0x45bb(%rip), %rsi      # 0xe781
callq 0x4550
movq %rax, %r12
jmp 0xa1f6
xorl %r12d, %r12d
jmp 0xa341
leaq 0x45e5(%rip), %rdi      # 0xe7c4
leaq 0x459b(%rip), %rsi      # 0xe781
callq 0x4550
movq %rax, %r12
testl %ebp, %ebp
jle 0xa318
movl %ebp, %r13d
xorl %ebp, %ebp
movq %r12, 0x8(%rsp)
movq %r13, (%rsp)
movq (%rbx,%rbp,8), %r15
testq %r15, %r15
je 0xa30c
movl 0x30(%r15), %eax
cmpl $0x1, %eax
je 0xa24c
testl %eax, %eax
jne 0xa292
movslq 0x30(%r12), %r14
leaq 0x1(%r14), %rax
movl %eax, 0x30(%r12)
movq 0x38(%r12), %rdi
leaq 0x8(,%r14,8), %rsi
callq 0x43f0
movq %rax, 0x38(%r12)
movq %r15, (%rax,%r14,8)
jmp 0xa30c
movq (%r15), %rsi
movq 0x38(%r15), %rax
movq (%rax), %r15
movq %r15, %rdi
callq 0x43d0
movslq 0x30(%r12), %r14
leaq 0x1(%r14), %rax
movl %eax, 0x30(%r12)
movq 0x38(%r12), %rdi
leaq 0x8(,%r14,8), %rsi
callq 0x43f0
movq %rax, 0x38(%r12)
movq %r15, (%rax,%r14,8)
movq (%rbx,%rbp,8), %rdi
callq 0xa353
jmp 0xa30c
cmpl $0x2, %eax
jl 0xa30c
movslq 0x30(%r12), %r13
movl %r13d, %eax
movq %rax, 0x10(%rsp)
movq 0x38(%r12), %rax
leaq 0x8(,%r13,8), %r12
shlq $0x3, %r13
xorl %r14d, %r14d
movq 0x38(%r15), %rcx
movq (%rcx,%r14,8), %r15
movq %rax, %rdi
movq %r12, %rsi
callq 0x43f0
movq %rax, %rcx
addq %r13, %rcx
movq %r15, (%rcx,%r14,8)
incq %r14
movq (%rbx,%rbp,8), %r15
movslq 0x30(%r15), %rcx
addq $0x8, %r12
cmpq %rcx, %r14
jl 0xa2b8
movq 0x10(%rsp), %rcx
addl %r14d, %ecx
movq 0x8(%rsp), %r12
movl %ecx, 0x30(%r12)
movq %rax, 0x38(%r12)
movq %r15, %rdi
callq 0xa353
movq (%rsp), %r13
incq %rbp
cmpq %r13, %rbp
jne 0xa204
cmpl $0x0, 0x30(%r12)
je 0xa341
movq 0x38(%r12), %rax
movq (%rax), %rax
movups 0x10(%rax), %xmm0
movups 0x20(%rax), %xmm1
movups %xmm0, 0x10(%r12)
movups %xmm1, 0x20(%r12)
jmp 0xa341
movq %rax, %r12
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq