// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/osd.c
// Function: OSD_HandleKey
int OSD_HandleKey(int sc, int press)
{
	if (!osdinited) return sc;
	if (!osdvisible) return sc;

	if (!press) {
		if (sc == 42 || sc == 54) // shift
			osdeditshift = 0;
		if (sc == 29 || sc == 157)	// control
			osdeditcontrol = 0;
		if (sc == 56 || sc == 184)	// alt
			osdeditalt = 0;
		return 0;
	}

	keytime = gettime();

	if (sc != 15) lastmatch = NULL;		// reset tab-completion cycle

	switch (sc) {
		case 1:		// escape
			OSD_ShowDisplay(0); break;
		case 211:	// delete
			OSD_Manipulate(OSDOP_DELETE); break;
		case 199:	// home
			if (osdeditcontrol) {
				OSD_Manipulate(OSDOP_SCROLL_TOP);
			} else {
				OSD_Manipulate(OSDOP_START);
			}
			break;
		case 207:	// end
			if (osdeditcontrol) {
				OSD_Manipulate(OSDOP_SCROLL_BOTTOM);
			} else {
				OSD_Manipulate(OSDOP_END);
			}
			break;
		case 201:	// page up
			OSD_Manipulate(OSDOP_PAGE_UP); break;
		case 209:	// page down
			OSD_Manipulate(OSDOP_PAGE_DOWN); break;
		case 200:	// up
			OSD_Manipulate(OSDOP_HISTORY_UP); break;
		case 208:	// down
			OSD_Manipulate(OSDOP_HISTORY_DOWN); break;
		case 203:	// left
			if (osdeditcontrol) {
				OSD_Manipulate(OSDOP_LEFT_WORD);
			} else {
				OSD_Manipulate(OSDOP_LEFT);
			}
			break;
		case 205:	// right
			if (osdeditcontrol) {
				OSD_Manipulate(OSDOP_RIGHT_WORD);
			} else {
				OSD_Manipulate(OSDOP_RIGHT);
			}
			break;
		case 33:	// f
			if (osdeditalt) {
				OSD_Manipulate(OSDOP_RIGHT_WORD);
			}
			break;
		case 48:	// b
			if (osdeditalt) {
				OSD_Manipulate(OSDOP_LEFT_WORD);
			}
			break;
		case 210:	// insert
			osdovertype ^= 1; break;
		case 58:	// capslock
			osdeditcaps ^= 1; break;
		case 42:
		case 54:	// shift
			osdeditshift = 1; break;
		case 29:
		case 157:	// control
			osdeditcontrol = 1; break;
		case 56:
		case 184:	// alt
			osdeditalt = 1; break;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edi, %r14d
cmpb $0x1, 0x5a7df7(%rip)    # 0x5f42c8
jne 0x4c540
cmpb $0x0, 0x5abe02(%rip)    # 0x5f82dc
je 0x4c540
testl %esi, %esi
je 0x4c54a
callq *0x587d2(%rip)          # 0xa4cb8
movl %eax, 0x5abdfc(%rip)    # 0x5f82e8
xorl %ebx, %ebx
cmpl $0xf, %r14d
je 0x4c543
movq $0x0, 0x5abdf1(%rip) # 0x5f82f0
cmpl $0x9c, %r14d
jle 0x4c568
leal -0xc7(%r14), %eax
cmpl $0xc, %eax
ja 0x4c5b2
leaq 0x2b6ed(%rip), %rcx     # 0x77c0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x1, 0x5abdb1(%rip)    # 0x5f82e0
jne 0x4c717
movl 0x58745(%rip), %eax     # 0xa4c80
jmp 0x4c60e
movl %r14d, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
andl $0xffffff7f, %r14d      # imm = 0xFFFFFF7F
xorl %ebx, %ebx
cmpl $0x38, %r14d
je 0x4c58e
cmpl $0x1d, %r14d
jne 0x4c543
movb $0x0, 0x5abd7a(%rip)    # 0x5f82e0
jmp 0x4c543
cmpl $0x2f, %r14d
jg 0x4c597
cmpl $0x1, %r14d
je 0x4c5e0
cmpl $0x1d, %r14d
je 0x4c5d4
cmpl $0x21, %r14d
jne 0x4c543
cmpb $0x1, 0x5abd5d(%rip)    # 0x5f82e4
jne 0x4c543
jmp 0x4c61f
movb $0x0, 0x5abd4f(%rip)    # 0x5f82e4
jmp 0x4c543
cmpl $0x30, %r14d
je 0x4c5ee
cmpl $0x38, %r14d
je 0x4c5c8
cmpl $0x3a, %r14d
jne 0x4c543
xorb $0x1, 0x5abd4c(%rip)    # 0x5f82fc
jmp 0x4c543
cmpl $0x9d, %r14d
je 0x4c5d4
cmpl $0xb8, %r14d
jne 0x4c543
movb $0x1, 0x5abd15(%rip)    # 0x5f82e4
jmp 0x4c543
movb $0x1, 0x5abd05(%rip)    # 0x5f82e0
jmp 0x4c543
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x4c79f
jmp 0x4c543
cmpb $0x1, 0x5abcef(%rip)    # 0x5f82e4
jne 0x4c543
jmp 0x4c6b4
movl 0x5abcfe(%rip), %eax    # 0x5f8304
testl %eax, %eax
jle 0x4c543
decl %eax
jmp 0x4c64b
cmpb $0x1, 0x5abcc7(%rip)    # 0x5f82e0
jne 0x4c6eb
movl $0x5, %edi
jmp 0x4c6b9
movl $0xf, %edi
jmp 0x4c6b9
movl 0x5abccb(%rip), %eax    # 0x5f8304
movl 0x58641(%rip), %ecx     # 0xa4c80
decl %ecx
cmpl %ecx, %eax
jge 0x4c543
incl %eax
movl %eax, 0x5abcb3(%rip)    # 0x5f8304
jmp 0x4c543
movl $0xe, %edi
jmp 0x4c6b9
movslq 0x5abeac(%rip), %rax    # 0x5f8510
movl 0x5abca2(%rip), %ebp    # 0x5f830c
cmpl %ebp, %eax
sete %cl
testl %ebp, %ebp
sete %dl
orb %cl, %dl
jne 0x4c543
cmpl %ebp, %eax
jge 0x4c69e
leaq 0x5abc89(%rip), %rcx    # 0x5f8310
leaq (%rcx,%rax), %rdi
leaq (%rax,%rcx), %rsi
incq %rsi
notl %eax
addl %ebp, %eax
movslq %eax, %rdx
callq 0x61a0
decl %ebp
movl %ebp, 0x5abc66(%rip)    # 0x5f830c
jmp 0x4c543
cmpb $0x1, 0x5abc2e(%rip)    # 0x5f82e0
jne 0x4c730
movl $0x3, %edi
callq 0x4bd21
jmp 0x4c543
cmpb $0x1, 0x5abc16(%rip)    # 0x5f82e0
jne 0x4c761
movl $0x0, 0x5abc2a(%rip)    # 0x5f8304
jmp 0x4c543
xorb $0x1, 0x5abc12(%rip)    # 0x5f82f8
jmp 0x4c543
movl 0x5abe1f(%rip), %eax    # 0x5f8510
cmpl 0x5abc15(%rip), %eax    # 0x5f830c
jge 0x4c701
incl %eax
movl %eax, 0x5abe0f(%rip)    # 0x5f8510
movl %eax, %ecx
subl 0x585df(%rip), %ecx     # 0xa4ce8
jl 0x4c543
addl %ecx, 0x5abbf3(%rip)    # 0x5f8308
jmp 0x4c794
xorl %ebx, %ebx
movl %ebx, 0x5abdf1(%rip)    # 0x5f8510
movl %ebx, 0x5abbe3(%rip)    # 0x5f8308
movl 0x585b1(%rip), %eax     # 0xa4cdc
addl $-0x4, %eax
jmp 0x4c794
movl 0x5abdda(%rip), %eax    # 0x5f8510
testl %eax, %eax
jle 0x4c742
decl %eax
movl %eax, 0x5abdce(%rip)    # 0x5f8510
movl %eax, %ecx
subl 0x5abbbe(%rip), %ecx    # 0x5f8308
jge 0x4c543
addl %ecx, 0x58592(%rip)     # 0xa4ce8
movl %eax, 0x5abbac(%rip)    # 0x5f8308
jmp 0x4c543
movl 0x5abba5(%rip), %ecx    # 0x5f830c
movl %ecx, 0x5abda3(%rip)    # 0x5f8510
movl %ecx, 0x58575(%rip)     # 0xa4ce8
movl 0x58563(%rip), %eax     # 0xa4cdc
addl $-0x4, %eax
subl %eax, %ecx
movl %ecx, 0x5abb84(%rip)    # 0x5f8308
jns 0x4c543
movl $0x0, 0x5abb74(%rip)    # 0x5f8308
movl %eax, 0x5854e(%rip)     # 0xa4ce8
jmp 0x4c543