// File: /workspace/github_c_makefile_star2_O1/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, 0x8(%rsp)
movq %rsi, %r13
movq %rdi, (%rsp)
movq 0x20(%rdi), %rbx
movl 0x10(%rbx), %ebp
movl %ebp, %r14d
testq %rsi, %rsi
je 0x95a2
movq 0x30(%r13), %rax
movl %ebp, %r14d
testq %rax, %rax
je 0x95a2
movl 0x10(%rax), %eax
leal (%rax,%rbp), %r14d
incl %r14d
movq 0x40(%r13), %r12
movslq %r14d, %rsi
addq $0x39, %rsi
movl $0x1, %edi
callq 0x3130
testq %rax, %rax
je 0x966f
movq %rax, %r15
movq $0x1, (%rax)
leaq 0x38(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x8(%rbx), %rsi
movq %r13, %rdi
movl %ebp, %edx
callq 0x800c
movl %r14d, 0x10(%r15)
movb $0x3, 0x14(%r15)
movl 0x28(%rbx), %esi
movq %r15, %rdi
movq %r12, %rdx
movq 0x8(%rsp), %r14
movq %r14, %rcx
callq 0x3f06
testq %rax, %rax
je 0x96d7
movq 0x20(%rbx), %rbx
testq %rbx, %rbx
je 0x9685
movq 0x8(%rbx), %rax
cmpb $0x28, (%rax)
jne 0x96d7
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x9645
cmpq $0x0, 0x20(%rax)
jne 0x9645
movq 0x8(%rax), %rsi
movq %r13, %rdi
movl $0x3, %edx
xorl %ecx, %ecx
callq 0x6103
movq %rax, 0x30(%r15)
movq 0x30(%r15), %rax
testq %rax, %rax
sete %cl
cmpq %r15, %rax
sete %dl
orb %cl, %dl
je 0x9689
movl 0x28(%rbx), %edx
leaq 0x950c(%rip), %rsi      # 0x12b6f
movq %r14, %rdi
xorl %eax, %eax
callq 0x3200
jmp 0x96d7
movq 0xfafa(%rip), %rsi      # 0x19170
movq 0x8(%rsp), %rdi
callq 0x3070
jmp 0x9843
xorl %ebx, %ebx
jmp 0x96d7
movq 0x20(%rax), %r12
testq %r12, %r12
je 0x96d3
leaq 0x20(%r15), %r13
leaq 0x28(%r15), %rbp
cmpb $0x0, (%r14)
jne 0x96d3
movq (%r12), %rdx
movq %r13, %rdi
movq %rbp, %rsi
callq 0x8098
testq %rax, %rax
je 0x96ba
incl 0x18(%r15)
jmp 0x96c9
movq 0xfaaf(%rip), %rsi      # 0x19170
movq %r14, %rdi
callq 0x3070
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x969a
movq 0x20(%rbx), %rbx
cmpb $0x0, (%r14)
jne 0x983b
testq %rbx, %rbx
je 0x9823
movq 0x8(%rbx), %rax
cmpb $0x7b, (%rax)
jne 0x9823
movq 0x18(%rbx), %r12
testq %r12, %r12
je 0x9855
leaq 0x20(%r15), %rax
movq %rax, (%rsp)
movq %r15, %rax
addq $0x28, %rax
movq %rax, 0x10(%rsp)
cmpb $0x0, (%r14)
jne 0x9855
movq %r12, %rdi
movq %r14, %rsi
callq 0x6f43
testl %eax, %eax
je 0x97ea
movq (%rsp), %rax
movq (%rax), %r13
testq %r13, %r13
je 0x9794
movq 0x8(%r12), %rbp
xorl %r14d, %r14d
movq (%r13), %rax
movq 0x8(%rax), %rdi
movq %rbp, %rsi
callq 0x3140
testl %eax, %eax
je 0x976f
incl %r14d
movq 0x8(%r13), %r13
testq %r13, %r13
jne 0x9749
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testl %r14d, %r14d
movq 0x8(%rsp), %r14
js 0x9794
movl 0x28(%r12), %ecx
movq %r14, %rdi
leaq 0x9434(%rip), %rsi      # 0x12bbc
movq %rbp, %rdx
xorl %eax, %eax
callq 0x3200
jmp 0x97ea
movq 0x8(%r12), %rdi
callq 0x37cf
testq %rax, %rax
je 0x97c2
movq %rax, %rbp
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rax, %rdx
callq 0x8098
testq %rax, %rax
je 0x97d3
incl 0x18(%r15)
jmp 0x97e2
movq 0xf9a7(%rip), %rsi      # 0x19170
movq %r14, %rdi
callq 0x3070
jmp 0x97ea
movq 0xf996(%rip), %rsi      # 0x19170
movq %r14, %rdi
callq 0x3070
movq %rbp, %rdi
callq 0x3979
cmpb $0x0, (%r14)
je 0x97fb
testq %r12, %r12
jne 0x9718
jmp 0x9855
movq 0x20(%r12), %r12
testq %r12, %r12
je 0x981e
movq 0x8(%r12), %rax
movzbl (%rax), %eax
cmpl $0x3b, %eax
je 0x9817
cmpl $0x2c, %eax
jne 0x97f0
movq 0x20(%r12), %r12
jmp 0x97f0
xorl %r12d, %r12d
jmp 0x97f0
movq (%rsp), %rax
movl 0x28(%rax), %edx
leaq 0x9363(%rip), %rsi      # 0x12b94
movq %r14, %rdi
xorl %eax, %eax
callq 0x3200
movq %r15, %rdi
callq 0x3979
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 0x986d
movq 0x8(%rbx), %rax
cmpb $0x3b, (%rax)
jne 0x983b
movq 0x20(%rbx), %rbx
jmp 0x983b
xorl %ebx, %ebx
jmp 0x983b