// File: /workspace/github_c_makefile_star2_O3/martincameron[P]towntalk/towntalk.c
// Function: parse_if_statement
static struct element* parse_if_statement( struct element *elem,
	struct function *func, struct variables *vars, struct statement *prev, char *message ) {
	struct expression expr;
	struct element *next = elem->next;
	struct statement block = { 0 }, *stmt = calloc( 1, sizeof( struct block_statement ) );
	if( stmt ) {
		stmt->dispose = dispose_block_statement;
		prev->next = stmt;
		expr.next = NULL;
		next = parse_expression( next, func, vars, &expr, message );
		if( expr.next ) {
			stmt->source = expr.next;
			stmt->execute = execute_if_statement;
			if( expr.next->evaluate == evaluate_arithmetic_expression
				&& strchr( "!<(=)>", expr.next->index ) && expr.next->parameters->evaluate == evaluate_local ) {
					if( expr.next->parameters->next->evaluate == evaluate_local ) {
						stmt->local = expr.next->parameters->index;
						( ( struct block_statement * ) stmt )->rhs = expr.next->parameters->next->index;
						( ( struct block_statement * ) stmt )->oper = expr.next->index;
						stmt->execute = execute_if_local_statement;
					} else if( expr.next->parameters->next->evaluate == evaluate_number_literal_expression ) {
						stmt->local = expr.next->parameters->index;
						( ( struct block_statement * ) stmt )->num = ( ( struct value_expression * ) expr.next->parameters->next )->num;
						( ( struct block_statement * ) stmt )->oper = expr.next->index;
						stmt->execute = execute_if_const_statement;
					}
			} else if( expr.next->evaluate == evaluate_local ) {
				stmt->local = expr.next->index;
				stmt->execute = execute_if_const_statement;
			}
			if( next->child ) {
				parse_keywords_indexed( func->env->statements_index, next->child, func, vars, &block, message );
				( ( struct block_statement * ) stmt )->if_block = block.next;
			}
			if( message[ 0 ] == 0 ) {
				next = next->next;
				if( next && is_keyword( next->str.string, "else" ) ) {
					if( next->next && ( next->next->str.string[ 0 ] == '{' || is_keyword( next->next->str.string, "if" ) ) ) {
						next = next->next;
						block.next = NULL;
						if( next->child ) {
							parse_keywords_indexed( func->env->statements_index, next->child, func, vars, &block, message );
							if( message[ 0 ] == 0 ) {
								next = next->next;
							}
						} else {
							validate_syntax( "x{", next->next, next, func->env, message );
							if( message[ 0 ] == 0 ) {
								next = parse_if_statement( next, func, vars, &block, message );
							}
						}
						( ( struct block_statement * ) stmt )->else_block = block.next;
					} else {
						sprintf( message, "Expected '{' or 'if' after 'else' on line %d.", next->line );
					}
				}
			}
		}
	} else {
		strcpy( message, OUT_OF_MEMORY );
	}
	return next;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %rbx
movq %rcx, %rbp
movq %rdx, %r15
movq %rsi, %r12
movq 0x20(%rdi), %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x30(%rsp)
movl $0x1, %edi
movl $0x48, %esi
callq 0x3130
testq %rax, %rax
je 0xa77e
movq %rax, %r14
leaq -0x6380(%rip), %rax     # 0x4387
movq %rax, 0x18(%r14)
movq %r14, 0x20(%rbp)
leaq 0x38(%rsp), %rbp
movq $0x0, 0x10(%rbp)
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbp, %rcx
movq %rbx, %r8
callq 0x4f62
movq %rax, %r13
movq 0x10(%rbp), %rbp
testq %rbp, %rbp
je 0xa7f6
movq %rbp, 0x8(%r14)
leaq 0xcb9(%rip), %rax       # 0xb404
movq %rax, 0x10(%r14)
movq 0x18(%rbp), %rax
leaq -0x5bed(%rip), %rcx     # 0x4b6d
cmpq %rcx, %rax
je 0xa78f
leaq -0x658a(%rip), %rcx     # 0x41dc
cmpq %rcx, %rax
jne 0xa7c1
movl 0x4(%rbp), %eax
movl %eax, (%r14)
leaq 0xdea(%rip), %rax       # 0xb562
movq %rax, 0x10(%r14)
jmp 0xa7c1
movq 0xe9eb(%rip), %rsi      # 0x19170
movq %rbx, %rdi
callq 0x3070
jmp 0xa7f6
movl 0x4(%rbp), %esi
leaq 0x8659(%rip), %rdi      # 0x12df2
movl $0x7, %edx
movl %esi, 0xc(%rsp)
callq 0x3110
testq %rax, %rax
je 0xa7c1
movq 0x8(%rbp), %rax
leaq -0x65db(%rip), %rdx     # 0x41dc
cmpq %rdx, 0x18(%rax)
je 0xa89f
movq 0x18(%r13), %rsi
testq %rsi, %rsi
je 0xa7f1
movq 0x40(%r12), %rdi
subq $-0x80, %rdi
leaq 0x10(%rsp), %rbp
movq %r12, %rdx
movq %r15, %rcx
movq %rbp, %r8
movq %rbx, %r9
callq 0x6e94
movq 0x20(%rbp), %rax
movq %rax, 0x28(%r14)
cmpb $0x0, (%rbx)
je 0xa808
movq %r13, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%r13), %r13
testq %r13, %r13
je 0xa897
movq 0x8(%r13), %rdi
leaq 0x85d9(%rip), %rsi      # 0x12df9
callq 0x65ba
testl %eax, %eax
je 0xa7f6
movq 0x20(%r13), %rbp
testq %rbp, %rbp
je 0xa8d6
movq 0x8(%rbp), %rdi
cmpb $0x7b, (%rdi)
je 0xa853
leaq 0x8466(%rip), %rsi      # 0x12cac
callq 0x65ba
testl %eax, %eax
je 0xa8d6
movq $0x0, 0x30(%rsp)
movq 0x18(%rbp), %rsi
testq %rsi, %rsi
je 0xa911
movq 0x40(%r12), %rdi
subq $-0x80, %rdi
leaq 0x10(%rsp), %r8
movq %r12, %rdx
movq %r15, %rcx
movq %rbx, %r9
callq 0x6e94
cmpb $0x0, (%rbx)
jne 0xa94a
movq 0x20(%rbp), %rbp
jmp 0xa94a
xorl %r13d, %r13d
jmp 0xa7f6
movq 0x10(%rax), %rcx
movq 0x18(%rcx), %rsi
cmpq %rdx, %rsi
je 0xa8f0
leaq -0x6e19(%rip), %rdx     # 0x3a9a
cmpq %rdx, %rsi
jne 0xa7c1
movl 0x4(%rax), %eax
movl %eax, (%r14)
movl 0x28(%rcx), %eax
movl %eax, 0x40(%r14)
movl 0xc(%rsp), %eax
movl %eax, 0x38(%r14)
jmp 0xa771
movl 0x28(%r13), %edx
leaq 0x851d(%rip), %rsi      # 0x12dfe
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3200
jmp 0xa7f6
movl 0x4(%rax), %eax
movl %eax, (%r14)
movl 0x4(%rcx), %eax
movl %eax, 0x3c(%r14)
movl 0xc(%rsp), %eax
movl %eax, 0x38(%r14)
leaq 0xb7f(%rip), %rax       # 0xb48b
jmp 0xa778
movq 0x20(%rbp), %rsi
movq 0x40(%r12), %rcx
leaq 0x838e(%rip), %rdi      # 0x12caf
movq %rbp, %rdx
movq %rbx, %r8
callq 0x65fe
cmpb $0x0, (%rbx)
jne 0xa94a
leaq 0x10(%rsp), %rcx
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %r8
callq 0xa6b1
movq %rax, %rbp
movq 0x30(%rsp), %rax
movq %rax, 0x30(%r14)
movq %rbp, %r13
jmp 0xa7f6