// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xe330
movq -0x8(%rbp), %rax
cmpl $0xc, (%rax)
je 0xe348
leaq 0x349b(%rip), %rdi      # 0x117d2
leaq 0x3410(%rip), %rsi      # 0x1174e
movl $0x76, %edx
callq 0x4b20
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xe390
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xe37c
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0xe363
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xe61e
movq -0x28(%rbp), %rax
cmpl $0xb, (%rax)
je 0xe3c8
leaq 0x3443(%rip), %rdi      # 0x117fa
leaq 0x3390(%rip), %rsi      # 0x1174e
movl $0x81, %edx
callq 0x4b20
movq -0x28(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xe53e
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xe3fa
leaq 0x342f(%rip), %rdi      # 0x11818
leaq 0x335e(%rip), %rsi      # 0x1174e
movl $0x83, %edx
callq 0x4b20
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x212b(%rip), %rsi      # 0x10534
callq 0xbdf0
cmpl $0x0, %eax
je 0xe4f3
movb $0x0, %al
callq 0x4e30
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x4fe0
movl %eax, %ecx
movl -0x44(%rbp), %eax
cmpl %ecx, %eax
jge 0xe4dd
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
movl -0x34(%rbp), %esi
callq 0x5030
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
leaq 0x21ab(%rip), %rsi      # 0x10613
callq 0xbdf0
cmpl $0x0, %eax
je 0xe4b2
movl -0x34(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x4fe0
movl %eax, %ecx
movl -0x48(%rbp), %eax
subl $0x1, %ecx
cmpl %ecx, %eax
je 0xe4a3
movq -0x40(%rbp), %rdi
leaq 0x3383(%rip), %rsi      # 0x1181f
movb $0x0, %al
callq 0x4d50
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x4f10
jmp 0xe4dd
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rdi
callq 0xe630
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x4f10
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xe429
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3ea0
movq %rax, -0x10(%rbp)
jmp 0xe60d
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x2005(%rip), %rsi      # 0x10507
callq 0xbdf0
cmpl $0x0, %eax
je 0xe526
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x40f0
movq %rax, -0x10(%rbp)
jmp 0xe60d
leaq 0x1b2a(%rip), %rdi      # 0x10057
leaq 0x321a(%rip), %rsi      # 0x1174e
movl $0x9b, %edx
callq 0x4b20
movq -0x28(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xe561
leaq 0x32fc(%rip), %rdi      # 0x1184c
leaq 0x31f7(%rip), %rsi      # 0x1174e
movl $0x9d, %edx
callq 0x4b20
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x1fc4(%rip), %rsi      # 0x10534
callq 0xbdf0
cmpl $0x0, %eax
je 0xe5ca
movq -0x28(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0xe598
movq -0x28(%rbp), %rax
movq 0xa0(%rax), %rax
cmpl $0xc, (%rax)
je 0xe5b0
leaq 0x32b7(%rip), %rdi      # 0x11856
leaq 0x31a8(%rip), %rsi      # 0x1174e
movl $0x9f, %edx
callq 0x4b20
movq -0x28(%rbp), %rax
movq 0xa0(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0xe310
movq %rax, -0x10(%rbp)
jmp 0xe60d
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x4, %esi
callq 0xbbe0
testb $0x1, %al
jne 0xe5f8
leaq 0x329b(%rip), %rdi      # 0x11882
leaq 0x3160(%rip), %rsi      # 0x1174e
movl $0xa3, %edx
callq 0x4b20
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x4020
movq %rax, -0x10(%rbp)
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xe39c
movq -0x10(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)