// File: /workspace/github_cpp_makefile_star2_O2/hunterlxt[P]swim-membership-protocol/Log.cpp
// Function: Log::LOG(Address*, char const*, ...)
void Log::LOG(Address *addr, const char * str, ...) {

	static FILE *fp;
	static FILE *fp2;
	va_list vararglist;
	static char buffer[30000];
	static int numwrites;
	static char stdstring[30];
	static char stdstring2[40];
	static char stdstring3[40]; 
	static int dbg_opened=0;

	if(dbg_opened != 639){
		numwrites=0;

		stdstring2[0]=0;

		strcpy(stdstring3, stdstring2);

		strcat(stdstring2, DBG_LOG);
		strcat(stdstring3, STATS_LOG);

		fp = fopen(stdstring2, "w");
		fp2 = fopen(stdstring3, "w");

		dbg_opened=639;
	}
	else 

	sprintf(stdstring, "%d.%d.%d.%d:%d ", addr->addr[0], addr->addr[1], addr->addr[2], addr->addr[3], *(short *)&addr->addr[4]);

	va_start(vararglist, str);
	vsprintf(buffer, str, vararglist);
	va_end(vararglist);

	if (!firstTime) {
		int magicNumber = 0;
		string magic = MAGIC_NUMBER;
		int len = magic.length();
		for ( int i = 0; i < len; i++ ) {
			magicNumber += (int)magic.at(i);
		}
		fprintf(fp, "%x\n", magicNumber);
		firstTime = true;
	}

	if(memcmp(buffer, "#STATSLOG#", 10)==0){
		fprintf(fp2, "\n %s", stdstring);
		fprintf(fp2, "[%d] ", par->getcurrtime());

		fprintf(fp2, buffer);
	}
	else{
		fprintf(fp, "\n %s", stdstring);
		fprintf(fp, "[%d] ", par->getcurrtime());
		fprintf(fp, buffer);

	}

	if(++numwrites >= MAXWRITES){
		fflush(fp);
		fflush(fp2);
		numwrites=0;
	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdx, %r14
movq %rdi, %rbx
movq %rcx, 0x68(%rsp)
movq %r8, 0x70(%rsp)
movq %r9, 0x78(%rsp)
testb %al, %al
je 0x4d3c
movaps %xmm0, 0x80(%rsp)
movaps %xmm1, 0x90(%rsp)
movaps %xmm2, 0xa0(%rsp)
movaps %xmm3, 0xb0(%rsp)
movaps %xmm4, 0xc0(%rsp)
movaps %xmm5, 0xd0(%rsp)
movaps %xmm6, 0xe0(%rsp)
movaps %xmm7, 0xf0(%rsp)
cmpb $0x0, 0xe285(%rip)      # 0x12fc8
je 0x4d77
movsbl (%rsi), %edx
movsbl 0x1(%rsi), %ecx
movsbl 0x2(%rsi), %r8d
movsbl 0x3(%rsi), %r9d
movswl 0x4(%rsi), %eax
movl %eax, (%rsp)
leaq 0xe1ec(%rip), %rdi      # 0x12f50
leaq 0x23e7(%rip), %rsi      # 0x7152
xorl %eax, %eax
callq 0x2030
jmp 0x4e04
andl $0x0, 0xe1c2(%rip)      # 0x12f40
movb $0x0, 0xe1eb(%rip)      # 0x12f70
leaq 0xe1e4(%rip), %r15      # 0x12f70
leaq 0xe20d(%rip), %r12      # 0x12fa0
movq %r12, %rdi
movq %r15, %rsi
callq 0x2140
movq %r15, %rdi
callq 0x2080
movabsq $0x676f6c2e676264, %rcx # imm = 0x676F6C2E676264
movq %rcx, (%rax,%r15)
movq %r12, %rdi
callq 0x2080
movabsq $0x6f6c2e7374617473, %rcx # imm = 0x6F6C2E7374617473
movq %rcx, (%rax,%r12)
movw $0x67, 0x8(%rax,%r12)
leaq 0x261a(%rip), %r13      # 0x73f3
movq %r15, %rdi
movq %r13, %rsi
callq 0x21d0
movq %rax, 0x6c0d(%rip)      # 0xb9f8
movq %r12, %rdi
movq %r13, %rsi
callq 0x21d0
movq %rax, 0x6c03(%rip)      # 0xba00
movb $0x1, 0xe1c4(%rip)      # 0x12fc8
leaq 0x50(%rsp), %rax
leaq 0x30(%rsp), %rdx
movq %rax, 0x10(%rdx)
leaq 0x140(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, (%rdx)
leaq 0x6bde(%rip), %rdi      # 0xba10
movq %r14, %rsi
callq 0x20a0
cmpb $0x0, 0x10(%rbx)
jne 0x4ea8
leaq 0x25ae(%rip), %rsi      # 0x73f5
leaq 0x10(%rsp), %r14
leaq 0xf(%rsp), %rdx
movq %r14, %rdi
callq 0x506e
movl 0x8(%r14), %r12d
xorl %r15d, %r15d
testl %r12d, %r12d
cmovlel %r15d, %r12d
xorl %ebp, %ebp
cmpq %r15, %r12
je 0x4e83
movq %r14, %rdi
movq %r15, %rsi
callq 0x2310
movsbl (%rax), %eax
addl %eax, %ebp
incq %r15
jmp 0x4e69
movq 0x6b6e(%rip), %rdi      # 0xb9f8
leaq 0x256a(%rip), %rsi      # 0x73fb
movl %ebp, %edx
xorl %eax, %eax
callq 0x2240
movb $0x1, 0x10(%rbx)
leaq 0x10(%rsp), %rdi
callq 0x2090
leaq 0x6b61(%rip), %r14      # 0xba10
leaq 0x2549(%rip), %rsi      # 0x73ff
pushq $0xa
popq %rdx
movq %r14, %rdi
callq 0x21a0
testl %eax, %eax
leaq 0x6b36(%rip), %rax      # 0xba00
leaq 0x6b27(%rip), %r12      # 0xb9f8
cmoveq %rax, %r12
movq (%r12), %rdi
leaq 0x252a(%rip), %rsi      # 0x740a
leaq 0xe069(%rip), %rdx      # 0x12f50
xorl %eax, %eax
callq 0x2240
movq (%r12), %r15
movq 0x8(%rbx), %rdi
callq 0x51f8
leaq 0x250d(%rip), %rsi      # 0x740f
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x2240
movq (%r12), %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2240
movl 0xe01e(%rip), %eax      # 0x12f40
leal 0x1(%rax), %ecx
movl %ecx, 0xe015(%rip)      # 0x12f40
testl %eax, %eax
js 0x4f4e
movq 0x6ac2(%rip), %rdi      # 0xb9f8
callq 0x21c0
movq 0x6abe(%rip), %rdi      # 0xba00
callq 0x21c0
andl $0x0, 0xdff2(%rip)      # 0x12f40
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2090
movq %rbx, %rdi
callq 0x22d0
nop