// File: /workspace/github_c_makefile_star2_O1/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, 0x5aa2a8(%rip)    # 0x5f32c8
je 0x490c4
movq %rdi, %rbx
testq %rdi, %rdi
je 0x490cd
cmpb $0x0, (%rbx)
je 0x490d6
movq %rdx, %r14
movb (%rbx), %cl
testb %cl, %cl
je 0x49095
movl $0x1, %eax
cmpq $0x1, %rax
setne %dl
leal -0x30(%rcx), %edi
cmpb $0xa, %dil
setae %dil
orb %dl, %dil
je 0x490ff
cmpb $0x30, %cl
jl 0x490df
leal -0x3a(%rcx), %edx
cmpb $0x7, %dl
jb 0x490df
leal -0x5b(%rcx), %edx
cmpb $0x6, %dl
setb %dl
cmpb $0x5f, %cl
setne %dil
cmpb $0x7a, %cl
jg 0x490df
andb %dl, %dil
jne 0x490df
movb (%rbx,%rax), %cl
incq %rax
testb %cl, %cl
jne 0x49049
testq %rsi, %rsi
leaq 0x2daee(%rip), %r15     # 0x76b8d
cmovneq %rsi, %r15
testq %r14, %r14
je 0x490e8
movq %rbx, %rdi
callq 0x4aa78
testq %rax, %rax
je 0x49108
cmpq %r14, 0x18(%rax)
je 0x49120
leaq 0x2db28(%rip), %rdi     # 0x76bea
jmp 0x4912b
leaq 0x2d977(%rip), %rdi     # 0x76a42
jmp 0x490ef
leaq 0x2d99b(%rip), %rdi     # 0x76a6f
jmp 0x490ef
leaq 0x2d9d8(%rip), %rdi     # 0x76ab5
jmp 0x490ef
leaq 0x2da66(%rip), %rdi     # 0x76b4c
jmp 0x4912b
leaq 0x2dac1(%rip), %rdi     # 0x76bb0
callq 0x32200
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r14
popq %r15
retq
leaq 0x2d9f1(%rip), %rdi     # 0x76af7
jmp 0x4912b
movq %rbx, %rdi
callq 0x4aab0
testq %rax, %rax
je 0x49124
movq %rbx, (%rax)
movq %r15, 0x10(%rax)
movq %r14, 0x18(%rax)
xorl %eax, %eax
jmp 0x490f9
leaq 0x2daf0(%rip), %rdi     # 0x76c1b
movq %rbx, %rsi
xorl %eax, %eax
callq 0x24cb4
jmp 0x490f4