// File: /workspace/github_c_makefile_star2_O0/mikebdp2[P]AtomDis/indices.c
// Function: index_load_registers
void index_load_registers (const char *file)
{
    FILE *f;
    char  buf[512], kind[32], offset[32];
    char *c, *d, *e, *name = NULL, *namefree = NULL;
    int   len, id, nr, size = 0;

    if (! (f = fopen (file, "r")) ) {
	perror (file);
	exit (1);
    }
    while (fgets (buf, 512, f)) {
	if ( (c = strstr (buf, "<register ")) ) {
	    if ( (d = strstr (c, " name=\"")) )
		if ( (e = strchr (d+7, '"')) ) {
		    free (namefree);
		    name = namefree = strndup (d+7, e-d-7);
		}
	    size = 0;
	    if ( (d = strstr (c, " size=\"")) )
		size = strtol (d+7, NULL, 0);
	}
	if ( (c = strstr (buf, "<addr ")) ) {
	    kind[0] = offset[0] = 0;
	    if ( (d = strstr (c, " kind=\"")) )
		if ( (e = strchr (d+7, '"')) ) {
		    strncpy (kind, d+7, e-d-7 > 31 ? 31 : e-d-7);
		    kind[ e-d-7 > 31 ? 31 : e-d-7] = 0;
		}
	    if ( (d = strstr (c, " offset=\"")) )
		if ( (e = strchr (d+9, '"')) ) {
		    strncpy (offset, d+9, e-d-9 > 31 ? 31 : e-d-9);
		    offset[ e-d-9 > 31 ? 31 : e-d-9] = 0;
		}
	    if (! kind[0] || ! offset[0])
		continue;
	    if (strcasestr (kind, "MMReg"))
		id = INDEX_REG_MM;
	    else if (strcasestr (kind, "MCIND"))
		id = INDEX_REG_MC;
	    else if (strcasestr (kind, "PCIEIND"))
		id = INDEX_REG_PCIE;
	    else if (strcasestr (kind, "pciConfig"))
		id = INDEX_REG_PCICONFIG;
	    else
		continue;
	    nr = strtol (offset, NULL, 0);
	    if (size != 32)
		continue;		/* TODO: 8-bit MM */
	    if (id == INDEX_REG_MM) {
		if (! (nr & 3))
		    nr >>= 2;
		else
		    continue;
	    }
	    if (index_tables[id].len <= nr || ! index_tables[id].tab) {
		len = (nr + 0x1f) & -0x20;
		if (len <= 0)
		    len = 0x20;
		index_tables[id].tab = realloc (index_tables[id].tab,
						len * sizeof (const char *));
		memset (index_tables[id].tab + index_tables[id].len,
			0,
			(len - index_tables[id].len) * sizeof (const char *));
		index_tables[id].len = len;
	    }
	    if (index_tables[id].tab[nr]) {
		fprintf (stderr, "Register clash: %04x = %s = %s in table %s\n",
			 nr, name, index_tables[id].tab[nr], index_tables[id].name);
	    } else {
#if 0
		fprintf (stderr, "   %s = %04x  [%02x]\n", name, nr, size);
#endif
		index_tables[id].tab[nr] = name;
		namefree = NULL;
	    }
	}
    }
    free (namefree);
    fclose (f);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rdi, -0x8(%rbp)
movq $0x0, -0x270(%rbp)
movq $0x0, -0x278(%rbp)
movl $0x0, -0x288(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x11765(%rip), %rsi     # 0x5cedf
callq 0x4170
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
jne 0x4b79c
movq -0x8(%rbp), %rdi
callq 0x4180
movl $0x1, %edi
callq 0x41c0
jmp 0x4b79e
leaq -0x210(%rbp), %rdi
movq -0x10(%rbp), %rdx
movl $0x200, %esi            # imm = 0x200
callq 0x40f0
cmpq $0x0, %rax
je 0x4be1b
leaq -0x210(%rbp), %rdi
leaq 0x1193a(%rip), %rsi     # 0x5d105
callq 0x41d0
movq %rax, -0x258(%rbp)
cmpq $0x0, %rax
je 0x4b8ac
movq -0x258(%rbp), %rdi
leaq 0x11921(%rip), %rsi     # 0x5d110
callq 0x41d0
movq %rax, -0x260(%rbp)
cmpq $0x0, %rax
je 0x4b864
movq -0x260(%rbp), %rdi
addq $0x7, %rdi
movl $0x22, %esi
callq 0x4080
movq %rax, -0x268(%rbp)
cmpq $0x0, %rax
je 0x4b862
movq -0x278(%rbp), %rdi
callq 0x4030
movq -0x260(%rbp), %rdi
addq $0x7, %rdi
movq -0x268(%rbp), %rsi
movq -0x260(%rbp), %rax
subq %rax, %rsi
subq $0x7, %rsi
callq 0x40e0
movq %rax, -0x278(%rbp)
movq %rax, -0x270(%rbp)
jmp 0x4b864
movl $0x0, -0x288(%rbp)
movq -0x258(%rbp), %rdi
leaq 0x1189c(%rip), %rsi     # 0x5d118
callq 0x41d0
movq %rax, -0x260(%rbp)
cmpq $0x0, %rax
je 0x4b8aa
movq -0x260(%rbp), %rdi
addq $0x7, %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x4140
movl %eax, -0x288(%rbp)
jmp 0x4b8ac
leaq -0x210(%rbp), %rdi
leaq 0x11866(%rip), %rsi     # 0x5d120
callq 0x41d0
movq %rax, -0x258(%rbp)
cmpq $0x0, %rax
je 0x4be16
movb $0x0, -0x250(%rbp)
movb $0x0, -0x230(%rbp)
movq -0x258(%rbp), %rdi
leaq 0x1183b(%rip), %rsi     # 0x5d127
callq 0x41d0
movq %rax, -0x260(%rbp)
cmpq $0x0, %rax
je 0x4b9fd
movq -0x260(%rbp), %rdi
addq $0x7, %rdi
movl $0x22, %esi
callq 0x4080
movq %rax, -0x268(%rbp)
cmpq $0x0, %rax
je 0x4b9fb
leaq -0x230(%rbp), %rax
movq %rax, -0x298(%rbp)
movq -0x260(%rbp), %rax
addq $0x7, %rax
movq %rax, -0x290(%rbp)
movq -0x268(%rbp), %rax
movq -0x260(%rbp), %rcx
subq %rcx, %rax
subq $0x7, %rax
cmpq $0x1f, %rax
jle 0x4b971
movl $0x1f, %eax
movq %rax, -0x2a0(%rbp)
jmp 0x4b98d
movq -0x268(%rbp), %rax
movq -0x260(%rbp), %rcx
subq %rcx, %rax
subq $0x7, %rax
movq %rax, -0x2a0(%rbp)
movq -0x290(%rbp), %rsi
movq -0x298(%rbp), %rdi
movq -0x2a0(%rbp), %rdx
callq 0x4040
movq -0x268(%rbp), %rax
movq -0x260(%rbp), %rcx
subq %rcx, %rax
subq $0x7, %rax
cmpq $0x1f, %rax
jle 0x4b9d0
movl $0x1f, %eax
movq %rax, -0x2a8(%rbp)
jmp 0x4b9ec
movq -0x268(%rbp), %rax
movq -0x260(%rbp), %rcx
subq %rcx, %rax
subq $0x7, %rax
movq %rax, -0x2a8(%rbp)
movq -0x2a8(%rbp), %rax
movb $0x0, -0x230(%rbp,%rax)
jmp 0x4b9fd
movq -0x258(%rbp), %rdi
leaq 0x11724(%rip), %rsi     # 0x5d12f
callq 0x41d0
movq %rax, -0x260(%rbp)
cmpq $0x0, %rax
je 0x4bb1c
movq -0x260(%rbp), %rdi
addq $0x9, %rdi
movl $0x22, %esi
callq 0x4080
movq %rax, -0x268(%rbp)
cmpq $0x0, %rax
je 0x4bb1a
leaq -0x250(%rbp), %rax
movq %rax, -0x2b8(%rbp)
movq -0x260(%rbp), %rax
addq $0x9, %rax
movq %rax, -0x2b0(%rbp)
movq -0x268(%rbp), %rax
movq -0x260(%rbp), %rcx
subq %rcx, %rax
subq $0x9, %rax
cmpq $0x1f, %rax
jle 0x4ba90
movl $0x1f, %eax
movq %rax, -0x2c0(%rbp)
jmp 0x4baac
movq -0x268(%rbp), %rax
movq -0x260(%rbp), %rcx
subq %rcx, %rax
subq $0x9, %rax
movq %rax, -0x2c0(%rbp)
movq -0x2b0(%rbp), %rsi
movq -0x2b8(%rbp), %rdi
movq -0x2c0(%rbp), %rdx
callq 0x4040
movq -0x268(%rbp), %rax
movq -0x260(%rbp), %rcx
subq %rcx, %rax
subq $0x9, %rax
cmpq $0x1f, %rax
jle 0x4baef
movl $0x1f, %eax
movq %rax, -0x2c8(%rbp)
jmp 0x4bb0b
movq -0x268(%rbp), %rax
movq -0x260(%rbp), %rcx
subq %rcx, %rax
subq $0x9, %rax
movq %rax, -0x2c8(%rbp)
movq -0x2c8(%rbp), %rax
movb $0x0, -0x250(%rbp,%rax)
jmp 0x4bb1c
cmpb $0x0, -0x230(%rbp)
je 0x4bb2e
cmpb $0x0, -0x250(%rbp)
jne 0x4bb33
jmp 0x4b79e
leaq -0x230(%rbp), %rdi
leaq 0x115f8(%rip), %rsi     # 0x5d139
callq 0x4190
cmpq $0x0, %rax
je 0x4bb58
movl $0x5, -0x280(%rbp)
jmp 0x4bbd2
leaq -0x230(%rbp), %rdi
leaq 0x115d9(%rip), %rsi     # 0x5d13f
callq 0x4190
cmpq $0x0, %rax
je 0x4bb7d
movl $0x7, -0x280(%rbp)
jmp 0x4bbd0
leaq -0x230(%rbp), %rdi
leaq 0x115ba(%rip), %rsi     # 0x5d145
callq 0x4190
cmpq $0x0, %rax
je 0x4bba2
movl $0x8, -0x280(%rbp)
jmp 0x4bbce
leaq -0x230(%rbp), %rdi
leaq 0x1159d(%rip), %rsi     # 0x5d14d
callq 0x4190
cmpq $0x0, %rax
je 0x4bbc7
movl $0x9, -0x280(%rbp)
jmp 0x4bbcc
jmp 0x4b79e
jmp 0x4bbce
jmp 0x4bbd0
jmp 0x4bbd2
leaq -0x250(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x4140
movl %eax, -0x284(%rbp)
cmpl $0x20, -0x288(%rbp)
je 0x4bbf8
jmp 0x4b79e
cmpl $0x5, -0x280(%rbp)
jne 0x4bc27
movl -0x284(%rbp), %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0x4bc20
movl -0x284(%rbp), %eax
sarl $0x2, %eax
movl %eax, -0x284(%rbp)
jmp 0x4bc25
jmp 0x4b79e
jmp 0x4bc27
movslq -0x280(%rbp), %rcx
leaq 0x1939b(%rip), %rax     # 0x64fd0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
cmpl -0x284(%rbp), %eax
jle 0x4bc67
movslq -0x280(%rbp), %rcx
leaq 0x1937b(%rip), %rax     # 0x64fd0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
jne 0x4bd54
movl -0x284(%rbp), %eax
addl $0x1f, %eax
andl $-0x20, %eax
movl %eax, -0x27c(%rbp)
cmpl $0x0, -0x27c(%rbp)
jg 0x4bc8c
movl $0x20, -0x27c(%rbp)
movslq -0x280(%rbp), %rcx
leaq 0x19336(%rip), %rax     # 0x64fd0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movslq -0x27c(%rbp), %rsi
shlq $0x3, %rsi
callq 0x4150
movq %rax, %rcx
movslq -0x280(%rbp), %rdx
leaq 0x1930a(%rip), %rax     # 0x64fd0
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movslq -0x280(%rbp), %rcx
leaq 0x192f1(%rip), %rax     # 0x64fd0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movslq -0x280(%rbp), %rcx
leaq 0x192d8(%rip), %rax     # 0x64fd0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq 0x10(%rax), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x27c(%rbp), %eax
movslq -0x280(%rbp), %rdx
leaq 0x192b2(%rip), %rcx     # 0x64fd0
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
subl 0x10(%rcx), %eax
movslq %eax, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x40b0
movl -0x27c(%rbp), %ecx
movslq -0x280(%rbp), %rdx
leaq 0x19286(%rip), %rax     # 0x64fd0
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
movslq -0x280(%rbp), %rcx
leaq 0x1926e(%rip), %rax     # 0x64fd0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x284(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x4bdde
movq 0x18276(%rip), %rax     # 0x63ff8
movq (%rax), %rdi
movl -0x284(%rbp), %edx
movq -0x270(%rbp), %rcx
movslq -0x280(%rbp), %rsi
leaq 0x19230(%rip), %rax     # 0x64fd0
imulq $0x18, %rsi, %rsi
addq %rsi, %rax
movq 0x8(%rax), %rax
movslq -0x284(%rbp), %rsi
movq (%rax,%rsi,8), %r8
movslq -0x280(%rbp), %rsi
leaq 0x1920c(%rip), %rax     # 0x64fd0
imulq $0x18, %rsi, %rsi
addq %rsi, %rax
movq (%rax), %r9
leaq 0x11382(%rip), %rsi     # 0x5d157
movb $0x0, %al
callq 0x4130
jmp 0x4be14
movq -0x270(%rbp), %rdx
movslq -0x280(%rbp), %rcx
leaq 0x191dd(%rip), %rax     # 0x64fd0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x284(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq $0x0, -0x278(%rbp)
jmp 0x4be16
jmp 0x4b79e
movq -0x278(%rbp), %rdi
callq 0x4030
movq -0x10(%rbp), %rdi
callq 0x4060
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq