// File: /workspace/github_c_makefile_star2_O0/martincameron[P]towntalk/optimizer.c
// Function: compile_arithmetic_expression
static struct instruction* compile_arithmetic_expression( struct arithmetic_statement *stmt, struct expression *expr, int top, char *message ) {
	struct instruction *insn;
	struct expression *parameter;
	enum arithmetic_op oper = get_arithmetic_op( expr );
	if( top > 6 ) {
		insn = add_instruction( &stmt->insns, PUSH_EXPR, 0, expr, message );
	} else if( oper ) {
		parameter = expr->parameters;
		insn = compile_arithmetic_expression( stmt, parameter, top, message );
		while( insn && parameter->next ) {
			parameter = parameter->next;
			insn = compile_arithmetic_expression( stmt, parameter, top + 1, message );
			if( insn ) {
				if( insn->oper == PUSH_CONST ) {
					insn->oper = oper + AND_CONST - AND_STACK;
				} else if( insn->oper == PUSH_LOCAL ) {
					insn->oper = oper + AND_LOCAL - AND_STACK;
				} else {
					insn = add_instruction( &stmt->insns, oper, 0, parameter, message );
				}
			}
		}
	} else if( expr->evaluate == evaluate_number_literal_expression ) {
		insn = add_instruction( &stmt->insns, PUSH_CONST, expr->index, expr, message );
		if( insn ) {
			insn->value = ( ( struct value_expression * ) expr )->num;
		}
	} else if( expr->evaluate == evaluate_local ) {
		insn = add_instruction( &stmt->insns, PUSH_LOCAL, expr->index, expr, message );
	} else if( expr->evaluate == evaluate_local_post_inc ) {
		insn = add_instruction( &stmt->insns, PUSH_LOCAL_PI, expr->index, expr, message );
	} else if( expr->evaluate == evaluate_local_post_dec ) {
		insn = add_instruction( &stmt->insns, PUSH_LOCAL_PD, expr->index, expr, message );
	} else if( expr->evaluate == evaluate_index_expression && expr->parameters->evaluate == evaluate_local ) {
		insn = compile_arithmetic_expression( stmt, expr->parameters->next, top, message );
		if( insn ) {
			insn = add_instruction( &stmt->insns, PUSH_ARRAY, expr->parameters->index, expr, message );
		}
	} else if( expr->evaluate == evaluate_chr_expression && expr->parameters->evaluate == evaluate_local ) {
		insn = compile_arithmetic_expression( stmt, expr->parameters->next, top, message );
		if( insn ) {
			insn = add_instruction( &stmt->insns, PUSH_STRING, expr->parameters->index, expr, message );
		}
	} else if( expr->evaluate == evaluate_unpack_expression && expr->parameters->evaluate == evaluate_global ) {
		insn = compile_arithmetic_expression( stmt, expr->parameters->next, top, message );
		if( insn ) {
			insn = add_instruction( &stmt->insns, PUSH_UNPACK, 0, expr->parameters, message );
		}
	} else if( expr->evaluate == evaluate_global ) {
		insn = add_instruction( &stmt->insns, PUSH_GLOBAL, 0, expr, message );
	} else {
		insn = add_instruction( &stmt->insns, PUSH_EXPR, 0, expr, message );
	}
	return insn;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x16620
movl %eax, -0x34(%rbp)
cmpl $0x6, -0x14(%rbp)
jle 0x14bae
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %r8
movl $0xb, %esi
xorl %edx, %edx
callq 0x14f70
movq %rax, -0x28(%rbp)
jmp 0x14f60
cmpl $0x0, -0x34(%rbp)
je 0x14c91
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
callq 0x14b60
movq %rax, -0x28(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x28(%rbp)
movb %al, -0x35(%rbp)
je 0x14bf7
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
setne %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0x14c03
jmp 0x14c8c
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x14(%rbp), %edx
addl $0x1, %edx
movq -0x20(%rbp), %rcx
callq 0x14b60
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x14c87
movq -0x28(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x14c4b
movl -0x34(%rbp), %ecx
addl $0x22, %ecx
subl $0x17, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x14c85
movq -0x28(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x14c65
movl -0x34(%rbp), %ecx
addl $0x2d, %ecx
subl $0x17, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x14c83
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movl -0x34(%rbp), %esi
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %r8
xorl %edx, %edx
callq 0x14f70
movq %rax, -0x28(%rbp)
jmp 0x14c85
jmp 0x14c87
jmp 0x14bdc
jmp 0x14f5e
movq -0x10(%rbp), %rax
leaq -0x10f1c(%rip), %rcx    # 0x3d80
cmpq %rcx, 0x18(%rax)
jne 0x14ce1
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %r8
movl $0x1, %esi
callq 0x14f70
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x14cdc
movq -0x10(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
jmp 0x14f5c
movq -0x10(%rbp), %rax
leaq -0x1012c(%rip), %rcx    # 0x4bc0
cmpq %rcx, 0x18(%rax)
jne 0x14d1c
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %r8
movl $0x2, %esi
callq 0x14f70
movq %rax, -0x28(%rbp)
jmp 0x14f5a
movq -0x10(%rbp), %rax
leaq -0x100f7(%rip), %rcx    # 0x4c30
cmpq %rcx, 0x18(%rax)
jne 0x14d57
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %r8
movl $0x7, %esi
callq 0x14f70
movq %rax, -0x28(%rbp)
jmp 0x14f58
movq -0x10(%rbp), %rax
leaq -0x100b2(%rip), %rcx    # 0x4cb0
cmpq %rcx, 0x18(%rax)
jne 0x14d92
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %r8
movl $0x9, %esi
callq 0x14f70
movq %rax, -0x28(%rbp)
jmp 0x14f56
movq -0x10(%rbp), %rax
leaq -0xf3ed(%rip), %rcx     # 0x59b0
cmpq %rcx, 0x18(%rax)
jne 0x14e0d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
leaq -0x101f2(%rip), %rcx    # 0x4bc0
cmpq %rcx, 0x18(%rax)
jne 0x14e0d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rsi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
callq 0x14b60
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x14e08
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x4(%rax), %edx
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %r8
movl $0xd, %esi
callq 0x14f70
movq %rax, -0x28(%rbp)
jmp 0x14f54
movq -0x10(%rbp), %rax
leaq -0xf018(%rip), %rcx     # 0x5e00
cmpq %rcx, 0x18(%rax)
jne 0x14e88
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
leaq -0x1026d(%rip), %rcx    # 0x4bc0
cmpq %rcx, 0x18(%rax)
jne 0x14e88
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rsi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
callq 0x14b60
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x14e83
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x4(%rax), %edx
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %r8
movl $0xf, %esi
callq 0x14f70
movq %rax, -0x28(%rbp)
jmp 0x14f52
movq -0x10(%rbp), %rax
leaq -0xeea3(%rip), %rcx     # 0x5ff0
cmpq %rcx, 0x18(%rax)
jne 0x14efb
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
leaq -0x10178(%rip), %rcx    # 0x4d30
cmpq %rcx, 0x18(%rax)
jne 0x14efb
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rsi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
callq 0x14b60
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x14ef9
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %r8
movl $0x10, %esi
xorl %edx, %edx
callq 0x14f70
movq %rax, -0x28(%rbp)
jmp 0x14f50
movq -0x10(%rbp), %rax
leaq -0x101d6(%rip), %rcx    # 0x4d30
cmpq %rcx, 0x18(%rax)
jne 0x14f2e
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %r8
movl $0x4, %esi
xorl %edx, %edx
callq 0x14f70
movq %rax, -0x28(%rbp)
jmp 0x14f4e
movq -0x8(%rbp), %rdi
addq $0x28, %rdi
movq -0x10(%rbp), %rcx
movq -0x20(%rbp), %r8
movl $0xb, %esi
xorl %edx, %edx
callq 0x14f70
movq %rax, -0x28(%rbp)
jmp 0x14f50
jmp 0x14f52
jmp 0x14f54
jmp 0x14f56
jmp 0x14f58
jmp 0x14f5a
jmp 0x14f5c
jmp 0x14f5e
jmp 0x14f60
movq -0x28(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)