// File: /workspace/github_c_makefile_star2_O0/inolen[P]gdb_server/./sh4.h
// Function: sh4_init_tables
void INIT_TABLES() {
  static int initialized = 0;

  if (initialized) {
    return;
  }

  initialized = 1;

  // extract argument encoding information from signature
  for (int i = 0; i < NUM_OPCODES; i++) {
    INSTR_TYPE_T *type = &instr_type[i];
    ARG_MASK(type->sig, 'i', &type->imm_mask, &type->imm_shift);
    ARG_MASK(type->sig, 'd', &type->disp_mask, &type->disp_shift);
    ARG_MASK(type->sig, 'm', &type->rm_mask, &type->rm_shift);
    ARG_MASK(type->sig, 'n', &type->rn_mask, &type->rn_shift);
    ARG_MASK(type->sig, 0, &type->opcode_mask, NULL);
  }

  // initialize lookup table
  memset(instr_lookup, 0, sizeof(instr_lookup));

  for (int w = 0; w < 0x10000; w += 0x1000) {
    for (int x = 0; x < 0x1000; x += 0x100) {
      for (int y = 0; y < 0x100; y += 0x10) {
        for (int z = 0; z < 0x10; z++) {
          uint16_t value = w + x + y + z;

          for (int i = 0; i < NUM_OPCODES; i++) {
            INSTR_TYPE_T *type = &instr_type[i];
            uint16_t arg_mask = type->imm_mask | type->disp_mask |
                                type->rm_mask | type->rn_mask;

            if ((value & ~arg_mask) == type->opcode_mask) {
              instr_lookup[value] = type;
              break;
            }
          }
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
cmpl $0x0, 0x9841(%rip)      # 0x11130
je 0x78f6
jmp 0x7b23
movl $0x1, 0x9830(%rip)      # 0x11130
movl $0x0, -0x4(%rbp)
cmpl $0xa9, -0x4(%rbp)
jge 0x79db
movslq -0x4(%rbp), %rcx
leaq 0x77f1(%rip), %rax      # 0xf110
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rdx
addq $0x18, %rdx
movq -0x10(%rbp), %rcx
addq $0x1a, %rcx
movl $0x69, %esi
callq 0x7b30
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rdx
addq $0x1c, %rdx
movq -0x10(%rbp), %rcx
addq $0x1e, %rcx
movl $0x64, %esi
callq 0x7b30
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rdx
addq $0x20, %rdx
movq -0x10(%rbp), %rcx
addq $0x22, %rcx
movl $0x6d, %esi
callq 0x7b30
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rdx
addq $0x24, %rdx
movq -0x10(%rbp), %rcx
addq $0x26, %rcx
movl $0x6e, %esi
callq 0x7b30
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rdx
addq $0x28, %rdx
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x7b30
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x7907
leaq 0x975e(%rip), %rdi      # 0x11140
xorl %esi, %esi
movl $0x7fff8, %edx          # imm = 0x7FFF8
callq 0x3100
movl $0x0, -0x14(%rbp)
cmpl $0x10000, -0x14(%rbp)   # imm = 0x10000
jge 0x7b23
movl $0x0, -0x18(%rbp)
cmpl $0x1000, -0x18(%rbp)    # imm = 0x1000
jge 0x7b11
movl $0x0, -0x1c(%rbp)
cmpl $0x100, -0x1c(%rbp)     # imm = 0x100
jge 0x7aff
movl $0x0, -0x20(%rbp)
cmpl $0x10, -0x20(%rbp)
jge 0x7aef
movl -0x14(%rbp), %eax
addl -0x18(%rbp), %eax
addl -0x1c(%rbp), %eax
addl -0x20(%rbp), %eax
movw %ax, -0x22(%rbp)
movl $0x0, -0x28(%rbp)
cmpl $0xa9, -0x28(%rbp)
jge 0x7adf
movslq -0x28(%rbp), %rcx
leaq 0x76a6(%rip), %rax      # 0xf110
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzwl 0x18(%rax), %eax
movq -0x30(%rbp), %rcx
movzwl 0x1c(%rcx), %ecx
orl %ecx, %eax
movq -0x30(%rbp), %rcx
movzwl 0x20(%rcx), %ecx
orl %ecx, %eax
movq -0x30(%rbp), %rcx
movzwl 0x24(%rcx), %ecx
orl %ecx, %eax
movw %ax, -0x32(%rbp)
movzwl -0x22(%rbp), %eax
movzwl -0x32(%rbp), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movq -0x30(%rbp), %rcx
movzwl 0x28(%rcx), %ecx
cmpl %ecx, %eax
jne 0x7acf
movq -0x30(%rbp), %rdx
movzwl -0x22(%rbp), %eax
movl %eax, %ecx
leaq 0x9677(%rip), %rax      # 0x11140
movq %rdx, (%rax,%rcx,8)
jmp 0x7adf
jmp 0x7ad1
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x7a52
jmp 0x7ae1
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x7a31
jmp 0x7af1
movl -0x1c(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x1c(%rbp)
jmp 0x7a1d
jmp 0x7b01
movl -0x18(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, -0x18(%rbp)
jmp 0x7a09
jmp 0x7b13
movl -0x14(%rbp), %eax
addl $0x1000, %eax           # imm = 0x1000
movl %eax, -0x14(%rbp)
jmp 0x79f5
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)