// File: /workspace/github_c_makefile_star2_O0/mikeakohn[P]print_pe/build/../src/pdb.c
// Function: print_pdb_tpi_stream
void print_pdb_tpi_stream(
  struct pdb_dir_t *pdb_dir,
  struct pdb_header_t *pdb_header,
  FILE *in,
  int index)
{
  struct pdb_tpi_header_t tpi;

  read_data(pdb_dir, index, pdb_header->block_size, in);

  uint8_t *data = pdb_dir->heap;

  tpi.version = get_uint32(data + 0);
  tpi.header_size = get_uint32(data + 4);
  tpi.type_index_begin = get_uint32(data + 8);
  tpi.type_index_end = get_uint32(data + 12);
  tpi.type_record_bytes = get_uint32(data + 16);
  tpi.hash_stream_index = get_uint16(data + 20);
  tpi.hash_aux_stream_index = get_uint16(data + 22);
  tpi.hash_key_size = get_uint32(data + 24);
  tpi.num_hash_buckets = get_uint32(data + 28);
  tpi.hash_value_buffer_offset = get_int32(data + 32);
  tpi.hash_value_buffer_length = get_uint32(data + 36);
  tpi.index_offset_buffer_offset = get_int32(data + 40);
  tpi.index_offset_buffer_length = get_uint32(data + 44);
  tpi.hash_adj_buffer_offset = get_int32(data + 48);
  tpi.hash_adj_buffer_length = get_uint32(data + 52);

  printf(" -- %s Stream --\n", index == 2 ? "TPI" : "IPI");
  printf("                   version: %d\n", tpi.version);
  printf("               header_size: %d\n", tpi.header_size);
  printf("          type_index_begin: %d\n", tpi.type_index_begin);
  printf("            type_index_end: %d\n", tpi.type_index_end);
  printf("         type_record_bytes: %d\n", tpi.type_record_bytes);
  printf("         hash_stream_index: %d\n", tpi.hash_stream_index);
  printf("     hash_aux_stream_index: %d\n", tpi.hash_aux_stream_index);
  printf("             hash_key_size: %d\n", tpi.hash_key_size);
  printf("          num_hash_buckets: %d\n", tpi.num_hash_buckets);
  printf("  hash_value_buffer_offset: %d\n", tpi.hash_value_buffer_offset);
  printf("  hash_value_buffer_length: %d\n", tpi.hash_value_buffer_length);
  printf("index_offset_buffer_offset: %d\n", tpi.index_offset_buffer_offset);
  printf("index_offset_buffer_length: %d\n", tpi.index_offset_buffer_length);
  printf("    hash_adj_buffer_offset: %d\n", tpi.hash_adj_buffer_offset);
  printf("    hash_adj_buffer_length: %d\n", tpi.hash_adj_buffer_length);
  printf("\n");

  int offset = 0;
  int id, unknown, n;
  uint8_t *next = data + tpi.header_size;

  while (offset < tpi.type_record_bytes)
  {
    struct type_record_t *type_record = (struct type_record_t *)next;
    int total_length = type_record->length + 2;

    switch (type_record->type)
    {
      case 0x1001:
        printf(" %d 0x%04x MODIFIER\n",
          type_record->length,
          type_record->type);
        break;
      case 0x1002:
        printf(" %d 0x%04x POINTER\n",
          type_record->length,
          type_record->type);
        break;
      case 0x1008:
        printf(" %d 0x%04x PROCEDURE\n",
          type_record->length,
          type_record->type);
        break;
      case 0x1009:
        printf(" %d 0x%04x MFUNCTION\n",
          type_record->length,
          type_record->type);
        break;
      case 0x1201:
        printf(" %d 0x%04x ARGLIST\n",
          type_record->length,
          type_record->type);
        break;
      case 0x1203:
        printf(" %d 0x%04x FIELDLIST\n",
          type_record->length,
          type_record->type);
        break;
      case 0x1206:
        printf(" %d 0x%04x METHODLIST\n",
          type_record->length,
          type_record->type);
        break;
      case 0x1503:
        printf(" %d 0x%04x ARRAY\n",
          type_record->length,
          type_record->type);
        break;
      case 0x1504:
        printf(" %d 0x%04x CLASS %s\n",
          type_record->length,
          type_record->type,
          next + 22);
        break;
      case 0x1505:
        printf(" %d 0x%04x STRUCTURE %s\n",
          type_record->length,
          type_record->type,
          next + 22);
        //printf("offset=0x%04x\n", offset + 56);
        break;
      case 0x1507:
        printf(" %d 0x%04x ENUM\n",
          type_record->length,
          type_record->type);
        break;
      case 0x1601:
        id = get_uint32(next + 4);
        unknown = get_uint32(next + 8);
        printf(" %d 0x%04x FUNC_ID [%d][0x%08x]\n   %s\n",
          type_record->length,
          type_record->type,
          id,
          unknown,
          next + 12);
        break;
      case 0x1602:
        id = get_uint32(next + 4);
        unknown = get_uint32(next + 8);
        printf(" %d 0x%04x MFUNC_ID [%d][0x%08x]\n   %s\n",
          type_record->length,
          type_record->type,
          id,
          unknown,
          next + 12);
        break;
      case 0x1605:
        id = get_uint32(next + 4);
        printf(" %d 0x%04x STRING_ID [%d]\n   %s\n",
          type_record->length,
          type_record->type,
          id,
          next + 8);
        break;
      case 0x1607:
        printf(" %d 0x%04x UDT_MOD_SRC_LINE\n",
          type_record->length,
          type_record->type);
        printf("  {");
        for (n = 0; n < type_record->length - 2; n++)
        {
          printf(" %02x", next[n + 4]);
        }
        printf(" }\n");
        break;
      default:
        printf(" %d 0x%04x\n", type_record->length, type_record->type);
        // printf("offset=0x%04x\n", offset + 56);
        break;
    }

    next += total_length;
    offset += total_length;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x10(%rbp), %rax
movl 0x58(%rax), %edx
movq -0x18(%rbp), %rcx
callq 0x36b0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x3c40
movl %eax, -0x54(%rbp)
movq -0x60(%rbp), %rdi
addq $0x4, %rdi
callq 0x3c40
movl %eax, -0x50(%rbp)
movq -0x60(%rbp), %rdi
addq $0x8, %rdi
callq 0x3c40
movl %eax, -0x4c(%rbp)
movq -0x60(%rbp), %rdi
addq $0xc, %rdi
callq 0x3c40
movl %eax, -0x48(%rbp)
movq -0x60(%rbp), %rdi
addq $0x10, %rdi
callq 0x3c40
movl %eax, -0x44(%rbp)
movq -0x60(%rbp), %rdi
addq $0x14, %rdi
callq 0x4370
movw %ax, -0x40(%rbp)
movq -0x60(%rbp), %rdi
addq $0x16, %rdi
callq 0x4370
movw %ax, -0x3e(%rbp)
movq -0x60(%rbp), %rdi
addq $0x18, %rdi
callq 0x3c40
movl %eax, -0x3c(%rbp)
movq -0x60(%rbp), %rdi
addq $0x1c, %rdi
callq 0x3c40
movl %eax, -0x38(%rbp)
movq -0x60(%rbp), %rdi
addq $0x20, %rdi
callq 0x43a0
movl %eax, -0x34(%rbp)
movq -0x60(%rbp), %rdi
addq $0x24, %rdi
callq 0x3c40
movl %eax, -0x30(%rbp)
movq -0x60(%rbp), %rdi
addq $0x28, %rdi
callq 0x43a0
movl %eax, -0x2c(%rbp)
movq -0x60(%rbp), %rdi
addq $0x2c, %rdi
callq 0x3c40
movl %eax, -0x28(%rbp)
movq -0x60(%rbp), %rdi
addq $0x30, %rdi
callq 0x43a0
movl %eax, -0x24(%rbp)
movq -0x60(%rbp), %rdi
addq $0x34, %rdi
callq 0x3c40
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %ecx
leaq 0x2e11(%rip), %rsi      # 0x6bc6
leaq 0x2e06(%rip), %rax      # 0x6bc2
cmpl $0x2, %ecx
cmoveq %rax, %rsi
leaq 0x2de6(%rip), %rdi      # 0x6bb0
movb $0x0, %al
callq 0x1070
movl -0x54(%rbp), %esi
leaq 0x2def(%rip), %rdi      # 0x6bca
movb $0x0, %al
callq 0x1070
movl -0x50(%rbp), %esi
leaq 0x2dfe(%rip), %rdi      # 0x6bea
movb $0x0, %al
callq 0x1070
movl -0x4c(%rbp), %esi
leaq 0x2e0d(%rip), %rdi      # 0x6c0a
movb $0x0, %al
callq 0x1070
movl -0x48(%rbp), %esi
leaq 0x2e1c(%rip), %rdi      # 0x6c2a
movb $0x0, %al
callq 0x1070
movl -0x44(%rbp), %esi
leaq 0x2e2b(%rip), %rdi      # 0x6c4a
movb $0x0, %al
callq 0x1070
movzwl -0x40(%rbp), %esi
leaq 0x2e39(%rip), %rdi      # 0x6c6a
movb $0x0, %al
callq 0x1070
movzwl -0x3e(%rbp), %esi
leaq 0x2e47(%rip), %rdi      # 0x6c8a
movb $0x0, %al
callq 0x1070
movl -0x3c(%rbp), %esi
leaq 0x2e56(%rip), %rdi      # 0x6caa
movb $0x0, %al
callq 0x1070
movl -0x38(%rbp), %esi
leaq 0x2e65(%rip), %rdi      # 0x6cca
movb $0x0, %al
callq 0x1070
movl -0x34(%rbp), %esi
leaq 0x2e74(%rip), %rdi      # 0x6cea
movb $0x0, %al
callq 0x1070
movl -0x30(%rbp), %esi
leaq 0x2e83(%rip), %rdi      # 0x6d0a
movb $0x0, %al
callq 0x1070
movl -0x2c(%rbp), %esi
leaq 0x2e92(%rip), %rdi      # 0x6d2a
movb $0x0, %al
callq 0x1070
movl -0x28(%rbp), %esi
leaq 0x2ea1(%rip), %rdi      # 0x6d4a
movb $0x0, %al
callq 0x1070
movl -0x24(%rbp), %esi
leaq 0x2eb0(%rip), %rdi      # 0x6d6a
movb $0x0, %al
callq 0x1070
movl -0x20(%rbp), %esi
leaq 0x2ebf(%rip), %rdi      # 0x6d8a
movb $0x0, %al
callq 0x1070
leaq 0x2702(%rip), %rdi      # 0x65db
movb $0x0, %al
callq 0x1070
movl $0x0, -0x64(%rbp)
movq -0x60(%rbp), %rax
movl -0x50(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x4365
movq -0x78(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movzwl (%rax), %eax
addl $0x2, %eax
movl %eax, -0x84(%rbp)
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %eax
movl %eax, -0x88(%rbp)
subl $0x1001, %eax           # imm = 0x1001
je 0x4041
jmp 0x3f34
movl -0x88(%rbp), %eax
subl $0x1002, %eax           # imm = 0x1002
je 0x4063
jmp 0x3f47
movl -0x88(%rbp), %eax
subl $0x1008, %eax           # imm = 0x1008
je 0x4085
jmp 0x3f5a
movl -0x88(%rbp), %eax
subl $0x1009, %eax           # imm = 0x1009
je 0x40a7
jmp 0x3f6d
movl -0x88(%rbp), %eax
subl $0x1201, %eax           # imm = 0x1201
je 0x40c9
jmp 0x3f80
movl -0x88(%rbp), %eax
subl $0x1203, %eax           # imm = 0x1203
je 0x40eb
jmp 0x3f93
movl -0x88(%rbp), %eax
subl $0x1206, %eax           # imm = 0x1206
je 0x410d
jmp 0x3fa6
movl -0x88(%rbp), %eax
subl $0x1503, %eax           # imm = 0x1503
je 0x412f
jmp 0x3fb9
movl -0x88(%rbp), %eax
subl $0x1504, %eax           # imm = 0x1504
je 0x4151
jmp 0x3fcc
movl -0x88(%rbp), %eax
subl $0x1505, %eax           # imm = 0x1505
je 0x417b
jmp 0x3fdf
movl -0x88(%rbp), %eax
subl $0x1507, %eax           # imm = 0x1507
je 0x41a5
jmp 0x3ff2
movl -0x88(%rbp), %eax
subl $0x1601, %eax           # imm = 0x1601
je 0x41c7
jmp 0x4005
movl -0x88(%rbp), %eax
subl $0x1602, %eax           # imm = 0x1602
je 0x4218
jmp 0x4018
movl -0x88(%rbp), %eax
subl $0x1605, %eax           # imm = 0x1605
je 0x4269
jmp 0x402b
movl -0x88(%rbp), %eax
subl $0x1607, %eax           # imm = 0x1607
je 0x42a6
jmp 0x4323
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
leaq 0x2d53(%rip), %rdi      # 0x6daa
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
leaq 0x2d46(%rip), %rdi      # 0x6dbf
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
leaq 0x2d38(%rip), %rdi      # 0x6dd3
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
leaq 0x2d2c(%rip), %rdi      # 0x6de9
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
leaq 0x2d20(%rip), %rdi      # 0x6dff
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
leaq 0x2d12(%rip), %rdi      # 0x6e13
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
leaq 0x2d06(%rip), %rdi      # 0x6e29
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
leaq 0x2cfb(%rip), %rdi      # 0x6e40
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
movq -0x78(%rbp), %rcx
addq $0x16, %rcx
leaq 0x2ce3(%rip), %rdi      # 0x6e52
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
movq -0x78(%rbp), %rcx
addq $0x16, %rcx
leaq 0x2cce(%rip), %rdi      # 0x6e67
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
leaq 0x2cc5(%rip), %rdi      # 0x6e80
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x78(%rbp), %rdi
addq $0x4, %rdi
callq 0x3c40
movl %eax, -0x68(%rbp)
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
callq 0x3c40
movl %eax, -0x6c(%rbp)
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
movl -0x68(%rbp), %ecx
movl -0x6c(%rbp), %r8d
movq -0x78(%rbp), %r9
addq $0xc, %r9
leaq 0x2c85(%rip), %rdi      # 0x6e91
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x78(%rbp), %rdi
addq $0x4, %rdi
callq 0x3c40
movl %eax, -0x68(%rbp)
movq -0x78(%rbp), %rdi
addq $0x8, %rdi
callq 0x3c40
movl %eax, -0x6c(%rbp)
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
movl -0x68(%rbp), %ecx
movl -0x6c(%rbp), %r8d
movq -0x78(%rbp), %r9
addq $0xc, %r9
leaq 0x2c5b(%rip), %rdi      # 0x6eb8
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x78(%rbp), %rdi
addq $0x4, %rdi
callq 0x3c40
movl %eax, -0x68(%rbp)
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
movl -0x68(%rbp), %ecx
movq -0x78(%rbp), %r8
addq $0x8, %r8
leaq 0x2c46(%rip), %rdi      # 0x6ee0
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
leaq 0x2c45(%rip), %rdi      # 0x6f01
movb $0x0, %al
callq 0x1070
leaq 0x2c54(%rip), %rdi      # 0x6f1e
movb $0x0, %al
callq 0x1070
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
movq -0x80(%rbp), %rcx
movzwl (%rcx), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jge 0x4313
movq -0x78(%rbp), %rax
movl -0x70(%rbp), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %esi
leaq 0x278b(%rip), %rdi      # 0x6a8c
movb $0x0, %al
callq 0x1070
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x42d8
leaq 0x272c(%rip), %rdi      # 0x6a46
movb $0x0, %al
callq 0x1070
jmp 0x4340
movq -0x80(%rbp), %rax
movzwl (%rax), %esi
movq -0x80(%rbp), %rax
movzwl 0x2(%rax), %edx
leaq 0x2be9(%rip), %rdi      # 0x6f22
movb $0x0, %al
callq 0x1070
movl -0x84(%rbp), %ecx
movq -0x78(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl -0x84(%rbp), %eax
addl -0x64(%rbp), %eax
movl %eax, -0x64(%rbp)
jmp 0x3ef5
addq $0x90, %rsp
popq %rbp
retq
nop