// File: /workspace/github_c_makefile_star2_O1/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, 0x5a92ce(%rip)    # 0x5f32c8
jne 0x4a069
cmpb $0x0, 0x5ad2d9(%rip)    # 0x5f72dc
je 0x4a069
testl %esi, %esi
je 0x4a073
callq *0x59ca9(%rip)          # 0xa3cb8
movl %eax, 0x5ad2d3(%rip)    # 0x5f72e8
xorl %ebx, %ebx
cmpl $0xf, %r14d
je 0x4a06c
movq $0x0, 0x5ad2c8(%rip) # 0x5f72f0
cmpl $0x9c, %r14d
jle 0x4a091
leal -0xc7(%r14), %eax
cmpl $0xc, %eax
ja 0x4a0db
leaq 0x2c8d4(%rip), %rcx     # 0x7691c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x1, 0x5ad288(%rip)    # 0x5f72e0
jne 0x4a24d
movl 0x59c1c(%rip), %eax     # 0xa3c80
jmp 0x4a137
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 0x4a0b7
cmpl $0x1d, %r14d
jne 0x4a06c
movb $0x0, 0x5ad251(%rip)    # 0x5f72e0
jmp 0x4a06c
cmpl $0x2f, %r14d
jg 0x4a0c0
cmpl $0x1, %r14d
je 0x4a109
cmpl $0x1d, %r14d
je 0x4a0fd
cmpl $0x21, %r14d
jne 0x4a06c
cmpb $0x1, 0x5ad234(%rip)    # 0x5f72e4
jne 0x4a06c
jmp 0x4a148
movb $0x0, 0x5ad226(%rip)    # 0x5f72e4
jmp 0x4a06c
cmpl $0x30, %r14d
je 0x4a117
cmpl $0x38, %r14d
je 0x4a0f1
cmpl $0x3a, %r14d
jne 0x4a06c
xorb $0x1, 0x5ad223(%rip)    # 0x5f72fc
jmp 0x4a06c
cmpl $0x9d, %r14d
je 0x4a0fd
cmpl $0xb8, %r14d
jne 0x4a06c
movb $0x1, 0x5ad1ec(%rip)    # 0x5f72e4
jmp 0x4a06c
movb $0x1, 0x5ad1dc(%rip)    # 0x5f72e0
jmp 0x4a06c
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x4a2db
jmp 0x4a06c
cmpb $0x1, 0x5ad1c6(%rip)    # 0x5f72e4
jne 0x4a06c
jmp 0x4a1e1
movl 0x5ad1d5(%rip), %eax    # 0x5f7304
testl %eax, %eax
jle 0x4a06c
decl %eax
jmp 0x4a174
cmpb $0x1, 0x5ad19e(%rip)    # 0x5f72e0
jne 0x4a218
movl $0x5, %edi
jmp 0x4a1e6
movl $0xf, %edi
jmp 0x4a1e6
movl 0x5ad1a2(%rip), %eax    # 0x5f7304
movl 0x59b18(%rip), %ecx     # 0xa3c80
decl %ecx
cmpl %ecx, %eax
jge 0x4a06c
incl %eax
movl %eax, 0x5ad18a(%rip)    # 0x5f7304
jmp 0x4a06c
movl $0xe, %edi
jmp 0x4a1e6
movslq 0x5ad383(%rip), %rax    # 0x5f7510
movl 0x5ad179(%rip), %ebp    # 0x5f730c
cmpl %ebp, %eax
sete %cl
testl %ebp, %ebp
sete %dl
orb %cl, %dl
jne 0x4a06c
cmpl %ebp, %eax
jge 0x4a1c7
leaq 0x5ad160(%rip), %rcx    # 0x5f7310
leaq (%rcx,%rax), %rdi
leaq (%rax,%rcx), %rsi
incq %rsi
notl %eax
addl %ebp, %eax
movslq %eax, %rdx
callq 0x61a0
decl %ebp
movl %ebp, 0x5ad13d(%rip)    # 0x5f730c
jmp 0x4a06c
cmpb $0x1, 0x5ad105(%rip)    # 0x5f72e0
jne 0x4a266
movl $0x3, %edi
callq 0x49858
jmp 0x4a06c
cmpb $0x1, 0x5ad0e9(%rip)    # 0x5f72e0
jne 0x4a29d
movl $0x0, 0x5ad0fd(%rip)    # 0x5f7304
jmp 0x4a06c
xorb $0x1, 0x5ad0e5(%rip)    # 0x5f72f8
jmp 0x4a06c
movl 0x5ad2f2(%rip), %eax    # 0x5f7510
cmpl 0x5ad0e8(%rip), %eax    # 0x5f730c
jge 0x4a22e
incl %eax
movl %eax, 0x5ad2e2(%rip)    # 0x5f7510
movl 0x5ad2dc(%rip), %eax    # 0x5f7510
movl %eax, %ecx
subl 0x59aac(%rip), %ecx     # 0xa3ce8
jl 0x4a06c
addl %ecx, 0x5ad0c0(%rip)    # 0x5f7308
jmp 0x4a2d0
xorl %ebx, %ebx
movl %ebx, 0x5ad2bb(%rip)    # 0x5f7510
movl %ebx, 0x5ad0ad(%rip)    # 0x5f7308
movl 0x59a7b(%rip), %eax     # 0xa3cdc
addl $-0x4, %eax
jmp 0x4a2d0
movl 0x5ad2a4(%rip), %eax    # 0x5f7510
testl %eax, %eax
jle 0x4a278
decl %eax
movl %eax, 0x5ad298(%rip)    # 0x5f7510
movl 0x5ad292(%rip), %eax    # 0x5f7510
movl %eax, %ecx
subl 0x5ad082(%rip), %ecx    # 0x5f7308
jge 0x4a06c
addl %ecx, 0x59a56(%rip)     # 0xa3ce8
movl %eax, 0x5ad070(%rip)    # 0x5f7308
jmp 0x4a06c
movl 0x5ad069(%rip), %ecx    # 0x5f730c
movl %ecx, 0x5ad267(%rip)    # 0x5f7510
movl %ecx, 0x59a39(%rip)     # 0xa3ce8
movl 0x59a27(%rip), %eax     # 0xa3cdc
addl $-0x4, %eax
subl %eax, %ecx
movl %ecx, 0x5ad048(%rip)    # 0x5f7308
jns 0x4a06c
movl $0x0, 0x5ad038(%rip)    # 0x5f7308
movl %eax, 0x59a12(%rip)     # 0xa3ce8
jmp 0x4a06c