LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/stacksmith[P]picoasm/cpicoblaze.cpp
// Function: CCode::CCode(CPicoBlaze*)
CCode::CCode( CPicoBlaze *cpu ) 
{
	m_cpu = cpu ;
	
	int i ;
	for ( i = 0 ; i < MAX_ADDRESS ; i++ )
		CodeMap[ i ] = NULL ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rsi, (%rdi)
xorl %eax, %eax
cmpq $0x400, %rax            # imm = 0x400
je 0x40a51e
andq $0x0, 0x8(%rdi,%rax,8)
incq %rax
jmp 0x40a50b
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/stacksmith[P]picoasm/cpicoblaze.cpp
// Function: CCode::ClearCode()
void CCode::ClearCode() {	
	int i ;
	for ( i = 0 ; i < MAX_ADDRESS ; i++ )
		if ( CodeMap[ i ] != NULL ) {
			delete CodeMap[ i ] ;
			CodeMap[ i ] = NULL ;
		}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r14d, %r14d
cmpq $0x400, %r14            # imm = 0x400
je 0x40a55b
movq 0x8(%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0x40a556
movq (%rdi), %rax
callq *0x8(%rax)
andq $0x0, 0x8(%rbx,%r14,8)
incq %r14
jmp 0x40a537
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/stacksmith[P]picoasm/cpicoblaze.cpp
// Function: CCode::setInstruction(unsigned short, unsigned int, unsigned int)
bool CCode::setInstruction( uint16_t address, uint32_t code, unsigned int sourceLine )
{
	CInstruction *instr = Disassemble( code ) ;
	if ( instr == NULL ) {
	  cout << ">>>>Unknown code at address " << address << "<<<<" << endl ;
		return FALSE ;
	}
	
	if ( address >= MAX_ADDRESS ) {
	  cout << ">>>>Invalid address" << address << "<<<<" << endl ;
		delete instr ;
		return FALSE ;
	}
	
	
	if ( CodeMap[ address ] != NULL ) {
	  cout << ">>>>Code is placed at same address (" << address << ")<<<<" << endl ;
		delete instr ;
		return FALSE ;
	}
	
	instr->setSourceLine( sourceLine ) ;
	CodeMap[ address ] = instr ;
	
	return TRUE ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %r15d
movl %esi, %r14d
movq %rdi, %r12
movl %edx, %esi
callq 0x40a560
testq %rax, %rax
je 0x40ade3
movq %rax, %rbx
cmpw $0x400, %r14w           # imm = 0x400
jb 0x40ae1b
movq $0x5f5580, %rdi         # imm = 0x5F5580
leaq 0x177040(%rip), %rsi    # 0x581e09
callq 0x4755f0
movzwl %r14w, %esi
movq %rax, %rdi
callq 0x475c10
leaq 0x176ff7(%rip), %rsi    # 0x581dd8
jmp 0x40ae4c
movq $0x5f5580, %rdi         # imm = 0x5F5580
leaq 0x176ffb(%rip), %rsi    # 0x581dec
callq 0x4755f0
movzwl %r14w, %esi
movq %rax, %rdi
callq 0x475c10
leaq 0x176fcf(%rip), %rsi    # 0x581dd8
movq %rax, %rdi
callq 0x4755f0
movq %rax, %rdi
callq 0x474ed0
jmp 0x40ae65
movzwl %r14w, %r14d
cmpq $0x0, 0x8(%r12,%r14,8)
je 0x40ae70
movq $0x5f5580, %rdi         # imm = 0x5F5580
leaq 0x176fe8(%rip), %rsi    # 0x581e1d
callq 0x4755f0
movq %rax, %rdi
movl %r14d, %esi
callq 0x475c10
leaq 0x176ff6(%rip), %rsi    # 0x581e42
movq %rax, %rdi
callq 0x4755f0
movq %rax, %rdi
callq 0x474ed0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %r15d, 0x20(%rbx)
movq %rbx, 0x8(%r12,%r14,8)
movb $0x1, %al
jmp 0x40ae67
nop
// File: /workspace/github_cpp_makefile_star2_O2/stacksmith[P]picoasm/cpicoblaze.cpp
// Function: CCode::Print()
void CCode::Print()
{
	int i ;
	
	cout << "----listing----" << endl ;
	for ( i = 0 ; i < MAX_ADDRESS ;  i++ ) {
		if ( CodeMap[ i ] != NULL ) {
			cout << i << "  : " ;
			CodeMap[ i ]->Print() ;
			cout << endl ;
		}
	}
	cout << "----end listing----" << endl ;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq $0x5f5580, %r14         # imm = 0x5F5580
leaq 0x176f94(%rip), %rsi    # 0x581e48
movq %r14, %rdi
callq 0x4755f0
movq %rax, %rdi
callq 0x474ed0
xorl %r15d, %r15d
leaq 0x176f8a(%rip), %r12    # 0x581e58
cmpq $0x400, %r15            # imm = 0x400
je 0x40af0d
cmpq $0x0, 0x8(%rbx,%r15,8)
je 0x40af08
movq %r14, %rdi
movl %r15d, %esi
callq 0x475990
movq %rax, %rdi
movq %r12, %rsi
callq 0x4755f0
movq 0x8(%rbx,%r15,8), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq %r14, %rdi
callq 0x474ed0
incq %r15
jmp 0x40aece
movq $0x5f5580, %rdi         # imm = 0x5F5580
leaq 0x176f42(%rip), %rsi    # 0x581e5d
callq 0x4755f0
movq %rax, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x474ed0
// File: /workspace/github_cpp_makefile_star2_O2/stacksmith[P]picoasm/cpicoblaze.cpp
// Function: CPicoBlaze::CPicoBlaze()
CPicoBlaze::CPicoBlaze()
{
	flags.zero = false ;
	flags.carry = false ;
	flags.interrupt_enable = false ;

	scratch = new CScratchPad ;
	pc = new CProgramCounter ;
	stack = new CStack ;
	port = new CPort ;
	code = new CCode( this ) ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
andw $0x0, 0x10(%rdi)
movb $0x0, 0x12(%rdi)
pushq $0x40
popq %r14
movq %r14, %rdi
callq 0x40ce70
movq %rax, %r15
movq %rax, %rdi
callq 0x40a312
movq %r15, 0x20(%rbx)
pushq $0x2
popq %rdi
callq 0x40ce70
andw $0x0, (%rax)
movq %rax, 0x18(%rbx)
movq %r14, %rdi
callq 0x40ce70
movq %rax, %r14
movq %rax, %rdi
callq 0x40a330
movq %r14, 0x28(%rbx)
pushq $0x20
popq %rdi
callq 0x40ce70
leaq 0x8(%rax), %rcx
movq %rcx, 0x10(%rax)
movq %rcx, 0x8(%rax)
andq $0x0, 0x18(%rax)
movq %rax, 0x30(%rbx)
movl $0x2008, %edi           # imm = 0x2008
callq 0x40ce70
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x40a502
movq %r14, 0x38(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/stacksmith[P]picoasm/cpicoblaze.cpp
// Function: CPicoBlaze::~CPicoBlaze()
CPicoBlaze::~CPicoBlaze()
{
	delete scratch ;
	delete pc ;
	delete stack ;
	delete port ;
	delete code ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
pushq $0x40
popq %r14
movq %r14, %rsi
callq 0x40bfd0
movq 0x18(%rbx), %rdi
pushq $0x2
popq %rsi
callq 0x40bfd0
movq 0x28(%rbx), %rdi
movq %r14, %rsi
callq 0x40bfd0
movq 0x30(%rbx), %r14
testq %r14, %r14
je 0x40b010
leaq 0x8(%r14), %rdi
callq 0x40bbfc
pushq $0x20
popq %rsi
movq %r14, %rdi
callq 0x40bfd0
movq 0x38(%rbx), %rbx
testq %rbx, %rbx
je 0x40b02c
movq %rbx, %rdi
callq 0x40a52a
movl $0x2008, %esi           # imm = 0x2008
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x40bfd0
nop
// File: /workspace/github_cpp_makefile_star2_O2/stacksmith[P]picoasm/cpicoblaze.cpp
// Function: CPicoBlaze::Print()
void CPicoBlaze::Print()
{
	int i ;
	
	cout << "----CPU----" << endl ;
	cout << "regs|" ;
	for ( i = 0 ; i < 15 ; i++ ) 
		cout << "s" << i << "=" << (int) s[ i ]  << "|" ;
	cout << endl ;
	
	cout << "flags|";
	cout << "c=" << flags.carry ;
	cout << "|z=" << flags.zero ;
	cout << "|ie=" << flags.interrupt_enable << "|" << endl ;
	cout << "----end CPU----" << endl ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq $0x5f5580, %r14         # imm = 0x5F5580
leaq 0x176d5c(%rip), %rsi    # 0x581e71
movq %r14, %rdi
callq 0x4755f0
movq %rax, %rdi
callq 0x474ed0
leaq 0x176d51(%rip), %rsi    # 0x581e7d
movq %r14, %rdi
callq 0x4755f0
xorl %r15d, %r15d
leaq 0x176738(%rip), %r12    # 0x581876
leaq 0x17aa8e(%rip), %r13    # 0x585bd3
leaq 0x176d3c(%rip), %r14    # 0x581e88
cmpq $0xf, %r15
je 0x40b194
movq $0x5f5580, %rdi         # imm = 0x5F5580
movq %r12, %rsi
callq 0x4755f0
movq %rax, %rdi
movl %r15d, %esi
callq 0x475990
movq %rax, %rdi
movq %r13, %rsi
callq 0x4755f0
movzbl (%rbx,%r15), %esi
movq %rax, %rdi
callq 0x475990
movq %rax, %rdi
movq %r14, %rsi
callq 0x4755f0
incq %r15
jmp 0x40b14c
movq $0x5f5580, %r14         # imm = 0x5F5580
movq %r14, %rdi
callq 0x474ed0
leaq 0x176cd9(%rip), %rsi    # 0x581e83
movq %r14, %rdi
callq 0x4755f0
leaq 0x176cd1(%rip), %rsi    # 0x581e8a
movq %r14, %rdi
callq 0x4755f0
movzbl 0x11(%rbx), %esi
movq %rax, %rdi
callq 0x475c30
leaq 0x176cb9(%rip), %rsi    # 0x581e8d
movq %r14, %rdi
callq 0x4755f0
movzbl 0x10(%rbx), %esi
movq %rax, %rdi
callq 0x475c30
leaq 0x176ca2(%rip), %rsi    # 0x581e91
movq %r14, %rdi
callq 0x4755f0
movzbl 0x12(%rbx), %esi
movq %rax, %rdi
callq 0x475c30
leaq 0x176c7e(%rip), %rsi    # 0x581e88
movq %rax, %rdi
callq 0x4755f0
movq %rax, %rdi
callq 0x474ed0
leaq 0x176c75(%rip), %rsi    # 0x581e96
movq %r14, %rdi
callq 0x4755f0
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x474ed0
nop
// File: /workspace/github_cpp_makefile_star2_O2/stacksmith[P]picoasm/cpicoblaze.cpp
// Function: CPicoBlaze::GetNextSourceLine()
unsigned int CPicoBlaze::GetNextSourceLine()
{
	CInstruction *instr = code->getInstruction( pc->Get() ) ;
	if ( instr == NULL ) {
	  cout << ">>>>Error in simulation (No code found at " << pc->Get() << ")<<<<" << endl ;
		return FALSE ;
	}

	return instr->getSourceLine() ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x18(%rdi), %rax
movzwl (%rax), %eax
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x40b26b
movq 0x38(%rbx), %rcx
movq 0x8(%rcx,%rax,8), %rax
testq %rax, %rax
je 0x40b26b
movl 0x20(%rax), %eax
jmp 0x40b2a6
movq $0x5f5580, %rdi         # imm = 0x5F5580
leaq 0x176c2d(%rip), %rsi    # 0x581ea6
callq 0x4755f0
movq 0x18(%rbx), %rcx
movzwl (%rcx), %esi
movq %rax, %rdi
callq 0x475c10
leaq 0x176bae(%rip), %rsi    # 0x581e42
movq %rax, %rdi
callq 0x4755f0
movq %rax, %rdi
callq 0x474ed0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/stacksmith[P]picoasm/cpicoblaze.cpp
// Function: CPicoBlaze::Next()
bool CPicoBlaze::Next()
{
	CInstruction *instr = code->getInstruction( pc->Get() ) ;
	if ( instr == NULL ) {
	  cout << ">>>>Error in simulation (No code found at " << pc->Get() << ")<<<<" << endl ;
		return FALSE ;
	}

	instr->Execute() ;
		
	return TRUE ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x18(%rdi), %rax
movzwl (%rax), %eax
cmpq $0x3ff, %rax            # imm = 0x3FF
ja 0x40b2de
movq 0x38(%rbx), %rcx
movq 0x8(%rcx,%rax,8), %rdi
testq %rdi, %rdi
je 0x40b2de
movq (%rdi), %rax
callq *0x10(%rax)
movb $0x1, %al
jmp 0x40b319
movq $0x5f5580, %rdi         # imm = 0x5F5580
leaq 0x176bba(%rip), %rsi    # 0x581ea6
callq 0x4755f0
movq 0x18(%rbx), %rcx
movzwl (%rcx), %esi
movq %rax, %rdi
callq 0x475c10
leaq 0x176b3b(%rip), %rsi    # 0x581e42
movq %rax, %rdi
callq 0x4755f0
movq %rax, %rdi
callq 0x474ed0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/./cpuuse.h
// Function: cal_cpuoccupy(CPU_OCCUPY*, CPU_OCCUPY*)
double cal_cpuoccupy(CPU_OCCUPY *o, CPU_OCCUPY *n)
{
	unsigned int od, nd;
	unsigned int id, sd;
	double cpu_use = 0;
	double st,tol;

	od = (unsigned int)(o->user + o->nice + o->system + o->idle);//��һ��(�û�+���ȼ�+ϵͳ+����)��ʱ���ٸ���od
	nd = (unsigned int)(n->user + n->nice + n->system + n->idle);//�ڶ���(�û�+���ȼ�+ϵͳ+����)��ʱ���ٸ���od

	id = (unsigned int)(n->user - o->user);    //�û���һ�κ͵ڶ��ε�ʱ��֮���ٸ���id
	sd = (unsigned int)(n->system - o->system);//ϵͳ��һ�κ͵ڶ��ε�ʱ��֮���ٸ���sd
	st=sd+id;
	tol=nd-od;
    printf("%.2f,%.2f\n",st,tol);
	if (tol != 0)
		cpu_use = (st * 100) / tol; //((�û�+ϵͳ)��100)��(��һ�κ͵ڶ��ε�ʱ����)�ٸ���g_cpu_used
	else 
		cpu_use = 0;
	//printf("cpu: %.2f\%\n", cpu_use);
	return cpu_use;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl 0x14(%rdi), %ecx
movl 0x1c(%rdi), %edx
movl 0x18(%rdi), %eax
addl %ecx, %eax
addl %edx, %eax
addl 0x20(%rdi), %eax
movl 0x14(%rsi), %edi
movl 0x1c(%rsi), %r8d
movl 0x18(%rsi), %r9d
addl %edi, %r9d
addl %r8d, %r9d
addl 0x20(%rsi), %r9d
addl %ecx, %edx
subl %edx, %edi
addl %r8d, %edi
cvtsi2sd %rdi, %xmm0
leaq 0x3827(%rip), %rdi      # 0x7063
xorpd %xmm2, %xmm2
subl %eax, %r9d
cvtsi2sd %r9, %xmm1
je 0x385a
movsd 0x37b6(%rip), %xmm2     # 0x7008
mulsd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, -0x8(%rbp)
movb $0x2, %al
callq 0x3040
movsd -0x8(%rbp), %xmm0
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/./cpuuse.h
// Function: get_cpuoccupy(CPU_OCCUPY*)
void get_cpuoccupy(CPU_OCCUPY *cpust) //��������get��������һ���βνṹ����Ū��ָ��O
{
	FILE *fd;
	int n;
	char buff[256];
	CPU_OCCUPY *cpu_occupy;
	cpu_occupy = cpust;

	fd = fopen("/proc/stat", "r");
	fgets(buff, sizeof(buff), fd);

	sscanf(buff, "%s %u %u %u %u", cpu_occupy->name, &cpu_occupy->user, &cpu_occupy->nice, &cpu_occupy->system, &cpu_occupy->idle);
	//printf("name = %s, user = %u, nice = %u, system = %u , idle = %u \n", cpu_occupy->name, cpu_occupy->user, cpu_occupy->nice, cpu_occupy->system, cpu_occupy->idle);

	fclose(fd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
leaq 0x37e3(%rip), %rdi      # 0x706e
leaq 0x3941(%rip), %rsi      # 0x71d3
callq 0x3410
movq %rax, %r14
leaq -0x120(%rbp), %r15
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %rax, %rdx
callq 0x3580
leaq 0x14(%rbx), %rcx
leaq 0x18(%rbx), %r8
leaq 0x1c(%rbx), %r9
leaq 0x20(%rbx), %rax
movq %rax, (%rsp)
leaq 0x37ad(%rip), %rsi      # 0x7079
movq %r15, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3380
movq %r14, %rdi
callq 0x33b0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/./cpuuse.h
// Function: cpuuse()
int cpuuse()
{
	CPU_OCCUPY cpu_stat1;
	CPU_OCCUPY cpu_stat2;
	double cpu;
	//��һ�λ�ȡcpuʹ������
	//printf("===============================cpu use================================\n");
	get_cpuoccupy((CPU_OCCUPY *)&cpu_stat1);
	sleep(5);

	//�ڶ��λ�ȡcpuʹ������
	get_cpuoccupy((CPU_OCCUPY *)&cpu_stat2);

	//����cpuʹ����
	cpu = cal_cpuoccupy((CPU_OCCUPY *)&cpu_stat1, (CPU_OCCUPY *)&cpu_stat2);
	printf("cpu use = %.2f\%\n", cpu);
	//printf("======================================================================\n");

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
leaq -0x58(%rbp), %rbx
movq %rbx, %rdi
callq 0x3871
pushq $0x5
popq %rdi
callq 0x3270
leaq -0x34(%rbp), %r14
movq %r14, %rdi
callq 0x3871
movq %rbx, %rdi
movq %r14, %rsi
callq 0x37fc
leaq 0x375c(%rip), %rdi      # 0x7088
movb $0x1, %al
callq 0x3040
xorl %eax, %eax
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/./maile.h
// Function: CAutoMail::init_socket()
bool CAutoMail::init_socket()
{
	char _buf_svr[BUF_LEN] = {0};
	wcstombs(_buf_svr, m_str_email_server.data(), m_str_email_server.length()+1);
	hostent *host_server = gethostbyname(_buf_svr);

	if (host_server == NULL)
	{
		ERROR_NUMBER = CHANGE_URL_TO_IP_FAILED;
		return false;
	}

	m_socket_server = socket(AF_INET,SOCK_STREAM,0);
	if (m_socket_server < 0)
	{
		ERROR_NUMBER = CREATE_SOCKET_FAILED;
		return false;
	}

	m_sockaddr_server.sin_family = AF_INET;
 	m_sockaddr_server.sin_port = htons(m_ns_server_port);
	m_sockaddr_server.sin_addr = *((struct in_addr *)host_server->h_addr);
	memset(&(m_sockaddr_server.sin_zero), 0, 8) ;

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rdi, %rbx
leaq -0x110(%rbp), %r14
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
xorl %esi, %esi
callq 0x31f0
movq 0x308(%rbx), %rsi
movq 0x310(%rbx), %rdx
incq %rdx
movq %r14, %rdi
callq 0x3320
movq %r14, %rdi
callq 0x33f0
testq %rax, %rax
je 0x4057
movq %rax, %r14
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x3090
movl %eax, 0x32c(%rbx)
testl %eax, %eax
js 0x4063
movw $0x2, 0x330(%rbx)
movzwl 0x328(%rbx), %eax
rolw $0x8, %ax
movw %ax, 0x332(%rbx)
movq 0x18(%r14), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, 0x334(%rbx)
andq $0x0, 0x338(%rbx)
movb $0x1, %al
jmp 0x406f
movl $0x14, 0x632f(%rip)     # 0xa390
jmp 0x406d
movl $0x12, 0x6323(%rip)     # 0xa390
xorl %eax, %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/./maile.h
// Function: CAutoMail::uninit()
void CAutoMail::uninit()
{
	shutdown(m_socket_server, SHUT_RDWR);
	close(m_socket_server);
	char _buf[BUF_LEN] = {0};
	
	memset(_buf, 0, sizeof(_buf));
	sprintf(_buf, "rm -f %s", STR_BASE_FILE);
	system(_buf);
	
	memset(_buf, 0, sizeof(_buf));
	sprintf(_buf, "rm -f %s", STR_TMP_FILE);
	system(_buf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rdi, %rbx
movl 0x32c(%rdi), %edi
pushq $0x2
popq %rsi
callq 0x3490
movl 0x32c(%rbx), %edi
callq 0x36b0
leaq -0x110(%rbp), %rbx
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
xorl %esi, %esi
callq 0x31f0
movq 0x62b5(%rip), %rdx      # 0xa378
leaq 0x3002(%rip), %r14      # 0x70cc
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x3070
movq %rbx, %rdi
callq 0x3310
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
xorl %esi, %esi
callq 0x31f0
movq 0x627b(%rip), %rdx      # 0xa370
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x3070
movq %rbx, %rdi
callq 0x3310
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/./maile.h
// Function: CAutoMail::base64(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>, char const*)
bool CAutoMail::base64(wstring data, const char *dst_file)
{
	if (dst_file == NULL)
	{
		ERROR_NUMBER = PARAM_INCORRECT;
		return false;
	}

	wofstream _ofs(STR_TMP_FILE); // create temp file to store data
	_ofs << data.data();
	_ofs.close();
	
	char buf[BUF_LEN] = {0}; // to encode data with base64 by shell
	sprintf(buf,"base64 %s >> %s", STR_TMP_FILE, dst_file);
	system(buf);

	memset(buf, 0, sizeof(buf));
	sprintf(buf, "rm -f %s", STR_TMP_FILE);
	system(buf);

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rdx, %rbx
testq %rdx, %rdx
je 0x41db
movq %rsi, %r14
movq 0x6234(%rip), %rsi      # 0xa370
leaq -0x320(%rbp), %r15
pushq $0x10
popq %rdx
movq %r15, %rdi
callq 0x3480
movq (%r14), %rsi
movq %r15, %rdi
callq 0x3670
leaq -0x320(%rbp), %rdi
callq 0x3460
leaq -0x120(%rbp), %r14
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
xorl %esi, %esi
callq 0x31f0
movq 0x61ee(%rip), %rdx      # 0xa370
leaq 0x2f4c(%rip), %rsi      # 0x70d5
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x3070
movq %r14, %rdi
callq 0x3310
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
xorl %esi, %esi
callq 0x31f0
movq 0x61bc(%rip), %rdx      # 0xa370
leaq 0x2f11(%rip), %rsi      # 0x70cc
movq %r14, %rdi
xorl %eax, %eax
callq 0x3070
movq %r14, %rdi
callq 0x3310
leaq -0x320(%rbp), %rdi
callq 0x3560
jmp 0x41e5
movl $0x10, 0x61ab(%rip)     # 0xa390
testq %rbx, %rbx
setne %al
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x41fb
movq %rax, %rbx
leaq -0x320(%rbp), %rdi
callq 0x3560
movq %rbx, %rdi
callq 0x3600
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/./maile.h
// Function: CAutoMail::get_time(char*)
void CAutoMail::get_time(char *time_buf)
{
	if (time_buf == NULL)
		return;
	time_t tt = time(NULL);
	struct tm *time_now = localtime(&tt);
	sprintf(time_buf, "%d-%d-%d-%d:%d:%d", time_now->tm_year+1900, time_now->tm_mon+1, time_now->tm_mday, time_now->tm_hour, 
	        time_now->tm_min, time_now->tm_sec);
}

// Assembly:
testq %rsi, %rsi
je 0x426c
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
xorl %edi, %edi
callq 0x3350
leaq -0x10(%rbp), %rdi
movq %rax, (%rdi)
callq 0x3260
movl $0x76c, %edx            # imm = 0x76C
addl 0x14(%rax), %edx
movl 0x10(%rax), %ecx
incl %ecx
movl 0xc(%rax), %r8d
movl 0x8(%rax), %r9d
movl (%rax), %r10d
movl 0x4(%rax), %r11d
leaq 0x2e8f(%rip), %rsi      # 0x70e5
movq %rbx, %rdi
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0x3070
popq %rcx
popq %rdx
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/./maile.h
// Function: run_mail()
int run_mail()
{
	CAutoMail automail;
	automail.init();
	if(!automail.send_mail())
		cout<<automail.get_error_no()<<endl;
	automail.uninit();
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
leaq -0x348(%rbp), %rbx
movq %rbx, %rdi
callq 0x393e
movq %rbx, %rdi
callq 0x3f9e
leaq -0x348(%rbp), %rdi
callq 0x49d6
testb %al, %al
jne 0x4d0e
movl 0x5696(%rip), %esi      # 0xa390
movq 0x52bf(%rip), %rdi      # 0x9fc0
callq 0x3230
movq %rax, %rdi
callq 0x3190
leaq -0x348(%rbp), %rdi
callq 0x407c
leaq -0x348(%rbp), %rdi
callq 0x3b30
xorl %eax, %eax
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %rbp
retq
movq %rax, %rbx
leaq -0x348(%rbp), %rdi
callq 0x3b30
movq %rbx, %rdi
callq 0x3600
nop
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/watchdog.cpp
// Function: PidTracker::PidTracker()
PidTracker::PidTracker() 
{
	  char path[80];
	  snprintf(path, sizeof(path), "/sys/fs/cgroup/cpu/%d.supervisor", getpid());
	  int rv = mkdir(path, 0777);

	  if (rv < 0) 
	  {
		perror("PidTracker: mkdir");
	  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x58, %rsp
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
callq 0x3520
leaq 0x2433(%rip), %rdx      # 0x71a2
leaq -0x60(%rbp), %rbx
pushq $0x50
popq %rsi
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x3590
movq %rbx, %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x3170
testl %eax, %eax
js 0x4d9a
addq $0x58, %rsp
popq %rbx
popq %rbp
retq
leaq 0x2422(%rip), %rdi      # 0x71c3
addq $0x58, %rsp
popq %rbx
popq %rbp
jmp 0x3300
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/watchdog.cpp
// Function: PidTracker::add(int)
void PidTracker::add(int pid) 
{
	  char path[80];
	  snprintf(path, sizeof(path), "/sys/fs/cgroup/cpu/%d.supervisor/tasks",
			   getpid());

	  char buf[64];
	  ssize_t n = snprintf(buf, sizeof(buf), "%d", pid);

	  int fd = open(path, O_WRONLY);
	  write(fd, buf, n);
	  close(fd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x98, %rsp
movl %esi, %ebx
callq 0x3520
leaq 0x23c5(%rip), %rdx      # 0x71d5
leaq -0xb0(%rbp), %r14
pushq $0x50
popq %rsi
movq %r14, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x3590
leaq 0x23fc(%rip), %rdx      # 0x7229
leaq -0x60(%rbp), %r15
pushq $0x40
popq %rsi
movq %r15, %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x3590
movslq %eax, %rbx
pushq $0x1
popq %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x3250
movl %eax, %r14d
movl %eax, %edi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x30f0
movl %r14d, %edi
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x36b0
nop
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/watchdog.cpp
// Function: PidTracker::collectAll()
std::vector<int> PidTracker::collectAll() 
{
	  std::vector<int> result;

	  char path[80];
	  snprintf(path, sizeof(path), "/sys/fs/cgroup/cpu/%d.supervisor/tasks",
			   getpid());

	  std::ifstream tasksFile(path);
	  std::string line;

	  while (std::getline(tasksFile, line)) 
	  {
		result.push_back(stoi(line));
	  }

	  return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
callq 0x3520
leaq 0x2331(%rip), %rdx      # 0x71d5
leaq -0xa0(%rbp), %r14
pushq $0x50
popq %rsi
movq %r14, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x3590
leaq -0x2a8(%rbp), %rdi
pushq $0x8
popq %rdx
movq %r14, %rsi
callq 0x3640
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x2a8(%rbp), %r14
leaq -0x50(%rbp), %r15
pushq $0xa
popq %r12
leaq -0x2c(%rbp), %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x3080
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x4f25
movq %r15, %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x5c0c
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x64d6
jmp 0x4eef
leaq -0x50(%rbp), %rdi
callq 0x3160
leaq -0x2a8(%rbp), %rdi
callq 0x30a0
movq %rbx, %rax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x4f6e
jmp 0x4f56
movq %rax, %r14
leaq -0x50(%rbp), %rdi
callq 0x3160
leaq -0x2a8(%rbp), %rdi
callq 0x30a0
movq %rbx, %rdi
callq 0x64c2
movq %r14, %rdi
callq 0x3600
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/watchdog.cpp
// Function: Program::spawn()
bool Program::spawn() 
	{
	  logger_->info("starting program (%s)...", exe_.c_str());

	  pid_t pid = fork();

	  if (pid < 0) 
	  {
		logger_->error("fork failed. %s", strerror(errno));
		return false;
	  } 
	  else if (pid > 0) 
	  {  // parent
		pid_ = pid;
		pidTracker_.add(pid);
		logger_->info("child pid is %d", pid);
		return true;
	  } 
	  else 
	  {  // child
		std::vector<char*> argv;

		for (const std::string& arg : argv_) 
		{
		  argv.push_back(const_cast<char*>(arg.c_str()));
		}
		argv.push_back(nullptr);

		execvp(exe_.c_str(), argv.data());
		logger_->error("execvp failed. %s", strerror(errno));
		abort();
	  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq (%rdi), %rdi
movq 0x8(%rbx), %rdx
leaq 0x1f58(%rip), %rsi      # 0x722c
callq 0x5dac
callq 0x30b0
movl %eax, %r14d
testl %eax, %eax
js 0x5307
je 0x533d
movl %r14d, 0x60(%rbx)
movl %r14d, %esi
callq 0x4df2
movq (%rbx), %rdi
leaq 0x1f58(%rip), %rsi      # 0x7255
movl %r14d, %edx
callq 0x5cf6
jmp 0x5328
movq (%rbx), %rbx
callq 0x3030
movl (%rax), %edi
callq 0x30e0
leaq 0x1f28(%rip), %rsi      # 0x7245
movq %rbx, %rdi
movq %rax, %rdx
callq 0x5e62
testl %r14d, %r14d
setns %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %r14
andq $0x0, 0x10(%r14)
movaps %xmm0, (%r14)
movq 0x28(%rbx), %r12
movq 0x30(%rbx), %r13
leaq -0x30(%rbp), %r15
cmpq %r13, %r12
je 0x5377
movq (%r12), %rax
movq %rax, -0x30(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x6854
addq $0x20, %r12
jmp 0x5359
leaq -0x30(%rbp), %rsi
andq $0x0, (%rsi)
leaq -0x50(%rbp), %rdi
callq 0x6854
movq 0x8(%rbx), %rdi
movq -0x50(%rbp), %rsi
callq 0x3290
movq (%rbx), %rbx
callq 0x3030
movl (%rax), %edi
callq 0x30e0
leaq 0x1eba(%rip), %rsi      # 0x7265
movq %rbx, %rdi
movq %rax, %rdx
callq 0x5e62
callq 0x3200
jmp 0x53bf
jmp 0x53bf
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x6840
movq %rbx, %rdi
callq 0x3600
nop
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/watchdog.cpp
// Function: Program::resume()
bool Program::resume() 
	{
		  pidTracker_.dump("resume");

		  if (pid_t pid = pidTracker_.findMainPID(mainPidfile_)) 
		  {
			logger_->info("new main pid: %d", pid);
			pid_ = pid;
			return true;
		  }

		  const auto pids = pidTracker_.collectAll();
		  if (!pids.empty()) 
		  {
			pid_ = pids[0];
			return true;
		  }

		  return false;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
addq $0x68, %rdi
leaq 0x40(%rbx), %rsi
callq 0x4f7e
testl %eax, %eax
je 0x5410
movl %eax, %r14d
movq (%rbx), %rdi
leaq 0x1e1b(%rip), %rsi      # 0x721b
movl %eax, %edx
callq 0x5cf6
movl %r14d, 0x60(%rbx)
movb $0x1, %r14b
jmp 0x5437
leaq -0x28(%rbp), %r14
movq %r14, %rdi
callq 0x4e76
movq (%r14), %rax
cmpq 0x8(%r14), %rax
setne %r14b
je 0x542e
movl (%rax), %eax
movl %eax, 0x60(%rbx)
leaq -0x28(%rbp), %rdi
callq 0x64c2
movl %r14d, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/watchdog.cpp
// Function: Supervisor::sighandler(int)
void Supervisor::sighandler(int signum) 
{
  if (self()->program_->pid()) 
  {
    self()->logger()->info(
        "Signal '%s' (%d) received. Forwarding to child PID %d.",
        strsignal(signum), signum, self()->program_->pid());

    // forward to child process
    self()->program_->signal(signum);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq 0x4b52(%rip), %r14      # 0xa3b8
movq 0x28(%r14), %rax
cmpl $0x0, 0x60(%rax)
je 0x58b0
movl %edi, %ebx
callq 0x3610
movq 0x4b3a(%rip), %rcx      # 0xa3b8
movq 0x28(%rcx), %rcx
movl 0x60(%rcx), %r8d
leaq 0x1c1d(%rip), %rsi      # 0x74aa
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
callq 0x6272
movq 0x4b17(%rip), %rax      # 0xa3b8
movq 0x28(%rax), %rdi
movl %ebx, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x544e
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/watchdog.cpp
// Function: Supervisor::restart()
bool Supervisor::restart() 
{
  if (restartDelay_) 
  {
    logger()->info("restart is sleeping for %d seconds\n", restartDelay_);
    sleep(restartDelay_);

    // exponential backoff for the next restart
    restartDelay_ = std::min(restartDelay_ << 1, restartDelayLimit_);
  } 
  else 
  {
    restartDelay_ = 1;
	cout<<endl;
  }

  restartCount_++;
  if(restartCount_%3==0)
  {
	  run_mail();
  }
  return program_->restart();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x74(%rdi), %edx
testl %edx, %edx
je 0x5b41
leaq 0x1967(%rip), %rsi      # 0x7486
movq %rbx, %rdi
callq 0x5cf6
movl 0x74(%rbx), %edi
callq 0x3270
movl 0x74(%rbx), %eax
movl 0x78(%rbx), %ecx
addl %eax, %eax
cmpl %eax, %ecx
cmovll %ecx, %eax
movl %eax, 0x74(%rbx)
jmp 0x5b54
movl $0x1, 0x74(%rbx)
movq 0x4471(%rip), %rdi      # 0x9fc0
callq 0x3190
movl 0x70(%rbx), %eax
incl %eax
movl %eax, 0x70(%rbx)
pushq $0x3
popq %rcx
cltd
idivl %ecx
testl %edx, %edx
jne 0x5b6b
callq 0x4cc1
movq 0x28(%rbx), %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x52b2
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/watchdog.cpp
// Function: Supervisor::isExitSuccess(int) const
bool Supervisor::isExitSuccess(int value) const 
{
  for (int code: successExitCodes_)
    if (value == code)
      return true;

  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x90(%rdi), %rdx
movq 0x98(%rdi), %rax
movq %rdx, %rcx
cmpq %rax, %rdx
je 0x5b9c
leaq 0x4(%rcx), %rdx
cmpl %esi, (%rcx)
jne 0x5b8c
cmpq %rax, %rcx
setne %al
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/watchdog.cpp
// Function: void Logger::info<int>(char const*, int)
void info(const char* fmt, Args... args) 
	{
		if (logLevel_ >= 2) 
		{
		  std::string fmt2("%s[%d]: ");
		  fmt2 += fmt;
		  fmt2 += "\n";
		  fprintf(stdout, fmt2.c_str(), basename_.c_str(), getpid(), args...);
		  fflush(stdout);
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpl $0x2, 0x20(%rdi)
jl 0x5d88
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
leaq 0x1835(%rip), %rsi      # 0x7551
leaq -0x50(%rbp), %r12
leaq -0x29(%rbp), %rdx
movq %r12, %rdi
callq 0x3110
movq %r12, %rdi
movq %r15, %rsi
callq 0x3690
leaq 0x144b(%rip), %rsi      # 0x7189
leaq -0x50(%rbp), %rdi
callq 0x3690
movq 0x4252(%rip), %r12      # 0x9fa0
movq (%r12), %r15
leaq -0x50(%rbp), %rax
movq (%rax), %r13
movq (%r14), %r14
callq 0x3520
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
movl %eax, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x34f0
movq (%r12), %rdi
callq 0x3400
leaq -0x50(%rbp), %rdi
callq 0x3160
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3160
movq %rbx, %rdi
callq 0x3600
nop
// File: /workspace/github_cpp_makefile_star2_O2/wangyufei95[P]watchdog_linux/watchdog.cpp
// Function: void Logger::error<char*>(char const*, char*)
void error(const char* fmt, Args... args) 
	{
    	if (logLevel_ >= 1) 
		{
		  std::string fmt2("%s[%d]: ");
		  fmt2 += fmt;
		  fmt2 += "\n";
		  fprintf(stderr, fmt2.c_str(), basename_.c_str(), getpid(), args...);
		  fflush(stderr);
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpl $0x0, 0x20(%rdi)
jg 0x5e88
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq 0x16b9(%rip), %rsi      # 0x7551
leaq -0x50(%rbp), %r12
leaq -0x29(%rbp), %rdx
movq %r12, %rdi
callq 0x3110
movq %r12, %rdi
movq %r15, %rsi
callq 0x3690
leaq 0x12cf(%rip), %rsi      # 0x7189
leaq -0x50(%rbp), %rdi
callq 0x3690
movq 0x40fe(%rip), %r12      # 0x9fc8
movq (%r12), %r15
leaq -0x50(%rbp), %rax
movq (%rax), %r13
movq (%r14), %r14
callq 0x3520
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
movl %eax, %ecx
movq %rbx, %r8
xorl %eax, %eax
callq 0x34f0
movq (%r12), %rdi
callq 0x3400
leaq -0x50(%rbp), %rdi
callq 0x3160
jmp 0x5e79
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3160
movq %rbx, %rdi
callq 0x3600
nop
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/common/blockmem.cpp
// Function: FreeBlock(void*)
bool            FreeBlock(void* pointer)
{
    if (!pointer)
    {
        Warning("Freeing a null pointer");
    }
    free(pointer);
    return true;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
testq %rdi, %rdi
jne 0x4836
leaq 0x147f4(%rip), %rdi     # 0x19023
xorl %eax, %eax
callq 0x90f1
movq %rbx, %rdi
callq 0x43b0
movb $0x1, %al
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/common/bspfile.cpp
// Function: CompressVis(unsigned char const*, unsigned int, unsigned char*, unsigned int)
int             CompressVis(const byte* const src, const unsigned int src_length, byte* dest, unsigned int dest_length)
{
    unsigned int    j;
    byte*           dest_p = dest;
    unsigned int    current_length = 0;

    for (j = 0; j < src_length; j++)
    {
        current_length++;
        hlassume(current_length <= dest_length, assume_COMPRESSVIS_OVERFLOW);

        *dest_p = src[j];
        dest_p++;

        if (src[j])
        {
            continue;
        }

        unsigned char   rep = 1;

        for (j++; j < src_length; j++)
        {
            if (src[j] || rep == 255)
            {
                break;
            }
            else
            {
                rep++;
            }
        }
        current_length++;
        hlassume(current_length <= dest_length, assume_COMPRESSVIS_OVERFLOW);

        *dest_p = rep;
        dest_p++;
        j--;
    }

    return dest_p - dest;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, (%rsp)
movq %rdx, %r12
movq %rdi, %r15
movl %esi, %ebx
movq %rsi, 0x8(%rsp)
leal -0x1(%rsi), %eax
movl %eax, 0x4(%rsp)
xorl %r13d, %r13d
movq %rdx, 0x10(%rsp)
xorl %ebp, %ebp
cmpl 0x8(%rsp), %r13d
jae 0x4923
leal 0x1(%rbp), %r14d
xorl %edi, %edi
cmpl (%rsp), %r14d
setbe %dil
pushq $0x33
popq %rsi
callq 0x9517
movl %r13d, %ecx
movb (%r15,%rcx), %al
movb %al, (%r12)
testb %al, %al
je 0x48b8
incq %r12
jmp 0x4918
movq 0x8(%rsp), %rax
subb %r13b, %al
incq %rcx
movb $0x1, %r14b
movq %rcx, %r13
cmpq %rbx, %r13
jae 0x48e9
movl %r14d, %ecx
incb %cl
sete %dl
cmpb $0x0, (%r15,%r13)
jne 0x48f5
testb %dl, %dl
jne 0x48f5
incq %r13
movl %ecx, %r14d
jmp 0x48c9
movl 0x4(%rsp), %ecx
movl %ecx, %r13d
movl %eax, %r14d
jmp 0x48f8
decl %r13d
addl $0x2, %ebp
xorl %edi, %edi
cmpl (%rsp), %ebp
setbe %dil
pushq $0x33
popq %rsi
callq 0x9517
movb %r14b, 0x1(%r12)
addq $0x2, %r12
movl %ebp, %r14d
incl %r13d
movl %r14d, %ebp
jmp 0x4883
subl 0x10(%rsp), %r12d
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/common/bspfile.cpp
// Function: DecompressVis(unsigned char const*, unsigned char*, unsigned int)
void            DecompressVis(const byte* src, byte* const dest, const unsigned int dest_length)
{
    unsigned int    current_length = 0;
    int             c;
    byte*           out;
    int             row;

#ifdef ZHLT_DecompressVis_FIX
	row = (g_dmodels[0].visleafs + 7) >> 3; // same as the length used by VIS program in CompressVis
	// The wrong size will cause DecompressVis to spend extremely long time once the source pointer runs into the invalid area in g_dvisdata (for example, in BuildFaceLights, some faces could hang for a few seconds), and sometimes to crash.
#else
    row = (g_numleafs + 7) >> 3;
#endif
    out = dest;

    do
    {
#ifdef ZHLT_DecompressVis_FIX
		hlassume (src - g_dvisdata < g_visdatasize, assume_DECOMPRESSVIS_OVERFLOW);
#endif
        if (*src)
        {
            current_length++;
            hlassume(current_length <= dest_length, assume_DECOMPRESSVIS_OVERFLOW);

            *out = *src;
            out++;
            src++;
            continue;
        }
		
#ifdef ZHLT_DecompressVis_FIX
		hlassume (&src[1] - g_dvisdata < g_visdatasize, assume_DECOMPRESSVIS_OVERFLOW);
#endif
        c = src[1];
        src += 2;
        while (c)
        {
            current_length++;
            hlassume(current_length <= dest_length, assume_DECOMPRESSVIS_OVERFLOW);

            *out = 0;
            out++;
            c--;

            if (out - dest >= row)
            {
                return;
            }
        }
    }
    while (out - dest < row);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
movl 0x22b7c(%rip), %eax     # 0x274d4
addl $0x7, %eax
sarl $0x3, %eax
movslq %eax, %r12
movq %rsi, %rax
negq %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
leaq 0x2ab3a(%rip), %rax     # 0x2f4b0
negq %rax
movq %rax, 0x10(%rsp)
movq %rsi, 0x20(%rsp)
movq 0x8(%rsp), %r15
movq %r15, %rax
leaq 0x2ab1e(%rip), %rcx     # 0x2f4b0
subq %rcx, %rax
movslq 0x2ab08(%rip), %rcx     # 0x2f4a4
xorl %edi, %edi
cmpq %rcx, %rax
setl %dil
pushq $0x34
popq %rbp
movl %ebp, %esi
callq 0x9517
cmpb $0x0, (%r15)
je 0x49e8
incl %r13d
xorl %edi, %edi
cmpl %ebx, %r13d
setbe %dil
movl %ebp, %esi
callq 0x9517
movb (%r15), %al
movb %al, (%r14)
incq %r14
incq %r15
movq %r15, 0x8(%rsp)
movq %r14, %rax
subq 0x20(%rsp), %rax
cmpq %r12, %rax
jl 0x4983
jmp 0x4a49
movq 0x10(%rsp), %rax
addq %r15, %rax
incq %rax
movslq 0x2aaaa(%rip), %rcx     # 0x2f4a4
xorl %edi, %edi
cmpq %rcx, %rax
setl %dil
movl %ebp, %esi
callq 0x9517
movzbl 0x1(%r15), %ebp
addq $0x2, %r15
movq %r15, 0x8(%rsp)
movq 0x18(%rsp), %rax
leaq (%rax,%r14), %r15
subl $0x1, %ebp
jb 0x49d9
incl %r13d
xorl %edi, %edi
cmpl %ebx, %r13d
setbe %dil
pushq $0x34
popq %rsi
callq 0x9517
movb $0x0, (%r14)
incq %r14
incq %r15
cmpq %r12, %r15
jl 0x4a21
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/common/bspfile.cpp
// Function: CopyLump(int, void*, int, dheader_t const*)
static int      CopyLump(int lump, void* dest, int size, const dheader_t* const header)
{
    int             length, ofs;

    length = header->lumps[lump].filelen;
    ofs = header->lumps[lump].fileofs;

    if (length % size)
    {
        Error("LoadBSPFile: odd lump size");
    }
	
	//special handling for tex and lightdata to keep things from exploding - KGP
	if(lump == LUMP_TEXTURES && dest == (void*)g_dtexdata)
	{ hlassume(g_max_map_miptex > length,assume_MAX_MAP_MIPTEX); }
	else if(lump == LUMP_LIGHTING && dest == (void*)g_dlightdata)
	{ hlassume(g_max_map_lightdata > length,assume_MAX_MAP_LIGHTING); }

    memcpy(dest, (byte*) header + ofs, length);

    return length / size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movl %edx, %ecx
movq %rsi, %r14
movl %edi, %r12d
movl %edi, %eax
movslq 0x8(%rbx,%rax,8), %r15
movslq 0x4(%rbx,%rax,8), %r13
movl %r15d, %eax
cltd
idivl %ecx
movl %eax, %ebp
testl %edx, %edx
je 0x4e43
leaq 0x148e2(%rip), %rdi     # 0x1971e
xorl %eax, %eax
callq 0x8d7b
cmpl $0x2, %r12d
jne 0x4e5e
cmpq %r14, 0x82a678(%rip)    # 0x82f4c8
jne 0x4e5e
pushq $0x25
popq %rsi
leaq 0x214e4(%rip), %rax     # 0x26340
jmp 0x4e77
cmpl $0x8, %r12d
jne 0x4e85
cmpq %r14, 0x82a64d(%rip)    # 0x82f4b8
jne 0x4e85
pushq $0x38
popq %rsi
leaq 0x214cd(%rip), %rax     # 0x26344
xorl %edi, %edi
cmpl %r15d, (%rax)
setg %dil
callq 0x9517
addq %r13, %rbx
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4280
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/common/bspfile.cpp
// Function: CalculatePointVecsProduct(float const volatile*, float const volatile*)
float CalculatePointVecsProduct (const volatile float *point, const volatile float *vecs)
{
	volatile double val;
	volatile double tmp;

	val = (double)point[0] * (double)vecs[0]; // always do one operation at a time and save to memory
	tmp = (double)point[1] * (double)vecs[1];
	val = val + tmp;
	tmp = (double)point[2] * (double)vecs[2];
	val = val + tmp;
	val = val + (double)vecs[3];

	return (float)val;
}

// Assembly:
cvtss2sd (%rdi), %xmm0
cvtss2sd (%rsi), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x10(%rsp)
cvtss2sd 0x4(%rdi), %xmm0
cvtss2sd 0x4(%rsi), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x8(%rsp)
movsd -0x10(%rsp), %xmm0
addsd -0x8(%rsp), %xmm0
movsd %xmm0, -0x10(%rsp)
cvtss2sd 0x8(%rdi), %xmm0
cvtss2sd 0x8(%rsi), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x8(%rsp)
movsd -0x10(%rsp), %xmm0
addsd -0x8(%rsp), %xmm0
movsd %xmm0, -0x10(%rsp)
movsd -0x10(%rsp), %xmm0
cvtss2sd 0xc(%rsi), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x10(%rsp)
cvtsd2ss -0x10(%rsp), %xmm0
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/common/bspfile.cpp
// Function: CalcFaceExtents_test()
bool CalcFaceExtents_test ()
{
	const int numtestcases = 6;
	volatile float testcases[numtestcases][8] = {
		{1, 1, 1, 1, 0.375 * DBL_EPSILON, 0.375 * DBL_EPSILON, -1, 0},
		{1, 1, 1, 0.375 * DBL_EPSILON, 0.375 * DBL_EPSILON, 1, -1, DBL_EPSILON},
		{DBL_EPSILON, DBL_EPSILON, 1, 0.375, 0.375, 1, -1, DBL_EPSILON},
		{1, 1, 1, 1, 1, 0.375 * FLT_EPSILON, -2, 0.375 * FLT_EPSILON},
		{1, 1, 1, 1, 0.375 * FLT_EPSILON, 1, -2, 0.375 * FLT_EPSILON},
		{1, 1, 1, 0.375 * FLT_EPSILON, 1, 1, -2, 0.375 * FLT_EPSILON}};
	bool ok;

	// If the test failed, please check:
	//   1. whether the calculation is performed on FPU
	//   2. whether the register precision is too low
		
	CorrectFPUPrecision ();

	ok = true;
	for (int i = 0; i < 6; i++)
	{
		float val = CalculatePointVecsProduct (&testcases[i][0], &testcases[i][3]);
		if (val != testcases[i][7])
		{
			Warning ("internal error: CalcFaceExtents_test failed on case %d (%.20f != %.20f).", i, val, testcases[i][7]);
			ok = false;
		}
	}
	return ok;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xc8, %rsp
leaq 0x140ef(%rip), %rsi     # 0x19790
movq %rsp, %rbx
movl $0xc0, %edx
movq %rbx, %rdi
callq 0x4280
movb $0x1, %bpl
xorl %r14d, %r14d
leaq 0x13a04(%rip), %r15     # 0x190c2
cmpq $0x6, %r14
je 0x56f9
leaq 0xc(%rbx), %rsi
movq %rbx, %rdi
callq 0x5613
ucomiss 0x1c(%rbx), %xmm0
jne 0x56d8
jnp 0x56f0
cvtss2sd %xmm0, %xmm0
cvtss2sd 0x1c(%rbx), %xmm1
movq %r15, %rdi
movl %r14d, %esi
movb $0x2, %al
callq 0x90f1
xorl %ebp, %ebp
incq %r14
addq $0x20, %rbx
jmp 0x56be
andb $0x1, %bpl
movl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/common/bspfile.cpp
// Function: WriteExtentFile(char const*)
void WriteExtentFile (const char *const filename)
{
	FILE *f;
	f = fopen (filename, "w");
	if (!f)
	{
		Error ("Error opening %s: %s", filename, strerror(errno));
	}
	fprintf (f, "%i\n", g_numfaces);
	for (int i = 0; i < g_numfaces; i++)
	{
		int mins[2];
		int maxs[2];
		GetFaceExtents (i, mins, maxs);
		fprintf (f, "%i %i %i %i\n", mins[0], mins[1], maxs[0], maxs[1]);
	}
	fclose (f);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r14
leaq 0x18d6f(%rip), %rsi     # 0x1e641
callq 0x43a0
movq %rax, %rbx
testq %rax, %rax
jne 0x58ff
callq 0x4060
movl (%rax), %edi
callq 0x4140
leaq 0x13819(%rip), %rdi     # 0x1910b
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x8d7b
movl 0x1b89b1f(%rip), %edx   # 0x1b8f424
leaq 0x1672c(%rip), %rsi     # 0x1c038
movq %rbx, %rdi
xorl %eax, %eax
callq 0x44a0
leaq 0x8(%rsp), %r14
movq %rsp, %r15
leaq 0x137fb(%rip), %r12     # 0x19120
xorl %ebp, %ebp
cmpl 0x1b89af7(%rip), %ebp   # 0x1b8f424
jge 0x595e
movl %ebp, %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x570d
movl 0x8(%rsp), %edx
movl 0xc(%rsp), %ecx
movl (%rsp), %r8d
movl 0x4(%rsp), %r9d
movq %rbx, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x44a0
incl %ebp
jmp 0x5927
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x4300
// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]vhlt/common/bspfile.cpp
// Function: DoAllocBlock(lightmapblock_s*, int, int)
void DoAllocBlock (lightmapblock_t *blocks, int w, int h)
{
	lightmapblock_t *block;
	// code from Quake
	int i, j;
	int best, best2;
	int x, y;
	if (w < 1 || h < 1)
	{
		Error ("DoAllocBlock: internal error.");
	}
	for (block = blocks; block; block = block->next)
	{
		best = BLOCK_HEIGHT;
		for (i = 0; i < BLOCK_WIDTH - w; i++)
		{
			best2 = 0;
			for (j = 0; j < w; j++)
			{
				if (block->allocated[i + j] >= best)
					break;
				if (block->allocated[i + j] > best2)
					best2 = block->allocated[i + j];
			}
			if (j == w)
			{
				x = i;
				y = best = best2;
			}
		}
		if (best + h <= BLOCK_HEIGHT)
		{
			block->used = true;
			for (i = 0; i < w; i++)
			{
				block->allocated[x + i] = best + h;
			}
			return;
		}
		if (!block->next)
		{ // need to allocate a new block
			if (!block->used)
			{
				Warning ("CountBlocks: invalid extents %dx%d", w, h);
				return;
			}
			block->next = (lightmapblock_t *)malloc (sizeof (lightmapblock_t));
			hlassume (block->next != NULL, assume_NoMemory);
			memset (block->next, 0, sizeof (lightmapblock_t));
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
testl %esi, %esi
setg %al
testl %edx, %edx
setg %cl
testb %cl, %al
movl %edx, 0x4(%rsp)
jne 0x59a6
leaq 0x13792(%rip), %rdi     # 0x1912d
xorl %eax, %eax
callq 0x8d7b
movl 0x4(%rsp), %edx
movl $0x80, %r12d
subl %ebp, %r12d
xorl %eax, %eax
testl %ebp, %ebp
movl $0x0, %r13d
cmovgl %ebp, %r13d
testl %r12d, %r12d
cmovlel %eax, %r12d
testq %rbx, %rbx
je 0x5a87
movq %rbx, %r15
leaq 0xc(%rbx), %rcx
movl $0x80, %eax
xorl %r9d, %r9d
cmpq %r12, %r9
je 0x5a14
xorl %edi, %edi
xorl %esi, %esi
cmpq %rdi, %r13
je 0x59ff
movl (%rcx,%rdi,4), %r8d
cmpl %eax, %r8d
jge 0x5a02
cmpl %esi, %r8d
cmovgl %r8d, %esi
incq %rdi
jmp 0x59e5
movl %r13d, %edi
cmpl %ebp, %edi
cmovel %esi, %eax
cmovel %r9d, %r14d
incq %r9
addq $0x4, %rcx
jmp 0x59dc
addl %edx, %eax
cmpl $0x80, %eax
jle 0x5a65
movq (%r15), %rbx
testq %rbx, %rbx
jne 0x59c4
cmpb $0x0, 0x8(%r15)
je 0x5a96
movl $0x210, %edi            # imm = 0x210
callq 0x4450
movq %rax, (%r15)
xorl %edi, %edi
testq %rax, %rax
setne %dil
pushq $0x1
popq %rsi
callq 0x9517
movq (%r15), %rdi
movl $0x210, %edx            # imm = 0x210
xorl %esi, %esi
callq 0x41e0
movl 0x4(%rsp), %edx
movq (%r15), %rbx
jmp 0x59c4
movb $0x1, 0x8(%r15)
movslq %r14d, %rdx
movl %r13d, %ecx
leaq (%r15,%rdx,4), %rdx
addq $0xc, %rdx
xorl %esi, %esi
cmpq %rsi, %rcx
je 0x5a87
movl %eax, (%rdx,%rsi,4)
incq %rsi
jmp 0x5a7a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x136ae(%rip), %rdi     # 0x1914b
movl %ebp, %esi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x90f1