// File: /workspace/github_c_makefile_star2_O0/hikalium[P]compilium/type.c
// Function: TestType
_Noreturn void TestType() {
  fprintf(stderr, "Testing Type...\n");

  struct Node *int_type = CreateTypeBase(CreateToken("int"));
  struct Node *another_int_type = CreateTypeBase(CreateToken("int"));
  struct Node *lvalue_int_type = CreateTypeLValue(int_type);
  struct Node *pointer_of_int_type = CreateTypePointer(int_type);
  struct Node *another_pointer_of_int_type =
      CreateTypePointer(another_int_type);

  assert(IsSameTypeExceptAttr(int_type, int_type));
  assert(IsSameTypeExceptAttr(int_type, another_int_type));
  assert(IsSameTypeExceptAttr(int_type, lvalue_int_type));
  assert(IsSameTypeExceptAttr(lvalue_int_type, lvalue_int_type));
  assert(!IsSameTypeExceptAttr(int_type, pointer_of_int_type));
  assert(
      IsSameTypeExceptAttr(pointer_of_int_type, another_pointer_of_int_type));
  assert(GetSizeOfType(int_type) == 4);
  assert(GetSizeOfType(pointer_of_int_type) == 8);

  struct Node *char_type = CreateTypeBase(CreateToken("char"));
  assert(GetSizeOfType(char_type) == 1);

  struct Node *long_type = CreateTypeBase(CreateToken("long"));
  assert(GetSizeOfType(long_type) == 4);

  struct Node *ppi_type = CreateTypePointer(pointer_of_int_type);

  struct Node *args_i = AllocList();
  PushToList(args_i, int_type);
  struct Node *if_i_type = CreateTypeFunction(int_type, args_i);
  struct Node *ppif_i_type = CreateTypeFunction(ppi_type, args_i);

  struct Node *args_pi = AllocList();
  PushToList(args_pi, pointer_of_int_type);
  struct Node *if_pi_type = CreateTypeFunction(int_type, args_pi);
  struct Node *ppif_pi_type = CreateTypeFunction(ppi_type, args_pi);

  struct Node *type;

  type = CreateTypeFromInput("void* (*f)(int size);");
  PrintASTNode(type);
  type = GetTypeWithoutAttr(type);
  assert(type->type == kTypePointer);
  type = type->right;
  assert(type->type == kTypeFunction);
  type = GetReturnTypeOfFunction(type);
  assert(type->type == kTypePointer);
  assert(GetSizeOfType(type) == 8);

  type = CreateTypeFromInput("int v;");
  PrintASTNode(type);
  assert(IsSameTypeExceptAttr(type, int_type));

  type = CreateTypeFromInput("int *p;");
  PrintASTNode(type);
  assert(IsSameTypeExceptAttr(type, pointer_of_int_type));

  type = CreateTypeFromInput("int **p;");
  PrintASTNode(type);
  assert(IsSameTypeExceptAttr(type, ppi_type));

  type = CreateTypeFromInput("int f(int a);");
  PrintASTNode(type);
  assert(IsSameTypeExceptAttr(type, if_i_type));
  assert(!IsSameTypeExceptAttr(type, if_pi_type));

  type = CreateTypeFromInput("int f(int *a);");
  PrintASTNode(type);
  assert(!IsSameTypeExceptAttr(type, if_i_type));
  assert(IsSameTypeExceptAttr(type, if_pi_type));

  type = CreateTypeFromInput("int **f(int a);");
  PrintASTNode(type);
  assert(IsSameTypeExceptAttr(type, ppif_i_type));
  assert(!IsSameTypeExceptAttr(type, ppif_pi_type));
  PrintASTNode(if_i_type);
  assert(!IsSameTypeExceptAttr(type, if_i_type));
  assert(!IsSameTypeExceptAttr(type, if_pi_type));

  type =
      CreateTypeFromInput("void (*signal(int sig, void (*func)(int)))(int);");
  assert(type && GetTypeWithoutAttr(type) &&
         GetTypeWithoutAttr(type)->type == kTypeFunction);
  PrintASTNode(type);

  type = CreateTypeFromInput("struct IncompleteStruct;");
  assert(type);
  PrintASTNode(type);

  fprintf(stderr, "PASS\n");
  exit(EXIT_SUCCESS);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x65b6(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x2e7a(%rip), %rsi      # 0x118c6
movb $0x0, %al
callq 0x2100
leaq 0x15de(%rip), %rdi      # 0x10038
callq 0xc8d0
movq %rax, %rdi
callq 0x3e10
movq %rax, -0x8(%rbp)
leaq 0x15c6(%rip), %rdi      # 0x10038
callq 0xc8d0
movq %rax, %rdi
callq 0x3e10
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3e40
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3e70
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3e70
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
jne 0xead4
leaq 0x2e14(%rip), %rdi      # 0x118d7
leaq 0x2c84(%rip), %rsi      # 0x1174e
movl $0x103, %edx            # imm = 0x103
callq 0x4b20
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
jne 0xeafe
leaq 0x2e13(%rip), %rdi      # 0x11900
leaq 0x2c5a(%rip), %rsi      # 0x1174e
movl $0x104, %edx            # imm = 0x104
callq 0x4b20
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
jne 0xeb28
leaq 0x2e1a(%rip), %rdi      # 0x11931
leaq 0x2c30(%rip), %rsi      # 0x1174e
movl $0x105, %edx            # imm = 0x105
callq 0x4b20
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
jne 0xeb52
leaq 0x2e20(%rip), %rdi      # 0x11961
leaq 0x2c06(%rip), %rsi      # 0x1174e
movl $0x106, %edx            # imm = 0x106
callq 0x4b20
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
je 0xeb7c
leaq 0x2e2d(%rip), %rdi      # 0x11998
leaq 0x2bdc(%rip), %rsi      # 0x1174e
movl $0x107, %edx            # imm = 0x107
callq 0x4b20
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
jne 0xeba6
leaq 0x2e38(%rip), %rdi      # 0x119cd
leaq 0x2bb2(%rip), %rsi      # 0x1174e
movl $0x109, %edx            # imm = 0x109
callq 0x4b20
movq -0x8(%rbp), %rdi
callq 0xe040
cmpl $0x4, %eax
je 0xebcc
leaq 0x2e59(%rip), %rdi      # 0x11a14
leaq 0x2b8c(%rip), %rsi      # 0x1174e
movl $0x10a, %edx            # imm = 0x10A
callq 0x4b20
movq -0x20(%rbp), %rdi
callq 0xe040
cmpl $0x8, %eax
je 0xebf2
leaq 0x2e50(%rip), %rdi      # 0x11a31
leaq 0x2b66(%rip), %rsi      # 0x1174e
movl $0x10b, %edx            # imm = 0x10B
callq 0x4b20
leaq 0x1443(%rip), %rdi      # 0x1003c
callq 0xc8d0
movq %rax, %rdi
callq 0x3e10
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0xe040
cmpl $0x1, %eax
je 0xec30
leaq 0x2e3a(%rip), %rdi      # 0x11a59
leaq 0x2b28(%rip), %rsi      # 0x1174e
movl $0x10e, %edx            # imm = 0x10E
callq 0x4b20
leaq 0x2a96(%rip), %rdi      # 0x116cd
callq 0xc8d0
movq %rax, %rdi
callq 0x3e10
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0xe040
cmpl $0x4, %eax
je 0xec6e
leaq 0x2e1a(%rip), %rdi      # 0x11a77
leaq 0x2aea(%rip), %rsi      # 0x1174e
movl $0x111, %edx            # imm = 0x111
callq 0x4b20
movq -0x20(%rbp), %rdi
callq 0x3e70
movq %rax, -0x40(%rbp)
movb $0x0, %al
callq 0x4e30
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x4f10
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x3ea0
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x3ea0
movq %rax, -0x58(%rbp)
movb $0x0, %al
callq 0x4e30
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4f10
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x3ea0
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x3ea0
movq %rax, -0x70(%rbp)
leaq 0x2d9f(%rip), %rdi      # 0x11a95
callq 0xf0d0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x4190
movq -0x78(%rbp), %rdi
callq 0xddf0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x16, (%rax)
je 0xed36
leaq 0x138c(%rip), %rdi      # 0x100b1
leaq 0x2a22(%rip), %rsi      # 0x1174e
movl $0x124, %edx            # imm = 0x124
callq 0x4b20
movq -0x78(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x17, (%rax)
je 0xed63
leaq 0x16bb(%rip), %rdi      # 0x1040d
leaq 0x29f5(%rip), %rsi      # 0x1174e
movl $0x126, %edx            # imm = 0x126
callq 0x4b20
movq -0x78(%rbp), %rdi
callq 0x3f10
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x16, (%rax)
je 0xed91
leaq 0x1331(%rip), %rdi      # 0x100b1
leaq 0x29c7(%rip), %rsi      # 0x1174e
movl $0x128, %edx            # imm = 0x128
callq 0x4b20
movq -0x78(%rbp), %rdi
callq 0xe040
cmpl $0x8, %eax
je 0xedb7
leaq 0x2d05(%rip), %rdi      # 0x11aab
leaq 0x29a1(%rip), %rsi      # 0x1174e
movl $0x129, %edx            # imm = 0x129
callq 0x4b20
leaq 0x2d06(%rip), %rdi      # 0x11ac4
callq 0xf0d0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x4190
movq -0x78(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
jne 0xedfa
leaq 0x2ce2(%rip), %rdi      # 0x11acb
leaq 0x295e(%rip), %rsi      # 0x1174e
movl $0x12d, %edx            # imm = 0x12D
callq 0x4b20
leaq 0x2cef(%rip), %rdi      # 0x11af0
callq 0xf0d0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x4190
movq -0x78(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
jne 0xee3d
leaq 0x2ccc(%rip), %rdi      # 0x11af8
leaq 0x291b(%rip), %rsi      # 0x1174e
movl $0x131, %edx            # imm = 0x131
callq 0x4b20
leaq 0x2ce4(%rip), %rdi      # 0x11b28
callq 0xf0d0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x4190
movq -0x78(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
jne 0xee80
leaq 0x2cc2(%rip), %rdi      # 0x11b31
leaq 0x28d8(%rip), %rsi      # 0x1174e
movl $0x135, %edx            # imm = 0x135
callq 0x4b20
leaq 0x2ccf(%rip), %rdi      # 0x11b56
callq 0xf0d0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x4190
movq -0x78(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
jne 0xeec3
leaq 0x2cea(%rip), %rdi      # 0x11b9c
leaq 0x2895(%rip), %rsi      # 0x1174e
movl $0x139, %edx            # imm = 0x139
callq 0x4b20
movq -0x78(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
je 0xeeed
leaq 0x2c88(%rip), %rdi      # 0x11b64
leaq 0x286b(%rip), %rsi      # 0x1174e
movl $0x13a, %edx            # imm = 0x13A
callq 0x4b20
leaq 0x2c98(%rip), %rdi      # 0x11b8c
callq 0xf0d0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x4190
movq -0x78(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
je 0xef30
leaq 0x2c7c(%rip), %rdi      # 0x11b9b
leaq 0x2828(%rip), %rsi      # 0x1174e
movl $0x13e, %edx            # imm = 0x13E
callq 0x4b20
movq -0x78(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
jne 0xef5a
leaq 0x2c1c(%rip), %rdi      # 0x11b65
leaq 0x27fe(%rip), %rsi      # 0x1174e
movl $0x13f, %edx            # imm = 0x13F
callq 0x4b20
leaq 0x2c61(%rip), %rdi      # 0x11bc2
callq 0xf0d0
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x4190
movq -0x78(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
jne 0xef9d
leaq 0x2c46(%rip), %rdi      # 0x11bd2
leaq 0x27bb(%rip), %rsi      # 0x1174e
movl $0x143, %edx            # imm = 0x143
callq 0x4b20
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
je 0xefc7
leaq 0x2c44(%rip), %rdi      # 0x11bfa
leaq 0x2791(%rip), %rsi      # 0x1174e
movl $0x144, %edx            # imm = 0x144
callq 0x4b20
movq -0x50(%rbp), %rdi
callq 0x4190
movq -0x78(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
je 0xeffa
leaq 0x2bb2(%rip), %rdi      # 0x11b9b
leaq 0x275e(%rip), %rsi      # 0x1174e
movl $0x146, %edx            # imm = 0x146
callq 0x4b20
movq -0x78(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0xdc00
cmpl $0x0, %eax
je 0xf024
leaq 0x2b51(%rip), %rdi      # 0x11b64
leaq 0x2734(%rip), %rsi      # 0x1174e
movl $0x147, %edx            # imm = 0x147
callq 0x4b20
leaq 0x2bf9(%rip), %rdi      # 0x11c24
callq 0xf0d0
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0xf058
movq -0x78(%rbp), %rdi
callq 0xddf0
cmpq $0x0, %rax
je 0xf058
movq -0x78(%rbp), %rdi
callq 0xddf0
cmpl $0x17, (%rax)
je 0xf070
leaq 0x2bf6(%rip), %rdi      # 0x11c55
leaq 0x26e8(%rip), %rsi      # 0x1174e
movl $0x14c, %edx            # imm = 0x14C
callq 0x4b20
movq -0x78(%rbp), %rdi
callq 0x4190
leaq 0x2c29(%rip), %rdi      # 0x11ca9
callq 0xf0d0
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0xf0a8
leaq 0xf8f(%rip), %rdi       # 0x10026
leaq 0x26b0(%rip), %rsi      # 0x1174e
movl $0x150, %edx            # imm = 0x150
callq 0x4b20
movq -0x78(%rbp), %rdi
callq 0x4190
movq 0x5f40(%rip), %rax      # 0x14ff8
movq (%rax), %rdi
leaq 0x1690(%rip), %rsi      # 0x10752
movb $0x0, %al
callq 0x2100
xorl %edi, %edi
callq 0x2190