// File: /workspace/github_c_makefile_star2_O2/martincameron[P]towntalk/towntalk.c
// Function: parse_child_element
static int parse_child_element( char *buffer, int idx, struct element *parent, int depth, char *message ) {
	struct element *elem = NULL;
	int offset = idx, length = 0, line = parent->line, len;
	char *bracket = NULL, chr = '\n';
	if( depth < 1 ) {
		sprintf( message, "Maximum element depth exceeded on line %d.", line );
		return -5;
	}
	while( chr ) {
		chr = buffer[ idx++ ];
		if( chr <= 32 || ( ( chr < '0' || ( chr & 0x1F ) > 26 ) && ( bracket = strchr( "\"#(),;=[]{}", chr ) ) ) ) {
			if( length > 0 ) {
				if( elem == NULL ) {
					elem = new_element( length );
					parent->child = elem;
				} else {
					elem->next = new_element( length );
					elem = elem->next;
				}
				if( elem ) {
					elem->line = line;
					memcpy( elem->str.string, &buffer[ offset ], sizeof( char ) * length );
					/*printf("%d %d %c :%s\n",offset,length,chr,elem->str.string);*/
				} else {
					strcpy( message, OUT_OF_MEMORY );
					return -1;
				}
			}
			if( chr == '\n' || chr == '#' ) {
				while( chr && chr != '\n' ) {
					chr = buffer[ idx++ ];
				}
				line++;
			} else if( chr == ')' || chr == ']' || chr == '}' ) {
				parent->line = line;
				return idx;
			} else if( chr > 32 ) {
				if( chr == '"' ) {
					len = parse_string( buffer, idx - 1, NULL, line, message );
					if( len < 0 ) {
						return len;
					} else {
						len = len - idx + 1;
					}
				} else {
					len = 2;
				}
				if( elem == NULL ) {
					elem = new_element( len );
					parent->child = elem;
				} else {
					elem->next = new_element( len );
					elem = elem->next;
				}
				if( elem ) {
					elem->line = line;
					if( chr == '"' ) {
						idx = parse_string( buffer, idx - 1, elem->str.string, line, message );
						if( idx < 0 ) {
							return idx;
						}
					} else if( chr == '(' || chr == '[' || chr == '{' ) {
						elem->str.string[ 0 ] = bracket[ 0 ];
						elem->str.string[ 1 ] = bracket[ 1 ];
						idx = parse_child_element( buffer, idx, elem, depth - 1, message );
						if( idx > 0 ) {
							/* Exchange line and elem->line. */
							len = elem->line;
							elem->line = line;
							line = len;
							if( buffer[ idx - 1 ] != bracket[ 1 ] ) {
								sprintf( message, "Unclosed element on line %d.", line );
								return -2;
							}
						} else {
							return idx;
						}
					} else {
						elem->str.string[ 0 ] = chr;
						elem->str.string[ 1 ] = 0;
						elem->str.length = 1;
					}
				} else {
					strcpy( message, OUT_OF_MEMORY );
					return -1;
				}
			}
			offset = idx;
			length = 0;
		} else {
			length++;
		}
	}
	return idx;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r12
movl 0x28(%rdx), %eax
testl %ecx, %ecx
jle 0x8663
movl %esi, %ebp
movl %eax, 0xc(%rsp)
movq %rdx, 0x38(%rsp)
leaq 0x18(%rdx), %rax
movq %rax, 0x30(%rsp)
decl %ecx
movl %ecx, 0x24(%rsp)
movb $0xa, %r14b
movq $0x0, 0x10(%rsp)
xorl %r15d, %r15d
movq %rdi, 0x18(%rsp)
testb %r14b, %r14b
sete %al
movq %rbp, %r13
incl %ebp
xorl %ebx, %ebx
movq %r13, 0x40(%rsp)
testb $0x1, %al
jne 0x868a
movslq %r13d, %rax
movsbl (%rdi,%rax), %r14d
cmpl $0x21, %r14d
jl 0x8477
cmpb $0x30, %r14b
setae %al
movl %r14d, %ecx
andl $0x1f, %ecx
cmpl $0x1b, %ecx
setb %cl
testb %cl, %al
jne 0x8463
leaq 0x9651(%rip), %rdi      # 0x11a9c
movl %r14d, %esi
pushq $0xc
popq %rdx
callq 0x3110
testq %rax, %rax
jne 0x846f
xorl %r15d, %r15d
movq 0x18(%rsp), %rdi
decq %rbx
incl %r13d
incl %ebp
xorl %eax, %eax
jmp 0x8417
movq %rax, %r15
movq 0x18(%rsp), %rdi
testl %ebx, %ebx
je 0x84da
movq %r12, 0x28(%rsp)
negq %rbx
movl %ebx, %edi
callq 0x3638
movq %rax, %r12
movq 0x10(%rsp), %rcx
leaq 0x20(%rcx), %rax
testq %rcx, %rcx
cmoveq 0x30(%rsp), %rax
movq %r12, (%rax)
testq %r12, %r12
je 0x869e
movl 0xc(%rsp), %eax
movl %eax, 0x28(%r12)
movq 0x8(%r12), %rdi
movslq 0x40(%rsp), %rsi
addq 0x18(%rsp), %rsi
movq %rbx, %rdx
callq 0x3180
movq 0x18(%rsp), %rdi
movq %r12, 0x10(%rsp)
movq 0x28(%rsp), %r12
movzbl %r14b, %eax
cmpl $0xa, %eax
je 0x85db
cmpl $0x7d, %eax
je 0x867b
cmpl $0x29, %eax
je 0x867b
cmpl $0x5d, %eax
je 0x867b
cmpl $0x23, %eax
je 0x85db
leal 0x1(%r13), %ebp
cmpb $0x21, %r14b
jl 0x8405
pushq $0x2
popq %rax
cmpb $0x22, %r14b
jne 0x853e
movl %r13d, %esi
xorl %edx, %edx
movl 0xc(%rsp), %ecx
movq %r12, %r8
callq 0x86da
testl %eax, %eax
js 0x86bf
subl %r13d, %eax
movl %eax, %edi
callq 0x3638
movq %rax, %rbx
movq 0x10(%rsp), %rcx
leaq 0x20(%rcx), %rax
testq %rcx, %rcx
cmoveq 0x30(%rsp), %rax
movq %rbx, (%rax)
testq %rbx, %rbx
je 0x86ac
movl 0xc(%rsp), %ecx
movl %ecx, 0x28(%rbx)
cmpb $0x22, %r14b
jne 0x85a4
movq 0x8(%rbx), %rdx
movq 0x18(%rsp), %r14
movq %r14, %rdi
movl %r13d, %esi
movq %r12, %r8
callq 0x86da
movq %r14, %rdi
movl %eax, %ebp
movb $0xa, %r14b
movq %rbx, 0x10(%rsp)
testl %eax, %eax
jns 0x8405
jmp 0x868d
cmpb $0x28, %r14b
movq 0x18(%rsp), %rdi
je 0x8602
movl %r14d, %eax
andb $0x5f, %al
cmpb $0x5b, %al
je 0x8602
movq 0x8(%rbx), %rax
movb %r14b, (%rax)
movq 0x8(%rbx), %rax
movb $0x0, 0x1(%rax)
movl $0x1, 0x10(%rbx)
movb $0xa, %r14b
movq %rbx, 0x10(%rsp)
jmp 0x8405
movslq %ebp, %rax
addq %rdi, %rax
testb %r14b, %r14b
je 0x85f9
movzbl %r14b, %ecx
cmpl $0xa, %ecx
je 0x85f9
movb (%rax), %r14b
incl %ebp
incq %rax
jmp 0x85e1
incl 0xc(%rsp)
jmp 0x8405
movb (%r15), %al
movq 0x8(%rbx), %rcx
movb %al, (%rcx)
movb 0x1(%r15), %al
movq 0x8(%rbx), %rcx
movb %al, 0x1(%rcx)
incl %r13d
movq %rdi, %r14
movl %r13d, %esi
movq %rbx, %rdx
movl 0x24(%rsp), %ecx
movq %r12, %r8
callq 0x83bb
movl %eax, %ebp
testl %eax, %eax
jle 0x86c3
movl 0x28(%rbx), %edx
movl 0xc(%rsp), %eax
movl %eax, 0x28(%rbx)
movl %ebp, %eax
movb -0x1(%r14,%rax), %al
movq %rbx, 0x10(%rsp)
movl %edx, 0xc(%rsp)
movq %r14, %rdi
movb $0xa, %r14b
cmpb 0x1(%r15), %al
jne 0x86c5
jmp 0x8405
leaq 0x9407(%rip), %rsi      # 0x11a71
movq %r12, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x3200
pushq $-0x5
popq %rbp
jmp 0x868d
movq 0x38(%rsp), %rax
movl 0xc(%rsp), %ecx
movl %ecx, 0x28(%rax)
incl %r13d
movl %r13d, %ebp
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xfacb(%rip), %rsi      # 0x18170
movq 0x28(%rsp), %rdi
jmp 0x86b6
movq 0xfabd(%rip), %rsi      # 0x18170
movq %r12, %rdi
callq 0x3070
pushq $-0x1
jmp 0x8678
movl %eax, %ebp
jmp 0x868d
jmp 0x868d
leaq 0x93dc(%rip), %rsi      # 0x11aa8
movq %r12, %rdi
xorl %eax, %eax
callq 0x3200
pushq $-0x2
jmp 0x8678