LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/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 0x3037
movq %rdi, %rbx
xorl %esi, %esi
xorl %edx, %edx
callq 0x22b0
pushq $-0x1
popq %rdx
movl %edx, %esi
movl %r14d, %ecx
shll %cl, %esi
notl %esi
cmpq %rsi, %rax
jg 0x301e
decb %r14b
movl %r14d, %ecx
shll %cl, %edx
movslq %edx, %rcx
cmpq %rcx, %rax
jl 0x301e
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x766c(%rip), %rdi      # 0xa691
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
pushq $0x1
popq %rdi
callq 0x2200
leaq 0x7639(%rip), %rsi      # 0xa677
movl %edx, %edi
callq 0x27ef
// File: /workspace/github_cpp_makefile_star2_O2/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
subq $0x18, %rsp
movl %r8d, %r14d
movl %ecx, %r15d
movq %rdx, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
leaq 0x7640(%rip), %rsi      # 0xa6ab
callq 0x2330
movq %rax, %r13
leaq 0x7633(%rip), %rsi      # 0xa6ad
xorl %edi, %edi
callq 0x2330
movq %rax, %rbx
pushq $0x1
popq %r12
movq %r13, %rdi
movl %r15d, %esi
movl %r14d, %edx
movl %r12d, %ecx
callq 0x2fc6
movq -0x30(%rbp), %rcx
movl %eax, (%rcx)
movq %rbx, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x2c37
movq -0x38(%rbp), %rcx
movl %eax, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 0x30ef
cmpl $0x17, %ecx
je 0x30eb
xorl %r15d, %r15d
cmpl $0x16, %ecx
jne 0x30f3
pushq $0x1
jmp 0x30f1
pushq $0x2
jmp 0x30f1
pushq $0x4
popq %r15
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 0x312f
incl 0xaa3d(%rip)            # 0xdb54
movl %r14d, %edi
movl %r15d, %esi
callq 0x25a7
testl %eax, %eax
js 0x316b
leaq 0xaa2b(%rip), %rax      # 0xdb58
jmp 0x318f
cmpl $0x10000, %r14d         # imm = 0x10000
jne 0x3150
leaq 0x7570(%rip), %rdi      # 0xa6af
movl %ebx, %esi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2040
leaq 0x756f(%rip), %rdi      # 0xa6c6
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 0x277a
movl %r14d, %edi
andl $0xfffc, %edi           # imm = 0xFFFC
movl (%r12,%rdi), %esi
callq 0x270b
leaq 0xa9c1(%rip), %rax      # 0xdb50
incl (%rax)
movl %r14d, %edi
movl %ebx, %esi
movl %r15d, %edx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x25ff
// File: /workspace/github_cpp_makefile_star2_O2/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 0x31dd
movl %r14d, %eax
leaq 0x72a7(%rip), %rcx      # 0xa480
movl (%rcx,%rax,4), %r12d
leal (%r12,%r15), %eax
cmpl $0x10000, %eax          # imm = 0x10000
ja 0x326f
incl 0xa96a(%rip)            # 0xdb5c
movl %r15d, %edi
movl %r12d, %esi
callq 0x25a7
testl %eax, %eax
js 0x3209
incl 0xa959(%rip)            # 0xdb60
jmp 0x322a
movl %r15d, %edi
movq %r13, %rsi
callq 0x277a
incl 0xa936(%rip)            # 0xdb50
movl %r15d, %edi
andl $-0x4, %edi
movl (%r13,%rdi), %esi
callq 0x270b
movl %r15d, %edi
movl %r12d, %esi
callq 0x268b
cmpl $0x5, %r14d
ja 0x326f
leaq 0x3dee(%rip), %rcx      # 0x7030
movslq (%rcx,%r14,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movsbl %al, %ebx
andl $0xffffff00, %ebx       # imm = 0xFFFFFF00
jmp 0x325f
movswl %ax, %ebx
andl $0xffff0000, %ebx       # imm = 0xFFFF0000
orl %eax, %ebx
jmp 0x326f
movzbl %al, %ebx
jmp 0x326f
movzwl %ax, %ebx
jmp 0x326f
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_O2/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 0x330d
testq %r9, %r9
setne %sil
testq %r8, %r8
setne %dil
andb %dil, %al
xorb $0x1, %al
orb %al, %sil
je 0x3324
testq %r9, %r9
sete %sil
orb %sil, %al
jne 0x337e
leaq 0x73e7(%rip), %rsi      # 0xa6e4
leaq -0xa0(%rbp), %rdi
xorl %eax, %eax
callq 0x2060
jmp 0x3339
leaq 0x73c0(%rip), %rsi      # 0xa6d4
leaq -0xa0(%rbp), %rdi
xorl %eax, %eax
callq 0x2060
jmp 0x3339
leaq 0x73af(%rip), %rsi      # 0xa6da
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 0x337e
addq (%rbx), %rdi
leaq -0xa0(%rbp), %rsi
movq %r15, %rdx
callq 0x2110
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_O2/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
movl %edi, -0x2c(%rbp)
leal (,%rsi,8), %eax
movq %rax, -0x38(%rbp)
movslq %esi, %r12
movslq %ecx, %r13
addq %rdx, %r13
xorl %edi, %edi
leaq 0x72ef(%rip), %rsi      # 0xa702
callq 0x2330
testq %rax, %rax
je 0x3464
movq %rax, %rbx
callq 0x2030
movq %rax, %r15
andl $0x0, (%rax)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x22b0
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rcx
sarq %cl, %rax
cmpl $0x22, (%r15)
je 0x3476
testq %rax, %rax
jg 0x3476
movq %r13, %rdi
leaq -0x40(%rbp), %rsi
movq %r12, %rdx
callq 0x2150
addl %r12d, %r14d
addq %r12, %r13
jmp 0x340a
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x728a(%rip), %rdi      # 0xa707
movl -0x2c(%rbp), %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2040
pushq $0x2
popq %rdi
callq 0x2200
// File: /workspace/github_cpp_makefile_star2_O2/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 0x725a(%rip), %rsi      # 0xa702
xorl %edi, %edi
callq 0x2330
movq %rax, %rdi
callq 0x2320
movslq %ebx, %r15
addq %r15, %r14
movslq %eax, %rbx
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2130
addl %r15d, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/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, %r15
movq %rsi, %r12
movl %edi, %r14d
movq %rsi, %rdi
callq 0x20f0
movq %rax, %r13
leaq 0x7224(%rip), %rsi      # 0xa72c
movq %r12, %rdi
movq %rax, %rdx
callq 0x21b0
testl %eax, %eax
je 0x35ab
leaq 0x7231(%rip), %rsi      # 0xa753
movq %r12, %rdi
movq %r13, %rdx
callq 0x21b0
testl %eax, %eax
je 0x35cf
leaq 0x721d(%rip), %rsi      # 0xa759
movq %r12, %rdi
movq %r13, %rdx
callq 0x21b0
testl %eax, %eax
je 0x35e5
leaq 0x7209(%rip), %rsi      # 0xa75f
movq %r12, %rdi
movq %r13, %rdx
callq 0x21b0
testl %eax, %eax
je 0x35e9
leaq 0x71f5(%rip), %rsi      # 0xa765
movq %r12, %rdi
movq %r13, %rdx
callq 0x21b0
testl %eax, %eax
je 0x35ed
leaq 0x71e5(%rip), %rsi      # 0xa76b
movq %r12, %rdi
movq %r13, %rdx
callq 0x21b0
testl %eax, %eax
je 0x360b
leaq 0x71d5(%rip), %rdi      # 0xa771
movl %r14d, %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2040
jmp 0x35d4
leaq 0x7150(%rip), %rsi      # 0xa702
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x2330
testq %rax, %rax
je 0x35d4
leaq 0x716b(%rip), %rsi      # 0xa732
movl %r14d, %edi
callq 0x27ef
movl $0x8000, %ebx           # imm = 0x8000
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
jmp 0x35ef
pushq $0x2
jmp 0x35ef
pushq $0x4
popq %rsi
movl %r14d, %edi
movq %r15, %rdx
movl %ebx, %ecx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x33df
movq %r15, %rsi
movl %ebx, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3492
// File: /workspace/github_cpp_makefile_star2_O2/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 0x5158
movq (%rbx), %rsi
leaq 0x5876(%rip), %rdi      # 0xa9c0
xorl %eax, %eax
callq 0x2040
pushq $0x1
jmp 0x521c
movl %edi, %r15d
movq 0x8(%rbx), %rdi
leaq 0x568c(%rip), %rsi      # 0xa7f2
callq 0x21f0
testq %rax, %rax
jne 0x5187
movq 0x8(%rbx), %rsi
leaq 0x5858(%rip), %rdi      # 0xa9d3
xorl %eax, %eax
callq 0x2040
jmp 0x521a
movq %rax, %r12
andl $0x0, -0x30(%rbp)
movl $0x10000, %edi          # imm = 0x10000
callq 0x2260
movq %rax, %rbx
movl $0x130000, %edi         # imm = 0x130000
callq 0x2260
movq %rax, %r14
movl $0x1200, %edi           # imm = 0x1200
callq 0x2260
andl $0x0, -0x2c(%rbp)
movq %rax, %r13
andl $0x0, -0x38(%rbp)
movl $0x100000, %edi         # imm = 0x100000
callq 0x2260
movq %rax, -0x40(%rbp)
testq %rbx, %rbx
sete %cl
testq %r13, %r13
sete %dl
orb %cl, %dl
testq %r14, %r14
sete %cl
testq %rax, %rax
sete %al
orb %cl, %al
orb %dl, %al
jne 0x520e
xorl %eax, %eax
cmpq $0x130000, %rax         # imm = 0x130000
je 0x5222
andq $0x0, (%r14,%rax)
andl $0x0, 0x30(%r14,%rax)
andl $0x0, 0x5c(%r14,%rax)
addq $0x98, %rax
jmp 0x51ed
leaq 0x594a(%rip), %rdi      # 0xab5f
callq 0x2300
pushq $0x2
popq %rdi
callq 0x2200
movq %rbx, %rsi
xorl %ebx, %ebx
cmpl $0x2, %r15d
setne %bl
leaq -0x40(%rbp), %rax
movq %rax, (%rsp)
leaq -0x30(%rbp), %rcx
leaq -0x2c(%rbp), %r15
movq %r12, %rdi
movq %rsi, %r12
movq %r14, %rdx
movq %r13, %r8
movq %r15, %r9
callq 0x43a3
movl (%r15), %edx
movq %r14, %rdi
movq %r13, %rsi
leaq -0x40(%rbp), %rcx
callq 0x4ef9
movq %r12, %rdi
movq %r14, %rsi
movl %ebx, %r8d
callq 0x45b1
leaq 0x58ff(%rip), %rdi      # 0xab78
callq 0x2300
xorl %edi, %edi
callq 0x2200
nop
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::Readline(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
inline bool Readline(const char *prompt, std::string& line) {
    if (isUnsupportedTerm()) {
        printf("%s",prompt);
        fflush(stdout);
        std::getline(std::cin, line);
        return false;
    } else {
        return linenoiseRaw(prompt, line);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
callq 0x53e1
testb %al, %al
je 0x531d
leaq 0x5401(%rip), %rdi      # 0xa6ef
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
movq 0x7cb1(%rip), %rax      # 0xcfb0
movq (%rax), %rdi
callq 0x21e0
movq 0x7cca(%rip), %rdi      # 0xcfd8
movq %rbx, %rsi
callq 0x2070
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x5439
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::AddHistory(char const*)
inline bool AddHistory(const char* line) {
    if (history_max_len == 0) return false;

    /* Don't add duplicated lines. */
    if (!history.empty() && history.back() == line) return false;

    /* If we reached the max length, remove the older line. */
    if (history.size() == history_max_len) {
        history.erase(history.begin());
    }
    history.push_back(line);

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
movq 0x87f7(%rip), %rsi      # 0xdb38
movq 0x87f8(%rip), %rdi      # 0xdb40
movq %rsi, %rax
cmpq %rdi, %rsi
je 0x5372
addq $-0x20, %rdi
movq %rbx, %rsi
callq 0x662e
testb %al, %al
je 0x5364
xorl %eax, %eax
jmp 0x53b6
movq 0x87d5(%rip), %rax      # 0xdb40
movq 0x87c6(%rip), %rsi      # 0xdb38
subq %rsi, %rax
cmpq $0xc80, %rax            # imm = 0xC80
jne 0x5389
leaq 0x87b4(%rip), %rdi      # 0xdb38
callq 0x663e
leaq -0x38(%rbp), %r14
leaq -0x11(%rbp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20d0
leaq 0x8795(%rip), %rdi      # 0xdb38
movq %r14, %rsi
callq 0x66d8
leaq -0x38(%rbp), %rdi
callq 0x2100
movb $0x1, %al
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x2380
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::isUnsupportedTerm()
inline bool isUnsupportedTerm(void) {
#ifndef _WIN32
    char *term = getenv("TERM");
    int j;

    if (term == NULL) return false;
    for (j = 0; unsupported_term[j]; j++)
        if (!strcasecmp(term,unsupported_term[j])) return true;
#endif
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0x55f2(%rip), %rdi      # 0xa9e5
callq 0x2210
testq %rax, %rax
je 0x542a
movq %rax, %rbx
xorl %r15d, %r15d
leaq 0x7976(%rip), %r12      # 0xcd80
cmpq $0x18, %r15
setne %r14b
je 0x542d
movq (%r15,%r12), %rsi
movq %rbx, %rdi
callq 0x21c0
addq $0x8, %r15
testl %eax, %eax
jne 0x540a
jmp 0x542d
xorl %r14d, %r14d
movl %r14d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
subq $0x1008, %rsp           # imm = 0x1008
movq %rsi, %rbx
movq %rdi, %r15
xorl %edi, %edi
callq 0x2370
testl %eax, %eax
je 0x54ad
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x54d0
testb %al, %al
je 0x54bf
pushq $0x1
popq %rsi
leaq -0x1020(%rbp), %rdx
xorl %edi, %edi
movl $0x1000, %ecx           # imm = 0x1000
movq %r15, %r8
callq 0x558c
cmpl $-0x1, %eax
sete %r14b
je 0x549c
movslq %eax, %rdx
leaq -0x1020(%rbp), %rsi
movq %rbx, %rdi
callq 0x2270
xorl %edi, %edi
callq 0x58e4
pushq $0xa
popq %rdi
callq 0x2290
jmp 0x54bf
movq 0x7b24(%rip), %rdi      # 0xcfd8
movq %rbx, %rsi
callq 0x2070
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x1008, %rsp           # imm = 0x1008
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::getColumns(int, int)
inline int getColumns(int ifd, int ofd) {
#ifdef _WIN32
    CONSOLE_SCREEN_BUFFER_INFO b;

    if (!GetConsoleScreenBufferInfo(hOut, &b)) return 80;
    return b.srWindow.Right - b.srWindow.Left;
#else
    struct winsize ws;

    if (ioctl(1, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) {
        /* ioctl() failed. Try to query the terminal itself. */
        int start, cols;

        /* Get the initial position so we can restore it later. */
        start = getCursorPosition(ifd,ofd);
        if (start == -1) goto failed;

        /* Go to right margin and get position. */
        if (write(ofd,"\x1b[999C",6) != 6) goto failed;
        cols = getCursorPosition(ifd,ofd);
        if (cols == -1) goto failed;

        /* Restore position. */
        if (cols > start) {
            char seq[32];
            snprintf(seq,32,"\x1b[%dD",cols-start);
            if (write(ofd,seq,strlen(seq)) == -1) {
                /* Can't recover... */
            }
        }
        return cols;
    } else {
        return ws.ws_col;
    }

failed:
    return 80;
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl %esi, %ebx
movl %edi, %r14d
pushq $0x1
popq %rdi
leaq -0x28(%rbp), %r15
movl $0x5413, %esi           # imm = 0x5413
movq %r15, %rdx
xorl %eax, %eax
callq 0x22c0
cmpl $-0x1, %eax
sete %cl
movzwl 0x2(%r15), %eax
testw %ax, %ax
sete %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x59d4
movl %r14d, %edi
movl %ebx, %esi
callq 0x602d
pushq $0x50
popq %r15
cmpl $-0x1, %eax
je 0x59d8
movl %eax, %r12d
leaq 0x5083(%rip), %rsi      # 0xa9fc
pushq $0x6
popq %rdx
movl %ebx, %edi
callq 0x20a0
cmpq $0x6, %rax
jne 0x59d8
movl %r14d, %edi
movl %ebx, %esi
callq 0x602d
cmpl $-0x1, %eax
je 0x59d8
movl %eax, %r14d
movl %eax, %ecx
subl %r12d, %ecx
jle 0x59cf
leaq 0x505a(%rip), %rdx      # 0xaa03
leaq -0x50(%rbp), %r15
pushq $0x20
popq %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0x2350
movq %r15, %rdi
callq 0x20f0
movl %ebx, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x20a0
movl %r14d, %r15d
jmp 0x59d8
movzwl %ax, %r15d
movl %r15d, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::unicodeReadUTF8Char(int, char*, int*)
inline int unicodeReadUTF8Char(int fd, char* buf, int* cp)
{
    int nread = read(fd,&buf[0],1);

    if (nread <= 0) { return nread; }

    unsigned char byte = buf[0];

    if ((byte & 0x80) == 0) {
        ;
    } else if ((byte & 0xE0) == 0xC0) {
        nread = read(fd,&buf[1],1);
        if (nread <= 0) { return nread; }
    } else if ((byte & 0xF0) == 0xE0) {
        nread = read(fd,&buf[1],2);
        if (nread <= 0) { return nread; }
    } else if ((byte & 0xF8) == 0xF0) {
        nread = read(fd,&buf[1],3);
        if (nread <= 0) { return nread; }
    } else {
        return -1;
    }

    return unicodeUTF8CharToCodePoint(buf, 4, cp);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %r15d
pushq $0x1
popq %rdx
callq 0x22d0
testl %eax, %eax
jle 0x5a71
movzbl (%r14), %eax
testb %al, %al
jns 0x5a56
movl %eax, %ecx
andl $-0x20, %ecx
cmpl $0xc0, %ecx
jne 0x5a24
leaq 0x1(%r14), %rsi
pushq $0x1
jmp 0x5a49
movl %eax, %ecx
andl $-0x10, %ecx
cmpl $0xe0, %ecx
jne 0x5a39
leaq 0x1(%r14), %rsi
pushq $0x2
jmp 0x5a49
andl $-0x8, %eax
cmpl $0xf0, %eax
jne 0x5a6e
leaq 0x1(%r14), %rsi
pushq $0x3
popq %rdx
movl %r15d, %edi
callq 0x22d0
testl %eax, %eax
jle 0x5a71
pushq $0x4
popq %rsi
movq %r14, %rdi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x60d8
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::linenoiseEditBackspace(linenoise::linenoiseState*)
inline void linenoiseEditBackspace(struct linenoiseState *l) {
    if (l->pos > 0 && l->len > 0) {
        int glen = unicodePrevGraphemeLen(l->buf,l->pos);
        memmove(l->buf+l->pos-glen,l->buf+l->pos,l->len-l->pos);
        l->pos-=glen;
        l->len-=glen;
        l->buf[l->len] = '\0';
        refreshLine(l);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl 0x38(%rdi), %esi
testl %esi, %esi
jle 0x5d16
movq %rdi, %rbx
cmpl $0x0, 0x40(%rdi)
jle 0x5d16
movq 0x8(%rbx), %rdi
callq 0x6246
movslq 0x38(%rbx), %rcx
movq 0x8(%rbx), %rsi
addq %rcx, %rsi
movslq %eax, %r14
movq %rsi, %rdi
subq %r14, %rdi
movslq 0x40(%rbx), %rdx
subq %rcx, %rdx
callq 0x2360
subl %r14d, 0x38(%rbx)
movslq 0x40(%rbx), %rax
subq %r14, %rax
movl %eax, 0x40(%rbx)
movq 0x8(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x63c7
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::linenoiseEditDelete(linenoise::linenoiseState*)
inline void linenoiseEditDelete(struct linenoiseState *l) {
    if (l->len > 0 && l->pos < l->len) {
        int glen = unicodeGraphemeLen(l->buf,l->len,l->pos);
        memmove(l->buf+l->pos,l->buf+l->pos+glen,l->len-l->pos-glen);
        l->len-=glen;
        l->buf[l->len] = '\0';
        refreshLine(l);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl 0x40(%rdi), %esi
testl %esi, %esi
jle 0x5d7a
movq %rdi, %rbx
movl 0x38(%rdi), %edx
cmpl %esi, %edx
jge 0x5d7a
movq 0x8(%rbx), %rdi
callq 0x6315
movslq 0x38(%rbx), %rdi
movslq %eax, %r14
leal (%r14,%rdi), %eax
addq 0x8(%rbx), %rdi
leaq (%rdi,%r14), %rsi
movl 0x40(%rbx), %ecx
subl %eax, %ecx
movslq %ecx, %rdx
callq 0x2360
movslq 0x40(%rbx), %rax
subq %r14, %rax
movl %eax, 0x40(%rbx)
movq 0x8(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x63c7
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::linenoiseEditHistoryNext(linenoise::linenoiseState*, int)
inline void linenoiseEditHistoryNext(struct linenoiseState *l, int dir) {
    if (history.size() > 1) {
        /* Update the current history entry before to
         * overwrite it with the next one. */
        history[history.size() - 1 - l->history_index] = l->buf;
        /* Show the new entry */
        l->history_index += (dir == LINENOISE_HISTORY_PREV) ? 1 : -1;
        if (l->history_index < 0) {
            l->history_index = 0;
            return;
        } else if (l->history_index >= (int)history.size()) {
            l->history_index = static_cast<int>(history.size())-1;
            return;
        }
        memset(l->buf, 0, l->buflen);
        strcpy(l->buf,history[history.size() - 1 - l->history_index].c_str());
        l->len = l->pos = static_cast<int>(strlen(l->buf));
        refreshLine(l);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq 0x7d5a(%rip), %rcx      # 0xdb40
movq 0x7d4b(%rip), %rax      # 0xdb38
subq %rax, %rcx
cmpq $0x21, %rcx
jb 0x5e9c
movl %esi, %r14d
movq %rdi, %rbx
movq 0x8(%rdi), %rsi
movslq 0x4c(%rdi), %rdi
notq %rdi
addq %rcx, %rax
shlq $0x5, %rdi
addq %rax, %rdi
callq 0x23a0
xorl %eax, %eax
cmpl $0x1, %r14d
sete %al
leal -0x1(,%rax,2), %eax
addl 0x4c(%rbx), %eax
movl %eax, 0x4c(%rbx)
js 0x5e91
movq 0x7d07(%rip), %rcx      # 0xdb40
subq 0x7cf8(%rip), %rcx      # 0xdb38
shrq $0x5, %rcx
cmpl %ecx, %eax
jge 0x5e97
movq 0x8(%rbx), %rdi
movslq 0x10(%rbx), %rdx
xorl %esi, %esi
callq 0x2130
movq 0x8(%rbx), %rdi
movq 0x7cde(%rip), %rax      # 0xdb40
movslq 0x4c(%rbx), %rcx
notq %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
callq 0x2170
movq 0x8(%rbx), %rdi
callq 0x20f0
movl %eax, 0x38(%rbx)
movl %eax, 0x40(%rbx)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x63c7
andl $0x0, 0x4c(%rbx)
jmp 0x5e9c
decl %ecx
movl %ecx, 0x4c(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::linenoiseEditInsert(linenoise::linenoiseState*, char const*, int)
inline int linenoiseEditInsert(struct linenoiseState *l, const char* cbuf, int clen) {
    if (l->len < l->buflen) {
        if (l->len == l->pos) {
            memcpy(&l->buf[l->pos],cbuf,clen);
            l->pos+=clen;
            l->len+=clen;;
            l->buf[l->len] = '\0';
            if ((!mlmode && unicodeColumnPos(l->prompt.c_str(), static_cast<int>(l->prompt.length()))+unicodeColumnPos(l->buf,l->len) < l->cols) /* || mlmode */) {
                /* Avoid a full update of the line in the
                 * trivial case. */
                if (write(l->ofd,cbuf,clen) == -1) return -1;
            } else {
                refreshLine(l);
            }
        } else {
            memmove(l->buf+l->pos+clen,l->buf+l->pos,l->len-l->pos);
            memcpy(&l->buf[l->pos],cbuf,clen);
            l->pos+=clen;
            l->len+=clen;
            l->buf[l->len] = '\0';
            refreshLine(l);
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movslq 0x40(%rdi), %rax
cmpl 0x10(%rdi), %eax
jge 0x5f89
movq %rsi, %r14
movq %rdi, %rbx
movslq 0x38(%rdi), %rcx
movq 0x8(%rdi), %rsi
movslq %edx, %r15
cmpl %ecx, %eax
jne 0x5f47
addq %rax, %rsi
movq %rsi, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2150
addl %r15d, 0x38(%rbx)
movslq 0x40(%rbx), %rax
addq %r15, %rax
movl %eax, 0x40(%rbx)
movq 0x8(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x18(%rbx), %rdi
movl 0x20(%rbx), %esi
callq 0x6525
movl %eax, %r12d
movq 0x8(%rbx), %rdi
movl 0x40(%rbx), %esi
callq 0x6525
addl %r12d, %eax
cmpl 0x44(%rbx), %eax
jge 0x5f81
movl 0x4(%rbx), %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x20a0
cmpq $-0x1, %rax
jne 0x5f89
pushq $-0x1
popq %rax
jmp 0x5f8b
addq %rcx, %rsi
leaq (%rsi,%r15), %rdi
subl %ecx, %eax
movslq %eax, %rdx
callq 0x2360
movslq 0x38(%rbx), %rdi
addq 0x8(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2150
addl %r15d, 0x38(%rbx)
movslq 0x40(%rbx), %rax
addq %r15, %rax
movl %eax, 0x40(%rbx)
movq 0x8(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq %rbx, %rdi
callq 0x63c7
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::linenoiseEditDeletePrevWord(linenoise::linenoiseState*)
inline void linenoiseEditDeletePrevWord(struct linenoiseState *l) {
    int old_pos = l->pos;
    int diff;

    while (l->pos > 0 && l->buf[l->pos-1] == ' ')
        l->pos--;
    while (l->pos > 0 && l->buf[l->pos-1] != ' ')
        l->pos--;
    diff = old_pos - l->pos;
    memmove(l->buf+l->pos,l->buf+old_pos,l->len-old_pos+1);
    l->len -= diff;
    refreshLine(l);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x38(%rdi), %ecx
movslq %ecx, %rax
movq 0x8(%rdi), %rsi
leaq -0x1(%rcx), %rdx
xorl %r14d, %r14d
leaq (%rcx,%r14), %rdi
testl %edi, %edi
jle 0x5fff
movl %edi, %edi
cmpb $0x20, -0x1(%rsi,%rdi)
jne 0x5fff
leal (%rdx,%r14), %edi
movl %edi, 0x38(%rbx)
decq %r14
jmp 0x5fcf
movl %edi, %edi
cmpb $0x20, -0x1(%rsi,%rdi)
je 0x6007
leal (%rdx,%r14), %edi
movl %edi, 0x38(%rbx)
decq %r14
leaq (%rcx,%r14), %rdi
testl %edi, %edi
jg 0x5fec
addq %rax, %rsi
leaq (%rsi,%r14), %rdi
movl 0x40(%rbx), %ecx
subl %eax, %ecx
incl %ecx
movslq %ecx, %rdx
callq 0x2360
addl %r14d, 0x40(%rbx)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x63c7
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::getCursorPosition(int, int)
inline int getCursorPosition(int ifd, int ofd) {
    char buf[32];
    int cols, rows;
    unsigned int i = 0;

    /* Report cursor location */
    if (write(ofd, "\x1b[6n", 4) != 4) return -1;

    /* Read the response: ESC [ rows ; cols R */
    while (i < sizeof(buf)-1) {
        if (read(ifd,buf+i,1) != 1) break;
        if (buf[i] == 'R') break;
        i++;
    }
    buf[i] = '\0';

    /* Parse it. */
    if (buf[0] != ESC || buf[1] != '[') return -1;
    if (sscanf(buf+2,"%d;%d",&rows,&cols) != 2) return -1;
    return cols;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl %esi, %eax
movl %edi, %r14d
leaq 0x49c1(%rip), %rsi      # 0xaa09
pushq $0x4
popq %rdx
movl %eax, %edi
callq 0x20a0
pushq $-0x1
popq %rbx
cmpq $0x4, %rax
jne 0x60c9
xorl %eax, %eax
pushq $0x1
popq %r15
movq %rax, %r12
cmpq $0x1f, %rax
je 0x6090
leaq (%r12,%rbp), %rsi
addq $-0x50, %rsi
movl %r14d, %edi
movq %r15, %rdx
callq 0x22d0
cmpq $0x1, %rax
jne 0x6090
leaq 0x1(%r12), %rax
cmpb $0x52, -0x50(%rbp,%r12)
jne 0x6061
movb $0x0, -0x50(%rbp,%r12)
cmpb $0x1b, -0x50(%rbp)
jne 0x60c9
cmpb $0x5b, -0x4f(%rbp)
jne 0x60c9
leaq -0x4e(%rbp), %rdi
leaq 0x4961(%rip), %rsi      # 0xaa0e
leaq -0x28(%rbp), %rdx
leaq -0x24(%rbp), %rcx
xorl %eax, %eax
callq 0x2190
cmpl $0x2, %eax
jne 0x60c6
movl -0x24(%rbp), %ebx
jmp 0x60c9
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::unicodeUTF8CharToCodePoint(char const*, int, int*)
inline int unicodeUTF8CharToCodePoint(
   const char* buf,
   int         len,
   int*        cp)
{
    if (len) {
        unsigned char byte = buf[0];
        if ((byte & 0x80) == 0) {
            *cp = byte;
            return 1;
        } else if ((byte & 0xE0) == 0xC0) {
            if (len >= 2) {
                *cp = (((unsigned long)(buf[0] & 0x1F)) << 6) |
                       ((unsigned long)(buf[1] & 0x3F));
                return 2;
            }
        } else if ((byte & 0xF0) == 0xE0) {
            if (len >= 3) {
                *cp = (((unsigned long)(buf[0] & 0x0F)) << 12) |
                      (((unsigned long)(buf[1] & 0x3F)) << 6) |
                       ((unsigned long)(buf[2] & 0x3F));
                return 3;
            }
        } else if ((byte & 0xF8) == 0xF0) {
            if (len >= 4) {
                *cp = (((unsigned long)(buf[0] & 0x07)) << 18) |
                      (((unsigned long)(buf[1] & 0x3F)) << 12) |
                      (((unsigned long)(buf[2] & 0x3F)) << 6) |
                       ((unsigned long)(buf[3] & 0x3F));
                return 4;
            }
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
testl %esi, %esi
je 0x61bb
movzbl (%rdi), %ecx
testb %cl, %cl
js 0x60f7
movl $0x1, %eax
jmp 0x61b9
movl %ecx, %r8d
andl $-0x20, %r8d
cmpl $0xc0, %r8d
jne 0x612c
cmpl $0x2, %esi
jl 0x61bb
andl $0x1f, %ecx
shll $0x6, %ecx
movl $0x2, %eax
movabsq $0x1, %r8
movl %ecx, %esi
jmp 0x61af
movl %ecx, %r8d
andl $-0x10, %r8d
cmpl $0xe0, %r8d
jne 0x6164
cmpl $0x3, %esi
jl 0x61bb
andl $0xf, %ecx
shll $0xc, %ecx
movzbl 0x1(%rdi), %esi
andl $0x3f, %esi
shll $0x6, %esi
orl %ecx, %esi
movl $0x3, %eax
movabsq $0x2, %r8
jmp 0x61af
movl %ecx, %r8d
andl $-0x8, %r8d
cmpl $0xf0, %r8d
setne %r8b
cmpl $0x4, %esi
setl %sil
orb %r8b, %sil
jne 0x61bb
andl $0x7, %ecx
shll $0x12, %ecx
movzbl 0x1(%rdi), %eax
andl $0x3f, %eax
shll $0xc, %eax
orl %ecx, %eax
movzbl 0x2(%rdi), %esi
andl $0x3f, %esi
shll $0x6, %esi
orl %eax, %esi
movl $0x4, %eax
movabsq $0x3, %r8
movzbl (%rdi,%r8), %ecx
andl $0x3f, %ecx
orl %esi, %ecx
movl %ecx, (%rdx)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::unicodePrevGraphemeLen(char*, int)
inline int unicodePrevGraphemeLen(char* buf, int pos)
{
    if (pos == 0) {
        return 0;
    }
    int end = pos;
    while (pos > 0) {
        int len = unicodePrevUTF8CharLen(buf, pos);
        pos -= len;
        int cp = 0;
        unicodeUTF8CharToCodePoint(buf + pos, len, &cp);
        if (!unicodeIsCombiningChar(cp)) {
            return end - pos;
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ebx, %ebx
testl %esi, %esi
je 0x62a1
movl %esi, %r14d
movq %rdi, %r15
leaq -0x2c(%rbp), %r13
movl %esi, %r12d
testl %r12d, %r12d
jle 0x62a1
movq %r15, %rdi
movl %r12d, %esi
callq 0x62b2
andl $0x0, -0x2c(%rbp)
subl %eax, %r12d
movslq %r12d, %rdi
addq %r15, %rdi
movl %eax, %esi
movq %r13, %rdx
callq 0x60d8
movslq -0x2c(%rbp), %rdi
callq 0x62e7
testl %eax, %eax
jne 0x6267
subl %r12d, %r14d
movl %r14d, %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_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::unicodeGraphemeLen(char*, int, int)
inline int unicodeGraphemeLen(char* buf, int buf_len, int pos)
{
    if (pos == buf_len) {
        return 0;
    }
    int beg = pos;
    pos += unicodeUTF8CharLen(buf, buf_len, pos);
    while (pos < buf_len) {
        int len = unicodeUTF8CharLen(buf, buf_len, pos);
        int cp = 0;
        unicodeUTF8CharToCodePoint(buf + pos, len, &cp);
        if (!unicodeIsCombiningChar(cp)) {
            return pos - beg;
        }
        pos += len;
    }
    return pos - beg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ebx, %ebx
cmpl %esi, %edx
je 0x6384
movl %edx, %r13d
movl %esi, %r14d
movq %rdi, %r15
callq 0x6395
movl %eax, %r12d
movl %r13d, -0x2c(%rbp)
addl %r13d, %r12d
leaq -0x30(%rbp), %r13
movl %r12d, %ebx
cmpl %r14d, %r12d
jge 0x6381
movq %r15, %rdi
movl %r14d, %esi
movl %ebx, %edx
callq 0x6395
andl $0x0, -0x30(%rbp)
movl %eax, %r12d
movslq %ebx, %rdi
addq %r15, %rdi
movl %eax, %esi
movq %r13, %rdx
callq 0x60d8
movslq -0x30(%rbp), %rdi
callq 0x62e7
addl %ebx, %r12d
testl %eax, %eax
jne 0x6345
subl -0x2c(%rbp), %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_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::unicodeUTF8CharLen(char*, int, int)
inline int unicodeUTF8CharLen(char* buf, int buf_len, int pos)
{
    if (pos == buf_len) { return 0; }
    unsigned char ch = buf[pos];
    if (ch < 0x80) { return 1; }
    else if (ch < 0xE0) { return 2; }
    else if (ch < 0xF0) { return 3; }
    else { return 4; }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
cmpl %esi, %edx
je 0x63c5
movslq %edx, %rax
movb (%rdi,%rax), %al
testb %al, %al
js 0x63b0
movl $0x1, %eax
jmp 0x63c5
cmpb $-0x20, %al
jae 0x63bb
movl $0x2, %eax
jmp 0x63c5
cmpb $-0x10, %al
movl $0x4, %eax
sbbl $0x0, %eax
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::refreshSingleLine(linenoise::linenoiseState*)
inline void refreshSingleLine(struct linenoiseState *l) {
    char seq[64];
    int pcolwid = unicodeColumnPos(l->prompt.c_str(), static_cast<int>(l->prompt.length()));
    int fd = l->ofd;
    char *buf = l->buf;
    int len = l->len;
    int pos = l->pos;
    std::string ab;

    while((pcolwid+unicodeColumnPos(buf, pos)) >= l->cols) {
        int glen = unicodeGraphemeLen(buf, len, 0);
        buf += glen;
        len -= glen;
        pos -= glen;
    }
    while (pcolwid+unicodeColumnPos(buf, len) > l->cols) {
        len -= unicodePrevGraphemeLen(buf, len);
    }

    /* Cursor to left edge */
    snprintf(seq,64,"\r");
    ab += seq;
    /* Write the prompt and the current buffer content */
    ab += l->prompt;
    ab.append(buf, len);
    /* Erase to right */
    snprintf(seq,64,"\x1b[0K");
    ab += seq;
    /* Move cursor to original position. */
    snprintf(seq,64,"\r\x1b[%dC", (int)(unicodeColumnPos(buf, pos)+pcolwid));
    ab += seq;
    if (write(fd,ab.c_str(), static_cast<int>(ab.length())) == -1) {} /* Can't recover from write error. */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %r13
leaq 0x18(%rdi), %rax
movq %rax, -0x58(%rbp)
movq 0x18(%rdi), %rdi
movl 0x20(%r13), %esi
callq 0x6525
movl %eax, %r14d
movl 0x4(%r13), %eax
movl %eax, -0x2c(%rbp)
movq 0x8(%r13), %r15
movl 0x40(%r13), %ebx
movl 0x38(%r13), %r12d
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %r15, %rdi
movl %r12d, %esi
callq 0x6525
addl %r14d, %eax
cmpl 0x44(%r13), %eax
jl 0x644e
movq %r15, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x6315
cltq
addq %rax, %r15
subl %eax, %ebx
subl %eax, %r12d
jmp 0x6416
movq %r15, %rdi
movl %ebx, %esi
callq 0x6246
subl %eax, %ebx
movq %r15, %rdi
movl %ebx, %esi
callq 0x6525
addl %r14d, %eax
cmpl 0x44(%r13), %eax
jg 0x6442
leaq -0xa0(%rbp), %rsi
movw $0xd, (%rsi)
leaq -0x50(%rbp), %rdi
callq 0x2390
leaq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x23b0
movslq %ebx, %rdx
leaq -0x50(%rbp), %rdi
movq %r15, %rsi
callq 0x2050
leaq -0xa0(%rbp), %rsi
movb $0x0, 0x4(%rsi)
movl $0x4b305b1b, (%rsi)     # imm = 0x4B305B1B
leaq -0x50(%rbp), %rdi
callq 0x2390
movq %r15, %rdi
movl %r12d, %esi
callq 0x6525
addl %r14d, %eax
leaq 0x4553(%rip), %rdx      # 0xaa14
leaq -0xa0(%rbp), %rbx
pushq $0x40
popq %rsi
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x2350
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x2390
movq -0x50(%rbp), %rsi
movslq -0x48(%rbp), %rdx
movl -0x2c(%rbp), %edi
callq 0x20a0
leaq -0x50(%rbp), %rdi
callq 0x2100
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6511
jmp 0x6511
jmp 0x6511
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x2380
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::unicodeColumnPos(char const*, int)
inline int unicodeColumnPos(const char* buf, int buf_len)
{
    int ret = 0;

    int off = 0;
    while (off < buf_len) {
        int len;
        if (isAnsiEscape(buf + off, buf_len - off, &len)) {
            off += len;
            continue;
        }

        int cp = 0;
        len = unicodeUTF8CharToCodePoint(buf + off, buf_len - off, &cp);

        if (!unicodeIsCombiningChar(cp)) {
            ret += unicodeIsWideChar(cp) ? 2 : 1;
        }

        off += len;
    }

    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %r13d
movq %rdi, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
leaq 0x3d34(%rip), %r12      # 0xa280
xorl %r15d, %r15d
movl %r13d, %ebx
subl %r15d, %ebx
jle 0x65cd
movslq %r15d, %r14
addq -0x40(%rbp), %r14
movq %r14, %rdi
movl %ebx, %esi
leaq -0x30(%rbp), %rdx
callq 0x65e0
testl %eax, %eax
jne 0x65c5
andl $0x0, -0x2c(%rbp)
movq %r14, %rdi
movl %ebx, %esi
leaq -0x2c(%rbp), %rdx
callq 0x60d8
movl %eax, -0x30(%rbp)
movslq -0x2c(%rbp), %rdi
callq 0x62e7
testl %eax, %eax
jne 0x65c5
movslq -0x2c(%rbp), %rax
xorl %ecx, %ecx
cmpq $0x200, %rcx            # imm = 0x200
je 0x65b4
cmpq %rax, (%rcx,%r12)
ja 0x65ae
cmpq %rax, 0x8(%rcx,%r12)
jae 0x65b8
addq $0x10, %rcx
jmp 0x6598
pushq $0x1
jmp 0x65ba
pushq $0x2
popq %rax
movq -0x38(%rbp), %rcx
addl %eax, %ecx
movq %rcx, -0x38(%rbp)
movl -0x30(%rbp), %eax
addl %eax, %r15d
jmp 0x654f
movq -0x38(%rbp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/sangwoojun[P]rv32emulator/./linenoise.hpp
// Function: linenoise::isAnsiEscape(char const*, int, int*)
inline int isAnsiEscape(const char* buf, int buf_len, int* len)
{
    if (buf_len > 2 && !memcmp("\033[", buf, 2)) {
        int off = 2;
        while (off < buf_len) {
            switch (buf[off++]) {
            case 'A': case 'B': case 'C': case 'D':
            case 'E': case 'F': case 'G': case 'H':
            case 'J': case 'K': case 'S': case 'T':
            case 'f': case 'm':
                *len = off;
                return 1;
            }
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
cmpl $0x3, %esi
jl 0x662c
cmpw $0x5b1b, (%rdi)         # imm = 0x5B1B
jne 0x662c
movl %esi, %esi
movabsq $0x2, %rcx
movabsq $0x1020000c06ff, %r8    # imm = 0x1020000C06FF
cmpq %rcx, %rsi
je 0x662c
movzbl (%rdi,%rcx), %r9d
incq %rcx
addl $-0x41, %r9d
cmpl $0x2c, %r9d
ja 0x6608
btq %r9, %r8
jae 0x6608
movl %ecx, (%rdx)
movl $0x1, %eax
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/smuething[P]dune-cxx11/26-unordered_map.cc
// Function: main
int main()
{
  std::unordered_map<double,int> m;
  m[3.7] = 4;
  assert(m[3.7] == 4);
  return 0;
}

// Assembly:
pushq %rbx
subq $0x40, %rsp
leaq 0x38(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movabsq $0x400d99999999999a, %rbx # imm = 0x400D99999999999A
movq %rsp, %rsi
movq %rbx, (%rsi)
leaq 0x8(%rsp), %rdi
callq 0x1354
movl $0x4, (%rax)
movq %rsp, %rsi
movq %rbx, (%rsi)
leaq 0x8(%rsp), %rdi
callq 0x1354
cmpl $0x4, (%rax)
jne 0x126b
leaq 0x8(%rsp), %rdi
callq 0x12a0
xorl %eax, %eax
addq $0x40, %rsp
popq %rbx
retq
leaq 0xd92(%rip), %rdi       # 0x2004
leaq 0xd97(%rip), %rsi       # 0x2010
leaq 0xda4(%rip), %rcx       # 0x2024
pushq $0x8
popq %rdx
callq 0x1080
jmp 0x128a
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x12a0
movq %rbx, %rdi
callq 0x10f0
nop
// File: /workspace/github_cpp_makefile_star2_O2/iZhangHui[P]CppPrimer/CH16_TemplatesAndGenericProgramming/exercises/ex16_51_52.cc
// Function: main
int main(int argc, char const *argv[])
{
	int i = 0;
	double d = 3.14;
	std::string s = "how now brown cow?";
	foo(i, s, 42, d);
	foo(s, 42, "hi");
	foo(d, s);
	foo("hi");

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
leaq -0x34(%rbp), %rbx
andl $0x0, (%rbx)
movabsq $0x40091eb851eb851f, %rax # imm = 0x40091EB851EB851F
leaq -0x30(%rbp), %r14
movq %rax, (%r14)
leaq 0xdfa(%rip), %rsi       # 0x2004
leaq -0x58(%rbp), %r15
leaq -0x24(%rbp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x1030
movl $0x2a, (%r12)
leaq -0x24(%rbp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x129a
leaq -0x24(%rbp), %rsi
movl $0x2a, (%rsi)
leaq 0xdcf(%rip), %rdx       # 0x2017
leaq -0x58(%rbp), %rdi
callq 0x12d6
leaq -0x30(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x1312
leaq 0xdb2(%rip), %rdi       # 0x2017
callq 0x134e
leaq -0x58(%rbp), %rdi
callq 0x1040
xorl %eax, %eax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1286
jmp 0x1286
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x1040
movq %rbx, %rdi
callq 0x1090