// File: /workspace/github_c_makefile_star2_O2/martincameron[P]towntalk/towntalk.c
// Function: parse_struct_declaration
static struct element* parse_struct_declaration( struct element *elem,
	struct function *func, struct variables *vars, struct statement *prev, char *message ) {
	struct string_list *field, *tail;
	struct environment *env = func->env;
	struct element *child, *next = elem->next;
	int qlen = qualify_name( func, next->str.string, next->str.length, NULL );
	struct structure *struc = calloc( 1, sizeof( struct structure ) + sizeof( char ) * ( qlen + 1 ) );
	if( struc ) {
		struc->str.reference_count = 1;
		struc->str.string = ( char * ) &struc[ 1 ];
		qualify_name( func, next->str.string, next->str.length, struc->str.string );
		struc->str.length = qlen;
		struc->str.type = STRUCT;
		tail = add_decl( &struc->str, next->line, env, message );
		if( tail ) {
			next = next->next;
			if( next && next->str.string[ 0 ] == '(' ) {
				child = next->child;
				if( child && child->next == NULL ) {
					struc->super = ( struct structure * ) find_decl( func, child->str.string, STRUCT, NULL );
				}
				if( struc->super && struc->super != struc ) {
					field = struc->super->fields;
					while( field && message[ 0 ] == 0 ) {
						if( append_string_list( &struc->fields, &struc->fields_tail, field->str ) ) {
							struc->length++;
						} else {
							strcpy( message, OUT_OF_MEMORY );
						}
						field = field->next;
					}
					next = next->next;
				} else {
					sprintf( message, "Invalid parent structure on line %d.", next->line );
				}
			}
		}
		if( message[ 0 ] == 0 ) {
			if( next && next->str.string[ 0 ] == '{' ) {
				child = next->child;
				while( child && message[ 0 ] == 0 ) {
					if( add_structure_field( struc, child, message ) ) {
						child = child->next;
						if( child && ( child->str.string[ 0 ] == ',' || child->str.string[ 0 ] == ';' ) ) {
							child = child->next;
						}
					}
				}
				next = next->next;
				if( next && next->str.string[ 0 ] == ';' ) {
					next = next->next;
				}
			} else {
				sprintf( message, "Expected '{' after 'struct' on line %d.", elem->line );
			}
		}
		unref_string( &struc->str );
	} else {
		strcpy( message, OUT_OF_MEMORY );
	}
	return next;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, 0x10(%rsp)
movq %rsi, %r13
movq 0x30(%rsi), %rax
movq %rdi, 0x8(%rsp)
movq 0x20(%rdi), %rcx
movq %rcx, %r15
movl 0x10(%rcx), %ebp
movl %ebp, %ebx
testq %rax, %rax
je 0x8ca1
movl 0x10(%rax), %eax
leal (%rax,%rbp), %ebx
incl %ebx
movq 0x40(%r13), %r12
movslq %ebx, %rsi
addq $0x39, %rsi
pushq $0x1
popq %rdi
callq 0x3130
testq %rax, %rax
je 0x8d6e
movq %rax, %r14
movq $0x1, (%rax)
leaq 0x38(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x8(%r15), %rsi
movq %r13, %rdi
movl %ebp, %edx
callq 0x787e
movl %ebx, 0x10(%r14)
movq %r15, %rbx
movb $0x3, 0x14(%r14)
movl 0x28(%r15), %esi
movq %r14, %rdi
movq %r12, %rdx
movq 0x10(%rsp), %r15
movq %r15, %rcx
callq 0x3d9a
testq %rax, %rax
je 0x8de6
movq 0x20(%rbx), %rbx
testq %rbx, %rbx
je 0x8d87
movq 0x8(%rbx), %rax
cmpb $0x28, (%rax)
jne 0x8de6
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x8d44
cmpq $0x0, 0x20(%rax)
jne 0x8d44
movq 0x8(%rax), %rsi
pushq $0x3
popq %rdx
movq %r13, %rdi
xorl %ecx, %ecx
callq 0x5f5b
movq %rax, 0x30(%r14)
movq 0x30(%r14), %r12
testq %r12, %r12
sete %al
cmpq %r14, %r12
sete %cl
orb %al, %cl
je 0x8d98
movl 0x28(%rbx), %edx
leaq 0x8e49(%rip), %rsi      # 0x11bab
movq %r15, %rdi
xorl %eax, %eax
callq 0x3200
jmp 0x8de6
movq 0xf3fb(%rip), %rsi      # 0x18170
movq 0x10(%rsp), %rdi
callq 0x3070
movq %r15, %rbx
jmp 0x8f2e
xorl %ebx, %ebx
cmpb $0x0, (%r15)
jne 0x8f26
jmp 0x8f0d
addq $0x20, %r12
leaq 0x20(%r14), %r13
leaq 0x28(%r14), %rbp
movq (%r12), %r12
testq %r12, %r12
je 0x8de2
cmpb $0x0, (%r15)
jne 0x8de2
movq (%r12), %rdx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x790a
testq %rax, %rax
je 0x8dcd
incl 0x18(%r14)
jmp 0x8ddc
movq 0xf39c(%rip), %rsi      # 0x18170
movq %r15, %rdi
callq 0x3070
addq $0x8, %r12
jmp 0x8da4
movq 0x20(%rbx), %rbx
cmpb $0x0, (%r15)
jne 0x8f26
testq %rbx, %rbx
je 0x8f0b
movq 0x8(%rbx), %rax
cmpb $0x7b, (%rax)
jne 0x8f0d
movq 0x18(%rbx), %rbp
leaq 0x20(%r14), %r12
movq %r14, %rax
addq $0x28, %rax
movq %rax, 0x8(%rsp)
xorl %eax, %eax
testb %al, %al
sete %cl
testq %rbp, %rbp
je 0x8f40
testb $0x1, %cl
je 0x8f40
movq %rbp, %rdi
movq %r15, %rsi
callq 0x6927
testl %eax, %eax
je 0x8ecb
movq (%r12), %rdi
movq 0x8(%rbp), %r13
testq %rdi, %rdi
je 0x8e78
movq %r13, %rsi
callq 0x7d09
testl %eax, %eax
js 0x8e78
movl 0x28(%rbp), %ecx
movq %r15, %rdi
leaq 0x8d8c(%rip), %rsi      # 0x11bf8
movq %r13, %rdx
xorl %eax, %eax
callq 0x3200
jmp 0x8ecb
movq %r13, %rdi
callq 0x3756
testq %rax, %rax
je 0x8ea3
movq %rax, %r13
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movq %rax, %rdx
callq 0x790a
testq %rax, %rax
je 0x8eb4
incl 0x18(%r14)
jmp 0x8ec3
movq 0xf2c6(%rip), %rsi      # 0x18170
movq %r15, %rdi
callq 0x3070
jmp 0x8ecb
movq 0xf2b5(%rip), %rsi      # 0x18170
movq %r15, %rdi
callq 0x3070
movq %r13, %rdi
callq 0x38b2
movb (%r15), %al
xorl %ecx, %ecx
testb %al, %al
jne 0x8e21
movq 0x20(%rbp), %rcx
movl $0x0, %ebp
testq %rcx, %rcx
je 0x8e1c
movq 0x8(%rcx), %rdx
movzbl (%rdx), %edx
cmpl $0x3b, %edx
je 0x8f02
movq %rcx, %rbp
cmpl $0x2c, %edx
jne 0x8e1c
movq 0x20(%rcx), %rbp
jmp 0x8e1c
xorl %ebx, %ebx
movq 0x8(%rsp), %rax
movl 0x28(%rax), %edx
leaq 0x8cb4(%rip), %rsi      # 0x11bd0
movq %r15, %rdi
xorl %eax, %eax
callq 0x3200
movq %r14, %rdi
callq 0x38b2
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%rbx), %rbx
testq %rbx, %rbx
je 0x8f58
movq 0x8(%rbx), %rax
cmpb $0x3b, (%rax)
jne 0x8f26
movq 0x20(%rbx), %rbx
jmp 0x8f26
xorl %ebx, %ebx
jmp 0x8f26