// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpb $0x0, 0x5aa655(%rip)    # 0x5ed2c8
je 0x42cdb
movq %rdi, %rbx
testq %rdi, %rdi
je 0x42ce4
movb (%rbx), %cl
testb %cl, %cl
je 0x42ced
movq %rdx, %r14
pushq $0x1
popq %rax
testb %cl, %cl
je 0x42d14
cmpq $0x1, %rax
setne %dl
leal -0x30(%rcx), %edi
cmpb $0xa, %dil
setae %dil
orb %dl, %dil
je 0x42d47
cmpb $0x30, %cl
jl 0x42d0b
leal -0x3a(%rcx), %edx
cmpb $0x7, %dl
jb 0x42d0b
leal -0x5b(%rcx), %edx
cmpb $0x6, %dl
setb %dl
cmpb $0x5f, %cl
setne %dil
cmpb $0x7a, %cl
ja 0x42d0b
andb %dl, %dil
jne 0x42d0b
movb (%rbx,%rax), %cl
incq %rax
jmp 0x42c89
leaq 0x29dc0(%rip), %rdi     # 0x6caa2
jmp 0x42cf4
leaq 0x29de4(%rip), %rdi     # 0x6cacf
jmp 0x42cf4
leaq 0x29e21(%rip), %rdi     # 0x6cb15
callq 0x30c8d
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x29e9a(%rip), %rdi     # 0x6cbac
jmp 0x42d4e
testq %rsi, %rsi
leaq 0x29ecf(%rip), %r12     # 0x6cbed
cmovneq %rsi, %r12
testq %r14, %r14
je 0x42d5a
movq %rbx, %rdi
callq 0x443e1
testq %rax, %rax
je 0x42d63
cmpq %r14, 0x18(%rax)
je 0x42ddc
leaq 0x29f05(%rip), %rdi     # 0x6cc4a
jmp 0x42d4e
leaq 0x29e09(%rip), %rdi     # 0x6cb57
movq %rbx, %rsi
xorl %eax, %eax
callq 0x22427
jmp 0x42cf9
leaq 0x29eaf(%rip), %rdi     # 0x6cc10
jmp 0x42cf4
pushq $0x1
popq %rdi
pushq $0x20
popq %rsi
callq 0x6930
testq %rax, %rax
je 0x42dc1
movq %rax, %r15
movq 0x5aa543(%rip), %r13    # 0x5ed2c0
testq %r13, %r13
je 0x42dca
movq (%r13), %rsi
movq %rbx, %rdi
callq 0x6880
testl %eax, %eax
jg 0x42d9b
movq %r15, 0x5aa527(%rip)    # 0x5ed2c0
jmp 0x42dbb
movq %r13, %rbp
movq 0x8(%r13), %r13
testq %r13, %r13
je 0x42db7
movq (%r13), %rdi
movq %rbx, %rsi
callq 0x6880
testl %eax, %eax
jle 0x42d9b
movq %r15, 0x8(%rbp)
movq %r13, 0x8(%r15)
jmp 0x42dd1
leaq 0x29eb3(%rip), %rdi     # 0x6cc7b
jmp 0x42d4e
movq %r15, 0x5aa4ef(%rip)    # 0x5ed2c0
movq %rbx, (%r15)
movq %r12, 0x10(%r15)
movq %r14, 0x18(%r15)
xorl %eax, %eax
jmp 0x42cfc