// File: zkl94[P]distributed-key-value-store/Application.cpp
// Function: Application::Application(char*)
Application::Application(char *infile) {
	int i;
	par = new Params();
	srand (time(NULL));
	par->setparams(infile);
	log = new Log(par);
	en = new EmulNet(par);
	en1 = new EmulNet(par);
	mp1 = (MP1Node **) malloc(par->EN_GPSZ * sizeof(MP1Node *));
	mp2 = (MP2Node **) malloc(par->EN_GPSZ * sizeof(MP2Node *));

	/*
	 * Init all nodes
	 */
	for( i = 0; i < par->EN_GPSZ; i++ ) {
		Member *memberNode = new Member;
		memberNode->inited = false;
		Address *addressOfMemberNode = new Address();
		Address joinaddr;
		joinaddr = getjoinaddr();
		addressOfMemberNode = (Address *) en->ENinit(addressOfMemberNode, par->PORTNUM);
		mp1[i] = new MP1Node(memberNode, par, en, log, addressOfMemberNode);
		mp2[i] = new MP2Node(memberNode, par, en1, log, addressOfMemberNode);
		log->LOG(&(mp1[i]->getMemberNode()->addr), "APP");
		log->LOG(&(mp2[i]->getMemberNode()->addr), "APP MP2");
		delete addressOfMemberNode;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x60(%rbp)
leaq 0x2a5de(%rip), %rax     # 0x35cc0
movq %rax, (%rdi)
addq $0x58, %rdi
movq %rdi, -0x58(%rbp)
callq 0x10620
movl $0x38, %edi
callq 0x4310
movq %rax, -0x50(%rbp)
jmp 0xb702
movq -0x50(%rbp), %rdi
callq 0x14e50
jmp 0xb70d
movq -0x60(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, 0x50(%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x42b0
movl %eax, %edi
callq 0x42e0
movq -0x60(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x14e70
jmp 0xb73c
movl $0x18, %edi
callq 0x4310
movq %rax, -0x68(%rbp)
jmp 0xb74c
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x50(%rax), %rsi
callq 0x13e90
jmp 0xb75f
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rcx, 0x38(%rax)
movl $0x1bb8e30, %edi        # imm = 0x1BB8E30
callq 0x4310
movq %rax, -0x70(%rbp)
jmp 0xb77b
movq -0x70(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x50(%rax), %rsi
callq 0xa840
jmp 0xb78e
movq -0x60(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rcx, 0x28(%rax)
movl $0x1bb8e30, %edi        # imm = 0x1BB8E30
callq 0x4310
movq %rax, -0x78(%rbp)
jmp 0xb7aa
movq -0x78(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x50(%rax), %rsi
callq 0xa840
jmp 0xb7bd
movq -0x60(%rbp), %rax
movq -0x78(%rbp), %rcx
movq %rcx, 0x30(%rax)
movq 0x50(%rax), %rax
movslq 0x18(%rax), %rdi
shlq $0x3, %rdi
callq 0x4440
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x40(%rax)
movq 0x50(%rax), %rax
movslq 0x18(%rax), %rdi
shlq $0x3, %rdi
callq 0x4440
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x48(%rax)
movl $0x0, -0x14(%rbp)
movq -0x60(%rbp), %rcx
movl -0x14(%rbp), %eax
movq 0x50(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jge 0xbb33
movl $0xe8, %edi
callq 0x4310
movq %rax, -0x80(%rbp)
jmp 0xb82c
movq -0x80(%rbp), %rdi
callq 0x10640
jmp 0xb837
movq -0x80(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movb $0x0, 0xe(%rax)
movl $0x6, %edi
callq 0x4310
movq %rax, -0x88(%rbp)
jmp 0xb85a
movq -0x88(%rbp), %rdi
callq 0x6d90
jmp 0xb868
movq -0x88(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x3e(%rbp), %rdi
callq 0x6d90
jmp 0xb87e
movq -0x60(%rbp), %rsi
leaq -0x44(%rbp), %rdi
callq 0xbb50
jmp 0xb88d
leaq -0x3e(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x150a0
jmp 0xb89c
movq -0x60(%rbp), %rax
movq -0x38(%rbp), %rsi
movq 0x28(%rax), %rdi
movq 0x50(%rax), %rax
movswl 0x30(%rax), %edx
callq 0xac40
movq %rax, -0x90(%rbp)
jmp 0xb8be
movq -0x90(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x40, %edi
callq 0x4310
movq %rax, -0x98(%rbp)
jmp 0xb8dc
movq -0x98(%rbp), %rdi
movq -0x60(%rbp), %rax
movq -0x30(%rbp), %rsi
movq 0x50(%rax), %rdx
movq 0x28(%rax), %rcx
movq 0x38(%rax), %r8
movq -0x38(%rbp), %r9
callq 0x4a10
jmp 0xb902
movq -0x98(%rbp), %rdx
movq -0x60(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0xc0, %edi
callq 0x4310
movq %rax, -0xa0(%rbp)
jmp 0xb92c
movq -0xa0(%rbp), %rdi
movq -0x60(%rbp), %rax
movq -0x30(%rbp), %rsi
movq 0x50(%rax), %rdx
movq 0x30(%rax), %rcx
movq 0x38(%rax), %r8
movq -0x38(%rbp), %r9
callq 0x19de0
jmp 0xb952
movq -0x60(%rbp), %rax
movq -0xa0(%rbp), %rsi
movq 0x48(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq 0x38(%rax), %rcx
movq %rcx, -0xb0(%rbp)
movq 0x40(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x10710
movq %rax, -0xa8(%rbp)
jmp 0xb98e
movq -0xb0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
addq $0x8, %rsi
leaq 0x1b9e2(%rip), %rdx     # 0x27389
xorl %eax, %eax
callq 0x13f70
jmp 0xb9b0
movq -0x60(%rbp), %rax
movq 0x38(%rax), %rcx
movq %rcx, -0xc0(%rbp)
movq 0x48(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x10730
movq %rax, -0xb8(%rbp)
jmp 0xb9d9
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
addq $0x8, %rsi
leaq 0x1b99b(%rip), %rdx     # 0x2738d
xorl %eax, %eax
callq 0x13f70
jmp 0xb9fb
movq -0x38(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpq $0x0, %rax
je 0xba1d
movq -0xc8(%rbp), %rdi
movl $0x6, %esi
callq 0x4320
jmp 0xba1f
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xb808
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0xbb3c
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x38, %esi
callq 0x4320
jmp 0xbb3c
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x18, %esi
callq 0x4320
jmp 0xbb3c
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x1bb8e30, %esi        # imm = 0x1BB8E30
callq 0x4320
jmp 0xbb3c
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x1bb8e30, %esi        # imm = 0x1BB8E30
callq 0x4320
jmp 0xbb3c
movq -0x80(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0xe8, %esi
callq 0x4320
jmp 0xbb3c
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x6, %esi
callq 0x4320
jmp 0xbb3c
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x40, %esi
callq 0x4320
jmp 0xbb3c
movq -0xa0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0xc0, %esi
callq 0x4320
jmp 0xbb3c
addq $0xd0, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x10750
movq -0x20(%rbp), %rdi
callq 0x4550
nop