// File: /workspace/github_cpp_makefile_star2_O1/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 0x4c44
movq %rdi, %r14
xorl %r15d, %r15d
xorl %ebp, %ebp
movb (%r14,%r15), %al
movzbl %al, %ecx
cmpl $0x39, %ecx
jle 0x4b4f
cmpl $0x5c, %ecx
jle 0x4b90
cmpl $0x5d, %ecx
je 0x4bc7
cmpl $0x7b, %ecx
je 0x4be5
cmpl $0x7d, %ecx
jne 0x4bf4
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x70, %cl
jmp 0x4c28
cmpl $0x28, %ecx
jg 0x4b74
cmpl $0x20, %ecx
je 0x4ba9
cmpl $0x28, %ecx
jne 0x4bf4
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x69, %cl
jmp 0x4c28
cmpl $0x29, %ecx
je 0x4bb8
cmpl $0x2f, %ecx
jne 0x4bf4
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x5e, %cl
jmp 0x4c28
cmpl $0x3a, %ecx
je 0x4bd6
cmpl $0x5b, %ecx
jne 0x4bf4
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x6d, %cl
jmp 0x4c28
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7e, (%rbx,%rcx)
movb $0x3f, %cl
jmp 0x4c28
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x6a, %cl
jmp 0x4c28
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x6e, %cl
jmp 0x4c28
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x46, %cl
jmp 0x4c28
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7f, (%rbx,%rcx)
movb $0x6f, %cl
jmp 0x4c28
leal -0x30(%rax), %ecx
cmpb $0x2a, %cl
ja 0x4c10
movslq %ebp, %rcx
leaq (%rbx,%rcx), %rax
movb $-0x7e, (%rbx,%rcx)
movb (%r14,%r15), %cl
addb $0x1f, %cl
jmp 0x4c28
addb $-0x61, %al
cmpb $0x19, %al
ja 0x4c2e
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 0x4b11
jmp 0x4c46
xorl %ebp, %ebp
cmpl $0x43, %ebp
jg 0x4c6f
movslq %ebp, %rax
addq %rax, %rbx
movl $0x43, %edx
subl %ebp, %edx
incq %rdx
movq %rbx, %rdi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2100
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq