// File: ariannagavioli[P]ALU/ExampleModule.cpp
// Function: ExampleModule::onNotify(message*)
void ExampleModule::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 Fetch = "Fetch";
		
		// 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() == Fetch){
				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);
			}
			else{
				message* myMessage = new message();
				myMessage->valid = 1;
				myMessage->timestamp = getTime();
				strcpy(myMessage->source, getName().c_str());
				strcpy(myMessage->dest, "Fetch");
				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 0x4c18
leaq -0x30(%rbp), %rdi
callq 0x20e0
movb -0xd9(%rbp), %al
testb $0x1, %al
jne 0x4c30
jmp 0x4f14
leaq -0x61(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x2260
movq -0x100(%rbp), %rdx
leaq 0x54b5(%rip), %rsi      # 0xa103
leaq -0x60(%rbp), %rdi
callq 0x21d0
jmp 0x4c59
leaq -0x61(%rbp), %rdi
callq 0x21a0
movq -0x10(%rbp), %rax
cmpl $0x32, 0x8(%rax)
jge 0x4f0b
movq -0xf8(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x8470
jmp 0x4c85
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 0x4cb6
jmp 0x4e08
movl $0x30, %edi
callq 0x2180
movq %rax, -0x110(%rbp)
jmp 0x4cc9
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 0x4d10
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 0x4d47
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 0x5378(%rip), %rsi      # 0xa0ff
callq 0x2150
movq -0xf8(%rbp), %rdi
movq -0x90(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x90(%rbp), %rsi
movl $0xa, %edx
callq 0x85c0
jmp 0x4db5
jmp 0x4f09
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x20e0
jmp 0x4f1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x21a0
jmp 0x4f1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x20e0
jmp 0x4f1d
movl $0x30, %edi
callq 0x2180
movq %rax, -0x130(%rbp)
jmp 0x4e1b
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 0x4e62
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 0x4e99
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 0x522a(%rip), %rsi      # 0xa103
callq 0x2150
movq -0xf8(%rbp), %rdi
movq -0xb8(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0xb8(%rbp), %rsi
movl $0xa, %edx
callq 0x85c0
jmp 0x4f07
jmp 0x4f09
jmp 0x4f0b
leaq -0x60(%rbp), %rdi
callq 0x20e0
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x2250
nopw %cs:(%rax,%rax)