LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/arinaschwartz[P]KNN-MNIST/MNISTImageImpls.cpp
// Function: FullArrayMNISTImage::FullArrayMNISTImage(unsigned char*, unsigned int, unsigned char)
FullArrayMNISTImage::FullArrayMNISTImage(uint8 data[], uint32 size, uint8 label):
		ArrayMNISTImage(label)
{
    
    this->data = new uint8[size];
    for(uint32 i = 0; i < size; i++){
        this->data[i] = data[i];
    }

    this->size = size;
    this->label = label;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movl %ecx, %esi
callq 0x29be
leaq 0x4275(%rip), %rax      # 0x6ce8
movq %rax, (%rbx)
movl %r14d, %r12d
movq %r12, %rdi
callq 0x2030
movq %rax, 0x10(%rbx)
xorl %eax, %eax
cmpq %rax, %r12
je 0x2a9c
movb (%r15,%rax), %cl
movq 0x10(%rbx), %rdx
movb %cl, (%rdx,%rax)
incq %rax
jmp 0x2a87
movl %r14d, 0x18(%rbx)
movb %bpl, 0x8(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x2980
movq %r14, %rdi
callq 0x2260
// File: /workspace/github_cpp_makefile_star2_O2/arinaschwartz[P]KNN-MNIST/MNISTImageImpls.cpp
// Function: DownsampleMNISTImage::DownsampleMNISTImage(unsigned char*, unsigned int, unsigned char, unsigned int)
DownsampleMNISTImage::DownsampleMNISTImage(uint8 data[], uint32 size, uint8 label, uint32 factor):
		ArrayMNISTImage(label)
{
    uint32 new_size = size/factor;
	this->data = new uint8[new_size];
    for(uint32 i = 0; i < size; i++){
        if(i % factor == 0){
            this->data[i/factor] = data[i];
        }
    }
    this->size = new_size;
    this->label = label;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %r14d
movl %ecx, %ebp
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, %rbx
movl %ecx, %esi
callq 0x29be
leaq 0x4229(%rip), %rax      # 0x6d10
movq %rax, (%rbx)
movl %r13d, %eax
xorl %edx, %edx
divl %r14d
movl %eax, %r12d
movq %r12, %rdi
callq 0x2030
movq %rax, 0x10(%rbx)
movl %r13d, %esi
xorl %ecx, %ecx
cmpq %rcx, %rsi
je 0x2b28
movl %ecx, %eax
xorl %edx, %edx
divl %r14d
testl %edx, %edx
jne 0x2b23
movb (%r15,%rcx), %dl
movq 0x10(%rbx), %rdi
movl %eax, %eax
movb %dl, (%rdi,%rax)
incq %rcx
jmp 0x2b06
movl %r12d, 0x18(%rbx)
movb %bpl, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x2980
movq %r14, %rdi
callq 0x2260
// File: /workspace/github_cpp_makefile_star2_O2/arinaschwartz[P]KNN-MNIST/MNISTImageImpls.cpp
// Function: ScaledMNISTImage::ScaledMNISTImage(unsigned char*, unsigned int, unsigned int, unsigned char, unsigned int)
ScaledMNISTImage::ScaledMNISTImage(uint8 data[], uint32 numRows, uint32 numCols, uint8 label, uint32 factor):
		ArrayMNISTImage(label)
{
    uint32 newNumRows = numRows/factor;
    uint32 newNumCols = numCols/factor;
    this->data = new uint8[newNumRows*newNumCols];
    for(uint32 i = 0; i < numRows; i++){
        for(uint32 j = 0; j < numCols; j++){
            this->data[(i/factor)*newNumRows + (j/factor)] +=
                        (data[(i * numRows) + j])/(factor*factor);
        }
    }
    this->size = newNumRows*newNumCols;
    this->label = label;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, %r14d
movl %ecx, %r15d
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
movl %r8d, 0xc(%rsp)
movl %r8d, %esi
callq 0x29be
leaq 0x41b6(%rip), %rax      # 0x6d38
movq %rax, (%rbx)
xorl %r13d, %r13d
movl %ebp, 0x8(%rsp)
movl %ebp, %eax
xorl %edx, %edx
divl %r14d
movl %eax, %ebp
movl %r15d, (%rsp)
movl %r15d, %eax
xorl %edx, %edx
divl %r14d
imull %ebp, %eax
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x2030
movq %rax, 0x10(%rbx)
movl %r14d, %r8d
imull %r14d, %r8d
movl (%rsp), %r9d
movl 0x8(%rsp), %r10d
movl %r10d, %eax
movq %rax, (%rsp)
xorl %r11d, %r11d
cmpl %r10d, %r13d
je 0x2c17
xorl %ecx, %ecx
cmpq %rcx, %r9
je 0x2c0e
leal (%r11,%rcx), %eax
movzbl (%r12,%rax), %eax
xorl %edx, %edx
divl %r8d
movl %eax, %esi
movq 0x10(%rbx), %r15
movl %r13d, %eax
xorl %edx, %edx
divl %r14d
movl %eax, %edi
imull %ebp, %edi
movl %ecx, %eax
xorl %edx, %edx
divl %r14d
addl %edi, %eax
addb %sil, (%r15,%rax)
incq %rcx
jmp 0x2bd6
incl %r13d
addq (%rsp), %r11
jmp 0x2bcf
movq 0x10(%rsp), %rax
movl %eax, 0x18(%rbx)
movl 0xc(%rsp), %eax
movb %al, 0x8(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x2980
movq %r14, %rdi
callq 0x2260
// File: /workspace/github_cpp_makefile_star2_O2/arinaschwartz[P]KNN-MNIST/MNISTImageImpls.cpp
// Function: SumMNISTImage::SumMNISTImage(unsigned char*, unsigned int, unsigned char)
SumMNISTImage::SumMNISTImage(uint8 data[], uint32 size, uint8 label):
		MNISTImage(label)
{
	uint32 sum = 0;
    for(uint32 i = 0; i < size; i++){
        sum += data[i];
    }
    this->sum = sum;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl %ecx, %esi
callq 0x2970
leaq 0x402e(%rip), %rax      # 0x6c90
movq %rax, (%rbx)
movl %ebp, %eax
xorl %ecx, %ecx
xorl %edx, %edx
cmpq %rcx, %rax
je 0x2c7c
movzbl (%r14,%rcx), %esi
addl %esi, %edx
incq %rcx
jmp 0x2c6b
movl %edx, 0xc(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/arinaschwartz[P]KNN-MNIST/MNISTImageImpls.cpp
// Function: SumMNISTImage::distance(MNISTImage const*) const
double SumMNISTImage::distance(const MNISTImage *img) const
{
    const SumMNISTImage *arrayimg = dynamic_cast<const SumMNISTImage*>(img);
    double first_image_sum = this->sum;
    double second_image_sum = arrayimg->sum;
    double diff = first_image_sum - second_image_sum;
    double distance = sqrt((diff*diff));

	return distance;

}

// Assembly:
pushq %rbx
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x3f76(%rip), %rsi      # 0x6c08
leaq 0x400f(%rip), %rdx      # 0x6ca8
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x21a0
movl 0xc(%rbx), %ecx
cvtsi2sd %rcx, %xmm0
movl 0xc(%rax), %eax
cvtsi2sd %rax, %xmm1
subsd %xmm1, %xmm0
mulsd %xmm0, %xmm0
sqrtsd %xmm0, %xmm0
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpMain.cpp
// Function: createAuthRequest(SRscpFrameBuffer*, e3dc_config_t*)
int createAuthRequest(SRscpFrameBuffer * frameBuffer, e3dc_config_t *e3dc_config)
{
    RscpProtocol protocol;
    SRscpValue rootValue;
    // The root container is create with the TAG ID 0 which is not used by any device.
    protocol.createContainerValue(&rootValue, 0);

    //---------------------------------------------------------------------------------------------------------
    // Create a auth request frame
    //---------------------------------------------------------------------------------------------------------
    printf("\nRequest authentication\n");
    // authentication request
    SRscpValue authenContainer;
    protocol.createContainerValue(&authenContainer,
				  TAG_RSCP_REQ_AUTHENTICATION);
    protocol.appendValue(&authenContainer, TAG_RSCP_AUTHENTICATION_USER,
			 e3dc_config->e3dc_user);
    protocol.appendValue(&authenContainer,
			 TAG_RSCP_AUTHENTICATION_PASSWORD, e3dc_config->e3dc_password);
    // append sub-container to root container
    protocol.appendValue(&rootValue, authenContainer);
    // free memory of sub-container as it is now copied to rootValue
    protocol.destroyValueData(authenContainer);

    // create buffer frame to send data to the S10
    protocol.createFrameAsBuffer(frameBuffer, rootValue.data, rootValue.length, true);	// true to calculate CRC on for transfer
    // the root value object should be destroyed after the data is copied into the frameBuffer and is not needed anymore
    protocol.destroyValueData(rootValue);

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsp, %r15
movq %r15, %rdi
callq 0x4380
leaq 0x10(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x21(%rsp), %rsi
movq %r15, %rdi
callq 0x3e06
leaq 0xd246(%rip), %rdi      # 0xf668
callq 0x2210
leaq 0xc(%rsp), %rdx
movl $0x1, (%rdx)
movq %rsp, %rdi
leaq 0x10(%rsp), %rsi
callq 0x3e06
leaq 0xc(%rsp), %rdx
movl $0x2, (%rdx)
leaq 0x18(%r14), %rcx
movq %rsp, %rdi
leaq 0x10(%rsp), %rsi
callq 0x3e16
leaq 0xc(%rsp), %rdx
movl $0x3, (%rdx)
addq $0x98, %r14
movq %rsp, %rdi
leaq 0x10(%rsp), %rsi
movq %r14, %rcx
callq 0x3e16
movq %rsp, %rdi
leaq 0x21(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x3e62
movq %rsp, %rdi
leaq 0x10(%rsp), %rsi
callq 0x4fe4
movq 0x28(%rsp), %rdx
movzwl 0x26(%rsp), %ecx
movq %rsp, %rdi
pushq $0x1
popq %r8
movq %rbx, %rsi
callq 0x445c
movq %rsp, %rdi
leaq 0x21(%rsp), %rsi
callq 0x4fe4
movq %rsp, %rdi
callq 0x438c
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x24de
jmp 0x24de
jmp 0x24de
jmp 0x24de
movq %rax, %rbx
movq %rsp, %rdi
callq 0x438c
movq %rbx, %rdi
callq 0x2280
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpMain.cpp
// Function: showhelp(char*)
void showhelp(char *prog)
{
    printf("Usage:\n");
    printf("%s [-hebts] [-w 0|1]\n", prog);
    printf("  --help, -h         \tshows this help\n");
    printf("  --battery, -b      \tshows battery details\n");
    printf("  --ems, -e          \tshows ems details\n");
    printf("  --time, -t         \tshows idle periods\n");
    printf("  --settime, -s      \tsets idle periods (currently hardcoded values)\n");
    printf("  --weather, -w      \tsets weather enable option [on|off]\n");
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0xbf80(%rip), %rdi      # 0xf70f
callq 0x2210
leaq 0xbd1e(%rip), %rdi      # 0xf4b9
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0xbf6a(%rip), %rdi      # 0xf716
callq 0x2210
leaq 0xbf84(%rip), %rdi      # 0xf73c
callq 0x2210
leaq 0xbfa4(%rip), %rdi      # 0xf768
callq 0x2210
leaq 0xbfc0(%rip), %rdi      # 0xf790
callq 0x2210
leaq 0xbfdd(%rip), %rdi      # 0xf7b9
callq 0x2210
leaq 0xc016(%rip), %rdi      # 0xf7fe
popq %rbx
jmp 0x2210
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/./RscpProtocol.h
// Function: unsigned int RscpProtocol::getValue<unsigned int>(SRscpValue const*)
cType getValue(const SRscpValue* value) {
    	if((value == NULL) || (value->data == NULL)) {
    		return cType();
    	}
    	// if the size is smaller than needed copy only the smaller part
    	if(sizeof(cType) <= value->length) {
    		cType tTmp;
    		memcpy(&tTmp, value->data, sizeof(cType));
    		return tTmp;
    	}
    	// if the size needed is bigger then zero out the rest
    	else {
    		cType tTmp;
    		memset(&tTmp, 0, sizeof(cType));
    		memcpy(&tTmp, value->data, value->length);
    		return tTmp;
    	}
    }

// Assembly:
xorl %eax, %eax
testq %rsi, %rsi
je 0x4176
movq %rsi, %rcx
movq 0x7(%rsi), %rsi
testq %rsi, %rsi
je 0x4176
movzwl 0x5(%rcx), %edx
cmpq $0x4, %rdx
jb 0x415a
movl (%rsi), %eax
retq
pushq %rbx
subq $0x10, %rsp
leaq 0xc(%rsp), %rbx
andl $0x0, (%rbx)
movq %rbx, %rdi
callq 0x2120
movl (%rbx), %eax
addq $0x10, %rsp
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::calculateCRC32(unsigned char const*, unsigned short)
uint32_t RscpProtocol::calculateCRC32(const uint8_t *data, uint16_t length) {
    static const uint32_t crc_table[] = {
      0x4DBDF21C, 0x500AE278, 0x76D3D2D4, 0x6B64C2B0,
      0x3B61B38C, 0x26D6A3E8, 0x000F9344, 0x1DB88320,
      0xA005713C, 0xBDB26158, 0x9B6B51F4, 0x86DC4190,
      0xD6D930AC, 0xCB6E20C8, 0xEDB71064, 0xF0000000
    };
	uint32_t crc = 0;
    for(uint32_t n = 0; n < length; n++) {
        crc = (crc >> 4) ^ crc_table[(crc ^ (data[n] >> 0)) & 0x0F];  /* lower nibble */
        crc = (crc >> 4) ^ crc_table[(crc ^ (data[n] >> 4)) & 0x0F];  /* upper nibble */
	}
	return crc;
}

// Assembly:
movl %edx, %ecx
xorl %edx, %edx
leaq 0xb545(%rip), %rdi      # 0xf920
xorl %eax, %eax
cmpq %rdx, %rcx
je 0x4416
movzbl (%rsi,%rdx), %r8d
xorl %eax, %r8d
movl %r8d, %r9d
andl $0xf, %r9d
movl (%rdi,%r9,4), %r9d
shrl $0x8, %eax
shrl $0x4, %r8d
xorl %r9d, %r8d
shrl $0x4, %r9d
xorl %eax, %r9d
andl $0xf, %r8d
xorl (%rdi,%r8,4), %r9d
incq %rdx
movl %r9d, %eax
jmp 0x43dd
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::getFrameLength(unsigned char const*, unsigned int const&)
int32_t RscpProtocol::getFrameLength(const uint8_t * data, const uint32_t & length) {
	// validate input
	if(data == NULL) {
		return RSCP::ERR_INVALID_INPUT;
	}
	// first the length must at least be of the header size
	if(length < sizeof(SRscpFrameHeader)) {
		return RSCP::ERR_INVALID_FRAME_LENGTH;
	}
	// check the header information for length
	SRscpFrameHeader *header = reinterpret_cast<SRscpFrameHeader *> ((uint8_t*)data);

	if(header->magic != RSCP::MAGIC) {
		return RSCP::ERR_INVALID_MAGIC;
	}
	// check the frame version number
	if(header->ctrl.bits.version != RSCP::VERSION) {
		return RSCP::ERR_PROT_VERSION_MISMATCH;
	}
	// calculate the expected frame length
	int32_t frameLength = sizeof(SRscpFrameHeader) + header->dataLength + ((header->ctrl.bits.crc != 0) ? sizeof(uint32_t) : 0);
	return frameLength;
}

// Assembly:
testq %rsi, %rsi
je 0x4426
cmpl $0x12, (%rdx)
jae 0x442a
pushq $-0x5
jmp 0x445a
pushq $-0x1
jmp 0x445a
cmpw $0xdce3, (%rsi)         # imm = 0xDCE3
jne 0x4454
movzwl 0x2(%rsi), %eax
movl %eax, %ecx
andl $0xf00, %ecx            # imm = 0xF00
cmpw $0x100, %cx             # imm = 0x100
jne 0x4458
movzwl 0x10(%rsi), %ecx
shrl $0xa, %eax
andl $0x4, %eax
addl %ecx, %eax
addl $0x12, %eax
retq
pushq $-0x3
jmp 0x445a
pushq $-0x4
popq %rax
retq
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::createFrameAsBuffer(SRscpFrameBuffer*, unsigned char const*, unsigned short, bool)
int32_t RscpProtocol::createFrameAsBuffer(SRscpFrameBuffer* frameBuffer, const uint8_t * data, uint16_t dataLength, bool calcCRC) {
	if(frameBuffer == NULL) {
		return RSCP::ERR_INVALID_INPUT;
	}
	// calculate the required frame size
	size_t sFrameSize =  sizeof(SRscpFrameHeader);
	// allocate the required memory
	frameBuffer->data = (uint8_t *) malloc(sFrameSize + dataLength + (calcCRC ? 4 : 0));
	if(frameBuffer->data == NULL) {
		return RSCP::ERR_NO_MEMORY;
	}
	// set the memory size
	frameBuffer->dataLength = sFrameSize + dataLength + (calcCRC ? 4 : 0);
	// set initial header values
	memset(frameBuffer->data, 0, sizeof(SRscpFrameHeader));
	SRscpFrame* tmpFrame = reinterpret_cast<SRscpFrame*>(frameBuffer->data);
	tmpFrame->header.magic = RSCP::MAGIC;
	tmpFrame->header.ctrl.bits.crc = calcCRC;
	tmpFrame->header.ctrl.bits.version = RSCP::VERSION;
	tmpFrame->header.dataLength = dataLength;
	setHeaderTimestamp(tmpFrame);

	// insert data from the SRscpValues
	memcpy(&tmpFrame->header + 1, data, dataLength);

	// calculate CRC if necessary and add to the frame
	if(calcCRC) {
		uint32_t uCRC32 = calculateCRC32(frameBuffer->data, frameBuffer->dataLength - sizeof(uint32_t));
		memcpy(&frameBuffer->data[frameBuffer->dataLength - sizeof(uCRC32)], &uCRC32, sizeof(uCRC32));
	}

	return RSCP::OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x4502
movl %ecx, %ebp
movq %rsi, %rbx
movq %rdx, (%rsp)
movzwl %bp, %r15d
movzbl %r8b, %r14d
leaq (%r15,%r14,4), %r13
addq $0x12, %r13
movq %r13, %rdi
callq 0x21d0
movq %rax, (%rbx)
testq %rax, %rax
je 0x4506
movq %rax, %r12
movl %r13d, 0x8(%rbx)
andl $0x0, 0xc(%rax)
andq $0x0, 0x4(%rax)
movw $0xdce3, (%rax)         # imm = 0xDCE3
movl %r14d, %eax
shll $0xc, %eax
orl $0x100, %eax            # imm = 0x100
movw %ax, 0x2(%r12)
movw %bp, 0x10(%r12)
movq %r12, %rsi
callq 0x4396
addq $0x12, %r12
movq %r12, %rdi
movq (%rsp), %rsi
movq %r15, %rdx
callq 0x2120
xorl %ebp, %ebp
testb %r14b, %r14b
je 0x4509
movq (%rbx), %r14
movl 0x8(%rbx), %ebx
leal -0x4(%rbx), %eax
movzwl %ax, %edx
movq %r14, %rsi
callq 0x43d0
movl %eax, -0x4(%r14,%rbx)
jmp 0x4509
pushq $-0x1
jmp 0x4508
pushq $-0x2
popq %rbp
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/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::createFrame(SRscpFrame*, std::vector<SRscpValue, std::allocator<SRscpValue>> const&, bool)
int32_t RscpProtocol::createFrame(SRscpFrame* frame, const std::vector<SRscpValue> & data, bool calcCRC) {
	if(frame == NULL) {
		return RSCP::ERR_INVALID_INPUT;
	}

	// set frame edge values
	memset(&frame->header, 0, sizeof(frame->header));
	frame->header.magic = RSCP::MAGIC;
	frame->header.ctrl.bits.crc = calcCRC;
	frame->header.ctrl.bits.version = RSCP::VERSION;
	setHeaderTimestamp(frame);
	frame->data = data;

	// calculate the data length
	for(size_t i = 0; i < data.size(); ++i) {
		frame->header.dataLength += sizeof(SRscpValue) - sizeof(data[i].data) + data[i].length;
	}

	// in case the CRC has to be calculated we need to generate a new frame buffer which then calculates the CRC
	if(calcCRC) {
		SRscpFrameBuffer frameBuffer;
		int32_t iResult = createFrameAsBuffer(&frameBuffer, *frame, calcCRC);
		if(iResult != RSCP::OK) {
			return iResult;
		}
		// get the CRC from the frame buffer
		memcpy(&frame->CRC, &frameBuffer.data + frameBuffer.dataLength - sizeof(frame->CRC), sizeof(frame->CRC));
		// free the buffer data again
		destroyFrameData(frameBuffer);
	}
	return RSCP::OK;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
testq %rsi, %rsi
je 0x48cb
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rsi)
andw $0x0, 0x10(%rsi)
movw $0xdce3, (%rsi)         # imm = 0xDCE3
movzbl %bpl, %eax
shll $0xc, %eax
orl $0x100, %eax            # imm = 0x100
movw %ax, 0x2(%rsi)
callq 0x4396
leaq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0x505c
movq (%r14), %rcx
movq 0x8(%r14), %rax
subq %rcx, %rax
pushq $0xf
popq %rsi
cqto
idivq %rsi
addq $0x5, %rcx
subq $0x1, %rax
jb 0x48ac
movzwl (%rcx), %edx
addw 0x10(%rbx), %dx
addl $0x7, %edx
movw %dx, 0x10(%rbx)
addq $0xf, %rcx
jmp 0x4892
xorl %r14d, %r14d
testb %bpl, %bpl
je 0x48e3
movq %rsp, %rsi
pushq $0x1
popq %rcx
movq %rbx, %rdx
callq 0x46ac
testl %eax, %eax
je 0x48d1
movl %eax, %r14d
jmp 0x48e3
pushq $-0x1
popq %r14
jmp 0x48e3
movq %rsp, %rsi
movl 0x8(%rsi), %eax
movl -0x20(%rsp,%rax,8), %eax
movl %eax, 0x30(%rbx)
callq 0x502e
movl %r14d, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::allocateMemory(SRscpValue*, unsigned long)
bool RscpProtocol::allocateMemory(SRscpValue* value, size_t size)  {
	// sanity check
	if(value == NULL) {
		return false;
	}
	// if no data is allocated yet -> allocate full size
	if(value->data == NULL) {
		if(size == 0) {
			return true;
		}
		value->data = (uint8_t *) malloc(size);
		return (value->data != NULL);
	}
	else {
		// if data is already allocated -> reallocate to the correct size
		uint8_t *ucTmp = (uint8_t *) realloc(value->data, size);
		if(ucTmp != NULL) {
			value->data = ucTmp;
			return true;
		}
	}
	return false;
}

// Assembly:
testq %rsi, %rsi
je 0x4915
pushq %rbx
movq %rsi, %rbx
movq 0x7(%rsi), %rdi
testq %rdi, %rdi
je 0x4918
movq %rdx, %rsi
callq 0x2260
testq %rax, %rax
je 0x4935
movq %rax, 0x7(%rbx)
jmp 0x4931
xorl %eax, %eax
retq
testq %rdx, %rdx
je 0x4931
movq %rdx, %rdi
callq 0x21d0
movq %rax, 0x7(%rbx)
testq %rax, %rax
setne %al
jmp 0x4937
movb $0x1, %al
jmp 0x4937
xorl %eax, %eax
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::parseData(unsigned char const*, unsigned int const&, std::vector<SRscpValue, std::allocator<SRscpValue>>&)
int32_t RscpProtocol::parseData(const uint8_t* data, const uint32_t & length, std::vector<SRscpValue> & vecValues) {
	// sanity check
	if(data == NULL) {
		return RSCP::ERR_INVALID_INPUT;
	}
	// start parsing
	uint32_t uiPos = 0;
	SRscpValue * value = reinterpret_cast<SRscpValue *>(((uint8_t*)data) + uiPos);

	// check the boundaries of the buffer
	while((uiPos < length) && ((uiPos + value->length) <= length)) {
		// parse the data
		SRscpValue newVal;
		newVal.tag = value->tag;
		newVal.dataType = value->dataType;
		newVal.length = value->length;
		if(value->length > 0) {
			// allocate data memory for each value separately
			newVal.data = (uint8_t *) malloc(value->length);
			if(newVal.data == NULL) {
				// not enough memory, return only what parsed until now
				destroyValueData(vecValues);
				return RSCP::ERR_NO_MEMORY;
			}
			memcpy(newVal.data, &value->data, value->length);
		}
		else {
			// set NULL pointer as no data is in this tag
			newVal.data = NULL;
		}
		//push new value to the return vector
		vecValues.push_back(newVal);
		// increment value pointer
		uiPos += sizeof(SRscpValue) - sizeof(newVal.data) + value->length;
		value =  reinterpret_cast<SRscpValue *>(((uint8_t*)data) + uiPos);
	}

	// return all collected values
	return uiPos;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rsi, %rsi
je 0x4ac6
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %rbp
movq %rdi, 0x10(%rsp)
xorl %ebx, %ebx
movq %rsi, %r13
movl (%r12), %eax
cmpl %eax, %ebx
jae 0x4ada
movzwl 0x5(%r13), %r15d
leal (%rbx,%r15), %ecx
cmpl %eax, %ecx
ja 0x4ada
movl (%r13), %eax
movl %eax, (%rsp)
movb 0x4(%r13), %al
movb %al, 0x4(%rsp)
movw %r15w, 0x5(%rsp)
testw %r15w, %r15w
je 0x4aa5
movq %r15, %rdi
callq 0x21d0
movq %rax, 0x7(%rsp)
testq %rax, %rax
je 0x4aca
leaq 0x7(%r13), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x2120
jmp 0x4aab
andq $0x0, 0x7(%rsp)
movq %r14, %rdi
movq %rsp, %rsi
callq 0x513c
movzwl 0x5(%r13), %eax
addl %eax, %ebx
addl $0x7, %ebx
leaq (%rbx,%rbp), %r13
jmp 0x4a4e
pushq $-0x1
jmp 0x4ad9
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x4aec
pushq $-0x2
popq %rbx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::destroyValueData(std::vector<SRscpValue, std::allocator<SRscpValue>>&)
int32_t RscpProtocol::destroyValueData(std::vector<SRscpValue> & value) {
	for(size_t i = 0; i < value.size(); ++i) {
		destroyValueData(value[i]);
	}
	value.clear();
	return RSCP::OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
xorl %r14d, %r14d
pushq $0xf
popq %r15
xorl %r12d, %r12d
movq (%rbx), %rsi
movq 0x8(%rbx), %rcx
movq %rcx, %rax
subq %rsi, %rax
cqto
idivq %r15
cmpq %rax, %r12
jae 0x4b29
addq %r14, %rsi
callq 0x4fe4
incq %r12
addq $0xf, %r14
jmp 0x4b01
cmpq %rsi, %rcx
je 0x4b32
movq %rsi, 0x8(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::getValueAsString[abi:cxx11](SRscpValue const*)
std::string RscpProtocol::getValueAsString(const SRscpValue* value) {
	// sanity check
	std::string strValue;
	if((value == NULL) || (value->data == NULL)) {
		return strValue;
	}
	// extract only the bytes that are defined by the length
	strValue.assign((char*)value->data, value->length);
	return strValue;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
testq %rdx, %rdx
je 0x4b71
movq 0x7(%rdx), %rsi
testq %rsi, %rsi
je 0x4b71
movzwl 0x5(%rdx), %edx
movq %rbx, %rdi
callq 0x21e0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x20b0
movq %r14, %rdi
callq 0x2280
nop
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::createValue(SRscpValue*, unsigned int const&, unsigned char const*, unsigned short const&, unsigned char const&)
int32_t RscpProtocol::createValue(SRscpValue* response, const SRscpTag & tag, const uint8_t * data, const uint16_t & dataLength, const uint8_t &dataType) {
	// sanity check
	if(response == NULL) {
		return RSCP::ERR_INVALID_INPUT;
	}
	// reset the memory of the response value to zero
	memset(response, 0, sizeof(SRscpValue));
	// calculate the new tag size
	uint16_t newTagLength = dataLength;
	// check boundaries
	if(newTagLength > 0xFFF8) {
		return RSCP::ERR_DATA_LIMIT_EXCEEDED;
	}
	// re-allocate the structure memory
	if(allocateMemory(response, newTagLength) == false) {
		return RSCP::ERR_NO_MEMORY;
	}
	// copy data
	response->tag = tag;
	response->dataType = dataType;
	response->length = dataLength;
	// copy into the position of the data pointer
	if(response->length > 0) {
		memcpy(response->data, data, dataLength);
	}
	return RSCP::OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x4bc3
movq %r8, %r14
movq %rdx, %r13
movq %rsi, %r15
andq $0x0, 0x7(%rsi)
andq $0x0, (%rsi)
movzwl (%r8), %edx
cmpq $0xfff8, %rdx           # imm = 0xFFF8
jbe 0x4bc7
pushq $-0x7
jmp 0x4c0c
pushq $-0x1
jmp 0x4c0c
movq %r9, %r12
movq %rcx, %rbx
movq %r15, %rsi
callq 0x48f0
testb %al, %al
je 0x4c0a
movl (%r13), %eax
movl %eax, (%r15)
movb (%r12), %al
movb %al, 0x4(%r15)
movzwl (%r14), %eax
movw %ax, 0x5(%r15)
xorl %ebp, %ebp
testw %ax, %ax
je 0x4c0d
movq 0x7(%r15), %rdi
movzwl (%r14), %edx
movq %rbx, %rsi
callq 0x2120
jmp 0x4c0d
pushq $-0x2
popq %rbp
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/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::createValue(SRscpValue*, unsigned int const&, std::vector<SRscpValue, std::allocator<SRscpValue>> const&)
int32_t RscpProtocol::createValue(SRscpValue* response, const SRscpTag & tag, const std::vector<SRscpValue> & value) {
	// sanity check
	if(response == NULL) {
		return RSCP::ERR_INVALID_INPUT;
	}
	// reset the memory of the response value to zero
	memset(response, 0, sizeof(SRscpValue));
	// calculate the new tag size
	uint32_t newTagLength = 0;
	for(size_t i = 0; i < value.size(); ++i) {
		newTagLength += sizeof(SRscpValue) - sizeof(value[i].data) + value[i].length;
	}
	// check boundaries
	if(newTagLength > 0xFFF8) {
		return RSCP::ERR_DATA_LIMIT_EXCEEDED;
	}
	// re-allocate the structure memory
	if(allocateMemory(response, newTagLength) == false) {
		return RSCP::ERR_NO_MEMORY;
	}
	// first add the TAG for a container
	response->tag = tag;
	response->dataType = RSCP::eTypeContainer;
	response->length = newTagLength;

	// copy data
	size_t sPos = 0;
	for(size_t i = 0; i < value.size(); ++i) {
		SRscpValue *newData = reinterpret_cast<SRscpValue *> (((uint8_t*)response->data) + sPos);
		newData->tag = value[i].tag;
		newData->dataType = value[i].dataType;
		newData->length = value[i].length;
		if(newData->length > 0) {
			// copy into the position of the data pointer and not into the data pointer itself as the data is appended
			memcpy(&newData->data, value[i].data, newData->length);
		}
		sPos += sizeof(SRscpValue) - sizeof(value[i].data) + value[i].length;
	}
	// all added successfully
	return RSCP::OK;
}

// Assembly:
testq %rsi, %rsi
je 0x4c80
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r14
andq $0x0, 0x7(%rsi)
andq $0x0, (%rsi)
movq (%rcx), %rcx
movq 0x8(%rbx), %rax
subq %rcx, %rax
pushq $0xf
popq %r12
cqto
idivq %r12
addq $0x5, %rcx
xorl %r13d, %r13d
subq $0x1, %rax
jb 0x4c70
movzwl (%rcx), %edx
addl %edx, %r13d
addl $0x7, %r13d
addq $0xf, %rcx
jmp 0x4c5a
cmpl $0xfff8, %r13d          # imm = 0xFFF8
jbe 0x4c84
pushq $-0x7
jmp 0x4d12
pushq $-0x1
popq %rax
retq
movl %r13d, %edx
movq %r14, %rsi
callq 0x48f0
testb %al, %al
je 0x4d10
movl (%r15), %eax
movl %eax, (%r14)
movb $0xe, 0x4(%r14)
movw %r13w, 0x5(%r14)
movq (%rbx), %rcx
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %r15d, %r15d
movq 0x8(%rbx), %rax
subq %rcx, %rax
cqto
idivq %r12
cmpq %rax, %r15
jae 0x4d15
movq 0x7(%r14), %rdi
movl (%rcx,%r13), %eax
movl %eax, (%rdi,%rbp)
movq (%rbx), %rcx
movb 0x4(%rcx,%r13), %al
movb %al, 0x4(%rdi,%rbp)
movzwl 0x5(%rcx,%r13), %edx
movw %dx, 0x5(%rdi,%rbp)
testq %rdx, %rdx
je 0x4cfa
addq %rbp, %rdi
addq $0x7, %rdi
movq 0x7(%rcx,%r13), %rsi
callq 0x2120
movq (%rbx), %rcx
movzwl 0x5(%rcx,%r13), %eax
addq %rax, %rbp
addq $0x7, %rbp
incq %r15
addq $0xf, %r13
jmp 0x4cae
pushq $-0x2
popq %rax
jmp 0x4d17
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::appendValue(SRscpValue*, unsigned int const&, unsigned char const*, unsigned short const&, unsigned char const&)
int32_t RscpProtocol::appendValue(SRscpValue* response, const SRscpTag & tag, const uint8_t * data, const uint16_t & dataLength, const uint8_t &dataType) {
	// sanity check
	if(response == NULL) {
		return RSCP::ERR_INVALID_INPUT;
	}
	// calculate the new tag size
	uint16_t newTagLength = sizeof(SRscpValue) - sizeof(response->data) + dataLength;
	// check boundaries
	if(response->length + newTagLength > 0xFFF8) {
		return RSCP::ERR_DATA_LIMIT_EXCEEDED;
	}
	// re-allocate the structure memory
	if(allocateMemory(response, response->length + newTagLength) == false) {
		return RSCP::ERR_NO_MEMORY;
	}
	// copy data
	SRscpValue *newData = reinterpret_cast<SRscpValue *>(response->data + response->length);
	newData->tag = tag;
	newData->dataType = dataType;
	newData->length = dataLength;
	// copy into the position of the data pointer and not into the data pointer itself as the data is appended
	if(newData->length > 0) {
		memcpy(&newData->data, data, dataLength);
	}
	// increment the total length by the new tag
	response->length += newTagLength;
	return RSCP::OK;
}

// Assembly:
testq %rsi, %rsi
je 0x4d5a
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r15
movq %rcx, %r14
movq %rsi, %rbx
movzwl (%r8), %ebp
addl $0x7, %ebp
movzwl 0x5(%rsi), %ecx
movzwl %bp, %eax
addl %ecx, %eax
cmpl $0xfff8, %eax           # imm = 0xFFF8
jbe 0x4d5e
pushq $-0x7
jmp 0x4db4
pushq $-0x1
popq %rax
retq
movq %r9, %r12
movq %rdx, %r13
movl %eax, %edx
movq %rbx, %rsi
callq 0x48f0
testb %al, %al
je 0x4db2
movq 0x7(%rbx), %rdi
movzwl 0x5(%rbx), %eax
movl (%r13), %ecx
movl %ecx, (%rdi,%rax)
movb (%r12), %cl
movb %cl, 0x4(%rdi,%rax)
movzwl (%r15), %ecx
movw %cx, 0x5(%rdi,%rax)
testw %cx, %cx
je 0x4daa
addq %rax, %rdi
addq $0x7, %rdi
movzwl (%r15), %edx
movq %r14, %rsi
callq 0x2120
addw %bp, 0x5(%rbx)
xorl %eax, %eax
jmp 0x4db5
pushq $-0x2
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::appendValue(SRscpValue*, std::vector<SRscpValue, std::allocator<SRscpValue>> const&)
int32_t RscpProtocol::appendValue(SRscpValue* response, const std::vector<SRscpValue> & value) {
	// sanity check
	if(response == NULL) {
		return RSCP::ERR_INVALID_INPUT;
	}
	// calculate the new tag size
	uint32_t newTagLength = 0;
	for(size_t i = 0; i < value.size(); ++i) {
		newTagLength += sizeof(SRscpValue) - sizeof(value[i].data) + value[i].length;
	}
	// check boundaries
	if(response->length + newTagLength > 0xFFF8) {
		return RSCP::ERR_DATA_LIMIT_EXCEEDED;
	}
	// re-allocate the structure memory
	if(allocateMemory(response, response->length + newTagLength) == false) {
		return RSCP::ERR_NO_MEMORY;
	}
	// copy data
	size_t sPos = 0;
	for(size_t i = 0; i < value.size(); ++i) {
		SRscpValue *newData = reinterpret_cast<SRscpValue *> (response->data + response->length + sPos);
		newData->tag = value[i].tag;
		newData->dataType = value[i].dataType;
		newData->length = value[i].length;
		if(newData->length > 0) {
			// copy into the position of the data pointer and not into the data pointer itself as the data is appended
			memcpy(&newData->data, value[i].data, newData->length);
		}
		sPos += sizeof(SRscpValue) - sizeof(value[i].data) + value[i].length;
	}
	// increment the total length by the new tag
	response->length += newTagLength;
	// all added successfully
	return RSCP::OK;
}

// Assembly:
testq %rsi, %rsi
je 0x4f42
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movq (%rdx), %rcx
movq 0x8(%rdx), %rax
subq %rcx, %rax
pushq $0xf
popq %rsi
cqto
idivq %rsi
addq $0x5, %rcx
xorl %r12d, %r12d
subq $0x1, %rax
jb 0x4f2d
movzwl (%rcx), %edx
addl %edx, %r12d
addl $0x7, %r12d
addq $0xf, %rcx
jmp 0x4f17
movzwl 0x5(%rbx), %eax
addl %r12d, %eax
cmpl $0xfff8, %eax           # imm = 0xFFF8
jbe 0x4f46
pushq $-0x7
jmp 0x4fcb
pushq $-0x1
popq %rax
retq
movl %eax, %edx
movq %rbx, %rsi
callq 0x48f0
testb %al, %al
je 0x4fc9
movq (%r14), %rcx
xorl %r13d, %r13d
xorl %ebp, %ebp
xorl %r15d, %r15d
movq 0x8(%r14), %rax
subq %rcx, %rax
cqto
pushq $0xf
popq %rsi
idivq %rsi
cmpq %rax, %r15
jae 0x4fce
movzwl 0x5(%rbx), %edi
addq 0x7(%rbx), %rdi
movl (%rcx,%r13), %eax
movl %eax, (%rbp,%rdi)
movq (%r14), %rcx
movb 0x4(%rcx,%r13), %al
movb %al, 0x4(%rbp,%rdi)
movzwl 0x5(%rcx,%r13), %edx
movw %dx, 0x5(%rbp,%rdi)
testq %rdx, %rdx
je 0x4fb3
addq %rbp, %rdi
addq $0x7, %rdi
movq 0x7(%rcx,%r13), %rsi
callq 0x2120
movq (%r14), %rcx
movzwl 0x5(%rcx,%r13), %eax
addq %rax, %rbp
addq $0x7, %rbp
incq %r15
addq $0xf, %r13
jmp 0x4f5f
pushq $-0x2
popq %rax
jmp 0x4fd5
addw %r12w, 0x5(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::destroyValueData(SRscpValue*)
int32_t RscpProtocol::destroyValueData(SRscpValue * value) {
	if(value == NULL) {
		return RSCP::ERR_INVALID_INPUT;
	}
	if(value->data != NULL) {
		free(value->data);
		value->data = NULL;
	}
	return RSCP::OK;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x5007
movq %rsi, %r14
movq 0x7(%rsi), %rdi
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x500a
callq 0x21c0
andq $0x0, 0x7(%r14)
jmp 0x500a
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/RscpProtocol.cpp
// Function: RscpProtocol::destroyFrameData(SRscpFrameBuffer*)
int32_t RscpProtocol::destroyFrameData(SRscpFrameBuffer * frameBuffer) {
	if(frameBuffer == NULL) {
		return RSCP::ERR_INVALID_INPUT;
	}
	if(frameBuffer->data != NULL) {
		free(frameBuffer->data);
		frameBuffer->data = NULL;
	}
	return RSCP::OK;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x504f
movq %rsi, %r14
movq (%rsi), %rdi
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x5052
callq 0x21c0
andq $0x0, (%r14)
jmp 0x5052
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/AES.cpp
// Function: AES::KeyExpansion(unsigned char const*)
void AES::KeyExpansion(const unsigned char * key)
	{
	int i;
	unsigned long temp, * Wb = reinterpret_cast<unsigned long*>(W); // todo not portable - Endian problems
	if (Nk <= 6)
		{
		// todo - memcpy
		for (i = 0; i < 4*Nk; i++)
			W[i] = key[i];
		for (i = Nk; i < Nb*(Nr+1); i++)
			{
			temp = Wb[i-1];
			if ((i%Nk) == 0)
				temp = SubByte(RotByte(temp)) ^ Rcon[i/Nk];
			Wb[i] = Wb[i - Nk]^temp;
			}
		}
	else
		{
		// todo - memcpy
		for (i = 0; i < 4*Nk; i++)
			W[i] = key[i];
		for (i = Nk; i < Nb*(Nr+1); i++)
			{
			temp = Wb[i-1];
			if ((i%Nk) == 0)
				temp = SubByte(RotByte(temp)) ^ Rcon[i/Nk];
			else if ((i%Nk) == 4)
				temp = SubByte(temp);
			Wb[i] = Wb[i - Nk]^temp;
			}
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xc(%rdi), %r15
movslq 0x4(%rdi), %r8
leal (,%r8,4), %eax
movl %r8d, %r13d
cmpq $0x7, %r8
movq %r8, (%rsp)
jge 0x5371
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x52ff
movb (%rsi,%rcx), %dl
movb %dl, 0xc(%rbx,%rcx)
incq %rcx
jmp 0x52ee
movslq (%rbx), %rax
movslq 0x8(%rbx), %r14
incq %r14
imulq %rax, %r14
xorl %r12d, %r12d
movq %r8, %rbp
cmpq %r14, %rbp
jge 0x5404
movq -0x8(%r15,%rbp,8), %rdi
leal (%r12,%r13), %ecx
movl %ecx, %eax
cltd
idivl %r8d
movl %edx, %esi
movl %ecx, %eax
cltd
idivl %r13d
testl %esi, %esi
jne 0x5361
movl %eax, %ebx
movq %rdi, %rax
shlq $0x18, %rax
shrq $0x8, %rdi
orq %rax, %rdi
callq 0x5413
movq (%rsp), %r8
movq %rax, %rdi
movslq %ebx, %rax
leaq 0xe3a3(%rip), %rcx      # 0x13700
xorq (%rcx,%rax,8), %rdi
xorq (%r15,%r12,8), %rdi
movq %rdi, (%r15,%rbp,8)
incq %rbp
incq %r12
jmp 0x5313
movl %eax, %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x5386
movb (%rsi,%rcx), %dl
movb %dl, 0xc(%rbx,%rcx)
incq %rcx
jmp 0x5375
movslq (%rbx), %rax
movslq 0x8(%rbx), %r12
incq %r12
imulq %rax, %r12
movq %r8, %r14
cmpq %r12, %r14
jge 0x5404
movq 0x4(%rbx,%r14,8), %rdi
movl %r14d, %eax
xorl %edx, %edx
divl %r13d
movl %edx, %ecx
movl %r14d, %eax
xorl %edx, %edx
divl %r8d
cmpl $0x4, %ecx
je 0x53e7
testl %ecx, %ecx
jne 0x53f3
movl %eax, %ebp
movq %rdi, %rax
shlq $0x18, %rax
shrq $0x8, %rdi
orq %rax, %rdi
callq 0x5413
movq (%rsp), %r8
movq %rax, %rdi
movl %ebp, %eax
leaq 0xe31f(%rip), %rcx      # 0x13700
xorq (%rcx,%rax,8), %rdi
jmp 0x53f3
callq 0x5413
movq (%rsp), %r8
movq %rax, %rdi
xorq (%r15), %rdi
movq %rdi, 0xc(%rbx,%r14,8)
incq %r14
addq $0x8, %r15
jmp 0x5397
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/AES.cpp
// Function: (anonymous namespace)::SubByte(unsigned long)
unsigned long SubByte(unsigned long data)
	{ // does the SBox on this 4 byte data
	unsigned result = 0;
	result = byte_sub[data>>24];
	result <<= 8;
	result |= byte_sub[(data>>16)&255];
	result <<= 8;
	result |= byte_sub[(data>>8)&255];
	result <<= 8;
	result |= byte_sub[data&255];
	return result;
	}

// Assembly:
movl %edi, %eax
movl %edi, %ecx
movzbl %dil, %edx
shrq $0x18, %rdi
leaq 0x164ca(%rip), %rsi     # 0x1b8f0
movzbl (%rdi,%rsi), %edi
shrl $0x10, %eax
movl $0xff, %r8d
andl %r8d, %eax
movzbl (%rax,%rsi), %eax
shll $0x10, %edi
shll $0x8, %eax
orl %edi, %eax
shrl $0x8, %ecx
andl %r8d, %ecx
movzbl (%rcx,%rsi), %ecx
orl %eax, %ecx
shll $0x8, %ecx
movzbl (%rdx,%rsi), %eax
orq %rcx, %rax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/AES.cpp
// Function: AES::SetParameters(int, int)
void AES::SetParameters(int keylength, int blocklength)
	{
	Nk = Nr = Nb = 0; // default values

	if ((keylength != 128) && (keylength != 192) && (keylength != 256))
		return; // nothing - todo - throw error?
	if ((blocklength != 128) && (blocklength != 192) && (blocklength != 256))
		return; // nothing - todo - throw error?

	static int const parameters[] = {
//Nk*32 128     192     256
		10, 	12,  	14,  // Nb*32 = 128
		12, 	12,  	14,  // Nb*32 = 192
		14, 	14,  	14,  // Nb*32 = 256
		};

	// legal parameters, so fire it up
	Nk = keylength  /32;
	Nb = blocklength/32;
	Nr = parameters[((Nk-4)/2 + 3*(Nb-4)/2)];
	}

// Assembly:
andq $0x0, (%rdi)
andl $0x0, 0x8(%rdi)
cmpl $0x80, %esi
je 0x547a
cmpl $0x100, %esi            # imm = 0x100
je 0x547a
cmpl $0xc0, %esi
jne 0x54b9
cmpl $0x80, %edx
je 0x5492
cmpl $0x100, %edx            # imm = 0x100
je 0x5492
cmpl $0xc0, %edx
jne 0x54b9
shrl $0x5, %esi
movl %esi, 0x4(%rdi)
shrl $0x5, %edx
movl %edx, (%rdi)
addl $-0x4, %esi
shrl %esi
leal (%rdx,%rdx,2), %eax
addl $-0xc, %eax
shrl %eax
addl %esi, %eax
leaq 0xa4dd(%rip), %rcx      # 0xf990
movl (%rcx,%rax,4), %eax
movl %eax, 0x8(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/AES.cpp
// Function: AES::Encrypt(unsigned char const*, unsigned char*, unsigned long, AES::BlockMode)
void AES::Encrypt(const unsigned char * datain, unsigned char * dataout, unsigned long numBlocks, BlockMode mode)
	{
	if (0 == numBlocks)
		return;
	unsigned int blocksize = Nb*4;
	switch (mode)
		{
		case ECB :
			while (numBlocks)
				{
				EncryptBlock(datain,dataout);
				datain   += blocksize;
				dataout  += blocksize;
				--numBlocks;
				}
			break;
		case CBC :
			{
			unsigned char buffer[32]; // max blocksize
			memcpy(buffer,iv,blocksize); // clear out - todo - allow setting the Initialization Vector - needed for security
			while (numBlocks)
				{
				for (unsigned int pos = 0; pos < blocksize; ++pos)
					buffer[pos] ^= *datain++;
				EncryptBlock(buffer,dataout);
				memcpy(buffer,dataout,blocksize);
				dataout  += blocksize;
				--numBlocks;
				}
			}
			break;
		default :
			break;
		}
	}

// Assembly:
testq %rcx, %rcx
je 0x9c02
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movl (%rdi), %eax
shll $0x2, %eax
cmpl $0x1, %r8d
je 0x9b92
testl %r8d, %r8d
jne 0x9bf4
movl %eax, %r13d
subq $0x1, %rbx
jb 0x9bf4
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x54ea
addq %r13, %r15
addq %r13, %r14
jmp 0x9b76
movq %r12, 0x8(%rsp)
leaq 0x1ec(%r12), %rsi
movl %eax, %r13d
leaq 0x10(%rsp), %rdi
movq %r13, %rdx
callq 0x2120
subq $0x1, %rbx
jb 0x9bf4
xorl %ebp, %ebp
movq 0x8(%rsp), %rdi
cmpq %rbp, %r13
je 0x9bce
movb (%r15,%rbp), %al
xorb %al, 0x10(%rsp,%rbp)
incq %rbp
jmp 0x9bbc
leaq 0x10(%rsp), %r12
movq %r12, %rsi
movq %r14, %rdx
callq 0x54ea
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2120
addq %r13, %r14
addq %rbp, %r15
jmp 0x9baf
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/AES.cpp
// Function: AES::Decrypt(unsigned char const*, unsigned char*, unsigned long, AES::BlockMode)
void AES::Decrypt(const unsigned char * datain, unsigned char * dataout, unsigned long numBlocks, BlockMode mode)
	{
	if (0 == numBlocks)
		return;
	unsigned int blocksize = Nb*4;
	switch (mode)
		{
		case ECB :
			while (numBlocks)
				{
				DecryptBlock(datain,dataout);
				datain   += blocksize;
				dataout  += blocksize;
				--numBlocks;
				}
			break;
		case CBC :
			{
			int iBuf = 0;
			unsigned char buffer[2][32]; // max blocksize
			memcpy(buffer[iBuf], datain, blocksize);
			DecryptBlock(datain,dataout); // do first block
			for (unsigned int pos = 0; pos < blocksize; ++pos)
				*dataout++ ^= iv[pos];
			datain += blocksize;
			numBlocks--;

			while (numBlocks)
				{
				memcpy(buffer[iBuf^1], datain, blocksize);
				DecryptBlock(datain,dataout); // do first block
				for (unsigned int pos = 0; pos < blocksize; ++pos)
					*dataout++ ^= *(buffer[iBuf]+pos);
				datain  += blocksize;
				iBuf ^= 1;
				--numBlocks;
				}
			}
			break;
		default :
			break;
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, 0x8(%rsp)
testq %rcx, %rcx
je 0xe644
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq 0x8(%rsp), %rax
movl (%rax), %eax
shll $0x2, %eax
cmpl $0x1, %r8d
je 0xe59d
testl %r8d, %r8d
jne 0xe644
movl %eax, %r12d
subq $0x1, %rbx
jb 0xe644
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x9e68
addq %r12, %r15
addq %r12, %r14
jmp 0xe57b
movl %eax, %r13d
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2120
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x9e68
xorl %eax, %eax
cmpq %rax, %r13
je 0xe5dc
movq 0x8(%rsp), %rcx
movb 0x1ec(%rcx,%rax), %cl
xorb %cl, (%r14,%rax)
incq %rax
jmp 0xe5c2
addq %rax, %r14
xorl %r12d, %r12d
decq %rbx
je 0xe644
addq %r13, %r15
movl %r12d, %ebp
xorl $0x1, %ebp
movq %rbp, %rax
shlq $0x5, %rax
leaq (%rsp,%rax), %rdi
addq $0x10, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2120
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x9e68
movl %r12d, %eax
shlq $0x5, %rax
leaq (%rsp,%rax), %rcx
addq $0x10, %rcx
xorl %eax, %eax
cmpq %rax, %r13
je 0xe63c
movb (%rcx,%rax), %dl
xorb %dl, (%r14,%rax)
incq %rax
jmp 0xe62b
addq %rax, %r14
movl %ebp, %r12d
jmp 0xe5e2
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/AES.cpp
// Function: (anonymous namespace)::CheckInverses(bool)
bool CheckInverses(bool create)
	{
	unsigned int a,b; // need int here to prevent wraps in loop
	if (create == true)
		gf2_8_inv[0] = 0;
	else if (gf2_8_inv[0] != 0)
		return false;
	for (a = 1; a <= 255; a++)
		{
		b = 1;
		while (GF2_8_mult(a,b) != 1)
			b++;

		if (create == true)
			gf2_8_inv[a] = b;
		else if (gf2_8_inv[a] != b)
			return false;
		}
	return true;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movb $0x0, 0xd127(%rip)      # 0x1b9f0
pushq $0x1
popq %r14
leaq 0xd11c(%rip), %r15      # 0x1b9f0
cmpq $0x100, %r14            # imm = 0x100
je 0xe8fe
xorl %ebp, %ebp
movzbl %r14b, %ebx
incb %bpl
movzbl %bpl, %esi
movl %ebx, %edi
callq 0x9e36
cmpb $0x1, %al
jne 0xe8e3
movb %bpl, (%r14,%r15)
incq %r14
jmp 0xe8d4
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/rellla[P]E3DC-Rscp/AES.cpp
// Function: (anonymous namespace)::CheckByteSub(bool)
bool CheckByteSub(bool create)
	{
	if (CheckInverses(create) == false)
		return false; // we cannot do this without inverses

	unsigned int x,y; // need ints here to prevent wrap in loop
	for (x = 0; x <= 255; x++)
		{
		y = gf2_8_inv[x]; // inverse to start with

		// affine transform
		y = BitSum(y&0xF1) | (BitSum(y&0xE3)<<1) | (BitSum(y&0xC7)<<2) | (BitSum(y&0x8F)<<3) |
			(BitSum(y&0x1F)<<4) | (BitSum(y&0x3E)<<5) | (BitSum(y&0x7C)<<6) | (BitSum(y&0xF8)<<7);
		y = y ^ 0x63;
		if (create == true)
			byte_sub[x] = y;
		else if (byte_sub[x] != y)
			return false;
		}
	return true;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
callq 0xe8bb
xorl %eax, %eax
cmpq $0x100, %rax            # imm = 0x100
je 0xe9f0
leaq 0xd0bf(%rip), %rcx      # 0x1b9f0
movzbl (%rax,%rcx), %ebp
movl %ebp, %edi
andl $-0xf, %edi
movq %rax, 0x10(%rsp)
callq 0xe9ff
movb %al, 0xf(%rsp)
movl %ebp, %edi
andl $-0x1d, %edi
callq 0xe9ff
movl %eax, %r14d
movl %ebp, %edi
andl $-0x39, %edi
callq 0xe9ff
movl %eax, %r15d
movl %ebp, %edi
andl $-0x71, %edi
callq 0xe9ff
movl %eax, %r12d
movl %ebp, %edi
andl $0x1f, %edi
callq 0xe9ff
movl %eax, %ebx
movl %ebp, %edi
andl $0x3e, %edi
callq 0xe9ff
movl %eax, %r13d
movl %ebp, %edi
andl $0x7c, %edi
callq 0xe9ff
movb %al, 0xe(%rsp)
andl $-0x8, %ebp
movl %ebp, %edi
callq 0xe9ff
addb %r14b, %r14b
addb 0xf(%rsp), %r14b
shlb $0x2, %r15b
orb %r14b, %r15b
shlb $0x3, %r12b
orb %r15b, %r12b
shlb $0x4, %bl
orb %r12b, %bl
shlb $0x5, %r13b
orb %bl, %r13b
movb 0xe(%rsp), %cl
shlb $0x6, %cl
shlb $0x7, %al
orb %cl, %al
orb %r13b, %al
xorb $0x63, %al
movq 0x10(%rsp), %rcx
leaq 0xcf10(%rip), %rdx      # 0x1b8f0
movb %al, (%rcx,%rdx)
movq 0x10(%rsp), %rax
incq %rax
jmp 0xe91e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq