// File: /workspace/github_c_makefile_star2_O0/hikalium[P]compilium/type.c
// Function: CreateBaseTypeFromDeclSpecs
static struct Node *CreateBaseTypeFromDeclSpecs(struct SymbolEntry *ctx,
                                                struct Node *decl_specs) {
  // 6.2.5 Types
  assert(IsASTList(decl_specs));
  struct Node *type_qual = NULL;
  struct Node *type_spec = NULL;
  for (int i = 0; i < GetSizeOfList(decl_specs); i++) {
    struct Node *t = GetNodeAt(decl_specs, i);
    if (IsTokenWithType(t, kTokenKwTypedef) ||
        IsTokenWithType(t, kTokenKwUnsigned) ||
        IsTokenWithType(t, kTokenKwExtern)) {
      continue;
    }
    if (IsTokenWithType(t, kTokenKwConst)) {
      assert(!type_qual);
      type_qual = t;
      continue;
    }
    assert(!type_spec);
    type_spec = t;
  }
  assert(type_spec);
  if (IsToken(type_spec)) {
    if (!IsTokenWithType(type_spec, kTokenKwInt) &&
        !IsTokenWithType(type_spec, kTokenKwChar) &&
        !IsTokenWithType(type_spec, kTokenKwLong) &&
        !IsEqualTokenWithCStr(type_spec, "__builtin_va_list") &&
        !IsTokenWithType(type_spec, kTokenKwVoid)) {
      ErrorWithToken(type_spec, "Unexpected token for base type specifier");
    }
    return CreateTypeBase(type_spec);
  }
  if (type_spec->type == kASTStructSpec) {
    if (!type_spec->struct_member_dict) {
      assert(type_spec->tag);
      struct Node *resolved_type = FindStructType(ctx, type_spec->tag);
      if (resolved_type) return resolved_type;
      return CreateTypeStruct(type_spec->tag, NULL);
    }
    return CreateTypeStruct(type_spec->tag, type_spec);
  }
  if (type_spec->type == kTypeStruct || type_spec->type == kTypeBase) {
    // typedef_type
    return type_spec;
  }
  PrintASTNode(decl_specs);
  assert(false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x39a0
testb $0x1, %al
jne 0xe715
leaq 0x35be(%rip), %rdi      # 0x11cc2
leaq 0x3043(%rip), %rsi      # 0x1174e
movl $0xac, %edx
callq 0x4b20
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4fe0
movl %eax, %ecx
movl -0x44(%rbp), %eax
cmpl %ecx, %eax
jge 0xe804
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x5030
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movl $0x13, %esi
callq 0xbbe0
testb $0x1, %al
jne 0xe790
movq -0x38(%rbp), %rdi
movl $0x14, %esi
callq 0xbbe0
testb $0x1, %al
jne 0xe790
movq -0x38(%rbp), %rdi
movl $0xa, %esi
callq 0xbbe0
testb $0x1, %al
jne 0xe790
jmp 0xe792
jmp 0xe7f6
movq -0x38(%rbp), %rdi
movl $0x7, %esi
callq 0xbbe0
testb $0x1, %al
jne 0xe7a6
jmp 0xe7cf
cmpq $0x0, -0x20(%rbp)
je 0xe7c5
leaq 0x3524(%rip), %rdi      # 0x11cd8
leaq 0x2f93(%rip), %rsi      # 0x1174e
movl $0xb7, %edx
callq 0x4b20
movq -0x38(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0xe7f6
cmpq $0x0, -0x28(%rbp)
je 0xe7ee
leaq 0x3506(%rip), %rdi      # 0x11ce3
leaq 0x2f6a(%rip), %rsi      # 0x1174e
movl $0xbb, %edx
callq 0x4b20
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xe72c
cmpq $0x0, -0x28(%rbp)
jne 0xe823
leaq 0x34d2(%rip), %rdi      # 0x11ce4
leaq 0x2f35(%rip), %rsi      # 0x1174e
movl $0xbe, %edx
callq 0x4b20
movq -0x28(%rbp), %rdi
callq 0xbbb0
testb $0x1, %al
jne 0xe835
jmp 0xe8b6
movq -0x28(%rbp), %rdi
movl $0xd, %esi
callq 0xbbe0
testb $0x1, %al
jne 0xe8a4
movq -0x28(%rbp), %rdi
movl $0x6, %esi
callq 0xbbe0
testb $0x1, %al
jne 0xe8a4
movq -0x28(%rbp), %rdi
movl $0xe, %esi
callq 0xbbe0
testb $0x1, %al
jne 0xe8a4
movq -0x28(%rbp), %rdi
leaq 0x297f(%rip), %rsi      # 0x111f5
callq 0xbdf0
cmpl $0x0, %eax
jne 0xe8a4
movq -0x28(%rbp), %rdi
movl $0x15, %esi
callq 0xbbe0
testb $0x1, %al
jne 0xe8a4
movq -0x28(%rbp), %rdi
leaq 0x3451(%rip), %rsi      # 0x11cee
movb $0x0, %al
callq 0x4d50
movq -0x28(%rbp), %rdi
callq 0x3e10
movq %rax, -0x8(%rbp)
jmp 0xe98e
movq -0x28(%rbp), %rax
cmpl $0x13, (%rax)
jne 0xe951
movq -0x28(%rbp), %rax
cmpq $0x0, 0x68(%rax)
jne 0xe937
movq -0x28(%rbp), %rax
cmpq $0x0, 0xe8(%rax)
jne 0xe8f4
leaq 0x3434(%rip), %rdi      # 0x11d17
leaq 0x2e64(%rip), %rsi      # 0x1174e
movl $0xcb, %edx
callq 0x4b20
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0xe8(%rax), %rsi
callq 0xbb40
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0xe91d
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xe98e
movq -0x28(%rbp), %rax
movq 0xe8(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3fb0
movq %rax, -0x8(%rbp)
jmp 0xe98e
movq -0x28(%rbp), %rax
movq 0xe8(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x3fb0
movq %rax, -0x8(%rbp)
jmp 0xe98e
movq -0x28(%rbp), %rax
cmpl $0x19, (%rax)
je 0xe963
movq -0x28(%rbp), %rax
cmpl $0x14, (%rax)
jne 0xe96d
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xe98e
movq -0x18(%rbp), %rdi
callq 0x4190
leaq 0x16da(%rip), %rdi      # 0x10057
leaq 0x2dca(%rip), %rsi      # 0x1174e
movl $0xd7, %edx
callq 0x4b20
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)