// File: sangwoojun[P]rv32emulator/emulator.cpp
// Function: parse_pseudoinstructions(int, char*, instr*, int, label_loc*, char*, char*, char*, char*, source*)
int parse_pseudoinstructions(int line, char* ftok, instr* imem, int ioff, label_loc* labels, char* o1, char* o2, char* o3, char* o4, source* src) {

	if ( streq(ftok, "li" ) ) {
		if ( !o1 || !o2 || o3 ) print_syntax_error(line, "Invalid format");

		int reg = parse_reg(o1, line);
		long int imml = strtol(o2, NULL, 0);


		if (reg < 0 || imml > UINT32_MAX || imml < INT32_MIN ) {
			printf( "Syntax error at line %d -- %lx, %x\n", line, imml, INT32_MAX);
			exit(1);
		}
		uint64_t uv = *(uint64_t*)&imml;
		uint32_t hv = (uv&UINT32_MAX);

		char areg[4]; sprintf(areg, "x%02d", reg);
		char immu[12]; sprintf(immu, "0x%08x" , (hv>>12));
		char immd[12]; sprintf(immd, "0x%08x" , (hv&((1<<12)-1)));


		instr* i = &imem[ioff];
		i->op = LUI;
		i->a1.type = OPTYPE_REG; i->a1.reg = reg;
		i->a2.type = OPTYPE_IMM; i->a2.imm = hv>>12;
		i->orig_line = line;
		append_source("lui", areg, immu, NULL, src, i);
		instr* i2 = &imem[ioff+1];

		i2->op = ADDI;
		i2->a1.type = OPTYPE_REG; i2->a1.reg = reg;
		i2->a2.type = OPTYPE_REG; i2->a2.reg = reg;
		i2->a3.type = OPTYPE_IMM; i2->a3.imm = (hv&((1<<12)-1)); 
		i2->orig_line = line;
		append_source("addi", areg, areg, immd, src, i2);
		//printf( ">> %d %x %d\n", reg, i->a2.imm, i->a2.imm );
		//printf( ">> %d %x %d\n", reg, i2->a3.imm, i2->a3.imm );
		return 2;
	}
	if ( streq(ftok, "la") || streq(ftok, "lla") ) {
		if ( !o1 || !o2 || o3 ) print_syntax_error(line, "Invalid format");

		int reg = parse_reg(o1, line);

		instr* i = &imem[ioff];
		i->op = LUI;
		i->a1.type = OPTYPE_REG; i->a1.reg = reg;
		i->a2.type = OPTYPE_LABEL; strncpy(i->a2.label, o2, MAX_LABEL_LEN);
		i->orig_line = line;
		//append_source(ftok, o1, o2, o3, src, i); // done in normalize
		instr* i2 = &imem[ioff+1];
		i2->op = ADDI;
		i2->a1.type = OPTYPE_REG; i2->a1.reg = reg;
		i2->a2.type = OPTYPE_REG; i2->a2.reg = reg;
		i2->a3.type = OPTYPE_LABEL; strncpy(i2->a3.label, o2, MAX_LABEL_LEN);
		i2->orig_line = line;
		//append_source(ftok, o1, o2, o3, src, i2); // done in normalize
		return 2;
	}
	if ( streq(ftok, "nop" )) {
		if ( o1 ) print_syntax_error(line, "Invalid format");

		instr* i = &imem[ioff];
		i->op = ADDI;
		i->a1.type = OPTYPE_REG; i->a1.reg = 0;
		i->a2.type = OPTYPE_REG; i->a2.reg = 0;
		i->a3.type = OPTYPE_IMM; i->a3.imm = 0;
		i->orig_line = line;
		append_source("nop", "zero", "zero", "0", src, i);
		return 1;
	}
	if ( streq(ftok, "ret" )) {
		if ( o1 ) print_syntax_error(line, "Invalid format");

		instr* i = &imem[ioff];
		i->op = JALR;
		i->a1.type = OPTYPE_REG; i->a1.reg = 0;
		i->a2.type = OPTYPE_REG; i->a2.reg = 1;
		i->a3.type = OPTYPE_IMM; i->a3.imm = 0;
		i->orig_line = line;
		append_source("jalr", "x0", "x1", "x0", src, i);
		return 1;
	}
	if ( streq(ftok, "jr" )) {
		if ( !o1 || o2 ) print_syntax_error(line, "Invalid format");

		instr* i = &imem[ioff];
		i->op = JALR;
		i->a1.type = OPTYPE_REG; i->a1.reg = 0;
		i->a2.type = OPTYPE_REG; i->a2.reg = parse_reg(o1, line);
		i->a3.type = OPTYPE_IMM; i->a3.imm = 0;
		i->orig_line = line;
		append_source("jalr", "x0", o1, "x0", src, i);
		return 1;
	}
	if ( streq(ftok, "j" )) {
		if ( !o1 || o2 ) print_syntax_error(line, "Invalid format");

		instr* i = &imem[ioff];
		i->op = JAL;
		i->a1.type = OPTYPE_REG; i->a1.reg = 0;
		i->a2.type = OPTYPE_LABEL; strncpy(i->a2.label, o1, MAX_LABEL_LEN);
		i->orig_line = line;
		append_source("j", "x0", o1, NULL, src, i);
		return 1;
	}
	if ( streq(ftok, "call" )) {
		if ( !o1 || o2 ) print_syntax_error(line, "Invalid format");

		instr* i = &imem[ioff];
		i->op = JAL;
		i->a1.type = OPTYPE_REG; i->a1.reg = 1;
		i->a2.type = OPTYPE_LABEL; strncpy(i->a2.label, o1, MAX_LABEL_LEN);
		i->orig_line = line;
		append_source("jal", "x1", o1, NULL, src, i);
		return 1;
	}
	if ( streq(ftok, "mv" )) {
		if ( !o1 || !o2 || o3 ) print_syntax_error(line, "Invalid format");
		instr* i = &imem[ioff];
		i->op = ADDI;
		i->a1.type = OPTYPE_REG; i->a1.reg = parse_reg(o1, line);
		i->a2.type = OPTYPE_REG; i->a2.reg = parse_reg(o2, line);
		i->a3.type = OPTYPE_IMM; i->a3.imm = 0;
		i->orig_line = line;
		append_source("addi",o1, o2, NULL, src, i);
		return 1;
	}
	if ( streq(ftok, "bnez" )) {
		if ( !o1 || !o2 || o3 ) print_syntax_error(line, "Invalid format");
		instr* i = &imem[ioff];
		i->op = BNE;
		i->a1.type = OPTYPE_REG; i->a1.reg = parse_reg(o1, line);
		i->a2.type = OPTYPE_REG; i->a2.reg = 0;
		i->a3.type = OPTYPE_LABEL; strncpy(i->a3.label, o2, MAX_LABEL_LEN);
		i->orig_line = line;
		append_source("bne", "x0", o1, o2, src, i);
		return 1;
	}
	if ( streq(ftok, "beqz" )) {
		if ( !o1 || !o2 || o3 ) print_syntax_error(line, "Invalid format");
		instr* i = &imem[ioff];
		i->op = BEQ;
		i->a1.type = OPTYPE_REG; i->a1.reg = parse_reg(o1, line);
		i->a2.type = OPTYPE_REG; i->a2.reg = 0;
		i->a3.type = OPTYPE_LABEL; strncpy(i->a3.label, o2, MAX_LABEL_LEN);
		i->orig_line = line;
		append_source("beq", "x0", o1, o2, src, i);
		return 1;
	}
	if ( streq(ftok, "bgt" )) {
		if ( !o1 || !o2 || !o3 || o4 ) print_syntax_error(line, "Invalid format");
		instr* i = &imem[ioff];
		i->op = BLT;
		i->a1.type = OPTYPE_REG; i->a2.reg = parse_reg(o1, line);
		i->a2.type = OPTYPE_REG; i->a1.reg = parse_reg(o2, line);
		i->a3.type = OPTYPE_LABEL; strncpy(i->a3.label, o3, MAX_LABEL_LEN);
		i->orig_line = line;
		append_source("blt", o2, o1, o3, src, i);
		return 1;
	}
	if ( streq(ftok, "ble" )) {
		if ( !o1 || !o2 || !o3 || o4 ) print_syntax_error(line, "Invalid format");
		instr* i = &imem[ioff];
		i->op = BGE;
		i->a1.type = OPTYPE_REG; i->a2.reg = parse_reg(o1, line);
		i->a2.type = OPTYPE_REG; i->a1.reg = parse_reg(o2, line);
		i->a3.type = OPTYPE_LABEL; strncpy(i->a3.label, o3, MAX_LABEL_LEN);
		i->orig_line = line;
		append_source("bge", o2, o1, o3, src, i);
		return 1;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7313(%rip), %rsi      # 0xb3ff
callq 0x2c10
testb $0x1, %al
jne 0x40fa
jmp 0x4305
cmpq $0x0, -0x30(%rbp)
je 0x410f
cmpq $0x0, 0x10(%rbp)
je 0x410f
cmpq $0x0, 0x18(%rbp)
je 0x411e
movl -0x8(%rbp), %edi
leaq 0x74da(%rip), %rsi      # 0xb5f3
callq 0x2c90
movq -0x30(%rbp), %rdi
movl -0x8(%rbp), %esi
movl $0x1, %edx
callq 0x3250
movl %eax, -0x34(%rbp)
movq 0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x2300
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x4160
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0x40(%rbp)
jg 0x4160
cmpq $-0x80000000, -0x40(%rbp) # imm = 0x80000000
jge 0x4184
movl -0x8(%rbp), %esi
movq -0x40(%rbp), %rdx
leaq 0x7494(%rip), %rdi      # 0xb602
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movb $0x0, %al
callq 0x2040
movl $0x1, %edi
callq 0x2250
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movabsq $0xffffffff, %rax       # imm = 0xFFFFFFFF
andq -0x48(%rbp), %rax
movl %eax, -0x4c(%rbp)
leaq -0x50(%rbp), %rdi
movl -0x34(%rbp), %edx
leaq 0x747b(%rip), %rsi      # 0xb626
movb $0x0, %al
callq 0x2060
leaq -0x5c(%rbp), %rdi
movl -0x4c(%rbp), %edx
shrl $0xc, %edx
leaq 0x7469(%rip), %rsi      # 0xb62c
movb $0x0, %al
callq 0x2060
leaq -0x68(%rbp), %rdi
movl -0x4c(%rbp), %edx
andl $0xfff, %edx            # imm = 0xFFF
leaq 0x744e(%rip), %rsi      # 0xb62c
movb $0x0, %al
callq 0x2060
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movl $0x12, (%rax)
movq -0x70(%rbp), %rax
movl $0x1, 0x4(%rax)
movl -0x34(%rbp), %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x70(%rbp), %rax
movl $0x2, 0x30(%rax)
movl -0x4c(%rbp), %ecx
shrl $0xc, %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x58(%rax)
movl -0x8(%rbp), %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x90(%rax)
leaq -0x50(%rbp), %rsi
leaq -0x5c(%rbp), %rdx
movq 0x28(%rbp), %r8
movq -0x70(%rbp), %r9
leaq 0x71f9(%rip), %rdi      # 0xb44f
xorl %eax, %eax
movl %eax, %ecx
callq 0x3b70
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl $0x2, (%rax)
movq -0x78(%rbp), %rax
movl $0x1, 0x4(%rax)
movl -0x34(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x78(%rbp), %rax
movl $0x1, 0x30(%rax)
movl -0x34(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0x78(%rbp), %rax
movl $0x2, 0x5c(%rax)
movl -0x4c(%rbp), %ecx
andl $0xfff, %ecx            # imm = 0xFFF
movq -0x78(%rbp), %rax
movl %ecx, 0x84(%rax)
movl -0x8(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, 0x90(%rax)
leaq -0x50(%rbp), %rsi
leaq -0x50(%rbp), %rdx
leaq -0x68(%rbp), %rcx
movq 0x28(%rbp), %r8
movq -0x78(%rbp), %r9
leaq 0x70ef(%rip), %rdi      # 0xb3e3
callq 0x3b70
movl $0x2, -0x4(%rbp)
jmp 0x4ed8
movq -0x10(%rbp), %rdi
leaq 0x7324(%rip), %rsi      # 0xb634
callq 0x2c10
testb $0x1, %al
jne 0x4332
movq -0x10(%rbp), %rdi
leaq 0x730f(%rip), %rsi      # 0xb633
callq 0x2c10
testb $0x1, %al
jne 0x4332
jmp 0x448e
cmpq $0x0, -0x30(%rbp)
je 0x4347
cmpq $0x0, 0x10(%rbp)
je 0x4347
cmpq $0x0, 0x18(%rbp)
je 0x4356
movl -0x8(%rbp), %edi
leaq 0x72a2(%rip), %rsi      # 0xb5f3
callq 0x2c90
movq -0x30(%rbp), %rdi
movl -0x8(%rbp), %esi
movl $0x1, %edx
callq 0x3250
movl %eax, -0x7c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movl $0x12, (%rax)
movq -0x88(%rbp), %rax
movl $0x1, 0x4(%rax)
movl -0x7c(%rbp), %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x88(%rbp), %rax
movl $0x3, 0x30(%rax)
movq -0x88(%rbp), %rdi
addq $0x30, %rdi
addq $0x4, %rdi
movq 0x10(%rbp), %rsi
movl $0x20, %edx
callq 0x2120
movl -0x8(%rbp), %ecx
movq -0x88(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movl $0x2, (%rax)
movq -0x90(%rbp), %rax
movl $0x1, 0x4(%rax)
movl -0x7c(%rbp), %ecx
movq -0x90(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x90(%rbp), %rax
movl $0x1, 0x30(%rax)
movl -0x7c(%rbp), %ecx
movq -0x90(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0x90(%rbp), %rax
movl $0x3, 0x5c(%rax)
movq -0x90(%rbp), %rdi
addq $0x5c, %rdi
addq $0x4, %rdi
movq 0x10(%rbp), %rsi
movl $0x20, %edx
callq 0x2120
movl -0x8(%rbp), %ecx
movq -0x90(%rbp), %rax
movl %ecx, 0x90(%rax)
movl $0x2, -0x4(%rbp)
jmp 0x4ed8
movq -0x10(%rbp), %rdi
leaq 0x719e(%rip), %rsi      # 0xb637
callq 0x2c10
testb $0x1, %al
jne 0x44a7
jmp 0x457e
cmpq $0x0, -0x30(%rbp)
je 0x44bd
movl -0x8(%rbp), %edi
leaq 0x713b(%rip), %rsi      # 0xb5f3
callq 0x2c90
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movl $0x2, (%rax)
movq -0x98(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x98(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x98(%rbp), %rax
movl $0x1, 0x30(%rax)
movq -0x98(%rbp), %rax
movl $0x0, 0x54(%rax)
movq -0x98(%rbp), %rax
movl $0x2, 0x5c(%rax)
movq -0x98(%rbp), %rax
movl $0x0, 0x84(%rax)
movl -0x8(%rbp), %ecx
movq -0x98(%rbp), %rax
movl %ecx, 0x90(%rax)
movq 0x28(%rbp), %r8
movq -0x98(%rbp), %r9
leaq 0x70db(%rip), %rdi      # 0xb637
leaq 0x705d(%rip), %rdx      # 0xb5c0
leaq 0x6f4f(%rip), %rcx      # 0xb4b9
movq %rdx, %rsi
callq 0x3b70
movl $0x1, -0x4(%rbp)
jmp 0x4ed8
movq -0x10(%rbp), %rdi
leaq 0x70b2(%rip), %rsi      # 0xb63b
callq 0x2c10
testb $0x1, %al
jne 0x4597
jmp 0x466e
cmpq $0x0, -0x30(%rbp)
je 0x45ad
movl -0x8(%rbp), %edi
leaq 0x704b(%rip), %rsi      # 0xb5f3
callq 0x2c90
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movl $0xd, (%rax)
movq -0xa0(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0xa0(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0xa0(%rbp), %rax
movl $0x1, 0x30(%rax)
movq -0xa0(%rbp), %rax
movl $0x1, 0x54(%rax)
movq -0xa0(%rbp), %rax
movl $0x2, 0x5c(%rax)
movq -0xa0(%rbp), %rax
movl $0x0, 0x84(%rax)
movl -0x8(%rbp), %ecx
movq -0xa0(%rbp), %rax
movl %ecx, 0x90(%rax)
movq 0x28(%rbp), %r8
movq -0xa0(%rbp), %r9
leaq 0x6df8(%rip), %rdi      # 0xb444
leaq 0x6fec(%rip), %rcx      # 0xb63f
leaq 0x6fe8(%rip), %rdx      # 0xb642
movq %rcx, %rsi
callq 0x3b70
movl $0x1, -0x4(%rbp)
jmp 0x4ed8
movq -0x10(%rbp), %rdi
leaq 0x6fcc(%rip), %rsi      # 0xb645
callq 0x2c10
testb $0x1, %al
jne 0x4687
jmp 0x4771
cmpq $0x0, -0x30(%rbp)
je 0x4695
cmpq $0x0, 0x10(%rbp)
je 0x46a4
movl -0x8(%rbp), %edi
leaq 0x6f54(%rip), %rsi      # 0xb5f3
callq 0x2c90
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movl $0xd, (%rax)
movq -0xa8(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0xa8(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0xa8(%rbp), %rax
movl $0x1, 0x30(%rax)
movq -0x30(%rbp), %rdi
movl -0x8(%rbp), %esi
movl $0x1, %edx
callq 0x3250
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0xa8(%rbp), %rax
movl $0x2, 0x5c(%rax)
movq -0xa8(%rbp), %rax
movl $0x0, 0x84(%rax)
movl -0x8(%rbp), %ecx
movq -0xa8(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x30(%rbp), %rdx
movq 0x28(%rbp), %r8
movq -0xa8(%rbp), %r9
leaq 0x6cee(%rip), %rdi      # 0xb444
leaq 0x6ee2(%rip), %rcx      # 0xb63f
movq %rcx, %rsi
callq 0x3b70
movl $0x1, -0x4(%rbp)
jmp 0x4ed8
movq -0x10(%rbp), %rdi
leaq 0x6ecc(%rip), %rsi      # 0xb648
callq 0x2c10
testb $0x1, %al
jne 0x478a
jmp 0x4856
cmpq $0x0, -0x30(%rbp)
je 0x4798
cmpq $0x0, 0x10(%rbp)
je 0x47a7
movl -0x8(%rbp), %edi
leaq 0x6e51(%rip), %rsi      # 0xb5f3
callq 0x2c90
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movl $0xc, (%rax)
movq -0xb0(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0xb0(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0xb0(%rbp), %rax
movl $0x3, 0x30(%rax)
movq -0xb0(%rbp), %rdi
addq $0x30, %rdi
addq $0x4, %rdi
movq -0x30(%rbp), %rsi
movl $0x20, %edx
callq 0x2120
movl -0x8(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x30(%rbp), %rdx
movq 0x28(%rbp), %r8
movq -0xb0(%rbp), %r9
leaq 0x6e0e(%rip), %rdi      # 0xb648
leaq 0x6dfe(%rip), %rsi      # 0xb63f
xorl %eax, %eax
movl %eax, %ecx
callq 0x3b70
movl $0x1, -0x4(%rbp)
jmp 0x4ed8
movq -0x10(%rbp), %rdi
leaq 0x6de9(%rip), %rsi      # 0xb64a
callq 0x2c10
testb $0x1, %al
jne 0x486f
jmp 0x493b
cmpq $0x0, -0x30(%rbp)
je 0x487d
cmpq $0x0, 0x10(%rbp)
je 0x488c
movl -0x8(%rbp), %edi
leaq 0x6d6c(%rip), %rsi      # 0xb5f3
callq 0x2c90
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movl $0xc, (%rax)
movq -0xb8(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0xb8(%rbp), %rax
movl $0x1, 0x28(%rax)
movq -0xb8(%rbp), %rax
movl $0x3, 0x30(%rax)
movq -0xb8(%rbp), %rdi
addq $0x30, %rdi
addq $0x4, %rdi
movq -0x30(%rbp), %rsi
movl $0x20, %edx
callq 0x2120
movl -0x8(%rbp), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x30(%rbp), %rdx
movq 0x28(%rbp), %r8
movq -0xb8(%rbp), %r9
leaq 0x6b21(%rip), %rdi      # 0xb440
leaq 0x6d1c(%rip), %rsi      # 0xb642
xorl %eax, %eax
movl %eax, %ecx
callq 0x3b70
movl $0x1, -0x4(%rbp)
jmp 0x4ed8
movq -0x10(%rbp), %rdi
leaq 0x6d09(%rip), %rsi      # 0xb64f
callq 0x2c10
testb $0x1, %al
jne 0x4954
jmp 0x4a52
cmpq $0x0, -0x30(%rbp)
je 0x4969
cmpq $0x0, 0x10(%rbp)
je 0x4969
cmpq $0x0, 0x18(%rbp)
je 0x4978
movl -0x8(%rbp), %edi
leaq 0x6c80(%rip), %rsi      # 0xb5f3
callq 0x2c90
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movl $0x2, (%rax)
movq -0xc0(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x30(%rbp), %rdi
movl -0x8(%rbp), %esi
movl $0x1, %edx
callq 0x3250
movl %eax, %ecx
movq -0xc0(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0xc0(%rbp), %rax
movl $0x1, 0x30(%rax)
movq 0x10(%rbp), %rdi
movl -0x8(%rbp), %esi
movl $0x1, %edx
callq 0x3250
movl %eax, %ecx
movq -0xc0(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0xc0(%rbp), %rax
movl $0x2, 0x5c(%rax)
movq -0xc0(%rbp), %rax
movl $0x0, 0x84(%rax)
movl -0x8(%rbp), %ecx
movq -0xc0(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x30(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq 0x28(%rbp), %r8
movq -0xc0(%rbp), %r9
leaq 0x69a6(%rip), %rdi      # 0xb3e3
xorl %eax, %eax
movl %eax, %ecx
callq 0x3b70
movl $0x1, -0x4(%rbp)
jmp 0x4ed8
movq -0x10(%rbp), %rdi
leaq 0x6bf5(%rip), %rsi      # 0xb652
callq 0x2c10
testb $0x1, %al
jne 0x4a6b
jmp 0x4b69
cmpq $0x0, -0x30(%rbp)
je 0x4a80
cmpq $0x0, 0x10(%rbp)
je 0x4a80
cmpq $0x0, 0x18(%rbp)
je 0x4a8f
movl -0x8(%rbp), %edi
leaq 0x6b69(%rip), %rsi      # 0xb5f3
callq 0x2c90
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movl $0xb, (%rax)
movq -0xc8(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x30(%rbp), %rdi
movl -0x8(%rbp), %esi
movl $0x1, %edx
callq 0x3250
movl %eax, %ecx
movq -0xc8(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0xc8(%rbp), %rax
movl $0x1, 0x30(%rax)
movq -0xc8(%rbp), %rax
movl $0x0, 0x54(%rax)
movq -0xc8(%rbp), %rax
movl $0x3, 0x5c(%rax)
movq -0xc8(%rbp), %rdi
addq $0x5c, %rdi
addq $0x4, %rdi
movq 0x10(%rbp), %rsi
movl $0x20, %edx
callq 0x2120
movl -0x8(%rbp), %ecx
movq -0xc8(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x30(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq 0x28(%rbp), %r8
movq -0xc8(%rbp), %r9
leaq 0x68eb(%rip), %rdi      # 0xb43c
leaq 0x6ae7(%rip), %rsi      # 0xb63f
callq 0x3b70
movl $0x1, -0x4(%rbp)
jmp 0x4ed8
movq -0x10(%rbp), %rdi
leaq 0x6ae3(%rip), %rsi      # 0xb657
callq 0x2c10
testb $0x1, %al
jne 0x4b82
jmp 0x4c80
cmpq $0x0, -0x30(%rbp)
je 0x4b97
cmpq $0x0, 0x10(%rbp)
je 0x4b97
cmpq $0x0, 0x18(%rbp)
je 0x4ba6
movl -0x8(%rbp), %edi
leaq 0x6a52(%rip), %rsi      # 0xb5f3
callq 0x2c90
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movl $0x6, (%rax)
movq -0xd0(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x30(%rbp), %rdi
movl -0x8(%rbp), %esi
movl $0x1, %edx
callq 0x3250
movl %eax, %ecx
movq -0xd0(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0xd0(%rbp), %rax
movl $0x1, 0x30(%rax)
movq -0xd0(%rbp), %rax
movl $0x0, 0x54(%rax)
movq -0xd0(%rbp), %rax
movl $0x3, 0x5c(%rax)
movq -0xd0(%rbp), %rdi
addq $0x5c, %rdi
addq $0x4, %rdi
movq 0x10(%rbp), %rsi
movl $0x20, %edx
callq 0x2120
movl -0x8(%rbp), %ecx
movq -0xd0(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x30(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq 0x28(%rbp), %r8
movq -0xd0(%rbp), %r9
leaq 0x67be(%rip), %rdi      # 0xb426
leaq 0x69d0(%rip), %rsi      # 0xb63f
callq 0x3b70
movl $0x1, -0x4(%rbp)
jmp 0x4ed8
movq -0x10(%rbp), %rdi
leaq 0x69d1(%rip), %rsi      # 0xb65c
callq 0x2c10
testb $0x1, %al
jne 0x4c99
jmp 0x4daa
cmpq $0x0, -0x30(%rbp)
je 0x4cb5
cmpq $0x0, 0x10(%rbp)
je 0x4cb5
cmpq $0x0, 0x18(%rbp)
je 0x4cb5
cmpq $0x0, 0x20(%rbp)
je 0x4cc4
movl -0x8(%rbp), %edi
leaq 0x6934(%rip), %rsi      # 0xb5f3
callq 0x2c90
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
movl $0x9, (%rax)
movq -0xd8(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x30(%rbp), %rdi
movl -0x8(%rbp), %esi
movl $0x1, %edx
callq 0x3250
movl %eax, %ecx
movq -0xd8(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0xd8(%rbp), %rax
movl $0x1, 0x30(%rax)
movq 0x10(%rbp), %rdi
movl -0x8(%rbp), %esi
movl $0x1, %edx
callq 0x3250
movl %eax, %ecx
movq -0xd8(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0xd8(%rbp), %rax
movl $0x3, 0x5c(%rax)
movq -0xd8(%rbp), %rdi
addq $0x5c, %rdi
addq $0x4, %rdi
movq 0x18(%rbp), %rsi
movl $0x20, %edx
callq 0x2120
movl -0x8(%rbp), %ecx
movq -0xd8(%rbp), %rax
movl %ecx, 0x90(%rax)
movq 0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq 0x18(%rbp), %rcx
movq 0x28(%rbp), %r8
movq -0xd8(%rbp), %r9
leaq 0x669a(%rip), %rdi      # 0xb433
callq 0x3b70
movl $0x1, -0x4(%rbp)
jmp 0x4ed8
movq -0x10(%rbp), %rdi
leaq 0x68ab(%rip), %rsi      # 0xb660
callq 0x2c10
testb $0x1, %al
jne 0x4dc3
jmp 0x4ed1
cmpq $0x0, -0x30(%rbp)
je 0x4ddf
cmpq $0x0, 0x10(%rbp)
je 0x4ddf
cmpq $0x0, 0x18(%rbp)
je 0x4ddf
cmpq $0x0, 0x20(%rbp)
je 0x4dee
movl -0x8(%rbp), %edi
leaq 0x680a(%rip), %rsi      # 0xb5f3
callq 0x2c90
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
movl $0x7, (%rax)
movq -0xe0(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x30(%rbp), %rdi
movl -0x8(%rbp), %esi
movl $0x1, %edx
callq 0x3250
movl %eax, %ecx
movq -0xe0(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0xe0(%rbp), %rax
movl $0x1, 0x30(%rax)
movq 0x10(%rbp), %rdi
movl -0x8(%rbp), %esi
movl $0x1, %edx
callq 0x3250
movl %eax, %ecx
movq -0xe0(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0xe0(%rbp), %rax
movl $0x3, 0x5c(%rax)
movq -0xe0(%rbp), %rdi
addq $0x5c, %rdi
addq $0x4, %rdi
movq 0x18(%rbp), %rsi
movl $0x20, %edx
callq 0x2120
movl -0x8(%rbp), %ecx
movq -0xe0(%rbp), %rax
movl %ecx, 0x90(%rax)
movq 0x10(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq 0x18(%rbp), %rcx
movq 0x28(%rbp), %r8
movq -0xe0(%rbp), %r9
leaq 0x6567(%rip), %rdi      # 0xb42a
callq 0x3b70
movl $0x1, -0x4(%rbp)
jmp 0x4ed8
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)