// File: /workspace/github_c_makefile_star2_O2/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 0x9a8d
movq %rdi, %r15
cmpl $0xc, (%rdi)
jne 0x9a8d
movq 0x18(%r15), %r14
testq %r14, %r14
je 0x987b
movq %r14, %rcx
movq %rcx, %rax
movq 0x20(%rcx), %rcx
testq %rcx, %rcx
jne 0x9869
movq %rsi, 0x20(%rax)
jmp 0x987e
movq %rsi, %r14
addq $0x20, %r15
leaq 0x1d3b(%rip), %r12      # 0xb5c4
leaq 0x1e11(%rip), %r13      # 0xb6a1
movq (%r15), %rbx
testq %rbx, %rbx
je 0x99f2
cmpl $0xb, (%rbx)
jne 0x9a04
leaq 0x18(%rbx), %r15
cmpq $0x0, 0x18(%rbx)
movq 0x10(%rbx), %rdi
je 0x9926
testq %rdi, %rdi
je 0x9a1c
movq %r12, %rsi
callq 0x87de
testl %eax, %eax
je 0x995f
movq %r15, (%rsp)
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x3ea7
movq %rax, %rbp
movq 0x20(%rbx), %rdi
callq 0x3fb7
cmpl %eax, %r12d
jge 0x99ac
movq 0x20(%rbx), %rdi
movl %r12d, %esi
callq 0x3fdf
movq %rax, %r15
movq %rax, %rdi
movq %r13, %rsi
callq 0x87de
testl %eax, %eax
jne 0x998b
movq %r15, %rdi
callq 0x9aa3
movq %rbp, %rdi
movq %rax, %rsi
callq 0x3f25
incl %r12d
jmp 0x98de
movq %r12, %rsi
callq 0x87de
testl %eax, %eax
je 0x99ca
movq 0xa0(%rbx), %rdi
testq %rdi, %rdi
je 0x9a34
cmpl $0xc, (%rdi)
jne 0x9a34
movq %r14, %rsi
callq 0x983d
movq %rax, %r14
jmp 0x9890
movq 0x10(%rbx), %rdi
leaq 0x1c2f(%rip), %rsi      # 0xb599
callq 0x87de
testl %eax, %eax
je 0x9a4c
movq 0x20(%rbx), %rsi
movq %r14, %rdi
callq 0x3548
movq %rax, %r14
jmp 0x9890
movq 0x20(%rbx), %rdi
callq 0x3fb7
subl %eax, %r12d
cmpl $-0x1, %r12d
jne 0x9a64
movq %rbp, %rdi
movq %r15, %rsi
callq 0x3f25
movq %r14, %rdi
movq %rbp, %rsi
callq 0x33f8
movq %rax, %r14
movq (%rsp), %r15
leaq 0x1bff(%rip), %r12      # 0xb5c4
jmp 0x9890
movq 0x10(%rbx), %rdi
pushq $0x4
popq %rsi
callq 0x86b7
testb %al, %al
je 0x9a75
movq 0x10(%rbx), %rdi
movq %r14, %rsi
callq 0x34cd
movq %rax, %r14
jmp 0x9890
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2f3c(%rip), %rdi      # 0xc947
leaq 0x2e89(%rip), %rsi      # 0xc89b
movl $0x81, %edx
callq 0x3cc4
leaq 0x2f42(%rip), %rdi      # 0xc965
leaq 0x2e71(%rip), %rsi      # 0xc89b
movl $0x83, %edx
callq 0x3cc4
leaq 0x2f5e(%rip), %rdi      # 0xc999
leaq 0x2e59(%rip), %rsi      # 0xc89b
movl $0x9f, %edx
callq 0x3cc4
leaq 0x1634(%rip), %rdi      # 0xb087
leaq 0x2e41(%rip), %rsi      # 0xc89b
movl $0x9b, %edx
callq 0x3cc4
leaq 0x2f01(%rip), %rsi      # 0xc96c
movq %r15, %rdi
xorl %eax, %eax
callq 0x3de9
leaq 0x2f49(%rip), %rdi      # 0xc9c5
leaq 0x2e18(%rip), %rsi      # 0xc89b
movl $0xa3, %edx
callq 0x3cc4
leaq 0x2e8b(%rip), %rdi      # 0xc91f
leaq 0x2e00(%rip), %rsi      # 0xc89b
pushq $0x76
popq %rdx
callq 0x3cc4