// File: 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
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0xf8(%rbp)
movq -0x10(%rbp), %rax
addq $0x16, %rax
movq %rax, -0xf0(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x8470
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x4320
movb %al, -0xd9(%rbp)
jmp 0x26e8
leaq -0x30(%rbp), %rdi
callq 0x20e0
movb -0xd9(%rbp), %al
testb $0x1, %al
jne 0x2700
jmp 0x29f0
leaq -0x61(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x2260
movq -0x100(%rbp), %rdx
leaq 0x79e1(%rip), %rsi      # 0xa0ff
leaq -0x60(%rbp), %rdi
callq 0x21d0
jmp 0x2729
leaq -0x61(%rbp), %rdi
callq 0x21a0
movq -0x10(%rbp), %rax
cmpl $0x32, 0x8(%rax)
jge 0x29e7
movq -0xf8(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x8470
jmp 0x2755
leaq -0x88(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x4220
movb %al, -0x101(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x20e0
movb -0x101(%rbp), %al
testb $0x1, %al
jne 0x2786
jmp 0x28e4
movl $0x30, %edi
callq 0x2180
movq %rax, -0x110(%rbp)
jmp 0x2799
movq -0x110(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x42b0
movq -0x110(%rbp), %rax
movq -0xf8(%rbp), %rdi
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movb $0x1, 0x4(%rax)
callq 0x85a0
movl %eax, -0x114(%rbp)
jmp 0x27e0
movq -0xf8(%rbp), %rsi
movl -0x114(%rbp), %ecx
movq -0x90(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x90(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x120(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x8470
jmp 0x2817
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x2080
movq -0x120(%rbp), %rdi
movq %rax, %rsi
callq 0x2150
movq -0x128(%rbp), %rdi
callq 0x20e0
movq -0x90(%rbp), %rdi
addq $0x16, %rdi
leaq 0x78ac(%rip), %rsi      # 0xa103
callq 0x2150
movq -0xf8(%rbp), %rdi
callq 0x2a10
jmp 0x286a
movq -0xf8(%rbp), %rdi
movq -0x90(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x90(%rbp), %rsi
movl 0x64(%rdi), %edx
callq 0x85c0
jmp 0x2891
jmp 0x29e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x20e0
jmp 0x29f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x21a0
jmp 0x29f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x20e0
jmp 0x29f9
movl $0x30, %edi
callq 0x2180
movq %rax, -0x130(%rbp)
jmp 0x28f7
movq -0x130(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x42b0
movq -0x130(%rbp), %rax
movq -0xf8(%rbp), %rdi
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movb $0x1, 0x4(%rax)
callq 0x85a0
movl %eax, -0x134(%rbp)
jmp 0x293e
movq -0xf8(%rbp), %rsi
movl -0x134(%rbp), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0xb8(%rbp), %rax
addq $0xc, %rax
movq %rax, -0x140(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x8470
jmp 0x2975
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x2080
movq -0x140(%rbp), %rdi
movq %rax, %rsi
callq 0x2150
movq -0x148(%rbp), %rdi
callq 0x20e0
movq -0xb8(%rbp), %rdi
addq $0x16, %rdi
leaq 0x774a(%rip), %rsi      # 0xa0ff
callq 0x2150
movq -0xf8(%rbp), %rdi
movq -0xb8(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0xb8(%rbp), %rsi
movl $0xa, %edx
callq 0x85c0
jmp 0x29e3
jmp 0x29e5
jmp 0x29e7
leaq -0x60(%rbp), %rdi
callq 0x20e0
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x2250
nopw %cs:(%rax,%rax)