// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rdx, %r14
movq %rdi, %rbx
movq %rcx, 0x68(%rsp)
movq %r8, 0x70(%rsp)
movq %r9, 0x78(%rsp)
testb %al, %al
je 0x4869
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, 0xeb68(%rip)      # 0x133d8
je 0x48a4
movsbl (%rsi), %edx
movsbl 0x1(%rsi), %ecx
movsbl 0x2(%rsi), %r8d
movsbl 0x3(%rsi), %r9d
movswl 0x4(%rsi), %eax
movl %eax, (%rsp)
leaq 0xeacf(%rip), %rdi      # 0x13360
leaq 0x2882(%rip), %rsi      # 0x711a
xorl %eax, %eax
callq 0x2050
jmp 0x4934
movl $0x0, 0xeaa2(%rip)      # 0x13350
movb $0x0, 0xeacb(%rip)      # 0x13380
leaq 0xeac4(%rip), %r15      # 0x13380
leaq 0xeaed(%rip), %r12      # 0x133b0
movq %r12, %rdi
movq %r15, %rsi
callq 0x2160
movq %r15, %rdi
callq 0x20b0
movabsq $0x676f6c2e676264, %rcx # imm = 0x676F6C2E676264
movq %rcx, (%rax,%r15)
movq %r12, %rdi
callq 0x20b0
movabsq $0x6f6c2e7374617473, %rcx # imm = 0x6F6C2E7374617473
movq %rcx, (%rax,%r12)
movw $0x67, 0x8(%rax,%r12)
leaq 0x2aaa(%rip), %r13      # 0x73b3
movq %r15, %rdi
movq %r13, %rsi
callq 0x2200
movq %rax, 0x74ed(%rip)      # 0xbe08
movq %r12, %rdi
movq %r13, %rsi
callq 0x2200
movq %rax, 0x74e3(%rip)      # 0xbe10
movb $0x1, 0xeaa4(%rip)      # 0x133d8
leaq 0x50(%rsp), %rax
leaq 0x30(%rsp), %rdx
movq %rax, 0x10(%rdx)
leaq 0x130(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, (%rdx)
leaq 0x74be(%rip), %rdi      # 0xbe20
movq %r14, %rsi
callq 0x20c0
cmpb $0x0, 0x10(%rbx)
jne 0x4a0b
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2a31(%rip), %rsi      # 0x73b5
leaq 0x2a2f(%rip), %rdx      # 0x73ba
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x4c00
movq 0x8(%r14), %rdx
testl %edx, %edx
jle 0x49d7
movq 0x10(%rsp), %rcx
movl %edx, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
leal -0x1(%rdx), %esi
cmpq %rsi, %rdx
cmovbq %rdx, %rsi
xorl %r8d, %r8d
xorl %eax, %eax
testq %rdx, %rdx
je 0x4ad3
movsbl (%rcx,%r8), %r9d
addl %r9d, %eax
incq %r8
cmpq %r8, %rdi
jne 0x49bc
jmp 0x49d9
xorl %eax, %eax
movq 0x7428(%rip), %rdi      # 0xbe08
leaq 0x29d4(%rip), %rsi      # 0x73bb
movl %eax, %edx
xorl %eax, %eax
callq 0x2260
movb $0x1, 0x10(%rbx)
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x4a0b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0x740e(%rip), %r14      # 0xbe20
movabsq $0x4f4c535441545323, %rax # imm = 0x4F4C535441545323
xorq 0x73fd(%rip), %rax      # 0xbe20
movzwl 0x73fe(%rip), %ecx      # 0xbe28
xorq $0x2347, %rcx           # imm = 0x2347
orq %rax, %rcx
leaq 0x73d5(%rip), %rax      # 0xbe10
leaq 0x73c6(%rip), %r12      # 0xbe08
cmoveq %rax, %r12
movq (%r12), %rdi
leaq 0x2979(%rip), %rsi      # 0x73ca
leaq 0xe908(%rip), %rdx      # 0x13360
xorl %eax, %eax
callq 0x2260
movq (%r12), %r15
movq 0x8(%rbx), %rdi
callq 0x4d50
leaq 0x295c(%rip), %rsi      # 0x73cf
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x2260
movq (%r12), %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2260
movl 0xe8bd(%rip), %eax      # 0x13350
leal 0x1(%rax), %ecx
movl %ecx, 0xe8b4(%rip)      # 0x13350
testl %eax, %eax
js 0x4ac2
movq 0x7361(%rip), %rdi      # 0xbe08
callq 0x21f0
movq 0x735d(%rip), %rdi      # 0xbe10
callq 0x21f0
movl $0x0, 0xe88e(%rip)      # 0x13350
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x2972(%rip), %rdi      # 0x744c
xorl %eax, %eax
callq 0x2290
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x4afb
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x22f0
nop