LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/matteorr[P]EarleyParser/EarleyParser.cpp
// Function: EarleyParser::~EarleyParser()
EarleyParser::~EarleyParser()
{
	for( unsigned int i = 0; i <= this->inputVector.size(); i++ )
	{
		//int j = 0;
		//cout << i << "  *****************************************************" << endl << "*****************************************************" << endl;
		for( vector<State*>::iterator it = this->earleyParserChart.at(i).begin(); it != this->earleyParserChart.at(i).end(); it++ )
		{
			//j++;
			delete *it;

		}
		//cout << endl << endl << "DELETED STATEs: " << j << endl << endl;

	}

	for( vector<Node*>::iterator it = this->returnVector.begin(); it != this->returnVector.end(); it++ )
	{
		delete *(it);
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xb692(%rip), %rax      # 0xdd08
movq %rax, (%rdi)
xorl %r14d, %r14d
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
movq 0x80(%rbx), %rcx
movq 0x88(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq %r14, %rdx
jbe 0x279d
movq 0x80(%rbx), %rax
movq 0x88(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq %r14, %rdx
jbe 0x279d
leaq (%r14,%r14,2), %r12
movq (%rcx,%r12,8), %r13
cmpq 0x8(%rax,%r12,8), %r13
je 0x270f
movq (%r13), %rdi
testq %rdi, %rdi
je 0x26e8
movq (%rdi), %rax
callq *0x8(%rax)
addq $0x8, %r13
movq 0x80(%rbx), %rax
movq 0x88(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r15, %rdx
cmpq %r14, %rdx
ja 0x26d2
jmp 0x279d
incl %r14d
movq 0xa0(%rbx), %rax
subq 0x98(%rbx), %rax
sarq $0x5, %rax
cmpq %r14, %rax
jae 0x2686
movq 0xb0(%rbx), %r14
cmpq 0xb8(%rbx), %r14
je 0x2751
movq (%r14), %rdi
testq %rdi, %rdi
je 0x274b
movq (%rdi), %rax
callq *0x8(%rax)
addq $0x8, %r14
jmp 0x2734
movq 0xb0(%rbx), %rdi
testq %rdi, %rdi
je 0x2762
callq 0x21a0
leaq 0x98(%rbx), %rdi
callq 0x60da
leaq 0x80(%rbx), %rdi
callq 0x6128
leaq 0x48(%rbx), %rdi
callq 0x6432
addq $0x10, %rbx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x650e
leaq 0x7e71(%rip), %rdi      # 0xa615
movq %r14, %rsi
xorl %eax, %eax
callq 0x2280
movq %rax, %rdi
callq 0x60cc
// File: /workspace/github_cpp_makefile_star2_O1/matteorr[P]EarleyParser/EarleyParser.cpp
// Function: EarleyParser::splitToVector(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool)
void EarleyParser::splitToVector
	(
		const std::string& inputString,
        std::vector<std::string>* outputVector,
        const std::string& separatorString,
        bool skipNullStrings
    )
{
    unsigned int pos = 0;
    outputVector->clear();

    while( pos < inputString.length() )
    {
        std::string next = inputString.substr( pos );
        unsigned int next_pos = next.find( separatorString );

        if( next_pos == static_cast<unsigned int> (std::string::npos) )
            next_pos = next.length();

        if( !skipNullStrings || next_pos > 0 )
        {
            std::string to_insert = next.substr( 0, next_pos );
            outputVector->push_back( to_insert );
        }

        pos += next_pos + separatorString.size();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, -0x2c(%rbp)
movq %rcx, %r14
movq %rdx, %rdi
movq %rsi, %rbx
movq %rdx, -0x38(%rbp)
callq 0x63a0
cmpq $0x0, 0x8(%rbx)
je 0x3351
xorl %r13d, %r13d
leaq -0x80(%rbp), %r12
movq %rbx, -0x40(%rbp)
leaq -0x60(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq $-0x1, %rcx
callq 0x2200
movq (%r14), %rsi
movq 0x8(%r14), %rcx
movq %r15, %rdi
xorl %edx, %edx
callq 0x22e0
cmpl $-0x1, %eax
jne 0x32e9
movl -0x58(%rbp), %eax
testl %eax, %eax
sete %cl
movl %eax, %ebx
testb %cl, -0x2c(%rbp)
jne 0x3327
movq %r12, %r15
movq %r12, %rdi
leaq -0x60(%rbp), %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x2200
movq -0x38(%rbp), %rdi
movq %r15, %rsi
callq 0x63e6
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x3327
callq 0x21a0
addq %rbx, %r13
addq 0x8(%r14), %r13
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x3340
callq 0x21a0
movl %r13d, %r13d
movq -0x40(%rbp), %rbx
cmpq 0x8(%rbx), %r13
jb 0x32b7
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x337a
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x337a
callq 0x21a0
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x338c
callq 0x21a0
movq %rbx, %rdi
callq 0x22f0
// File: /workspace/github_cpp_makefile_star2_O1/matteorr[P]EarleyParser/Node.cpp
// Function: Node::Node(Node*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, Production*, float)
Node::Node( Node* father, string grammarElement, vector<string> nodeProduction, Production* productionPointer, float productionProbability )
{
	this->father = father;

	this->grammarElement = grammarElement;
	this->production = nodeProduction;
	this->productionProbability = productionProbability;

	this->productionPointer = productionPointer;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movss %xmm0, -0x2c(%rbp)
movq %r8, %r14
movq %rcx, %r13
movq %rdi, %r12
leaq 0x642e(%rip), %rax      # 0xdd38
movq %rax, (%rdi)
leaq 0x8(%rdi), %rbx
leaq 0x18(%rdi), %rax
movq %rax, -0x40(%rbp)
movq %rax, 0x8(%rdi)
xorl %eax, %eax
movq %rax, 0x10(%rdi)
movb $0x0, 0x18(%rdi)
leaq 0x28(%rdi), %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rdi)
movq %rax, 0x38(%rdi)
leaq 0x48(%rdi), %rcx
movq %rcx, -0x38(%rbp)
movups %xmm0, 0x48(%rdi)
movq %rax, 0x58(%rdi)
movq %rsi, 0x40(%rdi)
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x2110
movq %r15, %rdi
movq %r13, %rsi
callq 0x8f4a
movss -0x2c(%rbp), %xmm0
movss %xmm0, 0x60(%r12)
movq %r14, 0x68(%r12)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq -0x38(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x7994
callq 0x21a0
movq %r15, %rdi
callq 0x60da
movq (%rbx), %rdi
cmpq -0x40(%rbp), %rdi
je 0x79aa
callq 0x21a0
movq %r14, %rdi
callq 0x22f0
// File: /workspace/github_cpp_makefile_star2_O1/matteorr[P]EarleyParser/Node.cpp
// Function: Node::print(bool)
float Node::print( bool printProbabilities )
{
	float prob = -1;

	cout << "Node [" << this->grammarElement << "]{";

	if( printProbabilities == true ){

		if( this->children.size() == 0 )
		{
			/*
			 * we are in a leaf node
			 */
			prob = this->productionProbability;

		}else{

			prob = this->productionProbability;
			for( vector<Node*>::iterator it = this->children.begin(); it != this->children.end(); it++ )
			{
				prob = prob * (*it)->print( printProbabilities );
			}
		}
	}else{

		for( vector<Node*>::iterator it = this->children.begin(); it != this->children.end(); it++ )
		{
			prob = (*it)->print( printProbabilities );
		}
	}
	cout << "prob [" << prob << "]}";

	return prob;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movq 0x5183(%rip), %r15      # 0xdfd8
leaq 0x1959(%rip), %rsi      # 0xa7b5
movl $0x6, %edx
movq %r15, %rdi
callq 0x2220
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
movq %r15, %rdi
callq 0x2220
leaq 0x193c(%rip), %rsi      # 0xa7bc
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
testl %r14d, %r14d
je 0x8ecd
movq 0x48(%rbx), %r14
movss 0x60(%rbx), %xmm0
cmpq 0x50(%rbx), %r14
movss %xmm0, -0x1c(%rbp)
je 0x8efa
movq (%r14), %rdi
movl $0x1, %esi
callq 0x8e3e
movss -0x1c(%rbp), %xmm1
mulss %xmm0, %xmm1
movss %xmm1, -0x1c(%rbp)
addq $0x8, %r14
cmpq 0x50(%rbx), %r14
jne 0x8ea6
jmp 0x8efa
movq 0x48(%rbx), %r14
cmpq 0x50(%rbx), %r14
je 0x8eed
movq (%r14), %rdi
xorl %esi, %esi
callq 0x8e3e
addq $0x8, %r14
cmpq 0x50(%rbx), %r14
jne 0x8ed7
jmp 0x8ef5
movss 0x1113(%rip), %xmm0     # 0xa008
movss %xmm0, -0x1c(%rbp)
movq 0x50d7(%rip), %rbx      # 0xdfd8
leaq 0x18b7(%rip), %rsi      # 0xa7bf
movl $0x6, %edx
movq %rbx, %rdi
callq 0x2220
xorps %xmm0, %xmm0
cvtss2sd -0x1c(%rbp), %xmm0
movq %rbx, %rdi
callq 0x22a0
leaq 0x189a(%rip), %rsi      # 0xa7c6
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
movss -0x1c(%rbp), %xmm0
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/matteorr[P]EarleyParser/State.cpp
// Function: State::State(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Production*, State*, int, int)
State::State( string nonTerminal, Production* productionPointer, State* backtraceState, int inputStringProgress, int productionProgress )
: productionProgress(0), printed(false)
{

	//cout << endl << endl << "!!!!!!!!!!!![DEBUG]: OTHER CONSTRUCTOR CALLED!!!!!!!!!!!!!" << endl << endl << endl;

	this->nonTerminal = nonTerminal;
	this->productionPointer = productionPointer;

	this->backtraceStateVector.push_back( backtraceState );

	this->inputStringProgress = inputStringProgress;
	this->productionProgress = productionProgress;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, -0x2c(%rbp)
movl %r8d, %r15d
movq %rdx, %r13
movq %rdi, %r12
movq %rcx, -0x40(%rbp)
leaq 0x4a57(%rip), %rax      # 0xdd98
movq %rax, (%rdi)
leaq 0x8(%rdi), %r14
leaq 0x18(%rdi), %rbx
movq %rbx, 0x8(%rdi)
movq $0x0, 0x10(%rdi)
xorl %eax, %eax
movb %al, 0x18(%rdi)
leaq 0x30(%rdi), %rcx
movq %rcx, -0x38(%rbp)
movb %al, 0x50(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x3c(%rdi)
movq %r14, %rdi
callq 0x2110
movq %r13, 0x28(%r12)
movq 0x38(%r12), %rsi
cmpq 0x40(%r12), %rsi
je 0x939b
movq -0x40(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x38(%r12)
jmp 0x93a8
leaq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rdi
callq 0x744e
movl %r15d, 0x4c(%r12)
movl -0x2c(%rbp), %eax
movl %eax, 0x48(%r12)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq -0x38(%rbp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x93d8
callq 0x21a0
movq (%r14), %rdi
cmpq %rbx, %rdi
je 0x93e5
callq 0x21a0
movq %r15, %rdi
callq 0x22f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/matteorr[P]EarleyParser/State.cpp
// Function: State::getProductionPointer() const
Production* State::getProductionPointer() const
{
	if( this->productionPointer == NULL ){
		cout << "[ERROR]: production pointer is null" << endl;
		exit(1);
	}

	return this->productionPointer;
}

// Assembly:
movq 0x28(%rdi), %rax
testq %rax, %rax
je 0x9492
retq
pushq %rbp
movq %rsp, %rbp
movq 0x4b3b(%rip), %rdi      # 0xdfd8
leaq 0x1338(%rip), %rsi      # 0xa7dc
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movl $0x1, %edi
callq 0x2230
nop
// File: /workspace/github_cpp_makefile_star2_O1/matteorr[P]EarleyParser/State.cpp
// Function: State::isComplete()
bool State::isComplete()
{
	if( this->getProductionProgress() == this->getProductionPointer()->getProductionContent().size() )
		return true;
	else
		return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movslq 0x48(%rdi), %r14
callq 0x9488
leaq -0x28(%rbp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x92e6
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x5, %rax
cmpq %r14, %rax
sete %r14b
movq %rbx, %rdi
callq 0x60da
movl %r14d, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/ronakshah725[P]SLR1Parser_C/parser1.cpp
// Function: printTokens(int)
void printTokens(int ntoken)
{
    //todo
		  switch (ntoken) {
                  
              case LBRACE:
                  printf("lb ");break;
              case RBRACE:
                  printf("rb ");break;
              case IDENTIFIER:
                  printf("x ");
                  break;
              case PRINT:
                  printf("p ");break;
                  break;
              case LOOP:
                  printf("l ");break;
                  break;
              case FUNCTION:
                  printf("f ");
                  break;
              case ASSIGN:
                  printf("= ");
                  break;
              case NUMBER:
                  printf("n ");
                  break;
              default:
                  printf("Syntax error in line %d\n",yylineno);
          }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
decl %edi
cmpl $0x7, %edi
ja 0x2535
leaq 0x2b26(%rip), %rax      # 0x5004
movslq (%rax,%rdi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
leaq 0x2b36(%rip), %rdi      # 0x5024
jmp 0x252d
leaq 0x2b41(%rip), %rdi      # 0x5038
jmp 0x252d
leaq 0x2b32(%rip), %rdi      # 0x5032
jmp 0x252d
leaq 0x2b26(%rip), %rdi      # 0x502f
jmp 0x252d
leaq 0x2b1a(%rip), %rdi      # 0x502c
jmp 0x252d
leaq 0x2b0d(%rip), %rdi      # 0x5028
jmp 0x252d
leaq 0x2b11(%rip), %rdi      # 0x5035
jmp 0x252d
leaq 0x2b0e(%rip), %rdi      # 0x503b
xorl %eax, %eax
popq %rbp
jmp 0x2040
leaq 0x5c8c(%rip), %rax      # 0x81c8
movl (%rax), %esi
leaq 0x2af9(%rip), %rdi      # 0x503e
xorl %eax, %eax
popq %rbp
jmp 0x2040
// File: /workspace/github_cpp_makefile_star2_O1/ronakshah725[P]SLR1Parser_C/parser1.cpp
// Function: read_table(_IO_FILE*, char (*) [16])
void read_table(FILE* fp, char x[row][col]){
    
    char buf[300];
    
    int i = 0;
    size_t n;
    fgets(buf,sizeof(buf),fp);
    printf("\t\t\t\t\t\t------------TABLE----------\n\n");
    puts(buf);
         printf("\n");
    
    while(fgets(buf,sizeof(buf),fp))
    {
        char *p = strtok(buf,"\t");
        while( p != NULL)
        {
            n = strlen(p);
            if(i>= row && n> col)
                break;
            strcpy(x[i],p);
            i++;
            p = strtok(NULL,"\t");
        }
    }

    
   
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rsi, -0x30(%rbp)
movq %rdi, %r14
leaq -0x170(%rbp), %rbx
movq %rbx, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r14, %rdx
callq 0x2280
leaq 0x2aed(%rip), %rdi      # 0x50da
callq 0x2250
movq %rbx, %rdi
callq 0x2250
movl $0xa, %edi
callq 0x21e0
movq %rbx, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r14, -0x38(%rbp)
movq %r14, %rdx
callq 0x2280
testq %rax, %rax
je 0x26a4
xorl %r14d, %r14d
leaq 0x2a39(%rip), %r15      # 0x5064
leaq -0x170(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x2270
testq %rax, %rax
je 0x268e
movq %rax, %rbx
movslq %r14d, %r14
movq %r14, %r13
shlq $0x4, %r13
addq -0x30(%rbp), %r13
movq %rbx, %rdi
callq 0x20d0
cmpq $0x1f4, %r14            # imm = 0x1F4
jl 0x266a
cmpq $0x10, %rax
ja 0x268e
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2140
incq %r14
xorl %edi, %edi
movq %r15, %rsi
callq 0x2270
movq %rax, %rbx
addq $0x10, %r13
testq %rax, %rax
jne 0x2653
movq %r12, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq -0x38(%rbp), %rdx
callq 0x2280
testq %rax, %rax
jne 0x2632
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/ronakshah725[P]SLR1Parser_C/parser1.cpp
// Function: states(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int states(string fname) {
    int number_of_lines = 0;
    string line;
    ifstream myfile(fname);
    
    while (std::getline(myfile, line))
        ++number_of_lines;
    
    return number_of_lines;
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x230, %rsp            # imm = 0x230
movq %rdi, %rsi
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
leaq -0x248(%rbp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x22a0
xorl %ebx, %ebx
leaq -0x40(%rbp), %r15
movq -0x248(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2310
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2cb1
incl %ebx
jmp 0x2c79
leaq -0x248(%rbp), %rdi
callq 0x2060
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x2ccb
callq 0x2150
movl %ebx, %eax
addq $0x230, %rsp            # imm = 0x230
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2cf1
movq %rax, %rbx
leaq -0x248(%rbp), %rdi
callq 0x2060
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x2cff
callq 0x2150
movq %rbx, %rdi
callq 0x22f0
// File: /workspace/github_cpp_makefile_star2_O1/ronakshah725[P]SLR1Parser_C/parser1.cpp
// Function: start_parser()
void start_parser(void)
{
    int ntoken;
    
    ntoken = yylex();
    
    while(ntoken!=DOLLAR) {
        
        
        //printTokens(ntoken);
        printf("%d ",ntoken);
        ntoken = yylex();
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
callq 0x37a4
cmpl $0x9, %eax
je 0x2d34
leaq 0x2340(%rip), %rbx      # 0x505e
movq %rbx, %rdi
movl %eax, %esi
xorl %eax, %eax
callq 0x2040
callq 0x37a4
cmpl $0x9, %eax
jne 0x2d1e
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/ronakshah725[P]SLR1Parser_C/parser1.cpp
// Function: print_table_to_console(char (*) [16])
void print_table_to_console(char x[row][col]){
    
    
    
    printf("\t");
    for (int st=1; st<=MAX_STATES; st++) {
        for (int sy = 1; sy<=MAX_SYMBOLS; sy++) {
            printf("%s\t",x[getValueFromMatrix(st, sy)]);
        }
        printf("\n");
        printf("\t");

    }


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x9, %edi
callq 0x21e0
cmpl $0x0, 0x54d7(%rip)      # 0x8234
jle 0x2dda
movl $0x1, %r12d
leaq 0x22f6(%rip), %r14      # 0x5062
movq %r12, %r15
movabsq $0xf00000000, %rax      # imm = 0xF00000000
imulq %rax, %r15
movabsq $-0xf00000000, %rax     # imm = 0xFFFFFFF100000000
addq %rax, %r15
sarq $0x1c, %r15
addq %rbx, %r15
movl $0x10, %r13d
leaq (%r15,%r13), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x2040
addq $0x10, %r13
cmpq $0xf0, %r13
jne 0x2d97
movl $0xa, %edi
callq 0x21e0
movl $0x9, %edi
callq 0x21e0
leaq 0x1(%r12), %rax
movslq 0x5462(%rip), %rcx      # 0x8234
cmpq %rcx, %r12
movq %rax, %r12
jl 0x2d6c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/ronakshah725[P]SLR1Parser_C/parser1.cpp
// Function: main
int main(int argc, char *argv[] )
{
    if ( argc != 2 ) /* argc should be 2 for correct execution */
    {
        
        printf( "usage: %s filename", argv[0] );
    }
    else
    {
        char x[row][col];
        FILE *file = fopen( argv[1], "r" );
        MAX_STATES = states(argv[1]);
        MAX_STATES -= 2;

        if ( file == 0 )
        {
            printf( "Could not open file\n" );
        }
        else
        {
            //start_parser();
            run(x, file);
        }
    }
 return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x1f70, %rsp           # imm = 0x1F70
movq %rsi, %r14
cmpl $0x2, %edi
jne 0x2e99
movq 0x8(%r14), %rdi
leaq 0x2239(%rip), %rsi      # 0x5079
callq 0x21a0
movq %rax, %rbx
movq 0x8(%r14), %rsi
leaq -0x38(%rbp), %r14
leaq -0x11(%rbp), %rdx
movq %r14, %rdi
callq 0x20b0
movq %r14, %rdi
callq 0x2c33
movl %eax, 0x53ca(%rip)      # 0x8234
leaq -0x28(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2e7c
callq 0x2150
addl $-0x2, 0x53b1(%rip)     # 0x8234
testq %rbx, %rbx
je 0x2eac
leaq -0x1f80(%rbp), %rdi
movq %rbx, %rsi
callq 0x2de9
jmp 0x2eb8
movq (%r14), %rsi
leaq 0x21c3(%rip), %rdi      # 0x5066
xorl %eax, %eax
callq 0x2040
jmp 0x2eb8
leaq 0x226a(%rip), %rdi      # 0x511d
callq 0x2250
xorl %eax, %eax
addq $0x1f70, %rsp           # imm = 0x1F70
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
leaq -0x28(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2edb
callq 0x2150
movq %rbx, %rdi
callq 0x22f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/cachesim.cpp
// Function: cache_peek(unsigned int, int)
int cache_peek(uint32_t addr, int bytes) {
	uint32_t idx = cache_calc_idx(addr);
	uint32_t tag = cache_calc_tag(addr);

	if ( cache_calc_idx(addr) != cache_calc_idx(addr+bytes-1) ) {
		printf( "ERROR: request spans line boundary\n" );
	}

	for ( int i = 0; i < CACHE_WAYS; i++ ) {
		if ( g_tags[idx][i] == tag && is_flag_valid(g_flags[idx][i]) ) return i;
	}

	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edi, %r14d
leal (%rdi,%rsi), %eax
decl %eax
movl %edi, %ebx
shrl $0x2, %ebx
movl $0xff, %ecx
andl %ecx, %ebx
shrl $0xa, %r14d
shrl $0x2, %eax
andl %ecx, %eax
cmpl %eax, %ebx
je 0x25db
leaq 0x5a2e(%rip), %rdi      # 0x8004
callq 0x22e0
leaq 0xc01e(%rip), %rax      # 0xe600
cmpl %r14d, (%rax,%rbx,4)
jne 0x25f7
leaq 0xc411(%rip), %rcx      # 0xea00
xorl %eax, %eax
testb $0x1, (%rbx,%rcx)
jne 0x25fc
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/cachesim.cpp
// Function: cache_write(unsigned int, unsigned int, int)
void cache_write(uint32_t addr, uint32_t data, int bytes) {
	uint32_t idx = cache_calc_idx(addr);
	uint32_t tag = cache_calc_tag(addr);
	uint32_t wid = cache_calc_word_idx(addr);
	int boff = (addr&(0x3));
	int way = cache_peek(addr,bytes);
	if ( way < 0 ) {
		return;
	}
	

	switch ( bytes ) {
		case 1: {
			uint8_t* cl = (((uint8_t*)&(g_cache[idx][way][wid]))+boff);
			*cl = (data&(0xff));
			break;
		}
		case 2: {
			uint8_t* cl = (((uint8_t*)&(g_cache[idx][way][wid]))+boff);
			*(uint16_t*)cl = (data&(0xffff));
			break;
		}
		case 4: {
			g_cache[idx][way][wid] = data;
			break;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r15d
movl %esi, %ebx
movl %edi, %r14d
movl %edx, %esi
callq 0x25a7
testl %eax, %eax
js 0x2682
movl %r14d, %ecx
shrl $0x2, %ecx
movzbl %cl, %ecx
cmpl $0x4, %r15d
je 0x2670
andl $0x3, %r14d
cmpl $0x2, %r15d
je 0x2656
cmpl $0x1, %r15d
jne 0x2682
movl %eax, %eax
movl %ecx, %ecx
leaq 0xbbb8(%rip), %rdx      # 0xe200
leaq (%rdx,%rcx,4), %rcx
leaq (%rcx,%rax,4), %rax
movb %bl, (%r14,%rax)
jmp 0x2682
movl %eax, %eax
movl %ecx, %ecx
leaq 0xbb9f(%rip), %rdx      # 0xe200
leaq (%rdx,%rcx,4), %rcx
leaq (%rcx,%rax,4), %rax
movw %bx, (%r14,%rax)
jmp 0x2682
movl %eax, %eax
movl %ecx, %ecx
leaq 0xbb85(%rip), %rdx      # 0xe200
leaq (%rdx,%rcx,4), %rcx
movl %ebx, (%rcx,%rax,4)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/cachesim.cpp
// Function: cache_read(unsigned int, int)
uint32_t cache_read(uint32_t addr, int bytes) {
	uint32_t idx = cache_calc_idx(addr);
	uint32_t tag = cache_calc_tag(addr);
	uint32_t wid = cache_calc_word_idx(addr);
	int boff = (addr&(0x3));
	int way = cache_peek(addr,bytes);
	if ( way < 0 ) {
		return 0xffffffff;
	}
	
	uint32_t ret = 0xffffffff;
	switch ( bytes ) {
		case 1: {
			uint8_t* cl = (((uint8_t*)&(g_cache[idx][way][wid]))+boff);
			ret = *cl;
			break;
		}
		case 2: {
			uint8_t* cl = (((uint8_t*)&(g_cache[idx][way][wid]))+boff);
			ret = *(uint16_t*)cl;
			break;
		}
		case 4: {
			ret = g_cache[idx][way][wid];
			break;
		}
	}

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
movl %edi, %ebx
callq 0x25a7
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
js 0x270a
movl %ebx, %edx
shrl $0x2, %edx
movzbl %dl, %edx
cmpl $0x4, %r14d
je 0x26f8
andl $0x3, %ebx
cmpl $0x2, %r14d
je 0x26df
cmpl $0x1, %r14d
jne 0x270a
movl %ecx, %eax
movl %edx, %ecx
leaq 0xbb2f(%rip), %rdx      # 0xe200
leaq (%rdx,%rcx,4), %rcx
leaq (%rcx,%rax,4), %rax
movzbl (%rbx,%rax), %eax
jmp 0x270a
movl %ecx, %eax
movl %edx, %ecx
leaq 0xbb16(%rip), %rdx      # 0xe200
leaq (%rdx,%rcx,4), %rcx
leaq (%rcx,%rax,4), %rax
movzwl (%rbx,%rax), %eax
jmp 0x270a
movl %ecx, %eax
movl %edx, %ecx
leaq 0xbafd(%rip), %rdx      # 0xe200
leaq (%rdx,%rcx,4), %rcx
movl (%rcx,%rax,4), %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/cachesim.cpp
// Function: cache_update(unsigned int, unsigned int)
void cache_update(uint32_t addr, uint32_t data) {
	uint32_t idx = cache_calc_idx(addr);
	uint32_t tag = cache_calc_tag(addr);
	uint32_t wid = cache_calc_word_idx(addr);
	int way = cache_peek(addr,4);
	if ( way < 0 ) {
		for ( int i = 0; i < CACHE_WAYS; i++ ) {
			if ( !is_flag_valid(g_flags[idx][i]) ) {
				way = i;
				break;
			}
		}
	}

	g_cache[idx][way][wid] = data;
	g_tags[idx][way] = tag;
	g_flags[idx][way] = set_flag_valid(g_flags[idx][way]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movl %edi, %ebx
movl %edi, %eax
shrl $0x2, %eax
movzbl %al, %r15d
movl $0x4, %esi
callq 0x25a7
leaq 0xc2c8(%rip), %rcx      # 0xea00
testl %eax, %eax
jns 0x2746
xorl %edx, %edx
testb $0x1, (%r15,%rcx)
cmovel %edx, %eax
shrl $0xa, %ebx
movl %r15d, %edx
cltq
shll $0x2, %r15d
leaq 0xbaa7(%rip), %rsi      # 0xe200
addq %r15, %rsi
movl %r14d, (%rsi,%rax,4)
leaq 0xbe99(%rip), %rsi      # 0xe600
addq %r15, %rsi
movl %ebx, (%rsi,%rax,4)
addq %rdx, %rcx
orb $0x1, (%rax,%rcx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/cachesim.cpp
// Function: cache_flush(unsigned int, unsigned char*)
void cache_flush(uint32_t addr, uint8_t* mem) {
	uint32_t idx = cache_calc_idx(addr);
	//uint32_t wid = cache_calc_word_idx(addr);

	//choose way
	//int way = rand()%CACHE_WAYS;
	int way = 0;

	if (!is_flag_valid(g_flags[idx][way])) return;
	uint32_t tag = g_tags[idx][way];

	//write to mem
	//set flag to empty
	for ( int i = 0; i < CACHE_LINE_WORD; i++ ) {
		uint32_t data = g_cache[idx][way][i];
		uint32_t maddr = cache_reassemble_addr(idx, tag) + (i*4);
		*(uint32_t*)(mem+maddr) = data;
		g_flags[idx][way] = set_flag_invalid(g_flags[idx][way]);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
shrl $0x2, %edi
movzbl %dil, %eax
leaq 0xc26f(%rip), %rcx      # 0xea00
testb $0x1, (%rax,%rcx)
je 0x27c0
leal (,%rax,4), %edx
leaq 0xbe5b(%rip), %rdi      # 0xe600
movl (%rdx,%rdi), %edi
leaq 0xba51(%rip), %r8       # 0xe200
movl (%rdx,%r8), %edx
shll $0xa, %edi
leal (%rdi,%rax,4), %edi
movl %edx, (%rsi,%rdi)
andb $-0x2, (%rax,%rcx)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/emulator.cpp
// Function: parse_imm(char*, int, int, bool)
uint32_t parse_imm(char* tok, int bits, int line, bool strict = true) {
	if ( !(tok[0]>='0'&&tok[0]<='9') && tok[0] != '-' && strict) {
		print_syntax_error(line, "Malformed immediate value" );
	}
	long int imml = strtol(tok, NULL, 0);


	if (imml > ((1<<bits)-1) || imml < -(1<<(bits-1)) ) {
		printf( "Syntax error at token %s\n", tok);
		exit(1);
	}
	uint64_t uv = *(uint64_t*)&imml;
	uint32_t hv = (uv&UINT32_MAX);

	return hv;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
xorb $0x1, %cl
movb (%rdi), %al
leal -0x3a(%rax), %esi
cmpb $-0xa, %sil
setae %sil
cmpb $0x2d, %al
sete %al
orb %cl, %al
orb %sil, %al
je 0x31e3
movq %rdi, %rbx
xorl %esi, %esi
xorl %edx, %edx
callq 0x2290
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %r14d, %ecx
shll %cl, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
notl %esi
cmpq %rsi, %rax
jg 0x31d0
decb %r14b
movl %r14d, %ecx
shll %cl, %edx
movslq %edx, %rcx
cmpq %rcx, %rax
jl 0x31d0
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x84ba(%rip), %rdi      # 0xb691
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
jmp 0x31fd
leaq 0x8356(%rip), %rdi      # 0xb540
leaq 0x8486(%rip), %rax      # 0xb677
movl %edx, %esi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2040
movl $0x1, %edi
callq 0x2210
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/emulator.cpp
// Function: parse_mem(char*, int*, unsigned int*, int, int)
void parse_mem(char* tok, int* reg, uint32_t* imm, int bits, int line) {
	char* imms = strtok(tok, "(");
	char* regs = strtok(NULL, ")");
	*imm = parse_imm(imms, bits, line);
	*reg = parse_reg(regs, line);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %r14d
movl %ecx, %r15d
movq %rdx, %r12
movq %rsi, -0x30(%rbp)
leaq 0x8482(%rip), %rsi      # 0xb6ab
callq 0x2320
movq %rax, %r13
leaq 0x8475(%rip), %rsi      # 0xb6ad
xorl %edi, %edi
callq 0x2320
movq %rax, %rbx
movq %r13, %rdi
movl %r15d, %esi
movl %r14d, %edx
movl $0x1, %ecx
callq 0x3173
movl %eax, (%r12)
movq %rbx, %rdi
movl %r14d, %esi
movl $0x1, %edx
callq 0x2d17
movq -0x30(%rbp), %rcx
movl %eax, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/emulator.cpp
// Function: mem_write(unsigned char*, unsigned int, unsigned int, instr_type)
void mem_write(uint8_t* mem, uint32_t addr, uint32_t data, instr_type op) {
	//printf( "Storing %x to %d\n", data, addr );
	int bytes = 0;
	switch (op ) {
		case SB: bytes = 1; break;
		case SH: bytes = 2; break;
		case SW: bytes = 4; break;
	}
	if ( addr < MEM_BYTES && addr + bytes <= MEM_BYTES ) {
		mem_write_reqs ++;
		int way = cache_peek(addr,bytes);
		if ( way < 0 ) {
			cache_flush(addr, mem);
			uint32_t waddr = addr-(addr&((1<<(2+CACHE_LINE_WORD_SZ))-1));
			for ( int i = 0; i < CACHE_LINE_WORD; i++ ) {
				cache_update(waddr+(i*4), *(uint32_t*)&(mem[waddr+(i*4)]));
			}
			mem_flush_words += CACHE_LINE_WORD;
		} else {
			cache_write_hits ++;
		}
		cache_write(addr,data,bytes);
	} else if ( addr == MEM_BYTES ) {
		printf( "[System output]: 0x%x\n", data );
	} else {
		printf( "0x%x -- 0x%x\n", addr, data);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebx
movl %esi, %r14d
movq %rdi, %r12
cmpl $0x23, %ecx
je 0x32b3
cmpl $0x17, %ecx
je 0x32ab
xorl %r15d, %r15d
cmpl $0x16, %ecx
jne 0x32b9
movl $0x1, %r15d
jmp 0x32b9
movl $0x2, %r15d
jmp 0x32b9
movl $0x4, %r15d
cmpl $0x10000, %r14d         # imm = 0x10000
setb %al
leal (%r15,%r14), %ecx
cmpl $0x10001, %ecx          # imm = 0x10001
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x32f5
incl 0xb867(%rip)            # 0xeb44
movl %r14d, %edi
movl %r15d, %esi
callq 0x25a7
testl %eax, %eax
js 0x3331
leaq 0xb855(%rip), %rax      # 0xeb48
jmp 0x3355
cmpl $0x10000, %r14d         # imm = 0x10000
jne 0x3316
leaq 0x83aa(%rip), %rdi      # 0xb6af
movl %ebx, %esi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2040
leaq 0x83a9(%rip), %rdi      # 0xb6c6
movl %r14d, %esi
movl %ebx, %edx
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2040
movl %r14d, %edi
movq %r12, %rsi
callq 0x277f
movl %r14d, %edi
andl $0xfffc, %edi           # imm = 0xFFFC
movl (%r12,%rdi), %esi
callq 0x270f
leaq 0xb7eb(%rip), %rax      # 0xeb40
incl (%rax)
movl %r14d, %edi
movl %ebx, %esi
movl %r15d, %edx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2601
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/emulator.cpp
// Function: mem_read(unsigned char*, unsigned int, instr_type)
uint32_t mem_read(uint8_t* mem, uint32_t addr, instr_type op) {
	uint32_t ret = 0;
	int bytes = 0;

	switch(op) {
		case LB: 
		case LBU: bytes = 1; break;
		case LH:
		case LHU: bytes = 2; break;
		case LW:  bytes = 4; break;
	}
	if ( addr + bytes <= MEM_BYTES ) {
		mem_read_reqs ++;
		int way = cache_peek(addr,bytes);
		if ( way < 0 ) {
			cache_flush(addr, mem);
			mem_flush_words += CACHE_LINE_WORD;
			uint32_t waddr = addr-(addr&((1<<(2+CACHE_LINE_WORD_SZ))-1));
			for ( int i = 0; i < CACHE_LINE_WORD; i++ ) {
				cache_update(waddr+(i*4), *(uint32_t*)&(mem[waddr+(i*4)]));
			}
		} else {
			cache_read_hits++;
			//printf( "%x %d--\n", addr,way);
		}
		uint32_t cr = cache_read(addr,bytes);
		switch(op) {
			case LB: ret = signextend(cr, 8); break;
			case LBU: ret = (cr&0xff); break;
			case LH: ret = signextend(cr,16); break;
			case LHU: ret = (cr&0xffff); break;
			case LW: ret = cr; break;
		}
	}
	//printf( "Reading %x from %d\n", ret, addr );

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r14d
movl %esi, %r15d
movq %rdi, %r13
addl $-0xe, %r14d
xorl %ebx, %ebx
movl $0x0, %r12d
cmpl $0x5, %r14d
ja 0x33a3
movl %r14d, %eax
leaq 0x80e1(%rip), %rcx      # 0xb480
movl (%rcx,%rax,4), %r12d
leal (%r12,%r15), %eax
cmpl $0x10000, %eax          # imm = 0x10000
ja 0x3435
incl 0xb794(%rip)            # 0xeb4c
movl %r15d, %edi
movl %r12d, %esi
callq 0x25a7
testl %eax, %eax
js 0x33cf
incl 0xb783(%rip)            # 0xeb50
jmp 0x33f0
movl %r15d, %edi
movq %r13, %rsi
callq 0x277f
incl 0xb760(%rip)            # 0xeb40
movl %r15d, %edi
andl $-0x4, %edi
movl (%r13,%rdi), %esi
callq 0x270f
movl %r15d, %edi
movl %r12d, %esi
callq 0x268d
cmpl $0x5, %r14d
ja 0x3435
leaq 0x4c28(%rip), %rcx      # 0x8030
movslq (%rcx,%r14,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movsbl %al, %ebx
andl $0xffffff00, %ebx       # imm = 0xFFFFFF00
jmp 0x3425
movswl %ax, %ebx
andl $0xffff0000, %ebx       # imm = 0xFFFF0000
orl %eax, %ebx
jmp 0x3435
movzbl %al, %ebx
jmp 0x3435
movzwl %ax, %ebx
jmp 0x3435
movl %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/emulator.cpp
// Function: append_source(char const*, char const*, char const*, char const*, source*, instr*)
void append_source(const char* op, const char* a1, const char* a2, const char* a3, source* src, instr* i) {
	char tbuf[128]; // not safe... static size... but should be okay since label length enforced
	if ( op && a1 && !a2 && !a3 ) {
		sprintf(tbuf, "%s %s", op, a1);
	} else if ( op && a1 && a2 && !a3 ) {
		sprintf(tbuf, "%s %s, %s", op, a1, a2);
	} else if ( op && a1 && a2 && a3 ) {
		sprintf(tbuf, "%s %s, %s, %s", op, a1, a2, a3);
	} else {
		return;
	}
	int slen = strlen(tbuf);
	if ( slen + src->offset < MAX_SRC_LEN ) {
		strncpy(src->src+src->offset, tbuf, strlen(tbuf));

		i->psrc = src->src+src->offset;
		src->offset += slen+1;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x88, %rsp
movq %r9, %r14
movq %r8, %rbx
movq %rcx, %r9
movq %rdx, %r8
movq %rsi, %rcx
movq %rdi, %rdx
testq %rdi, %rdi
setne %sil
testq %rcx, %rcx
setne %al
andb %sil, %al
movl %eax, %esi
xorb $0x1, %sil
testq %r8, %r8
setne %dil
testq %r9, %r9
setne %r10b
orb %dil, %r10b
orb %sil, %r10b
je 0x34d3
testq %r9, %r9
setne %sil
testq %r8, %r8
setne %dil
andb %dil, %al
xorb $0x1, %al
orb %al, %sil
je 0x34ea
testq %r9, %r9
sete %sil
orb %sil, %al
jne 0x3544
leaq 0x8221(%rip), %rsi      # 0xb6e4
leaq -0xa0(%rbp), %rdi
xorl %eax, %eax
callq 0x2060
jmp 0x34ff
leaq 0x81fa(%rip), %rsi      # 0xb6d4
leaq -0xa0(%rbp), %rdi
xorl %eax, %eax
callq 0x2060
jmp 0x34ff
leaq 0x81e9(%rip), %rsi      # 0xb6da
leaq -0xa0(%rbp), %rdi
xorl %eax, %eax
callq 0x2060
leaq -0xa0(%rbp), %rdi
callq 0x20f0
movq %rax, %r15
movslq 0x8(%rbx), %rdi
addl %edi, %eax
cmpl $0xfffff, %eax          # imm = 0xFFFFF
jg 0x3544
addq (%rbx), %rdi
leaq -0xa0(%rbp), %rsi
movq %r15, %rdx
callq 0x2100
movslq 0x8(%rbx), %rax
leal (%r15,%rax), %ecx
incl %ecx
addq (%rbx), %rax
movq %rax, 0x88(%r14)
movl %ecx, 0x8(%rbx)
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/emulator.cpp
// Function: parse_data_element(int, int, unsigned char*, int)
int parse_data_element(int line, int size, uint8_t* mem, int offset) {
	while (char* t = strtok(NULL, " \t\r\n") ) {
		errno = 0;
		int64_t v = strtol(t, NULL, 0);
		int64_t vs = (v>>(size*8));
		if ( errno == ERANGE || (vs > 0 && vs != -1 ) ) {
			printf( "Value out of bounds at line %d : %s\n", line, t);
			exit(2);
		}
		//printf ( "parse_data_element %d: %d %ld %d %d\n", line, size, v, errno, sizeof(long int));
		memcpy(&mem[offset], &v, size);
		offset += size;
		//strtok(NULL, ",");
	}
	return offset;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r14d
movq %rdx, -0x38(%rbp)
movl %edi, -0x2c(%rbp)
leal (,%rsi,8), %r12d
movslq %esi, %r13
xorl %edi, %edi
leaq 0x80f7(%rip), %rsi      # 0xb702
callq 0x2320
movq %rax, %rbx
testq %rax, %rax
je 0x3661
callq 0x2030
movq %rax, %r15
movl $0x0, (%rax)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2290
movq %rax, -0x40(%rbp)
movl %r12d, %ecx
sarq %cl, %rax
cmpl $0x22, (%r15)
je 0x3678
testq %rax, %rax
jg 0x3678
movslq %r14d, %r14
movq -0x38(%rbp), %rax
leaq (%rax,%r14), %rdi
leaq -0x40(%rbp), %rsi
movq %r13, %rdx
callq 0x2150
addl %r13d, %r14d
testq %rbx, %rbx
jne 0x3602
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8088(%rip), %rdi      # 0xb707
movl -0x2c(%rbp), %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2040
movl $0x2, %edi
callq 0x2210
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/emulator.cpp
// Function: parse_data_zero(int, unsigned char*, int)
int parse_data_zero(int line, uint8_t* mem, int offset) {
	char* t = strtok(NULL, " \t\r\n");
	int bytes = atoi(t);
	memset(&mem[offset], 0, bytes);

	return offset + bytes;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
leaq 0x8056(%rip), %rsi      # 0xb702
xorl %edi, %edi
callq 0x2320
movq %rax, %rdi
callq 0x2310
movslq %ebx, %r15
addq %r15, %r14
movslq %eax, %rbx
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2120
addl %r15d, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/emulator.cpp
// Function: parse_assembler_directive(int, char*, unsigned char*, int)
int parse_assembler_directive(int line, char* ftok, uint8_t* mem, int memoff) {
	//printf( "assembler directive %s\n", ftok );
	if ( 0 == memcmp(ftok, ".text", strlen(ftok) ) ) {
		if (strtok(NULL, " \t\r\n") ) {
			print_syntax_error(line, "Tokens after assembler directive");
		}
		//cur_section = SECTION_TEXT;
		memoff = TEXT_OFFSET;
		//printf( "starting text section\n" );
	} else if ( 0 == memcmp(ftok, ".data", strlen(ftok) ) ) {
		//cur_section = SECTION_TEXT;
		memoff = DATA_OFFSET;
		//printf( "starting data section\n" );
	} else if ( 0 == memcmp(ftok, ".byte", strlen(ftok)) ) memoff = parse_data_element(line, 1, mem, memoff);
	else if ( 0 == memcmp(ftok, ".half", strlen(ftok)) ) memoff = parse_data_element(line, 2, mem, memoff);
	else if ( 0 == memcmp(ftok, ".word", strlen(ftok)) ) memoff = parse_data_element(line, 4, mem, memoff);
	else if ( 0 == memcmp(ftok, ".zero", strlen(ftok)) ) memoff = parse_data_zero(line, mem, memoff);
	else {
		printf( "Undefined assembler directive at line %d: %s\n", line, ftok );
		//exit(3);
	}
	return memoff;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movq %rdx, %r14
movq %rsi, %r12
movl %edi, %r15d
movq %rsi, %rdi
callq 0x20f0
movq %rax, %r13
leaq 0x8020(%rip), %rsi      # 0xb72c
movq %r12, %rdi
movq %rax, %rdx
callq 0x21c0
testl %eax, %eax
je 0x37b7
leaq 0x802d(%rip), %rsi      # 0xb753
movq %r12, %rdi
movq %r13, %rdx
callq 0x21c0
testl %eax, %eax
je 0x37ee
leaq 0x8019(%rip), %rsi      # 0xb759
movq %r12, %rdi
movq %r13, %rdx
callq 0x21c0
testl %eax, %eax
je 0x3804
leaq 0x8005(%rip), %rsi      # 0xb75f
movq %r12, %rdi
movq %r13, %rdx
callq 0x21c0
testl %eax, %eax
je 0x380e
leaq 0x7ff1(%rip), %rsi      # 0xb765
movq %r12, %rdi
movq %r13, %rdx
callq 0x21c0
testl %eax, %eax
je 0x3818
leaq 0x7fdd(%rip), %rsi      # 0xb76b
movq %r12, %rdi
movq %r13, %rdx
callq 0x21c0
testl %eax, %eax
je 0x3838
leaq 0x7fc9(%rip), %rdi      # 0xb771
movl %r15d, %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2040
jmp 0x37f3
leaq 0x7f44(%rip), %rsi      # 0xb702
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x2320
testq %rax, %rax
je 0x37f3
leaq 0x7d6d(%rip), %rdi      # 0xb540
leaq 0x7f58(%rip), %rdx      # 0xb732
movl %r15d, %esi
xorl %eax, %eax
callq 0x2040
movl $0x1, %edi
callq 0x2210
movl $0x8000, %ebx           # imm = 0x8000
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r15d, %edi
movl $0x1, %esi
jmp 0x3820
movl %r15d, %edi
movl $0x2, %esi
jmp 0x3820
movl %r15d, %edi
movl $0x4, %esi
movq %r14, %rdx
movl %ebx, %ecx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x35dc
leaq 0x7ec3(%rip), %rsi      # 0xb702
xorl %edi, %edi
callq 0x2320
movq %rax, %rdi
callq 0x2310
movslq %ebx, %rcx
addq %rcx, %r14
movslq %eax, %r15
movq %r14, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x2120
addl %ebx, %r15d
movl %r15d, %ebx
jmp 0x37f3
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/emulator.cpp
// Function: main
int
main(int argc, char** argv) {
	if ( argc < 2 ) {
		printf( "usage: %s asmfile\n", argv[0] );
		exit(1);
	}

	FILE* fin = fopen(argv[1], "r" );
	if ( !fin ) {
		printf( "%s: No such file\n", argv[1] );
		exit(2);
	}

	bool start_immediate = false;
	if ( argc >= 3 ) {
		start_immediate = true;
	}


	//ProcessorState* ps = new ProcessorState();
	
	int memoff = 0;
	uint8_t* mem = (uint8_t*)malloc(MEM_BYTES);
	instr* imem = (instr*)malloc(DATA_OFFSET*sizeof(instr)/4);
	label_loc* labels = (label_loc*)malloc(MAX_LABEL_COUNT*sizeof(label_loc));
	int label_count = 0;
	source src;
	src.offset = 0;
	src.src = (char*)malloc(sizeof(char)*MAX_SRC_LEN);

	if ( !mem || !labels || !imem || !src.src ) {
		printf( "Memory allocation failed\n" );
		exit(2);
	}

	for ( int i = 0; i < DATA_OFFSET/4; i++ ) {
		imem[i].op = UNIMPL;
		imem[i].a1.type = OPTYPE_NONE;
		imem[i].a2.type = OPTYPE_NONE;
		imem[i].a3.type = OPTYPE_NONE;
	}

	parse(fin, mem, imem, memoff, labels, label_count, &src);
	normalize_labels(imem, labels, label_count, &src);
	
	execute(mem, imem, labels, label_count, start_immediate);

	printf( "Execution done!\n" );
	exit(0);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
cmpl $0x1, %edi
jg 0x5670
movq (%rbx), %rsi
leaq 0x6361(%rip), %rdi      # 0xb9c0
xorl %eax, %eax
callq 0x2040
movl $0x1, %edi
callq 0x2210
movl %edi, %r15d
movq 0x8(%rbx), %rdi
leaq 0x6174(%rip), %rsi      # 0xb7f2
callq 0x2200
testq %rax, %rax
jne 0x569f
movq 0x8(%rbx), %rsi
leaq 0x6340(%rip), %rdi      # 0xb9d3
xorl %eax, %eax
callq 0x2040
jmp 0x579c
movq %rax, -0x38(%rbp)
xorl %ebx, %ebx
movl %ebx, -0x30(%rbp)
movl $0x10000, %edi          # imm = 0x10000
callq 0x2260
movq %rax, %r13
movl $0x130000, %edi         # imm = 0x130000
callq 0x2260
movq %rax, %r14
movl $0x1200, %edi           # imm = 0x1200
callq 0x2260
movq %rax, %r12
movl %ebx, -0x2c(%rbp)
movl %ebx, -0x40(%rbp)
movl $0x100000, %edi         # imm = 0x100000
callq 0x2260
movq %rax, -0x48(%rbp)
testq %r13, %r13
sete %cl
testq %r12, %r12
sete %dl
orb %cl, %dl
testq %r14, %r14
sete %cl
testq %rax, %rax
sete %al
orb %cl, %al
orb %dl, %al
jne 0x5790
movq %r13, %rsi
movq %r12, %r13
xorl %eax, %eax
movq $0x0, (%r14,%rax)
movl %ebx, 0x30(%r14,%rax)
movl %ebx, 0x5c(%r14,%rax)
addq $0x98, %rax
cmpq $0x130000, %rax         # imm = 0x130000
jne 0x570f
xorl %ebx, %ebx
cmpl $0x2, %r15d
setne %bl
leaq -0x48(%rbp), %rax
movq %rax, (%rsp)
leaq -0x30(%rbp), %rcx
leaq -0x2c(%rbp), %r15
movq -0x38(%rbp), %rdi
movq %rsi, %r12
movq %r14, %rdx
movq %r13, %r8
movq %r15, %r9
callq 0x46b0
movl (%r15), %edx
movq %r14, %rdi
movq %r13, %rsi
leaq -0x48(%rbp), %rcx
callq 0x540f
movq %r12, %rdi
movq %r14, %rsi
movl %ebx, %r8d
callq 0x48df
leaq 0x641e(%rip), %rdi      # 0xbba2
callq 0x22e0
xorl %edi, %edi
callq 0x2210
leaq 0x63f2(%rip), %rdi      # 0xbb89
callq 0x22e0
movl $0x2, %edi
callq 0x2210
// File: /workspace/github_cpp_makefile_star2_O1/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::linenoiseRaw(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
inline bool linenoiseRaw(const char *prompt, std::string& line) {
    bool quit = false;

    if (!isatty(STDIN_FILENO)) {
        /* Not a tty: read from file / pipe. */
        std::getline(std::cin, line);
    } else {
        /* Interactive editing. */
        if (enableRawMode(STDIN_FILENO) == false) {
            return quit;
        }

        char buf[LINENOISE_MAX_LINE];
        auto count = linenoiseEdit(STDIN_FILENO, STDOUT_FILENO, buf, LINENOISE_MAX_LINE, prompt);
        if (count == -1) {
            quit = true;
        } else {
            line.assign(buf, count);
        }

        disableRawMode(STDIN_FILENO);
        printf("\n");
    }
    return quit;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
movq %rsi, %rbx
movq %rdi, %r14
xorl %edi, %edi
callq 0x2360
testl %eax, %eax
je 0x5966
xorl %edi, %edi
callq 0x2360
testl %eax, %eax
je 0x5959
cmpb $0x0, 0x92f7(%rip)      # 0xeb54
jne 0x5872
leaq 0x71a(%rip), %rdi       # 0x5f80
callq 0x7200
movb $0x1, 0x92e2(%rip)      # 0xeb54
leaq 0x92df(%rip), %rsi      # 0xeb58
xorl %edi, %edi
callq 0x21e0
cmpl $-0x1, %eax
je 0x5959
movups 0x92c8(%rip), %xmm0     # 0xeb58
leaq -0x1010(%rbp), %rdx
movaps %xmm0, (%rdx)
movups 0x92c7(%rip), %xmm0     # 0xeb68
movaps %xmm0, 0x10(%rdx)
movups 0x92d8(%rip), %xmm0     # 0xeb84
movups %xmm0, 0x2c(%rdx)
movups 0x92c1(%rip), %xmm0     # 0xeb78
andl $0xfffffacd, (%rdx)     # imm = 0xFFFFFACD
movaps %xmm0, 0x20(%rdx)
orb $0x30, 0x8(%rdx)
andl $0xffff7ff4, 0xc(%rdx)  # imm = 0xFFFF7FF4
movw $0x100, 0x16(%rdx)      # imm = 0x100
xorl %edi, %edi
movl $0x2, %esi
callq 0x2250
testl %eax, %eax
js 0x5959
movb $0x1, 0x92ab(%rip)      # 0xeb94
leaq -0x1010(%rbp), %rdx
xorl %edi, %edi
movl $0x1, %esi
movl $0x1000, %ecx           # imm = 0x1000
movq %r14, %r8
callq 0x59a1
cmpl $-0x1, %eax
sete %r14b
je 0x5925
movslq %eax, %r8
movq 0x8(%rbx), %rdx
leaq -0x1010(%rbp), %rcx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x22f0
cmpb $0x1, 0x9268(%rip)      # 0xeb94
jne 0x594d
leaq 0x9223(%rip), %rdx      # 0xeb58
xorl %edi, %edi
movl $0x2, %esi
callq 0x2250
cmpl $-0x1, %eax
je 0x594d
movb $0x0, 0x9247(%rip)      # 0xeb94
movl $0xa, %edi
callq 0x2270
jmp 0x5992
callq 0x2030
movl $0x19, (%rax)
jmp 0x598f
movq 0x866b(%rip), %r14      # 0xdfd8
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2390
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r14
popq %rbp
retq