// File: /workspace/github_cpp_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
cmpb $0x0, (%rdi)
je 0x4cb4
movq %rdi, %r14
xorl %r15d, %r15d
xorl %ebp, %ebp
movb (%r14,%r15), %al
movzbl %al, %ecx
cmpl $0x39, %ecx
jle 0x4bb1
cmpl $0x5c, %ecx
jle 0x4bf2
cmpl $0x5d, %ecx
je 0x4c29
cmpl $0x7b, %ecx
je 0x4c47
cmpl $0x7d, %ecx
jne 0x4c56
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x70, %cl
jmp 0x4c8a
cmpl $0x28, %ecx
jg 0x4bd6
cmpl $0x20, %ecx
je 0x4c0b
cmpl $0x28, %ecx
jne 0x4c56
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x69, %cl
jmp 0x4c8a
cmpl $0x29, %ecx
je 0x4c1a
cmpl $0x2f, %ecx
jne 0x4c56
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x5e, %cl
jmp 0x4c8a
cmpl $0x3a, %ecx
je 0x4c38
cmpl $0x5b, %ecx
jne 0x4c56
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x6d, %cl
jmp 0x4c8a
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7e, (%rbx,%rcx)
movb $0x3f, %cl
jmp 0x4c8a
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x6a, %cl
jmp 0x4c8a
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x6e, %cl
jmp 0x4c8a
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x46, %cl
jmp 0x4c8a
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x6f, %cl
jmp 0x4c8a
leal -0x30(%rax), %ecx
cmpb $0x2a, %cl
ja 0x4c72
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7e, (%rbx,%rcx)
movb (%r14,%r15), %cl
addb $0x1f, %cl
jmp 0x4c8a
addb $-0x61, %al
cmpb $0x19, %al
ja 0x4c90
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7e, (%rbx,%rcx)
movb (%r14,%r15), %cl
addb $0x20, %cl
addl $0x2, %ebp
movb %cl, 0x1(%rax)
incq %r15
movq %r14, %rdi
callq 0x20c0
cmpq %rax, %r15
jb 0x4b73
cmpl $0x43, %ebp
jle 0x4cb6
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
movslq %ebp, %rax
addq %rax, %rbx
movl $0x43, %edx
subl %eax, %edx
incq %rdx
movq %rbx, %rdi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2100