// File: /workspace/github_c_makefile_star2_O1/martincameron[P]towntalk/optimizer.c
// Function: optimize_statements
struct statement* optimize_statements( struct function *func, struct statement *prev, char *message ) {
	struct statement *stmt = prev, *next = stmt->next;
	while( next ) {
		if( next->execute == execute_local_assignment ) {
			next = optimize_local_assignment( next, prev, message );
		} else if( next->execute == execute_array_assignment ) {
			next = optimize_array_assignment( next, prev, message );
		} else if( next->execute == execute_increment_statement ) {
			next = optimize_increment( next, prev, INC_LOCAL, message );
		} else if( next->execute == execute_decrement_statement ) {
			next = optimize_increment( next, prev, DEC_LOCAL, message );
		} else if( next->execute == execute_return_statement ) {
			next = optimize_return( next, prev, message );
		}
		if( message[ 0 ] ) {
			return prev;
		}
		prev = next;
		next = next->next;
	}
#if defined( PRINT_INSNS )
	while( stmt ) {
		if( stmt->execute == execute_arithmetic_statement ) {
			print_insns( func, ( struct arithmetic_statement * ) stmt, stmt->source->line );
		}
		stmt = stmt->next;
	}
#endif
	return prev;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %r15, %r14
movq 0x20(%r15), %r15
testq %r15, %r15
je 0xf14b
movq 0x10(%r15), %rax
cmpq 0xa0b4(%rip), %rax      # 0x18fb0
je 0xef9c
cmpq 0xa097(%rip), %rax      # 0x18fa0
je 0xf011
cmpq 0xa052(%rip), %rax      # 0x18f68
je 0xf0e9
cmpq 0xa095(%rip), %rax      # 0x18fb8
je 0xf0f6
cmpq 0xa0b0(%rip), %rax      # 0x18fe0
jne 0xf142
movq 0x8(%r15), %r12
leaq -0xa397(%rip), %rax     # 0x4baa
cmpq %rax, 0x18(%r12)
jne 0xf142
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xf1c0
testq %rax, %rax
je 0xf142
movq %rax, %r13
movq %rax, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0xf28a
testq %rax, %rax
je 0xef94
movq %r13, %rdi
addq $0x28, %rdi
movl $0x16, %esi
xorl %edx, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xf560
movq %r13, %r15
jmp 0xf142
movq 0x8(%r15), %r12
movl (%r15), %ebp
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xf1c0
testq %rax, %rax
je 0xf142
movq %rax, %r13
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0xf28a
testq %rax, %rax
je 0xf142
movq 0x28(%r15), %rax
movslq 0x34(%r15), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rax
movl -0x18(%rax), %ecx
movl $0x11, %esi
cmpl $0xa, %ecx
jg 0xf10e
cmpl $0x2, %ecx
je 0xf124
cmpl $0x4, %ecx
je 0xf124
jmp 0xf12e
movq 0x8(%r15), %rbp
movq 0x10(%rbp), %r12
leaq -0xae13(%rip), %rax     # 0x420d
cmpq %rax, 0x18(%r12)
jne 0xf142
movq 0x10(%r12), %rax
movq %rax, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0xf1c0
testq %rax, %rax
je 0xf142
movq %rax, %r13
movq %rax, %r15
movq %r13, %rdi
movq (%rsp), %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0xf28a
testq %rax, %rax
je 0xf142
addq $0x28, %r13
movl 0x4(%r12), %edx
movq %r13, %rdi
movl $0x13, %esi
movq (%rsp), %rcx
movq %rbx, %r8
callq 0xf560
testq %rax, %rax
je 0xf142
movq %r15, %rdi
movq %rbp, %rsi
movl $0x1, %edx
movq %rbx, %rcx
callq 0xf28a
testq %rax, %rax
je 0xf142
movq 0x28(%r15), %rax
movslq 0x34(%r15), %rcx
leaq (%rcx,%rcx,2), %rdx
movl -0x18(%rax,%rdx,8), %ecx
movl $0x14, %esi
cmpl $0xd, %ecx
ja 0xf0df
movl $0x2814, %edi           # imm = 0x2814
btl %ecx, %edi
jae 0xf0df
leaq (%rax,%rdx,8), %rax
incl %ecx
movl %ecx, -0x18(%rax)
movl $0x15, %esi
movl 0x4(%r12), %edx
movq %r13, %rdi
jmp 0xf137
movq %r15, %rdi
movq %r14, %rsi
movl $0x6, %edx
jmp 0xf101
movq %r15, %rdi
movq %r14, %rsi
movl $0x8, %edx
movq %rbx, %rcx
callq 0xf15d
movq %rax, %r15
jmp 0xf142
cmpl $0xd, %ecx
je 0xf124
cmpl $0xb, %ecx
jne 0xf12e
movl $0xa, -0x18(%rax)
movl %ebp, -0x14(%rax)
jmp 0xf142
incl %ecx
movl %ecx, -0x18(%rax)
movl $0x12, %esi
addq $0x28, %r13
movq %r13, %rdi
movl %ebp, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0xf560
cmpb $0x0, (%rbx)
je 0xeee1
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq