// File: /workspace/github_c_makefile_star2_O0/Joy-Division[P]tools-mgs/dat-extract_enc.c
// Function: getDictionary
void getDictionary(dicentry **dic, int *num, char *path, char *name, unsigned int flags) {
	char tempname[256], *token = NULL;
	int i, j;
	if(flags & GAME_MGS2) *num = loaddic(dic, path, name, DIC_HASH_SINGLE_EXT | DIC_ADJUST_EXT_MGS2, StrCode24);
	if(flags & GAME_ZOE2) *num = loaddic(dic, path, name, DIC_HASH_FULL_NAME, StrCode32);
	if(flags & (GAME_MGS3|GAME_MGS4)) {
		*num = loaddic(dic, path, name, DIC_USE_EXTERNAL, StrCode24);
		for(i = 0; i < *num; i++) {
			strcpy(tempname, (*dic)[i].name);
			token = strtok(tempname, ".");
			token = strtok(NULL, ".");
			for(j = 0; j < 256; j++) {
				if(!strcmp(token, extList[(flags & GAME_MGS4) ? 1 : 0][j])) {
					(*dic)[i].extension = j;
					printf("set extension of entry %d to %08x\n", i, j);
					break;
				}
			}
			if(j > 255) printf("unknown extension %s\n", token);
		}
	}
	if(*num > 0) numdicentries += *num;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq $0x0, -0x138(%rbp)
movl -0x24(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x58da
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl $0xa, %ecx
leaq -0x53d(%rip), %r8       # 0x5390
callq 0x5480
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x24(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x590a
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl $0x1, %ecx
leaq -0x4ed(%rip), %r8       # 0x5410
callq 0x5480
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x24(%rbp), %eax
andl $0x6, %eax
cmpl $0x0, %eax
je 0x5a99
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl $0x4, %ecx
leaq -0x5a1(%rip), %r8       # 0x5390
callq 0x5480
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x13c(%rbp)
movl -0x13c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x5a97
leaq -0x130(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movslq -0x13c(%rbp), %rax
imulq $0x108, %rax, %rax      # imm = 0x108
addq %rax, %rsi
addq $0x8, %rsi
callq 0x5060
leaq -0x130(%rbp), %rdi
leaq 0x36d7(%rip), %rsi      # 0x9067
callq 0x51d0
movq %rax, -0x138(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x36c0(%rip), %rsi      # 0x9067
callq 0x51d0
movq %rax, -0x138(%rbp)
movl $0x0, -0x140(%rbp)
cmpl $0x100, -0x140(%rbp)    # imm = 0x100
jge 0x5a60
movq -0x138(%rbp), %rdi
movl -0x24(%rbp), %edx
andl $0x4, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movslq %eax, %rcx
leaq 0x675f(%rip), %rax      # 0xc150
shlq $0xb, %rcx
addq %rcx, %rax
movslq -0x140(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x5130
cmpl $0x0, %eax
jne 0x5a4a
movl -0x140(%rbp), %ecx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x13c(%rbp), %rdx
imulq $0x108, %rdx, %rdx      # imm = 0x108
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x13c(%rbp), %esi
movl -0x140(%rbp), %edx
leaq 0x3b28(%rip), %rdi      # 0x9569
movb $0x0, %al
callq 0x50c0
jmp 0x5a60
jmp 0x5a4c
movl -0x140(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x140(%rbp)
jmp 0x59bd
cmpl $0xff, -0x140(%rbp)
jle 0x5a81
movq -0x138(%rbp), %rsi
leaq 0x3b12(%rip), %rdi      # 0x958c
movb $0x0, %al
callq 0x50c0
jmp 0x5a83
movl -0x13c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x5948
jmp 0x5a99
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jle 0x5ab4
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl 0x77e2(%rip), %eax      # 0xd290
movl %eax, 0x77dc(%rip)      # 0xd290
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopl (%rax)