// File: /workspace/github_c_makefile_star2_O0/Joy-Division[P]tools-mgs/simple-hash-list.c
// Function: main
int main( int argc, char** argv ) {
	
	if ( argc < 2 )
	{
		printf( "Not enough arguments given!\nUsage: %s textlist\n", argv[0] );
		return 1;
	}
	
	uint16_t hash1;
	uint32_t hash2;
	uint32_t hash3;
	FILE *tin, *tout;
	
	if( !(tin = fopen( argv[1], "r" ))) {
		printf("Couldnt open file %s as textlist\n", argv[1]);
		return 1;
	}
	
	char scanname[512] = {0}, *outtext = malloc(strlen(argv[1])+5+4+1);
	sprintf(outtext, "%s-hash.txt", argv[1]);
	
	if( !(tout = fopen( outtext, "w" ))) {
		printf("Couldnt open file %s as outtext\n", outtext);
		return 1;
	}
	
	while(fgets(scanname, 512, tin)) {
		if(!(strncmp(scanname, "//", 2))) fprintf(tout, "%s", scanname);
		else {
			scanname[strcspn(scanname,"\r\n")] = 0;
			hash1 = StrCode16(scanname);
			hash2 = StrCode24(scanname);
			hash3 = StrCode32(scanname);
			fprintf(tout, "%-21s %04x %08x %08x\n", scanname, hash1, hash2, hash3);
		}
	}
	
	fclose(tin);
	fclose(tout);
	printf("Done.\n");
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x1370
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0xca7(%rip), %rdi       # 0x2004
movb $0x0, %al
callq 0x1060
movl $0x1, -0x4(%rbp)
jmp 0x1539
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xcb5(%rip), %rsi       # 0x2034
callq 0x10c0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x13b0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xc99(%rip), %rdi       # 0x2036
movb $0x0, %al
callq 0x1060
movl $0x1, -0x4(%rbp)
jmp 0x1539
leaq -0x230(%rbp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x1070
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1050
movq %rax, %rdi
addq $0x5, %rdi
addq $0x4, %rdi
addq $0x1, %rdi
callq 0x10b0
movq %rax, -0x238(%rbp)
movq -0x238(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0xc57(%rip), %rsi       # 0x2058
movb $0x0, %al
callq 0x10d0
movq -0x238(%rbp), %rdi
leaq 0xc4e(%rip), %rsi       # 0x2064
callq 0x10c0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x1446
movq -0x238(%rbp), %rsi
leaq 0xc33(%rip), %rdi       # 0x2066
movb $0x0, %al
callq 0x1060
movl $0x1, -0x4(%rbp)
jmp 0x1539
jmp 0x1448
leaq -0x230(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x200, %esi            # imm = 0x200
callq 0x1090
cmpq $0x0, %rax
je 0x1512
leaq -0x230(%rbp), %rdi
leaq 0xc12(%rip), %rsi       # 0x2087
movl $0x2, %edx
callq 0x1030
cmpl $0x0, %eax
jne 0x149f
movq -0x30(%rbp), %rdi
leaq -0x230(%rbp), %rdx
leaq 0xbf4(%rip), %rsi       # 0x208a
movb $0x0, %al
callq 0x10a0
jmp 0x150d
leaq -0x230(%rbp), %rdi
leaq 0xbe0(%rip), %rsi       # 0x208d
callq 0x1080
movb $0x0, -0x230(%rbp,%rax)
leaq -0x230(%rbp), %rdi
callq 0x11e0
movw %ax, -0x12(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x1240
movl %eax, -0x18(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x12c0
movl %eax, -0x1c(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x230(%rbp), %rdx
movzwl -0x12(%rbp), %ecx
movl -0x18(%rbp), %r8d
movl -0x1c(%rbp), %r9d
leaq 0xb8a(%rip), %rsi       # 0x2090
movb $0x0, %al
callq 0x10a0
jmp 0x1448
movq -0x28(%rbp), %rdi
callq 0x1040
movq -0x30(%rbp), %rdi
callq 0x1040
leaq 0xb7b(%rip), %rdi       # 0x20a6
movb $0x0, %al
callq 0x1060
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq