LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/library.cpp
// Function: NetSocket::recvData(unsigned int)
char* NetSocket::recvData(uint32_t len){

	char *buffer = new char[len];
	if(buffer == NULL)
		return NULL;

	if(utilityRecv(buffer,len))
		return buffer;
	else
		return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movl %esi, %edi
callq 0x4030
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
movl %ebx, %edx
callq 0x661c
xorl %ecx, %ecx
testb %al, %al
cmovneq %r15, %rcx
movq %rcx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/library.cpp
// Function: NetSocket::recvInt(int&)
bool NetSocket::recvInt(int &val){

	int ret,tmp;

	ret = recvfrom(this->socket,&tmp,sizeof(uint32_t),0,NULL,0);
	if(ret < (int)sizeof(uint32_t)){
		perror("[Error] recv");
		return 0;
	}

	val = ntohl(tmp);

	return (ret == (int)sizeof(uint32_t));

}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movl (%rdi), %edi
leaq 0xc(%rsp), %rsi
pushq $0x4
popq %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x4350
cmpl $0x3, %eax
jle 0x66e4
movl 0xc(%rsp), %ecx
bswapl %ecx
movl %ecx, (%rbx)
cmpl $0x4, %eax
sete %al
addq $0x10, %rsp
popq %rbx
retq
leaq 0x3d85(%rip), %rdi      # 0xa470
callq 0x43a0
xorl %eax, %eax
jmp 0x66de
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/library.cpp
// Function: get_file_list[abi:cxx11](char const*)
vector<string> get_file_list(const char* path){

	DIR* folder = opendir(path);
	struct dirent* dp;
	vector <string> result;

	while( (dp = readdir(folder)) != NULL){						//WARNING SICUREZZA
		char *filename = dp->d_name;
		if(filename[0] == '.')
			continue;
		result.push_back(filename);
	}

	closedir(folder);
	return result;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x46b0
movq %rax, %r14
andq $0x0, 0x10(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
leaq 0x8(%rsp), %r15
leaq 0x7(%rsp), %r12
movq %r14, %rdi
callq 0x46c0
testq %rax, %rax
je 0x675c
cmpb $0x2e, 0x13(%rax)
je 0x6722
addq $0x13, %rax
movq %r15, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x639e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6c6e
movq %r15, %rdi
callq 0x41b0
jmp 0x6722
movq %r14, %rdi
callq 0x4710
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x6784
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x41b0
jmp 0x6787
movq %rax, %r14
movq %rbx, %rdi
callq 0x63da
movq %r14, %rdi
callq 0x47a0
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/library.cpp
// Function: split(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
vector<string> split (string s, string delimiter) {
    size_t pos_start = 0, pos_end, delim_len = delimiter.length();
    string token;
    vector<string> res;

    while ((pos_end = s.find (delimiter, pos_start)) != string::npos) {
        token = s.substr (pos_start, pos_end - pos_start);
        pos_start = pos_end + delim_len;
        res.push_back (token);
    }

    res.push_back (s.substr (pos_start));
    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq 0x8(%rdx), %rax
movq %rax, 0x10(%rsp)
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
andq $0x0, 0x10(%rdi)
movq %rdi, 0x8(%rsp)
movups %xmm0, (%rdi)
xorl %ebx, %ebx
leaq 0x18(%rsp), %r12
leaq 0x38(%rsp), %r13
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x48b0
cmpq $-0x1, %rax
je 0x6836
movq %rax, %rbp
movq %rax, %rcx
subq %rbx, %rcx
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x4440
movq %r13, %rdi
movq %r12, %rsi
callq 0x4550
movq %r12, %rdi
callq 0x41b0
addq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x6c42
movq %rbp, %rbx
jmp 0x67e1
leaq 0x18(%rsp), %rdi
pushq $-0x1
popq %rcx
movq %r14, %rsi
movq %rbx, %rdx
callq 0x4440
leaq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x6c6e
leaq 0x18(%rsp), %rdi
callq 0x41b0
leaq 0x38(%rsp), %rdi
callq 0x41b0
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x41b0
jmp 0x6897
jmp 0x6894
jmp 0x6894
movq %rax, %r14
movq 0x8(%rsp), %rdi
callq 0x63da
leaq 0x38(%rsp), %rdi
callq 0x41b0
movq %r14, %rdi
callq 0x47a0
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/library.cpp
// Function: sendIntHMAC(NetSocket&, int)
bool sendIntHMAC(NetSocket& sender_socket,int32_t value){

	if(!sender_socket.sendInt(value))
		return false;

	HMACManager hm;

	Chunk c;
	c.setPlainText((char*)&value,false);
	c.size = sizeof(uint32_t);
	hm.HMACUpdate(c);

	char *digest = hm.HMACFinal(LOCAL_NONCE);

	if(digest == NULL) return false;
	bool return_value;

	return_value = sender_socket.sendData(digest,HASH_SIZE);

	delete[] digest;

	return return_value;

}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movl %esi, 0xc(%rsp)
callq 0x6574
testb %al, %al
je 0x692d
movq %rsp, %rdi
callq 0x7888
leaq 0x10(%rsp), %rdi
callq 0x93ac
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rsi
xorl %edx, %edx
callq 0x9402
leaq 0x10(%rsp), %rsi
movl $0x4, 0x10(%rsi)
movq %rsp, %rdi
callq 0x7930
movq %rsp, %rdi
xorl %esi, %esi
callq 0x799a
movq %rax, %r14
testq %rax, %rax
je 0x6931
pushq $0x20
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x65c2
movl %eax, %ebx
movq %r14, %rdi
callq 0x45a0
jmp 0x6933
xorl %ebx, %ebx
jmp 0x6945
xorl %ebx, %ebx
leaq 0x10(%rsp), %rdi
callq 0x93ba
movq %rsp, %rdi
callq 0x7a66
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
retq
jmp 0x6958
jmp 0x6958
movq %rax, %rbx
jmp 0x6965
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x93ba
movq %rsp, %rdi
callq 0x7a66
movq %rbx, %rdi
callq 0x47a0
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/library.cpp
// Function: recvIntHMAC(NetSocket&, int&)
bool recvIntHMAC(NetSocket& receiver_socket,int32_t& value){

	if(!receiver_socket.recvInt(value))
		return false;

	char *received_digest = receiver_socket.recvData(HASH_SIZE);
	if(received_digest == NULL)
		return false;


	HMACManager hm;
	Chunk c;
	c.size = sizeof(uint32_t);
	c.setPlainText((char*)&value,false);

	hm.HMACUpdate(c);
	char *digest = hm.HMACFinal(REMOTE_NONCE);

	if(digest == NULL){
		return false;
	}

	bool result;

	if(CRYPTO_memcmp(received_digest,digest,HASH_SIZE)){
		cout<<"HASH DIVERSI"<<endl;
		cout<<"Ricevuto:"<<endl;
		//close connection
		result = false;
	} else {
		result = true;
	}

	delete[] digest;
	delete[] received_digest;
	return result;

}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x66ac
testb %al, %al
je 0x6a4d
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0x667a
testq %rax, %rax
je 0x6a4d
movq %rax, %rbx
movq %rsp, %rdi
callq 0x7888
leaq 0x8(%rsp), %rdi
callq 0x93ac
leaq 0x8(%rsp), %rdi
movl $0x4, 0x10(%rdi)
movq %r14, %rsi
xorl %edx, %edx
callq 0x9402
movq %rsp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x7930
movq %rsp, %rdi
pushq $0x1
popq %rsi
callq 0x799a
movq %rax, %r14
testq %rax, %rax
je 0x6a51
pushq $0x20
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x47b0
testl %eax, %eax
sete %bpl
je 0x6a3b
movq 0x85bc(%rip), %rdi      # 0xefc8
leaq 0x3a6a(%rip), %rsi      # 0xa47d
callq 0x4400
movq %rax, %rdi
callq 0x41d0
movq 0x85a1(%rip), %rdi      # 0xefc8
leaq 0x3a5c(%rip), %rsi      # 0xa48a
callq 0x4400
movq %rax, %rdi
callq 0x41d0
movq %r14, %rdi
callq 0x45a0
movq %rbx, %rdi
callq 0x45a0
jmp 0x6a53
xorl %ebp, %ebp
jmp 0x6a65
xorl %ebp, %ebp
leaq 0x8(%rsp), %rdi
callq 0x93ba
movq %rsp, %rdi
callq 0x7a66
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
jmp 0x6a79
movq %rax, %rbx
jmp 0x6a86
jmp 0x6a79
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x93ba
movq %rsp, %rdi
callq 0x7a66
movq %rbx, %rdi
callq 0x47a0
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/library.cpp
// Function: sendDataHMAC(NetSocket&, char const*, int)
bool sendDataHMAC(NetSocket& sender_socket,const char *data,int32_t length){

	if(!sendIntHMAC(sender_socket,length+HASH_SIZE))
		return false;

	if(!sender_socket.sendData(data,length)){
		return false;
	}

	HMACManager hmac;

	if(!hmac.HMACUpdate(data,length)) return false;

	char *digest = hmac.HMACFinal(LOCAL_NONCE);

	bool ret = sender_socket.sendData(digest,HASH_SIZE);

	delete[] digest;
	return ret;

}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
leal 0x20(%r14), %esi
callq 0x68b3
testb %al, %al
je 0x6b0f
movq %rbx, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x65c2
testb %al, %al
je 0x6b0f
movq %rsp, %r12
movq %r12, %rdi
callq 0x7888
movq %r12, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x7972
testb %al, %al
je 0x6b13
movq %rsp, %rdi
xorl %esi, %esi
callq 0x799a
movq %rax, %r14
pushq $0x20
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x65c2
movl %eax, %ebx
testq %r14, %r14
je 0x6b15
movq %r14, %rdi
callq 0x45a0
jmp 0x6b15
xorl %ebx, %ebx
jmp 0x6b1d
xorl %ebx, %ebx
movq %rsp, %rdi
callq 0x7a66
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x6b2f
jmp 0x6b2f
movq %rax, %rbx
movq %rsp, %rdi
callq 0x7a66
movq %rbx, %rdi
callq 0x47a0
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/library.cpp
// Function: recvDataHMAC(NetSocket&, int&)
char* recvDataHMAC(NetSocket& receiver_socket,int32_t &length){

	if(!recvIntHMAC(receiver_socket,length))
		return false;

	length -= HASH_SIZE;

	char *data = receiver_socket.recvData(length);

	HMACManager hmac;
	if(!hmac.HMACUpdate(data,length)) return NULL;

	char *digest = hmac.HMACFinal(REMOTE_NONCE);

	if(digest == NULL) return NULL;

	char *received_digest = receiver_socket.recvData(HASH_SIZE);

	if(received_digest == NULL){
		delete[] digest;
		return NULL;
	}

	if(CRYPTO_memcmp(received_digest,digest,HASH_SIZE)){
		cout<<"HASH DIVERSI"<<endl;
		delete[] digest;
		delete[] received_digest;
		return NULL;
	}

	delete[] digest;
	delete[] received_digest;
	return data;


}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
callq 0x6975
testb %al, %al
je 0x6bed
movl (%r14), %esi
addl $-0x20, %esi
movl %esi, (%r14)
movq %r15, %rdi
callq 0x667a
movq %rax, %rbx
movq %rsp, %r12
movq %r12, %rdi
callq 0x7888
movl (%r14), %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x7972
testb %al, %al
je 0x6bf1
movq %rsp, %rdi
pushq $0x1
popq %rsi
callq 0x799a
movq %rax, %r14
testq %rax, %rax
je 0x6bf1
pushq $0x20
popq %rsi
movq %r15, %rdi
callq 0x667a
movq %rax, %r15
testq %rax, %rax
je 0x6bf5
pushq $0x20
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x47b0
testl %eax, %eax
je 0x6be3
movq 0x83fb(%rip), %rdi      # 0xefc8
leaq 0x38a9(%rip), %rsi      # 0xa47d
callq 0x4400
movq %rax, %rdi
callq 0x41d0
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x45a0
jmp 0x6bfa
xorl %ebx, %ebx
jmp 0x6c0a
xorl %ebx, %ebx
jmp 0x6c02
xorl %ebx, %ebx
movq %r14, %r15
movq %r15, %rdi
callq 0x45a0
movq %rsp, %rdi
callq 0x7a66
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x6c1d
jmp 0x6c1d
movq %rax, %rbx
movq %rsp, %rdi
callq 0x7a66
movq %rbx, %rdi
callq 0x47a0
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/WriteFileManager.cpp
// Function: WriteFileManager::WriteFileManager(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, unsigned long)
WriteFileManager::WriteFileManager(string &name, uint64_t size) : FileManager(name,size){
	if(file_exists()){
		original_file_name = file_name;
		string tmp(".tmp");
		string new_name = file_name + tmp;
		changeName(new_name);
	} else{
		original_file_name = "";
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
callq 0x6f40
leaq 0x7c88(%rip), %rax      # 0xed48
movq %rax, (%rbx)
leaq 0x248(%rbx), %r14
leaq 0x258(%rbx), %rax
movq %rax, 0x248(%rbx)
andq $0x0, 0x250(%rbx)
movb $0x0, 0x258(%rbx)
movq %rbx, %rdi
callq 0x6ff6
testb %al, %al
je 0x7145
leaq 0x8(%rbx), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x4210
leaq 0x33b3(%rip), %rsi      # 0xa4bc
leaq 0x20(%rsp), %rdi
movq %rsp, %rdx
callq 0x639e
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
movq %r15, %rsi
callq 0x63fb
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x706c
movq %rsp, %rdi
callq 0x41b0
leaq 0x20(%rsp), %rdi
callq 0x41b0
jmp 0x7154
leaq 0x3126(%rip), %rsi      # 0xa272
movq %r14, %rdi
callq 0x4860
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %r15
movq %rsp, %rdi
callq 0x41b0
jmp 0x716e
movq %rax, %r15
leaq 0x20(%rsp), %rdi
callq 0x41b0
jmp 0x717f
jmp 0x717c
movq %rax, %r15
movq %r14, %rdi
callq 0x41b0
movq %rbx, %rdi
callq 0x7076
movq %r15, %rdi
callq 0x47a0
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/WriteFileManager.cpp
// Function: WriteFileManager::openStream()
bool WriteFileManager::openStream(){
	if(!fs.is_open()){
		fs.open(file_name, fstream::out | fstream::app | fstream::binary);
		if(fs.fail()){ 
			cout << "[LOG] file can't open" << endl;
			return false;
		}
	}
	return true;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
addq $0xa8, %rdi
callq 0x40c0
movb $0x1, %bl
testb %al, %al
jne 0x7200
leaq 0x28(%r14), %rdi
leaq 0x8(%r14), %rsi
pushq $0x15
popq %rdx
callq 0x4630
movq 0x28(%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x48(%r14,%rax)
je 0x7200
movq 0x7dde(%rip), %rdi      # 0xefc8
leaq 0x32d0(%rip), %rsi      # 0xa4c1
callq 0x4400
movq %rax, %rdi
callq 0x41d0
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/WriteFileManager.cpp
// Function: WriteFileManager::write(Chunk&)
file_status WriteFileManager::write(Chunk& c){ //write in append
	if(!openStream()){ // Check if stream its open
		return FILE_ERROR;
	}
	fs.write(c.getPlainText(), c.size); // Write new block in to the file
	if(!fs){
		return FILE_ERROR;
	}

	remaining_size -= c.size;
	closeStream();
	if(remaining_size <= 0){
		return END_OF_FILE;
	}
	return NO_ERRORS; // All good
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rax
callq *(%rax)
pushq $0x2
popq %rbp
testb %al, %al
je 0x7270
leaq 0x38(%rbx), %r15
movq %r14, %rdi
callq 0x9422
movslq 0x10(%r14), %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x45e0
movq 0x28(%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x48(%rbx,%rax)
jne 0x7270
movslq 0x10(%r14), %rax
subq %rax, 0x240(%rbx)
movq %rbx, %rdi
callq 0x6fc0
xorl %eax, %eax
cmpq $0x0, 0x240(%rbx)
sete %al
leal (%rax,%rax,2), %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/WriteFileManager.cpp
// Function: WriteFileManager::finalize(bool)
void WriteFileManager::finalize(bool error){
	if(error || remaining_size > 0){ // after error, remove file
		remove((const char*)file_name.c_str());
		return;
	}
	if(original_file_name != ""){ // end of write, substitute previous file with tmp
		remove((const char*)original_file_name.c_str());
		rename((const char*)file_name.c_str(),(const char*)original_file_name.c_str());
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
testl %esi, %esi
jne 0x72c4
cmpq $0x0, 0x240(%rbx)
jne 0x72c4
leaq 0x248(%rbx), %rdi
leaq 0x2fd4(%rip), %rsi      # 0xa272
callq 0x6433
testb %al, %al
je 0x72ce
movq 0x248(%rbx), %rdi
callq 0x47e0
movq 0x8(%rbx), %rdi
movq 0x248(%rbx), %rsi
popq %rbx
jmp 0x4240
movq 0x8(%rbx), %rdi
popq %rbx
jmp 0x47e0
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/ReadFileManager.cpp
// Function: ReadFileManager::compute_size_file()
uint64_t ReadFileManager::compute_size_file(){
	fs.open(file_name, fstream::in | fstream::binary);
	if(fs.fail()){ 
		cout << "LOG: file can't open" << endl;
		return false;
	}	
	fs.seekg (0,fs.end);
	uint64_t length = fs.tellg(); 
	fs.close();
	return length;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x28(%rdi), %rbx
leaq 0x8(%rdi), %rsi
pushq $0xc
popq %rdx
movq %rbx, %rdi
callq 0x4630
movq 0x28(%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x48(%r14,%rax)
je 0x7364
movq 0x7c7d(%rip), %rdi      # 0xefc8
leaq 0x3198(%rip), %rsi      # 0xa4ea
callq 0x4400
movq %rax, %rdi
callq 0x41d0
xorl %r14d, %r14d
jmp 0x7384
pushq $0x2
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4610
movq %rbx, %rdi
callq 0x4780
movq %rax, %r14
movq %rbx, %rdi
callq 0x4060
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/ReadFileManager.cpp
// Function: ReadFileManager::openStream()
bool ReadFileManager::openStream(){
	if(!fs.is_open()){
		fs.open(file_name, fstream::in | fstream::binary);
		if(fs.fail()){ 
			cout << "LOG: file can't open" << endl;
			return false;
		}
	}
	return true;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
addq $0xa8, %rdi
callq 0x40c0
movb $0x1, %bl
testb %al, %al
jne 0x73f8
leaq 0x28(%r14), %rdi
leaq 0x8(%r14), %rsi
pushq $0xc
popq %rdx
callq 0x4630
movq 0x28(%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x48(%r14,%rax)
je 0x73f8
movq 0x7be6(%rip), %rdi      # 0xefc8
leaq 0x3101(%rip), %rsi      # 0xa4ea
callq 0x4400
movq %rax, %rdi
callq 0x41d0
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/ReadFileManager.cpp
// Function: ReadFileManager::read(Chunk&)
file_status ReadFileManager::read(Chunk &c){ 	

	if(!openStream()){
		return FILE_ERROR;
	}	
	uint64_t chunk_address = file_size - remaining_size; //secure, only internal modify
	uint64_t size; // curent chunk size
	if(remaining_size >= MAX_CHUNK_SIZE){
		size = MAX_CHUNK_SIZE;
	} else{
		size = remaining_size; //if last chunk have lower size
	}
	c.size = size;
	fs.seekg(chunk_address); // Set position on disk in input stream
	c.setPlainText(new char[size]);

	fs.read(c.getPlainText(), size);
	if(!fs){
		return FILE_ERROR;
	}

	remaining_size -= c.size;

	closeStream();
	
	if(remaining_size <= 0){
		return END_OF_FILE;
	}
	return NO_ERRORS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rax
callq *(%rax)
pushq $0x2
popq %rbp
testb %al, %al
je 0x74ab
movq 0x238(%rbx), %rsi
movq 0x240(%rbx), %rax
subq %rax, %rsi
movl $0x40000, %r15d         # imm = 0x40000
cmpq %r15, %rax
cmovbq %rax, %r15
movl %r15d, 0x10(%r14)
leaq 0x28(%rbx), %r12
movq %r12, %rdi
xorl %edx, %edx
callq 0x4580
movq %r15, %rdi
callq 0x4030
movq %r14, %rdi
movq %rax, %rsi
callq 0x93e2
movq %r14, %rdi
callq 0x9422
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x4570
movq 0x28(%rbx), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x48(%rbx,%rax)
jne 0x74ab
movslq 0x10(%r14), %rax
subq %rax, 0x240(%rbx)
movq %rbx, %rdi
callq 0x6fc0
xorl %eax, %eax
cmpq $0x0, 0x240(%rbx)
sete %al
leal (%rax,%rax,2), %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/EncryptManager.cpp
// Function: EncryptManager::EncryptManager()
EncryptManager::EncryptManager(){

  	this->ctx = EVP_CIPHER_CTX_new();
  	if(!EVP_EncryptInit(ctx, EVP_aes_128_cbc(), this->key, this->IV)){
  		perror("Error In EVP_EncryptInit");
  	}

	incrementIV();

}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x4270
movq %rax, %r14
movq %rax, (%rbx)
callq 0x4220
leaq 0x80ca(%rip), %rdx      # 0xf5a0
leaq 0x80d3(%rip), %rcx      # 0xf5b0
movq %r14, %rdi
movq %rax, %rsi
callq 0x45c0
testl %eax, %eax
je 0x74f8
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x9262
leaq 0x3012(%rip), %rdi      # 0xa511
callq 0x43a0
jmp 0x74ec
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/EncryptManager.cpp
// Function: EncryptManager::EncryptUpdate(char*&, int&, char const*, int)
bool EncryptManager::EncryptUpdate(char *& ciphertext, int32_t& ciphertext_len, const char* plaintext ,int32_t plaintext_len){

	ciphertext = new char[plaintext_len + AES_BLOCK];
 	
 	if(!EVP_EncryptUpdate(this->ctx, (unsigned char*)ciphertext, &ciphertext_len, (unsigned char*)plaintext, plaintext_len)){
    	perror("Error in EVP_EncryptUpdate");
    	return false;
    }

    return true;

}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %r8d, %ebx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
leal 0x10(%rbx), %eax
movslq %eax, %rdi
callq 0x4030
movq %rax, (%r12)
movq (%r13), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
movl %ebx, %r8d
callq 0x4080
movl %eax, %ebx
testl %eax, %eax
je 0x75a7
testl %ebx, %ebx
setne %al
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x2f7c(%rip), %rdi      # 0xa52a
callq 0x43a0
jmp 0x7598
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/EncryptManager.cpp
// Function: EncryptManager::EncryptUpdate(EncryptedChunk&, Chunk&)
bool EncryptManager::EncryptUpdate(EncryptedChunk& ec, Chunk& c){

	ec.setCipherText(new char[c.size + AES_BLOCK]);
 	
 	if(!EVP_EncryptUpdate(this->ctx, (unsigned char*)ec.getCipherText(), &ec.size, (unsigned char*)c.getPlainText(), c.size)){
    	perror("Error in EVP_EncryptUpdate");
    	return false;
    }

    return true;

	//return EncryptUpdate(ec.ciphertext,ec.size,c.plaintext,c.size);

}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movslq 0x10(%rdx), %rdi
addq $0x10, %rdi
callq 0x4030
movq %rbx, %rdi
movq %rax, %rsi
callq 0x9496
movq (%r15), %r15
movq %rbx, %rdi
callq 0x94b6
movq %rax, %r12
addq $0x10, %rbx
movq %r14, %rdi
callq 0x9422
movl 0x10(%r14), %r8d
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %rax, %rcx
callq 0x4080
movl %eax, %ebx
testl %eax, %eax
je 0x7625
testl %ebx, %ebx
setne %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x2efe(%rip), %rdi      # 0xa52a
callq 0x43a0
jmp 0x7614
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/EncryptManager.cpp
// Function: EncryptManager::EncryptFinal(char*, int&)
bool EncryptManager::EncryptFinal(char* ciphertext,int32_t &len){

	int local_len;
	
	if(!EVP_EncryptFinal(ctx, (unsigned char*)ciphertext + len, &local_len)){
		perror("Error in EVP_EncryptFinal");
		return false;
	}
  	len += local_len;
	//EVP_CIPHER_CTX_free(ctx);
	return true;

}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq (%rdi), %rdi
movslq (%rdx), %rax
addq %rax, %rsi
leaq 0x4(%rsp), %rdx
callq 0x4800
movl %eax, %ebp
testl %eax, %eax
je 0x7691
movl 0x4(%rsp), %eax
addl %eax, (%rbx)
testl %ebp, %ebp
setne %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x2ead(%rip), %rdi      # 0xa545
callq 0x43a0
jmp 0x7685
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/DecryptManager.cpp
// Function: DecryptManager::DecryptManager()
DecryptManager::DecryptManager(){
	
	this->ctx = EVP_CIPHER_CTX_new();
  	if(!EVP_DecryptInit(ctx, EVP_aes_128_cbc(), this->key, this->IV)){
  		perror("Error In EVP_DecryptInit");
  	}

	incrementIV();

}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x4270
movq %rax, %r14
movq %rax, (%rbx)
callq 0x4220
leaq 0x7ee2(%rip), %rdx      # 0xf5a0
leaq 0x7eeb(%rip), %rcx      # 0xf5b0
movq %r14, %rdi
movq %rax, %rsi
callq 0x40f0
testl %eax, %eax
je 0x76e0
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x9262
leaq 0x2e78(%rip), %rdi      # 0xa55f
callq 0x43a0
jmp 0x76d4
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/DecryptManager.cpp
// Function: DecryptManager::DecryptUpdate(Chunk&, EncryptedChunk&)
bool DecryptManager::DecryptUpdate(Chunk &c, EncryptedChunk& ec){
	
	c.setPlainText(new char[ec.size + AES_BLOCK]);


    if(!EVP_DecryptUpdate(this->ctx, (unsigned char*)c.getPlainText(), &c.size, (unsigned char*)ec.getCipherText(), ec.size)){
    	perror("Error in EVP_DecryptUpdate");
    	return false;
    }

    return true;


}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movslq 0x10(%rdx), %rdi
addq $0x10, %rdi
callq 0x4030
movq %rbx, %rdi
movq %rax, %rsi
callq 0x93e2
movq (%r15), %r15
movq %rbx, %rdi
callq 0x9422
movq %rax, %r12
addq $0x10, %rbx
movq %r14, %rdi
callq 0x94b6
movl 0x10(%r14), %r8d
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %rax, %rcx
callq 0x4250
movl %eax, %ebx
testl %eax, %eax
je 0x77ad
testl %ebx, %ebx
setne %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x2dc4(%rip), %rdi      # 0xa578
callq 0x43a0
jmp 0x779c
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/DecryptManager.cpp
// Function: DecryptManager::DecryptUpdate(char*&, int&, char const*, int)
bool DecryptManager::DecryptUpdate(char *& plaintext,int32_t& plaintext_len,const char* ciphertext,int ciphertext_len){
    plaintext = new char[ciphertext_len + AES_BLOCK];


    if(!EVP_DecryptUpdate(this->ctx, (unsigned char*)plaintext, &plaintext_len, (unsigned char*)ciphertext, ciphertext_len)){
    	perror("Error in EVP_DecryptUpdate");
    	return false;
    }

    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %r8d, %ebx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
leal 0x10(%rbx), %eax
movslq %eax, %rdi
callq 0x4030
movq %rax, (%r12)
movq (%r13), %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
movl %ebx, %r8d
callq 0x4250
movl %eax, %ebx
testl %eax, %eax
je 0x780d
testl %ebx, %ebx
setne %al
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x2d64(%rip), %rdi      # 0xa578
callq 0x43a0
jmp 0x77fe
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/DecryptManager.cpp
// Function: DecryptManager::DecryptFinal(char*, int&)
bool DecryptManager::DecryptFinal(char* plaintext,int32_t &plaintext_len){
	int len;
	
	if(!EVP_DecryptFinal(ctx, (unsigned char*)plaintext + plaintext_len, &len)){
		perror("Error in EVP_DecryptFinal");
		return false;
	}
  	
  	plaintext_len += len;
	//EVP_CIPHER_CTX_free(ctx);
	return true;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq (%rdi), %rdi
movslq (%rdx), %rax
addq %rax, %rsi
leaq 0x4(%rsp), %rdx
callq 0x4050
movl %eax, %ebp
testl %eax, %eax
je 0x784d
movl 0x4(%rsp), %eax
addl %eax, (%rbx)
testl %ebp, %ebp
setne %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x2d3f(%rip), %rdi      # 0xa593
callq 0x43a0
jmp 0x7841
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/HMACManager.cpp
// Function: HMACManager::HMACManager()
HMACManager::HMACManager(){
  this->mdctx = HMAC_CTX_new();
 // size_t key_hmac_size = HMAC_KEY_SIZE;


    if(!HMAC_Init_ex(mdctx, this->hmac_key, HMAC_KEY_SIZE, EVP_sha256(), NULL)){
      perror("Error In HMAC_Init_ex");
    }

}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x4530
movq %rax, %r14
movq %rax, (%rbx)
callq 0x4760
leaq 0x7d1a(%rip), %rsi      # 0xf5c0
pushq $0x10
popq %rdx
movq %r14, %rdi
movq %rax, %rcx
xorl %r8d, %r8d
callq 0x41e0
testl %eax, %eax
je 0x78c3
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x2ce3(%rip), %rdi      # 0xa5ad
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x43a0
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/HMACManager.cpp
// Function: HMACManager::HMACFinal(enum_nonce)
char* HMACManager::HMACFinal(enum_nonce en){
	int hash_size = EVP_MD_size(EVP_sha256());
	char *digest = new char [HASH_SIZE];

  if(nonce != 0){
    Chunk c;
    c.size = sizeof(uint32_t);
    c.setInt(nonce[en]);

    if(!HMACUpdate(c)){
      return NULL;
    }

    nonce[en]++;
  }
  
	if(!HMAC_Final(mdctx, (unsigned char*)digest, (unsigned int*)&hash_size)){
		perror("Error in HMAC_Final");
		return NULL;
	}

//	HMAC_CTX_free(mdctx);
	return digest;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movl %esi, %ebp
movq %rdi, %r14
callq 0x4760
movq %rax, %rdi
callq 0x4170
movl %eax, 0x4(%rsp)
pushq $0x20
popq %rdi
callq 0x4030
movq %rax, %rbx
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x93ac
movl $0x4, 0x10(%r12)
movl %ebp, %eax
leaq 0x7b8e(%rip), %rcx      # 0xf574
leaq (%rcx,%rax,4), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x9428
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x7930
testb %al, %al
je 0x7a35
incl (%r15)
leaq 0x8(%rsp), %rdi
callq 0x93ba
movq (%r14), %rdi
leaq 0x4(%rsp), %rdx
movq %rbx, %rsi
callq 0x40d0
testl %eax, %eax
jne 0x7a41
leaq 0x2b95(%rip), %rdi      # 0xa5c3
callq 0x43a0
jmp 0x7a3f
leaq 0x8(%rsp), %rdi
callq 0x93ba
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x93ba
movq %rbx, %rdi
callq 0x47a0
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/RSAVerifyManager.cpp
// Function: RSAVerifyManager::RSAVerifyManager(char const*)
RSAVerifyManager::RSAVerifyManager(const char *pubkey_path){
	
	this->mdctx = EVP_MD_CTX_new();
  if(!this->mdctx){
    perror("ERRORE new");
  }

	//size_t key_hmac_size = sizeof(KEY_HMAC);
  FILE* pubkey_file = fopen(pubkey_path, "r");
  if(!pubkey_file){ cerr << "Error: cannot open file '" << pubkey_path << "' (missing?)\n"; exit(1); }
  this->pubkey = PEM_read_PUBKEY(pubkey_file, NULL, NULL, NULL);
  fclose(pubkey_file);
  if(!this->pubkey){ cerr << "Error: PEM_read_PUBKEY returned NULL\n"; exit(1); }


  if(!EVP_VerifyInit(this->mdctx,EVP_sha256())){
  	perror("Error In RSA_Init_ex");
  }

  shouldFree = true;

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
callq 0x44b0
movq %rax, (%rbx)
testq %rax, %rax
je 0x7b0d
leaq 0x286e(%rip), %rsi      # 0xa329
movq %r14, %rdi
callq 0x44f0
testq %rax, %rax
je 0x7b29
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x47f0
movq %rax, 0x8(%rbx)
movq %r15, %rdi
callq 0x4410
cmpq $0x0, 0x8(%rbx)
je 0x7b53
movq (%rbx), %r14
callq 0x4760
movq %r14, %rdi
movq %rax, %rsi
callq 0x4840
testl %eax, %eax
je 0x7b1b
movb $0x1, 0x10(%rbx)
popq %rbx
popq %r14
popq %r15
retq
leaq 0x2ac3(%rip), %rdi      # 0xa5d7
callq 0x43a0
jmp 0x7ab4
leaq 0x2ae6(%rip), %rdi      # 0xa608
callq 0x43a0
jmp 0x7b03
movq 0x74c0(%rip), %rdi      # 0xeff0
leaq 0x2714(%rip), %rsi      # 0xa24b
callq 0x4400
movq %rax, %rdi
movq %r14, %rsi
callq 0x4400
leaq 0x2717(%rip), %rsi      # 0xa265
movq %rax, %rdi
jmp 0x7b61
movq 0x7496(%rip), %rdi      # 0xeff0
leaq 0x2a81(%rip), %rsi      # 0xa5e2
callq 0x4400
pushq $0x1
popq %rdi
callq 0x4540
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/RSAVerifyManager.cpp
// Function: RSAVerifyManager::RSAVerifyManager(PublicKey&)
RSAVerifyManager::RSAVerifyManager(PublicKey &pubClass){
  
  this->mdctx = EVP_MD_CTX_new();
  if(!this->mdctx){
    perror("ERRORE new");
  }

  this->pubkey = pubClass.getKey();
  if(!EVP_VerifyInit(this->mdctx,EVP_sha256())){
      perror("Error In RSA_Init_ex");
    }

  shouldFree = false;

}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
callq 0x44b0
movq %rax, (%rbx)
testq %rax, %rax
je 0x7bb4
movq %r14, %rdi
callq 0x9390
movq %rax, 0x8(%rbx)
movq (%rbx), %r14
callq 0x4760
movq %r14, %rdi
movq %rax, %rsi
callq 0x4840
testl %eax, %eax
je 0x7bc2
movb $0x0, 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x2a1c(%rip), %rdi      # 0xa5d7
callq 0x43a0
jmp 0x7b85
leaq 0x2a3f(%rip), %rdi      # 0xa608
callq 0x43a0
jmp 0x7ba8
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/RSAVerifyManager.cpp
// Function: RSAVerifyManager::~RSAVerifyManager()
RSAVerifyManager::~RSAVerifyManager(){
  EVP_MD_CTX_free(mdctx);
  CRYPTO_cleanup_all_ex_data();
  if(shouldFree)
    EVP_PKEY_free(this->pubkey);

}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x47d0
cmpb $0x1, 0x10(%rbx)
jne 0x7cc3
movq 0x8(%rbx), %rdi
callq 0x4260
popq %rbx
retq
movq %rax, %rdi
callq 0x643d
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/RSASignManager.cpp
// Function: RSASignManager::RSASignManager(char const*)
RSASignManager::RSASignManager(const char *key_path){
	
  this->mdctx = NULL;
  this->prvkey = NULL;

	this->mdctx = EVP_MD_CTX_new();
	//size_t key_hmac_size = sizeof(KEY_HMAC);
  this->privkeyPath = string(key_path);
  
  if(!EVP_SignInit(mdctx,EVP_sha256())){
  		perror("Error In RSA_Init_ex");
  }

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0x20(%rdi), %rax
movq %rax, 0x10(%rdi)
andq $0x0, 0x18(%rdi)
leaq 0x10(%rdi), %rbx
movb $0x0, 0x20(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
callq 0x44b0
movq %rax, (%r14)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %r15, %rsi
callq 0x639e
leaq 0x10(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4550
movq %r15, %rdi
callq 0x41b0
movq (%r14), %r14
callq 0x4760
movq %r14, %rdi
movq %rax, %rsi
callq 0x4840
testl %eax, %eax
je 0x7d4d
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x28b4(%rip), %rdi      # 0xa608
callq 0x43a0
jmp 0x7d43
jmp 0x7d5d
movq %rax, %r14
movq %rbx, %rdi
callq 0x41b0
movq %r14, %rdi
callq 0x47a0
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/RSASignManager.cpp
// Function: RSASignManager::RSAFinal(unsigned int&)
char* RSASignManager::RSAFinal(uint32_t& len){

  FILE* prvkey_file = fopen(this->privkeyPath.c_str(), "r");
  cout<<this->privkeyPath.c_str()<<endl;


  if(!prvkey_file){ cerr << "Error: cannot open file '" << this->privkeyPath << "' (missing?)\n"; exit(1); }
  this->prvkey = PEM_read_PrivateKey(prvkey_file, NULL, NULL, NULL);
  fclose(prvkey_file);
  if(!this->prvkey){ cerr << "Error: PEM_read_PrivateKey returned NULL\n"; exit(1); }
  

	char *signature = new char [EVP_PKEY_size(this->prvkey)];
  unsigned int signature_len;


	if(!EVP_SignFinal(mdctx,(unsigned char*)signature, &signature_len, this->prvkey)){
		perror("Error in RSA_Final");
		return NULL;
	}

  len = signature_len;

  //distruggere chiave privata
  EVP_PKEY_free(this->prvkey);
  this->prvkey = NULL;

	return signature;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
leaq 0x2527(%rip), %rsi      # 0xa329
callq 0x44f0
movq %rax, %r15
movq 0x10(%rbx), %rsi
movq 0x71b3(%rip), %rdi      # 0xefc8
callq 0x4400
movq %rax, %rdi
callq 0x41d0
testq %r15, %r15
je 0x7ead
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4300
movq %rax, 0x8(%rbx)
movq %r15, %rdi
callq 0x4410
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x7edb
callq 0x4790
movslq %eax, %rdi
callq 0x4030
movq %rax, %r15
movq (%rbx), %rdi
movq 0x8(%rbx), %rcx
leaq 0xc(%rsp), %rdx
movq %rax, %rsi
callq 0x4090
testl %eax, %eax
je 0x7e9c
movl 0xc(%rsp), %eax
movl %eax, (%r14)
movq 0x8(%rbx), %rdi
callq 0x4260
andq $0x0, 0x8(%rbx)
movq %r15, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x27d6(%rip), %rdi      # 0xa679
callq 0x43a0
xorl %r15d, %r15d
jmp 0x7e8f
addq $0x10, %rbx
movq 0x7138(%rip), %rdi      # 0xeff0
leaq 0x238c(%rip), %rsi      # 0xa24b
callq 0x4400
movq %rax, %rdi
movq %rbx, %rsi
callq 0x43d0
leaq 0x238f(%rip), %rsi      # 0xa265
movq %rax, %rdi
jmp 0x7ee9
movq 0x710e(%rip), %rdi      # 0xeff0
leaq 0x2766(%rip), %rsi      # 0xa64f
callq 0x4400
pushq $0x1
popq %rdi
callq 0x4540
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/RSASignManager.cpp
// Function: RSASignManager::~RSASignManager()
RSASignManager::~RSASignManager(){
  if(this->prvkey != NULL){
    EVP_PKEY_free(this->prvkey);
  }

  if(this->mdctx != NULL){
    EVP_MD_CTX_free(this->mdctx);
  }

  CRYPTO_cleanup_all_ex_data();
  
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x7f08
callq 0x4260
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x7f15
callq 0x47d0
addq $0x10, %rbx
movq %rbx, %rdi
popq %rbx
jmp 0x41b0
movq %rax, %rdi
callq 0x643d
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/CertificateManager.cpp
// Function: CertificateManager::verifyCertificate(x509_st*)
bool CertificateManager::verifyCertificate(X509* certificate){

	if(!certificate)
		return false;

	int ret;

	X509_STORE_CTX* certvfy_ctx = X509_STORE_CTX_new();
	if(!certvfy_ctx) { cerr << "Error: X509_STORE_CTX_new returned NULL\n" << ERR_error_string(ERR_get_error(), NULL) << "\n"; exit(1); }
	ret = X509_STORE_CTX_init(certvfy_ctx, store, certificate, NULL);
	if(ret != 1) { cerr << "Error: X509_STORE_CTX_init returned " << ret << "\n" << ERR_error_string(ERR_get_error(), NULL) << "\n"; exit(1); }
	ret = X509_verify_cert(certvfy_ctx);
	
	X509_STORE_CTX_free(certvfy_ctx);

	if(ret != 1) { 
		cerr << "Error: X509_verify_cert returned " << ret << "\n" << ERR_error_string(ERR_get_error(), NULL) << endl; 
		return false;
	} else {
		return true;
	}


}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x8b58
movq %rsi, %r14
movq %rdi, %r15
callq 0x4370
testq %rax, %rax
je 0x8b67
movq %rax, %rbx
movq (%r15), %rsi
movq %rax, %rdi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0x4280
cmpl $0x1, %eax
jne 0x8ba3
movq %rbx, %rdi
callq 0x4340
movl %eax, %ebp
movq %rbx, %rdi
callq 0x46e0
movb $0x1, %bl
cmpl $0x1, %ebp
je 0x8b5a
movq 0x64e6(%rip), %rdi      # 0xeff0
leaq 0x1de3(%rip), %rsi      # 0xa8f4
callq 0x4400
movq %rax, %rdi
movl %ebp, %esi
callq 0x4770
leaq 0x174a(%rip), %rsi      # 0xa271
movq %rax, %rdi
callq 0x4400
movq %rax, %r14
callq 0x45f0
xorl %ebx, %ebx
movq %rax, %rdi
xorl %esi, %esi
callq 0x4140
movq %r14, %rdi
movq %rax, %rsi
callq 0x4400
movq %rax, %rdi
callq 0x41d0
jmp 0x8b5a
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x6482(%rip), %rdi      # 0xeff0
leaq 0x1d31(%rip), %rsi      # 0xa8a6
callq 0x4400
movq %rax, %rbx
callq 0x45f0
movq %rax, %rdi
xorl %esi, %esi
callq 0x4140
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4400
leaq 0x16d3(%rip), %rsi      # 0xa271
movq %rax, %rdi
jmp 0x8bf7
movl %eax, %ebp
movq 0x6444(%rip), %rdi      # 0xeff0
leaq 0x1d1c(%rip), %rsi      # 0xa8cf
callq 0x4400
movq %rax, %rdi
movl %ebp, %esi
callq 0x4770
leaq 0x16a8(%rip), %rbx      # 0xa271
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4400
movq %rax, %r14
callq 0x45f0
movq %rax, %rdi
xorl %esi, %esi
callq 0x4140
movq %r14, %rdi
movq %rax, %rsi
callq 0x4400
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4400
pushq $0x1
popq %rdi
callq 0x4540
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/CertificateManager.cpp
// Function: CertificateManager::extractCommonName(x509_st*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool CertificateManager::extractCommonName(X509* certificate,string &string_name){

	if(!certificate)
		return false;

	X509_NAME* name = X509_get_subject_name(certificate);
	int len;
	
	len = X509_NAME_get_text_by_NID(name,NID_commonName,NULL,0);				//i get the length of the commonname
	if(len == -1)
		return false;

	len++;																		//terminator char

	char *tmp = new char[len];

	if(X509_NAME_get_text_by_NID(name,NID_commonName,tmp,len) == -1)
		return false;

	string_name = (string)tmp;
	delete[] tmp;

	return true;

}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
testq %rsi, %rsi
je 0x8c98
movq %rdx, %rbx
movq %rsi, %rdi
callq 0x4450
movq %rax, %r15
xorl %r14d, %r14d
pushq $0xd
popq %rsi
movq %rax, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4500
cmpl $-0x1, %eax
je 0x8c9b
incl %eax
movslq %eax, %r12
movq %r12, %rdi
callq 0x4030
movq %rax, %r14
pushq $0xd
popq %rsi
movq %r15, %rdi
movq %rax, %rdx
movl %r12d, %ecx
callq 0x4500
cmpl $-0x1, %eax
je 0x8c98
leaq 0x8(%rsp), %r15
leaq 0x7(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x639e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4550
movq %r15, %rdi
callq 0x41b0
movq %r14, %rdi
callq 0x45a0
movb $0x1, %r14b
jmp 0x8c9b
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/RSAEncryptManager.cpp
// Function: RSAEncryptManager::RSAEncryptManager(evp_pkey_st*)
RSAEncryptManager::RSAEncryptManager(EVP_PKEY *pubkey){
  
  this->mdctx = NULL;

  this->mdctx = EVP_CIPHER_CTX_new();
  //size_t key_hmac_size = sizeof(KEY_HMAC);
  this->pubkey = pubkey;
  
  unsigned char* key = new unsigned char[EVP_PKEY_size(pubkey)];
  unsigned char *iv = new unsigned char[EVP_CIPHER_iv_length(EVP_aes_128_cbc())];

  int key_len;


  if(!EVP_SealInit(mdctx,EVP_aes_128_cbc(),&key,&key_len,iv,&pubkey,1)){
      perror("Error In RSA_Init_ex");
  }

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, 0x10(%rsp)
leaq 0x20(%rdi), %rax
movq %rax, 0x10(%rdi)
andq $0x0, 0x18(%rdi)
movb $0x0, 0x20(%rdi)
andq $0x0, (%rdi)
callq 0x4270
movq %rax, (%rbx)
movq %r14, 0x8(%rbx)
movq %r14, %rdi
callq 0x4790
movslq %eax, %rdi
callq 0x4030
movq %rax, 0x8(%rsp)
callq 0x4220
movq %rax, %rdi
callq 0x4810
movslq %eax, %rdi
callq 0x4030
movq %rax, %r14
movq (%rbx), %r15
callq 0x4220
movl $0x1, (%rsp)
leaq 0x8(%rsp), %rdx
leaq 0x1c(%rsp), %rcx
leaq 0x10(%rsp), %r9
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %r8
callq 0x4880
testl %eax, %eax
je 0x8d50
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x18b1(%rip), %rdi      # 0xa608
callq 0x43a0
jmp 0x8d46
jmp 0x8d64
jmp 0x8d64
jmp 0x8d64
movq %rax, %r14
addq $0x10, %rbx
movq %rbx, %rdi
callq 0x41b0
movq %r14, %rdi
callq 0x47a0
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/RSAEncryptManager.cpp
// Function: RSAEncryptManager::RSAFinal(EncryptedChunk&)
bool RSAEncryptManager::RSAFinal(EncryptedChunk& ec){

  int len;

  if(!EVP_SealFinal(this->mdctx, (unsigned char*)ec.getCipherText() + ec.size, &len)){
    perror("Error in RSA_Final");
    return false;
  }

  ec.size += len;
  return true;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq (%rdi), %r14
movq %rsi, %rdi
callq 0x94b6
movslq 0x10(%rbx), %rsi
addq %rax, %rsi
leaq 0xc(%rsp), %rdx
movq %r14, %rdi
callq 0x4480
movl %eax, %ebp
testl %eax, %eax
je 0x8e23
movl 0xc(%rsp), %eax
addl %eax, 0x10(%rbx)
testl %ebp, %ebp
setne %al
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x184f(%rip), %rdi      # 0xa679
callq 0x43a0
jmp 0x8e15
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/RSADecryptManager.cpp
// Function: RSADecryptManager::RSADecryptManager(char const*, unsigned int)
RSADecryptManager::RSADecryptManager(const char *privkey_path,uint32_t key_len){
  
  this->mdctx = NULL;

  this->mdctx = EVP_CIPHER_CTX_new();
  //size_t key_hmac_size = sizeof(KEY_HMAC);
  
  FILE* privkey_file = fopen(privkey_path, "r");
  if(!privkey_file){ 
    cerr << "Error: cannot open file '" << privkey_path << "' (missing?)\n"; 
    exit(1); 
  }

  this->privkey = PEM_read_PrivateKey(privkey_file, NULL, NULL, NULL);
  fclose(privkey_file);

  if(!this->privkey){ 
    cerr << "Error: PEM_read_PUBKEY returned NULL\n"; 
    exit(1); 
  }

  this->key = new unsigned char[key_len];
  this->iv = new unsigned char[EVP_CIPHER_iv_length(EVP_aes_128_cbc())];

  if(!EVP_OpenInit(this->mdctx,EVP_aes_128_cbc(),key,key_len,iv,this->privkey)){
      perror("Error In RSA_Init_ex");
  }

}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
andq $0x0, (%rdi)
callq 0x4270
movq %rax, (%r14)
leaq 0x14b2(%rip), %rsi      # 0xa329
movq %r15, %rdi
callq 0x44f0
testq %rax, %rax
je 0x8f1c
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4300
movq %rax, 0x8(%r14)
movq %r12, %rdi
callq 0x4410
cmpq $0x0, 0x8(%r14)
je 0x8f46
movl %ebx, %edi
callq 0x4030
movq %rax, 0x18(%r14)
callq 0x4220
movq %rax, %rdi
callq 0x4810
movslq %eax, %rdi
callq 0x4030
movq %rax, 0x10(%r14)
movq (%r14), %r15
callq 0x4220
movq 0x18(%r14), %rdx
movq 0x8(%r14), %r9
movq 0x10(%r14), %r8
movq %r15, %rdi
movq %rax, %rsi
movl %ebx, %ecx
callq 0x43e0
testl %eax, %eax
je 0x8f05
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x16fc(%rip), %rdi      # 0xa608
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x43a0
movq 0x60cd(%rip), %rdi      # 0xeff0
leaq 0x1321(%rip), %rsi      # 0xa24b
callq 0x4400
movq %rax, %rdi
movq %r15, %rsi
callq 0x4400
leaq 0x1324(%rip), %rsi      # 0xa265
movq %rax, %rdi
jmp 0x8f54
movq 0x60a3(%rip), %rdi      # 0xeff0
leaq 0x168e(%rip), %rsi      # 0xa5e2
callq 0x4400
pushq $0x1
popq %rdi
callq 0x4540
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/RSADecryptManager.cpp
// Function: RSADecryptManager::RSAFinal(Chunk&)
bool RSADecryptManager::RSAFinal(Chunk& c){

  int len;

  if(!EVP_OpenFinal(this->mdctx, (unsigned char*)c.getPlainText() + c.size, &len)){
    perror("Error in RSA_Final");
    return false;
  }

  c.size += len;
  return true;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq (%rdi), %r14
movq %rsi, %rdi
callq 0x9422
movslq 0x10(%rbx), %rsi
addq %rax, %rsi
leaq 0xc(%rsp), %rdx
movq %r14, %rdi
callq 0x44a0
movl %eax, %ebp
testl %eax, %eax
je 0x9009
movl 0xc(%rsp), %eax
addl %eax, 0x10(%rbx)
testl %ebp, %ebp
setne %al
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1669(%rip), %rdi      # 0xa679
callq 0x43a0
jmp 0x8ffb
nop
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/DHManager.cpp
// Function: DHManager::DHManager(char const*)
DHManager::DHManager(const char *path){

	FILE* dh_params = fopen(path, "r");
	if(!dh_params){ cerr << "Error: cannot open file '" << path << "' (missing?)\n"; exit(1); }
	this->session = PEM_read_DHparams(dh_params, NULL, NULL, NULL);
	fclose(dh_params);
	if(!this->session){ cerr << "Error: PEM_read_DHparams returned NULL\n"; exit(1); }

	int res;

	if(DH_check(this->session,&res) != 1){
		cout<<"Errore"<<endl;
	} 

	if(res != 0){
		cerr<<"Error in DH params"<<endl;
		exit(-1);
	}

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x12e7(%rip), %rsi      # 0xa329
movq %r14, %rdi
callq 0x44f0
testq %rax, %rax
je 0x90ae
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4180
movq %rax, (%rbx)
movq %r15, %rdi
callq 0x4410
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x90d8
leaq 0xc(%rsp), %rsi
callq 0x4290
cmpl $0x1, %eax
je 0x909d
movq 0x5f3f(%rip), %rdi      # 0xefc8
leaq 0x18c2(%rip), %rsi      # 0xa952
callq 0x4400
movq %rax, %rdi
callq 0x41d0
cmpl $0x0, 0xc(%rsp)
jne 0x90ef
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0x5f3b(%rip), %rdi      # 0xeff0
leaq 0x118f(%rip), %rsi      # 0xa24b
callq 0x4400
movq %rax, %rdi
movq %r14, %rsi
callq 0x4400
leaq 0x1192(%rip), %rsi      # 0xa265
movq %rax, %rdi
jmp 0x90e6
movq 0x5f11(%rip), %rdi      # 0xeff0
leaq 0x1844(%rip), %rsi      # 0xa92a
callq 0x4400
pushq $0x1
jmp 0x910c
movq 0x5efa(%rip), %rdi      # 0xeff0
leaq 0x185c(%rip), %rsi      # 0xa959
callq 0x4400
movq %rax, %rdi
callq 0x41d0
pushq $-0x1
popq %rdi
callq 0x4540
// File: /workspace/github_cpp_makefile_star2_O2/luigix25[P]SSLP/library/DHManager.cpp
// Function: DHManager::generatePublicKey(int&)
char * DHManager::generatePublicKey(int &len){
	if(DH_generate_key(this->session) != 1){
		cerr<<"Error in DH_generate_key"<<endl;
		return NULL;
	}

	BIGNUM *pub_key;
	DH_get0_key(this->session,(const BIGNUM**)&pub_key,NULL);

	unsigned char *return_value = new unsigned char[BN_num_bytes(pub_key)];


	len = BN_bn2bin(pub_key,return_value);
	if(len <= 0){
		delete[] return_value;
		return NULL;
	}

	return (char*)return_value;

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rdi
callq 0x4130
cmpl $0x1, %eax
jne 0x9177
movq (%r14), %rdi
leaq 0x8(%rsp), %r15
movq %r15, %rsi
xorl %edx, %edx
callq 0x42b0
movq (%r15), %rdi
callq 0x44c0
addl $0x7, %eax
pushq $0x8
popq %rcx
cltd
idivl %ecx
movslq %eax, %rdi
callq 0x4030
movq %rax, %r14
movq (%r15), %rdi
movq %rax, %rsi
callq 0x4560
movl %eax, (%rbx)
testl %eax, %eax
jg 0x9195
movq %r14, %rdi
callq 0x45a0
jmp 0x9192
movq 0x5e72(%rip), %rdi      # 0xeff0
leaq 0x17e7(%rip), %rsi      # 0xa96c
callq 0x4400
movq %rax, %rdi
callq 0x41d0
xorl %r14d, %r14d
movq %r14, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq