// File: /workspace/github_c_makefile_star2_O3/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 0xa611
cmpl $0xc, (%rdi)
jne 0xa611
movq 0x18(%rdi), %rbx
testq %rbx, %rbx
je 0xa408
movq %rbx, %rcx
movq %rcx, %rax
movq 0x20(%rcx), %rcx
testq %rcx, %rcx
jne 0xa3f6
movq %rsi, 0x20(%rax)
jmp 0xa40b
movq %rsi, %rbx
movq 0x20(%rdi), %r14
testq %r14, %r14
je 0xa576
leaq 0x11a5(%rip), %r15      # 0xb5c4
leaq 0x127b(%rip), %r12      # 0xb6a1
cmpl $0xb, (%r14)
jne 0xa588
cmpq $0x0, 0x18(%r14)
movq 0x10(%r14), %rdi
je 0xa4b9
testq %rdi, %rdi
je 0xa5a0
movq %r15, %rsi
callq 0x9210
testl %eax, %eax
je 0xa4e8
xorl %eax, %eax
callq 0x47d2
movq %rax, %r13
movq 0x20(%r14), %rdi
callq 0x48ee
testl %eax, %eax
jle 0xa554
xorl %ebp, %ebp
movq 0x20(%r14), %rdi
movl %ebp, %esi
callq 0x4918
movq %rax, %r15
movq %rax, %rdi
movq %r12, %rsi
callq 0x9210
testl %eax, %eax
jne 0xa535
movq %r15, %rdi
callq 0xa629
movq %r13, %rdi
movq %rax, %rsi
callq 0x485a
incl %ebp
movq 0x20(%r14), %rdi
callq 0x48ee
cmpl %eax, %ebp
jl 0xa471
jmp 0xa554
movq %r15, %rsi
callq 0x9210
testl %eax, %eax
je 0xa50e
movq 0xa0(%r14), %rdi
testq %rdi, %rdi
je 0xa5b8
cmpl $0xc, (%rdi)
jne 0xa5b8
movq %rbx, %rsi
callq 0xa3cd
jmp 0xa530
movq 0x10(%r14), %rdi
leaq 0x10a6(%rip), %rsi      # 0xb599
callq 0x9210
testl %eax, %eax
je 0xa5d0
movq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x43b0
jmp 0xa530
movq 0x10(%r14), %rdi
movl $0x4, %esi
callq 0x90d3
testb %al, %al
je 0xa5e8
movq 0x10(%r14), %rdi
movq %rbx, %rsi
callq 0x431b
movq %rax, %rbx
jmp 0xa569
movq 0x20(%r14), %rdi
callq 0x48ee
subl %eax, %ebp
cmpl $-0x1, %ebp
jne 0xa600
movq %r13, %rdi
movq %r15, %rsi
callq 0x485a
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4224
movq %rax, %rbx
leaq 0x105b(%rip), %r15      # 0xb5c4
movq 0x18(%r14), %r14
testq %r14, %r14
jne 0xa426
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x23d0(%rip), %rdi      # 0xc95f
leaq 0x231d(%rip), %rsi      # 0xc8b3
movl $0x81, %edx
callq 0x46d0
leaq 0x23d6(%rip), %rdi      # 0xc97d
leaq 0x2305(%rip), %rsi      # 0xc8b3
movl $0x83, %edx
callq 0x46d0
leaq 0x23f2(%rip), %rdi      # 0xc9b1
leaq 0x22ed(%rip), %rsi      # 0xc8b3
movl $0x9f, %edx
callq 0x46d0
leaq 0xab0(%rip), %rdi       # 0xb087
leaq 0x22d5(%rip), %rsi      # 0xc8b3
movl $0x9b, %edx
callq 0x46d0
leaq 0x23ee(%rip), %rdi      # 0xc9dd
leaq 0x22bd(%rip), %rsi      # 0xc8b3
movl $0xa3, %edx
callq 0x46d0
leaq 0x237d(%rip), %rsi      # 0xc984
movq %r15, %rdi
xorl %eax, %eax
callq 0x470c
leaq 0x231f(%rip), %rdi      # 0xc937
leaq 0x2294(%rip), %rsi      # 0xc8b3
movl $0x76, %edx
callq 0x46d0