// File: /workspace/github_c_makefile_star2_O0/hughbarney[P]zepl/zepl.c
// Function: get_key
char_t *get_key(keymap_t *keys, keymap_t **key_return)
{
	keymap_t *k;
	int submatch;
	static char_t buffer[K_BUFFER_LENGTH];
	static char_t *record = buffer;

	*key_return = NULL;

	/* if recorded bytes remain, return next recorded byte. */
	if (*record != '\0') {
		*key_return = NULL;
		return record++;
	}
	/* reset record buffer. */
	record = buffer;

	do {
		assert(K_BUFFER_LENGTH > record - buffer);
		/* read and record one byte. */
		*record++ = (unsigned)getch();
		*record = '\0';

		/* if recorded bytes match any multi-byte sequence... */
		for (k = keys, submatch = 0; k != NULL; k = k->k_next) {
			char_t *p, *q;

			if (k->k_func == NULL) continue;
			assert(k->k_bytes != NULL);

			for (p = buffer, q = (char_t *)k->k_bytes; *p == *q; ++p, ++q) {
			        /* an exact match */
				if (*q == '\0' && *p == '\0') {
	    				record = buffer;
					*record = '\0';
					*key_return = k;
					return record; /* empty string */
				}
			}
			/* record bytes match part of a command sequence */
			if (*p == '\0' && *q != '\0') {
				submatch = 1;
			}
		}
	} while (submatch);
	/* nothing matched, return recorded bytes. */
	record = buffer;
	return (record++);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq 0xc54e(%rip), %rax      # 0xf1d0
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x2cb3
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq 0xc534(%rip), %rax      # 0xf1d0
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0xc526(%rip)      # 0xf1d0
movq %rax, -0x8(%rbp)
jmp 0x2e12
leaq 0xce96(%rip), %rax      # 0xfb50
movq %rax, 0xc50f(%rip)      # 0xf1d0
movq 0xc308(%rip), %rax      # 0xefd0
movq (%rax), %rdi
callq 0x20d0
movb %al, %cl
movq 0xc4f7(%rip), %rax      # 0xf1d0
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0xc4e9(%rip)      # 0xf1d0
movb %cl, (%rax)
movq 0xc4e0(%rip), %rax      # 0xf1d0
movb $0x0, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x2ddf
movq -0x20(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x2d1d
jmp 0x2dce
leaq 0xce2c(%rip), %rax      # 0xfb50
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
addq $0xd, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
movq -0x38(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x2dad
movq -0x38(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x2d91
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x2d91
leaq 0xcdeb(%rip), %rax      # 0xfb50
movq %rax, 0xc464(%rip)      # 0xf1d0
movq 0xc45d(%rip), %rax      # 0xf1d0
movb $0x0, (%rax)
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq 0xc448(%rip), %rax      # 0xf1d0
movq %rax, -0x8(%rbp)
jmp 0x2e12
jmp 0x2d93
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2d34
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x2dcc
movq -0x38(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x2dcc
movl $0x1, -0x24(%rbp)
jmp 0x2dce
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x2d02
jmp 0x2de1
cmpl $0x0, -0x24(%rbp)
jne 0x2cc1
leaq 0xcd5e(%rip), %rax      # 0xfb50
movq %rax, 0xc3d7(%rip)      # 0xf1d0
movq 0xc3d0(%rip), %rax      # 0xf1d0
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0xc3c2(%rip)      # 0xf1d0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)