// File: /workspace/github_cpp_makefile_star2_O1/ariannagavioli[P]ALU/AluModule.cpp
// Function: AluModule::onNotify(message*)
void AluModule::onNotify(message* m) {
	//Don't forget to check if the message was for me since we are in a broadcast environment
	if(m->dest == getName()){
		string Alu = "Alu";
		
		
		// cout << "Message " << m->id << ": Sent at " << m->timestamp << ", current timestamp " << getTime() << ". My name is " << getName() << "." << endl;
		
		//Send some test messages
		if(m->timestamp < 50) {
			if(getName() == Alu){
				message* myMessage = new message();
				myMessage->valid = 1;
				myMessage->timestamp = getTime();
				strcpy(myMessage->source, getName().c_str());
				strcpy(myMessage->dest, "Fetch");

				/*** OUR CODE ***/
				operate();

				myMessage->magic_struct = NULL;
				
				sendWithDelay(myMessage, delay);
			}
			else{
				message* myMessage = new message();
				myMessage->valid = 1;
				myMessage->timestamp = getTime();
				strcpy(myMessage->source, getName().c_str());
				strcpy(myMessage->dest, "Alu");
				myMessage->magic_struct = NULL;
				
				sendWithDelay(myMessage, 10);
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x16(%rsi), %r15
leaq 0x28(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x456c
movq %r12, %rdi
movq %r15, %rsi
callq 0x2040
movl %eax, %ebp
movq (%r12), %rdi
leaq 0x38(%rsp), %r12
cmpq %r12, %rdi
je 0x2598
callq 0x2120
testl %ebp, %ebp
jne 0x272e
leaq 0x28(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x2b50(%rip), %rsi      # 0x50ff
leaq 0x2b4c(%rip), %rdx      # 0x5102
callq 0x3456
cmpl $0x31, 0x8(%r14)
jg 0x271f
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x456c
movq 0x10(%rsp), %rdx
cmpq 0x30(%rsp), %rdx
jne 0x25fb
testq %rdx, %rdx
je 0x25ff
movq 0x28(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x2150
testl %eax, %eax
sete %bpl
jmp 0x2602
xorl %ebp, %ebp
jmp 0x2602
movb $0x1, %bpl
leaq 0x18(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x2615
callq 0x2120
testb %bpl, %bpl
je 0x26a6
movl $0x30, %edi
callq 0x2140
movq %rax, %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
movb $0x1, 0x4(%rax)
movq %rbx, %rdi
callq 0x4600
movl %eax, 0x8(%r14)
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x456c
movq %r14, %rdi
addq $0xc, %rdi
movq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x2110
cmpq %r13, %r15
je 0x2677
movq %r15, %rdi
callq 0x2120
movw $0x68, 0x1a(%r14)
movl $0x63746546, 0x16(%r14) # imm = 0x63746546
movq %rbx, %rdi
callq 0x2760
movq $0x0, 0x20(%r14)
movl 0x64(%rbx), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4604
jmp 0x271f
movl $0x30, %edi
callq 0x2140
movq %rax, %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
movb $0x1, 0x4(%rax)
movq %rbx, %rdi
callq 0x4600
movl %eax, 0x8(%r14)
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x456c
movq %r14, %rdi
addq $0xc, %rdi
movq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x2110
cmpq %r13, %r15
je 0x26ff
movq %r15, %rdi
callq 0x2120
movl $0x756c41, 0x16(%r14)   # imm = 0x756C41
movq $0x0, 0x20(%r14)
movq %rbx, %rdi
movq %r14, %rsi
movl $0xa, %edx
callq 0x4604
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x272e
callq 0x2120
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2745
jmp 0x2745
jmp 0x2745
jmp 0x2745
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x2757
callq 0x2120
movq %rbx, %rdi
callq 0x21c0
nop