// File: /workspace/github_cpp_makefile_star2_O2/ticky[P]ps2iconsys/src/ps2_iconsys.cpp
// Function: IconSys::EncodeTitle(char const*, unsigned char*)
void IconSys::EncodeTitle(char const* str_in, unsigned char* str_out) {
	int sjis_count = 0;
	for(size_t i=0; i<strlen(str_in); i++) {
		switch(str_in[i]) {
			case ' ':
				str_out[sjis_count++] = 0x82;
				str_out[sjis_count++] = 0x3F;
				break;
			case ':':
				str_out[sjis_count++] = 0x81;
				str_out[sjis_count++] = 0x46;
				break;
			case '/':
				str_out[sjis_count++] = 0x81;
				str_out[sjis_count++] = 0x5E;
				break;
			case '(':
				str_out[sjis_count++] = 0x81;
				str_out[sjis_count++] = 0x69;
				break;
			case ')':
				str_out[sjis_count++] = 0x81;
				str_out[sjis_count++] = 0x6A;
				break;
			case '[':
				str_out[sjis_count++] = 0x81;
				str_out[sjis_count++] = 0x6D;
				break;
			case ']':
				str_out[sjis_count++] = 0x81;
				str_out[sjis_count++] = 0x6E;
				break;
			case '{':
				str_out[sjis_count++] = 0x81;
				str_out[sjis_count++] = 0x6F;
				break;
			case '}':
				str_out[sjis_count++] = 0x81;
				str_out[sjis_count++] = 0x70;
				break;
			default:
				if((str_in[i] >= 48) && (str_in[i] <= 90)) {
					//digits (0-9), capital letters (A-Z)
					str_out[sjis_count++] = 0x82;
					str_out[sjis_count++] = str_in[i] + 31;
				} else if((str_in[i] >= 97) && (str_in[i] <= 122)) {
					//lowercase letters (a-z)
					str_out[sjis_count++] = 0x82;
					str_out[sjis_count++] = str_in[i] + 32;
				}
				break;
		}
	}
	for(; sjis_count < 68; sjis_count++) {
		str_out[sjis_count] = 0;
	}	
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
movq %r14, %rdi
callq 0x20b0
cmpq %rax, %r12
jae 0x4332
movzbl (%r14,%r12), %eax
cmpl $0x7d, %eax
je 0x42a4
cmpl $0x28, %eax
je 0x42e0
cmpl $0x29, %eax
je 0x42d1
cmpl $0x2f, %eax
je 0x4271
cmpl $0x3a, %eax
je 0x4295
cmpl $0x5b, %eax
je 0x42c2
cmpl $0x5d, %eax
je 0x42b3
cmpl $0x7b, %eax
je 0x4283
cmpl $0x20, %eax
jne 0x42ef
movslq %r15d, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7e, (%rbx,%rcx)
movb $0x3f, %cl
jmp 0x4323
movslq %r15d, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x5e, %cl
jmp 0x4323
movslq %r15d, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x6f, %cl
jmp 0x4323
movslq %r15d, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x46, %cl
jmp 0x4323
movslq %r15d, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x70, %cl
jmp 0x4323
movslq %r15d, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x6e, %cl
jmp 0x4323
movslq %r15d, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x6d, %cl
jmp 0x4323
movslq %r15d, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x6a, %cl
jmp 0x4323
movslq %r15d, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x69, %cl
jmp 0x4323
leal -0x30(%rax), %ecx
cmpb $0x2a, %cl
ja 0x430b
movslq %r15d, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7e, (%rbx,%rcx)
movb (%r14,%r12), %cl
addb $0x1f, %cl
jmp 0x4323
addb $-0x61, %al
cmpb $0x19, %al
ja 0x432a
movslq %r15d, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7e, (%rbx,%rcx)
movb (%r14,%r12), %cl
addb $0x20, %cl
addl $0x2, %r15d
movb %cl, 0x1(%rax)
incq %r12
jmp 0x4210
movslq %r15d, %rax
cmpq $0x43, %rax
jg 0x4344
movb $0x0, (%rbx,%rax)
incq %rax
jmp 0x4335
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq