// File: /workspace/github_c_makefile_star2_O1/hikalium[P]compilium/type.c
// Function: CreateTypeFromDecltor
struct Node *CreateTypeFromDecltor(struct Node *decltor, struct Node *type) {
  assert(decltor && decltor->type == kASTDecltor);
  struct Node *pointer = decltor->left;
  if (pointer) {
    struct Node *p = pointer;
    while (p->right) {
      p = p->right;
    }
    p->right = type;
    type = pointer;
  }
  for (struct Node *dd = decltor->right; dd; dd = dd->left) {
    assert(dd->type == kASTDirectDecltor);
    if (dd->left) {
      assert(dd->op);
      if (IsEqualTokenWithCStr(dd->op, "(")) {
        // direct-declarator ( parameter-type-list | identifier-list_opt )
        struct Node *arg_type_list = AllocList();
        for (int i = 0; i < GetSizeOfList(dd->right); i++) {
          struct Node *arg = GetNodeAt(dd->right, i);
          if (IsEqualTokenWithCStr(arg, "...")) {
            if (i != GetSizeOfList(dd->right) - 1) {
              ErrorWithToken(arg,
                             "va arg is only allowed at the end of params.");
            }
            PushToList(arg_type_list, arg);
            break;
          }
          PushToList(arg_type_list, CreateTypeFromDecl(arg));
        }
        type = CreateTypeFunction(type, arg_type_list);
        continue;
      }
      if (IsEqualTokenWithCStr(dd->op, "[")) {
        // direct-declarator [ list ]
        type = CreateTypeArray(type, dd->right);
        continue;
      }
      assert(false);
    }
    assert(!dd->left);
    if (IsEqualTokenWithCStr(dd->op, "(")) {
      assert(dd->value && dd->value->type == kASTDecltor);
      type = CreateTypeFromDecltor(dd->value, type);
      continue;
    }
    assert(IsTokenWithType(dd->op, kTokenIdent));
    type = CreateTypeAttrIdent(dd->op, type);
  }
  return type;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0xa664
cmpl $0xc, (%rdi)
jne 0xa664
movq 0x18(%rdi), %rbx
testq %rbx, %rbx
je 0xa45a
movq %rbx, %rcx
movq %rcx, %rax
movq 0x20(%rcx), %rcx
testq %rcx, %rcx
jne 0xa448
movq %rsi, 0x20(%rax)
jmp 0xa45d
movq %rsi, %rbx
movq 0x20(%rdi), %r12
testq %r12, %r12
je 0xa5c9
leaq 0x1153(%rip), %r14      # 0xb5c4
cmpl $0xb, (%r12)
jne 0xa5ec
cmpq $0x0, 0x18(%r12)
movq 0x10(%r12), %rdi
je 0xa53c
testq %rdi, %rdi
je 0xa604
movq %r14, %rsi
callq 0x9278
testl %eax, %eax
je 0xa56c
xorl %eax, %eax
callq 0x4806
movq %rax, %r13
movq 0x20(%r12), %rdi
callq 0x4922
testl %eax, %eax
jle 0xa525
xorl %ebp, %ebp
movq 0x20(%r12), %rdi
movl %ebp, %esi
callq 0x494c
movq %rax, %r15
movq %rax, %rdi
leaq 0x11c8(%rip), %rsi      # 0xb6a1
callq 0x9278
movl %eax, %r14d
testl %eax, %eax
je 0xa4fa
movq 0x20(%r12), %rdi
callq 0x4922
decl %eax
cmpl %eax, %ebp
je 0xa505
jmp 0xa5db
movq %r15, %rdi
callq 0xa67c
movq %rax, %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x488e
testl %r14d, %r14d
jne 0xa525
incl %ebp
movq 0x20(%r12), %rdi
callq 0x4922
cmpl %eax, %ebp
jl 0xa4c0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4218
movq %rax, %rbx
leaq 0x108a(%rip), %r14      # 0xb5c4
jmp 0xa5bb
movq %r14, %rsi
callq 0x9278
testl %eax, %eax
je 0xa594
movq 0xa0(%r12), %rdi
testq %rdi, %rdi
je 0xa61c
cmpl $0xc, (%rdi)
jne 0xa61c
movq %rbx, %rsi
callq 0xa41f
jmp 0xa5b8
movq 0x10(%r12), %rdi
leaq 0x1021(%rip), %rsi      # 0xb599
callq 0x9278
testl %eax, %eax
je 0xa634
movq 0x20(%r12), %rsi
movq %rbx, %rdi
callq 0x43a4
jmp 0xa5b8
movq 0x10(%r12), %rdi
movl $0x4, %esi
callq 0x913f
testb %al, %al
je 0xa64c
movq 0x10(%r12), %rdi
movq %rbx, %rsi
callq 0x430f
movq %rax, %rbx
movq 0x18(%r12), %r12
testq %r12, %r12
jne 0xa471
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x238e(%rip), %rsi      # 0xc970
movq %r15, %rdi
xorl %eax, %eax
callq 0x4740
leaq 0x2358(%rip), %rdi      # 0xc94b
leaq 0x22a5(%rip), %rsi      # 0xc89f
movl $0x81, %edx
callq 0x4704
leaq 0x235e(%rip), %rdi      # 0xc969
leaq 0x228d(%rip), %rsi      # 0xc89f
movl $0x83, %edx
callq 0x4704
leaq 0x237a(%rip), %rdi      # 0xc99d
leaq 0x2275(%rip), %rsi      # 0xc89f
movl $0x9f, %edx
callq 0x4704
leaq 0xa4c(%rip), %rdi       # 0xb087
leaq 0x225d(%rip), %rsi      # 0xc89f
movl $0x9b, %edx
callq 0x4704
leaq 0x2376(%rip), %rdi      # 0xc9c9
leaq 0x2245(%rip), %rsi      # 0xc89f
movl $0xa3, %edx
callq 0x4704
leaq 0x22b8(%rip), %rdi      # 0xc923
leaq 0x222d(%rip), %rsi      # 0xc89f
movl $0x76, %edx
callq 0x4704