// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/src/osd.c
// Function: OSD_RegisterFunction
int OSD_RegisterFunction(const char *name, const char *help, int (*func)(const osdfuncparm_t*))
{
	symbol_t *symb;
	const char *cp;

	if (!osdinited) {
        buildputs("OSD_RegisterFunction(): OSD not initialised\n");
        return -1;
    }

	if (!name) {
		buildputs("OSD_RegisterFunction(): may not register a function with a null name\n");
		return -1;
	}
	if (!name[0]) {
		buildputs("OSD_RegisterFunction(): may not register a function with no name\n");
		return -1;
	}

	// check for illegal characters in name
	for (cp = name; *cp; cp++) {
		if ((cp == name) && (*cp >= '0') && (*cp <= '9')) {
			buildprintf("OSD_RegisterFunction(): first character of function name \"%s\" must not be a numeral\n", name);
			return -1;
		}
		if ((*cp < '0') ||
		    (*cp > '9' && *cp < 'A') ||
		    (*cp > 'Z' && *cp < 'a' && *cp != '_') ||
		    (*cp > 'z')) {
			buildprintf("OSD_RegisterFunction(): illegal character in function name \"%s\"\n", name);
			return -1;
		}
	}

	if (!help) help = "(no description for this function)";
	if (!func) {
		buildputs("OSD_RegisterFunction(): may not register a null function\n");
		return -1;
	}

	symb = findexactsymbol(name);
	if (symb && symb->func == func) {
		// Same function being defined a second time, so we'll quietly ignore it.
		return 0;
	} else if (symb) {
		buildprintf("OSD_RegisterFunction(): \"%s\" is already defined\n", name);
		return -1;
	}

	symb = addnewsymbol(name);
	if (!symb) {
		buildprintf("OSD_RegisterFunction(): Failed registering function \"%s\"\n", name);
		return -1;
	}

	symb->name = name;
	symb->help = help;
	symb->func = func;

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpb $0x0, 0x5a8de4(%rip)    # 0x5f42c8
je 0x4b587
movq %rdi, %rbx
testq %rdi, %rdi
je 0x4b590
movb (%rbx), %cl
testb %cl, %cl
je 0x4b599
movq %rdx, %r14
movl $0x1, %eax
cmpq $0x1, %rax
setne %dl
leal -0x30(%rcx), %edi
cmpb $0xa, %dil
setae %dil
orb %dl, %dil
je 0x4b5b9
cmpb $0x30, %cl
jl 0x4b5b0
leal -0x3a(%rcx), %edx
cmpb $0x7, %dl
jb 0x4b5b0
leal -0x5b(%rcx), %edx
cmpb $0x6, %dl
setb %dl
cmpb $0x5f, %cl
setne %dil
cmpb $0x7a, %cl
ja 0x4b5b0
andb %dl, %dil
jne 0x4b5b0
movb (%rbx,%rax), %cl
incq %rax
testb %cl, %cl
jne 0x4b508
testq %rsi, %rsi
leaq 0x2c91b(%rip), %r15     # 0x77e7d
cmovneq %rsi, %r15
testq %r14, %r14
je 0x4b5cc
movq %rbx, %rdi
callq 0x4cf63
testq %rax, %rax
je 0x4b5d5
cmpq %r14, 0x18(%rax)
je 0x4b5ed
leaq 0x2c955(%rip), %rdi     # 0x77eda
jmp 0x4b5c0
leaq 0x2c7a4(%rip), %rdi     # 0x77d32
jmp 0x4b5a0
leaq 0x2c7c8(%rip), %rdi     # 0x77d5f
jmp 0x4b5a0
leaq 0x2c805(%rip), %rdi     # 0x77da5
callq 0x32d18
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r14
popq %r15
retq
leaq 0x2c885(%rip), %rdi     # 0x77e3c
jmp 0x4b5c0
leaq 0x2c827(%rip), %rdi     # 0x77de7
movq %rbx, %rsi
xorl %eax, %eax
callq 0x25221
jmp 0x4b5a5
leaq 0x2c8cd(%rip), %rdi     # 0x77ea0
jmp 0x4b5a0
movq %rbx, %rdi
callq 0x4cf9b
testq %rax, %rax
je 0x4b5f1
movq %rbx, (%rax)
movq %r15, 0x10(%rax)
movq %r14, 0x18(%rax)
xorl %eax, %eax
jmp 0x4b5aa
leaq 0x2c913(%rip), %rdi     # 0x77f0b
jmp 0x4b5c0