// File: akshayrajput[P]ARMV8_Simulator/simulo.cpp
// Function: decode()
void decode()
{

    NIO = 4;
    int sf = (IR.getLowerData() & SF_MASK)>>31;
    int type_inst = (IR.getLowerData() & TYPE_MASK) >>25;//instruction group
    int sw = 0;
    
    if(type_inst == 8 || type_inst == 9)  //operand data processing immediate
    {
	    if(skip)
	{ 
	   printf("[log]- Skipping instruction\n"); 
	   return;
	}
	sw = 0;
	
        int inst = (IR.getData() & INST_IMM_TYPE) >> 23;

        if(inst == 0 || inst == 1) // PC relative addressing
        {
		//ADR , ADRP
            printf("[log] - PC relative\n");
	    if(sf == 1)
	    {
		    printf("[log]- ADRP\n");
		    ADR();
	    }
	    else
	    {
		    printf("[log] - ADR\n");
		    ADR();
	    }
        }
        else if(inst == 2 || inst == 3) // Add or subtract
        {
		int opc = (IR.getLowerData() & 0x60000000)>>29;//op + S
		int op1 = IR.getLowerData() & 0x0000001f ;//Rd
		int op2 = (IR.getLowerData() & 0x000003e0) >> 5 ;//Rn
		int op3 = (IR.getLowerData() & 0x003ffc00)>>10;//imm10
		if(opc == 0)
		{
			
			ADD(sf,sw,op1,op2,op3);
		}
		else if(opc == 1)
		{
			//TODO - adds
			ADDS();
		}
		else if(opc == 2)
		{
			
			SUB(sf,sw,op1,op2,op3);
			
		}
		else if(opc == 3)
		{
			//TODO - subs
			ADDS();
		}
        }
        
        else if(inst == 4)  //Logical 
        {
       		//only AND 
		int op1 = IR.getLowerData() & 0x0000001f ;//Rd
		int op2 = (IR.getLowerData() & 0x000003e0) >> 5 ;//Rn
		int op3 = (IR.getLowerData() & 0x04000000) >> 22;//N
		int op4 = (IR.getLowerData() & 0x0000fc00 ) >> 10 ;//imms
		int op5 = (IR.getLowerData() & 0x003f0000)>>16;//immr

		AND(sf,sw,op1,op2,0,op3,op4,op5);
        }
        
        else if(inst == 5)  //Move wide
        {
		printf("[log] - move instruction\n");
		int op1 = IR.getLowerData() & 0x0000001f ;//Rd
		int op2 = (IR.getLowerData() & 0x001fffe0 )>> 5; //imm16
		MOV(sf, sw,op1,op2);
       		 
        }
        
        else if(inst == 6)  //Bit field
        {

		printf("[log] - lsr|lsl|asr instruction\n");
		int opc = (IR.getLowerData() & 0x60000000)>>29;//op + S
		int op1 = IR.getLowerData() & 0x0000001f ;//Rd
		int op2 = (IR.getLowerData() & 0x000003e0) >> 5 ;//Rn
		int op3 = (IR.getLowerData() & 0x04000000) >> 22;//N
		int op4 = (IR.getLowerData() & 0x0000fc00 ) >> 10 ;//imms
		int op5 = (IR.getLowerData() & 0x003f0000)>>16;//immr

		if(opc == 0)
		{
			ASR(sf,sw,op1,op2,op5);
		}

		else if(opc == 2)
		{
			if(op4  == 31 || op4 == 63 )
			{
				printf("[log] - lsr instruction\n");
			 	LSR(sf,sw,op1,op2,op5);

			}

			else
			{
			 	printf("[log] - lsl instruction");
				LSL(sf,sw,op1,op2,op5);

			} 
		}
        }
        
        else if (inst == 7) //Extract
        {
        
        }
        
    }
    
    else if (type_inst == 5 || type_inst == 13)  //operand data processing register
    { 
	    if(skip)
	{ 
	   printf("[log]- Skipping instruction\n"); 
	   return;
	}
	sw  = 1;
        int inst = (IR.getLowerData() & INST_REG_TYPE)>>21;

        if(inst >= 80 && inst <=87)
        {
	   int opc = (IR.getLowerData() & 0x60000000)>>29;//opc
	   int op1 = IR.getLowerData() & 0x0000001f ;//Rd
	   int op2 = (IR.getLowerData() & 0x000003e0) >> 5 ;//Rn
	   int op3 = (IR.getLowerData() & 0x001f0000)>>16; //Rm
	   int op4 = (IR.getLowerData() & 0x0000fc00)>>10;//imm6


            printf("[log] - Logical shifted register instruction\n");

	    if(opc == 0)
	    {
		    printf("[log]- AND instruction\n");
		    AND(sf,sw,op1,op2,op3,0,0,0);
	    }
	    else if(opc == 1)
	    {
		    printf("[log]- MOV instruction\n");
		    MOV(sf, sw,op1,op3);

	    }


        }
        
        else if(inst == 88 || inst == 90 || inst == 92 || inst == 94)
        {
            printf("[log] - Add/ sub shifted register instruction\n");
		int opc = (IR.getLowerData() & 0x60000000)>>29;//op + S
		int op1 = IR.getLowerData() & 0x0000001f ;//Rd
		int op2 = (IR.getLowerData() & 0x000003e0) >> 5 ;//Rn
		int op3 = (IR.getLowerData() & 0x001f0000)>>16; //Rm
		int op4 = (IR.getLowerData() & 0x0000fc00)>>10;//imm6
		if(opc == 0)
		{
			// TODO - add
			ADD(sf,sw,op1,op2,op3);

		}
		else if(opc == 1)
		{
			//TODO - adds
			ADDS();
		}
		else if(opc == 2)
		{
			//TODO - sub
			SUB(sf,sw,op1,op2,op3);
		}
		else if(opc == 3)
		{
			//TODO - subs
			ADDS();
		}

        }
        
        else if(inst == 89 || inst == 91 || inst == 93 || inst == 95)
        {
            printf("[log] - Add/ sub extended register instruction\n");
        }
        
        else if(inst == 208)
        {
            printf("[log ] - Add/ sub with instruction\n");
        }
        
        else if(inst == 210)
        {
            printf("[log ] - condition compare register or immediate instruction\n");
        }
        
        else if(inst == 212)
        {
            printf("[log] - condition select instruction\n");
        }
        
          
    }

    else if (type_inst == 10 || type_inst == 11) // branch instructions 
  {

	 int inst = (IR.getLowerData() & INST_B_TYPE)>>25;

	 if(inst  == 10 || inst == 11)//unconditional branch
	 {
		if(skip)
		{ 
		   printf("[log]- Skipping instruction\n"); 
		   return;
		}
		 int op  = sf;//opcode for unconditional types
		 int64_t imm = IR.getLowerData()&0x03ffffff;
		 imm = signExtend(imm,25);
		 uint64_t offset = ((imm-1)*4) + PC.getData();
		 NIO = offset - PC.getData();
		 BBL(op,offset);
	 }
	 else if(inst == 42)
	 {
		 //conditional branch
		if(skip)
		{	 
	 	  printf("[log]- Skipping instruction\n"); 
	 	  return;
		}	

		if(sf ==1)
		{
			NOP();
			return;
		}

		int64_t imm = (IR.getLowerData()&0x00ffffe0)>>5;
		imm = signExtend(imm,25);
		int cond = IR.getLowerData()&0x0000000f;
			
		uint64_t offset = ((imm-1)*4)+PC.getData();//FIXME - take BR.getData() and imm*4 instead
		NIO = offset - PC.getData();
		BCOND(offset,cond);	

	 }
	 else if(inst == 43)
	 {
		 //unconditional branch register
		 int op = (IR.getLowerData() & 0x00600000)>>21;
		 int RN = (IR.getLowerData() & 0x000003e0)>>5;
		 if(op == 1 || op == 0)
		{
			//unconditional call register
		if(skip)
			{	 
	 		  printf("[log]- Skipping instruction\n"); 
	 		  return;
			}	

			BBRL(op,RN);

		}
		else if(op ==2)
		{
		
			//unconditional ret
			RN = 30;
			RET(RN);

		}
	 }
	 else if(inst == 26)
	 {
		if(skip)
			{	 
	 		  printf("[log]- Skipping instruction\n"); 
	 		  return;
			}
				
		//compare and branch immediate
		int op  = (IR.getLowerData() & 0x01000000)>>24;//opcode
		 int64_t imm = (IR.getLowerData()&0x00ffffe0)>>5;
		 imm = signExtend(imm,25);
		 int RT = IR.getLowerData()&0x0000001f ;
		 uint64_t offset = ((imm-1)*4)+PC.getData();//FIXME - use imm and BR.getData()
		 assert(RT >=0 && RT <= 31);

		 NIO = offset - PC.getData();
		 CBZNZ(sf,op,RT,offset);

	 }

  }
  else //load / store
  {
	int inst = (IR.getLowerData() & 0x10000000)>>28;

	  if(skip)
		{	 
	 		  printf("[log]- Skipping instruction\n"); 
	 		  return;
		}	
	
	if(inst == 0)
	{
		//TODO - STP,LDP 
		printf("[log] - LDP/STP instruction\n");
		LDP();
	}

	else if(inst == 1)
	{
	//TODO - LDR,LDRSW,STR
	printf("[log] - LDR/STR instruction\n");
	LDR();
	}

  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movl $0x4, 0x14853(%rip)     # 0x1e1f8
leaq 0x14834(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x80000000, %eax       # imm = 0x80000000
shrl $0x1f, %eax
movl %eax, -0x4(%rbp)
leaq 0x1481d(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1e000000, %eax       # imm = 0x1E000000
shrl $0x19, %eax
movl %eax, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x8, -0x8(%rbp)
je 0x99ea
cmpl $0x9, -0x8(%rbp)
jne 0x9d5f
testb $0x1, 0x1480c(%rip)     # 0x1e1fd
je 0x9a06
leaq 0x2459(%rip), %rdi      # 0xbe53
movb $0x0, %al
callq 0x1030
jmp 0xa49f
movl $0x0, -0xc(%rbp)
leaq 0x147cc(%rip), %rdi     # 0x1e1e0
callq 0xa6c0
andq $0x3800000, %rax        # imm = 0x3800000
shrq $0x17, %rax
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
je 0x9a32
cmpl $0x1, -0x10(%rbp)
jne 0x9a73
leaq 0x2437(%rip), %rdi      # 0xbe70
movb $0x0, %al
callq 0x1030
cmpl $0x1, -0x4(%rbp)
jne 0x9a5b
leaq 0x2438(%rip), %rdi      # 0xbe85
movb $0x0, %al
callq 0x1030
callq 0x7150
jmp 0x9a6e
leaq 0x2430(%rip), %rdi      # 0xbe92
movb $0x0, %al
callq 0x1030
callq 0x7150
jmp 0x9d5a
cmpl $0x2, -0x10(%rbp)
je 0x9a83
cmpl $0x3, -0x10(%rbp)
jne 0x9b37
leaq 0x14756(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x60000000, %eax       # imm = 0x60000000
shrl $0x1d, %eax
movl %eax, -0x14(%rbp)
leaq 0x1473f(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1f, %eax
movl %eax, -0x18(%rbp)
leaq 0x1472d(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x3e0, %eax            # imm = 0x3E0
shrl $0x5, %eax
movl %eax, -0x1c(%rbp)
leaq 0x14716(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x3ffc00, %eax         # imm = 0x3FFC00
shrl $0xa, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x9af7
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
callq 0x18a0
jmp 0x9b32
cmpl $0x1, -0x14(%rbp)
jne 0x9b04
callq 0x3010
jmp 0x9b30
cmpl $0x2, -0x14(%rbp)
jne 0x9b21
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
callq 0x21d0
jmp 0x9b2e
cmpl $0x3, -0x14(%rbp)
jne 0x9b2c
callq 0x3010
jmp 0x9b2e
jmp 0x9b30
jmp 0x9b32
jmp 0x9d58
cmpl $0x4, -0x10(%rbp)
jne 0x9bdb
leaq 0x14698(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1f, %eax
movl %eax, -0x24(%rbp)
leaq 0x14686(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x3e0, %eax            # imm = 0x3E0
shrl $0x5, %eax
movl %eax, -0x28(%rbp)
leaq 0x1466f(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x4000000, %eax        # imm = 0x4000000
shrl $0x16, %eax
movl %eax, -0x2c(%rbp)
leaq 0x14658(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0xfc00, %eax           # imm = 0xFC00
shrl $0xa, %eax
movl %eax, -0x30(%rbp)
leaq 0x14641(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x3f0000, %eax         # imm = 0x3F0000
shrl $0x10, %eax
movl %eax, -0x34(%rbp)
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
movl -0x2c(%rbp), %r9d
movl -0x30(%rbp), %r10d
movl -0x34(%rbp), %eax
xorl %r8d, %r8d
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x24a0
jmp 0x9d56
cmpl $0x5, -0x10(%rbp)
jne 0x9c2e
leaq 0x22b7(%rip), %rdi      # 0xbe9f
movb $0x0, %al
callq 0x1030
leaq 0x145ea(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1f, %eax
movl %eax, -0x38(%rbp)
leaq 0x145d8(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1fffe0, %eax         # imm = 0x1FFFE0
shrl $0x5, %eax
movl %eax, -0x3c(%rbp)
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x38(%rbp), %edx
movl -0x3c(%rbp), %ecx
callq 0x2380
jmp 0x9d54
cmpl $0x6, -0x10(%rbp)
jne 0x9d48
leaq 0x227a(%rip), %rdi      # 0xbeb9
movb $0x0, %al
callq 0x1030
leaq 0x14593(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x60000000, %eax       # imm = 0x60000000
shrl $0x1d, %eax
movl %eax, -0x40(%rbp)
leaq 0x1457c(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1f, %eax
movl %eax, -0x44(%rbp)
leaq 0x1456a(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x3e0, %eax            # imm = 0x3E0
shrl $0x5, %eax
movl %eax, -0x48(%rbp)
leaq 0x14553(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x4000000, %eax        # imm = 0x4000000
shrl $0x16, %eax
movl %eax, -0x4c(%rbp)
leaq 0x1453c(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0xfc00, %eax           # imm = 0xFC00
shrl $0xa, %eax
movl %eax, -0x50(%rbp)
leaq 0x14525(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x3f0000, %eax         # imm = 0x3F0000
shrl $0x10, %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x40(%rbp)
jne 0x9ce8
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x44(%rbp), %edx
movl -0x48(%rbp), %ecx
movl -0x54(%rbp), %r8d
callq 0x1c80
jmp 0x9d46
cmpl $0x2, -0x40(%rbp)
jne 0x9d44
cmpl $0x1f, -0x50(%rbp)
je 0x9cfa
cmpl $0x3f, -0x50(%rbp)
jne 0x9d1f
leaq 0x21d9(%rip), %rdi      # 0xbeda
movb $0x0, %al
callq 0x1030
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x44(%rbp), %edx
movl -0x48(%rbp), %ecx
movl -0x54(%rbp), %r8d
callq 0x2010
jmp 0x9d42
leaq 0x21cd(%rip), %rdi      # 0xbef3
movb $0x0, %al
callq 0x1030
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x44(%rbp), %edx
movl -0x48(%rbp), %ecx
movl -0x54(%rbp), %r8d
callq 0x1e20
jmp 0x9d44
jmp 0x9d46
jmp 0x9d52
cmpl $0x7, -0x10(%rbp)
jne 0x9d50
jmp 0x9d50
jmp 0x9d52
jmp 0x9d54
jmp 0x9d56
jmp 0x9d58
jmp 0x9d5a
jmp 0xa49f
cmpl $0x5, -0x8(%rbp)
je 0x9d6f
cmpl $0xd, -0x8(%rbp)
jne 0xa014
testb $0x1, 0x14487(%rip)     # 0x1e1fd
je 0x9d8b
leaq 0x20d4(%rip), %rdi      # 0xbe53
movb $0x0, %al
callq 0x1030
jmp 0xa49f
movl $0x1, -0xc(%rbp)
leaq 0x14447(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1fe00000, %eax       # imm = 0x1FE00000
shrl $0x15, %eax
movl %eax, -0x58(%rbp)
cmpl $0x50, -0x58(%rbp)
jl 0x9ea2
cmpl $0x57, -0x58(%rbp)
jg 0x9ea2
leaq 0x1441c(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x60000000, %eax       # imm = 0x60000000
shrl $0x1d, %eax
movl %eax, -0x5c(%rbp)
leaq 0x14405(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1f, %eax
movl %eax, -0x60(%rbp)
leaq 0x143f3(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x3e0, %eax            # imm = 0x3E0
shrl $0x5, %eax
movl %eax, -0x64(%rbp)
leaq 0x143dc(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1f0000, %eax         # imm = 0x1F0000
shrl $0x10, %eax
movl %eax, -0x68(%rbp)
leaq 0x143c5(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0xfc00, %eax           # imm = 0xFC00
shrl $0xa, %eax
movl %eax, -0x6c(%rbp)
leaq 0x20d9(%rip), %rdi      # 0xbf0b
movb $0x0, %al
callq 0x1030
cmpl $0x0, -0x5c(%rbp)
jne 0x9e76
leaq 0x20f3(%rip), %rdi      # 0xbf39
movb $0x0, %al
callq 0x1030
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x60(%rbp), %edx
movl -0x64(%rbp), %ecx
movl -0x68(%rbp), %r8d
xorl %r9d, %r9d
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
callq 0x24a0
jmp 0x9e9d
cmpl $0x1, -0x5c(%rbp)
jne 0x9e9b
leaq 0x20ce(%rip), %rdi      # 0xbf51
movb $0x0, %al
callq 0x1030
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x60(%rbp), %edx
movl -0x68(%rbp), %ecx
callq 0x2380
jmp 0x9e9d
jmp 0xa00f
cmpl $0x58, -0x58(%rbp)
je 0x9ebe
cmpl $0x5a, -0x58(%rbp)
je 0x9ebe
cmpl $0x5c, -0x58(%rbp)
je 0x9ebe
cmpl $0x5e, -0x58(%rbp)
jne 0x9f94
leaq 0x20a4(%rip), %rdi      # 0xbf69
movb $0x0, %al
callq 0x1030
leaq 0x1430d(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x60000000, %eax       # imm = 0x60000000
shrl $0x1d, %eax
movl %eax, -0x70(%rbp)
leaq 0x142f6(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1f, %eax
movl %eax, -0x74(%rbp)
leaq 0x142e4(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x3e0, %eax            # imm = 0x3E0
shrl $0x5, %eax
movl %eax, -0x78(%rbp)
leaq 0x142cd(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1f0000, %eax         # imm = 0x1F0000
shrl $0x10, %eax
movl %eax, -0x7c(%rbp)
leaq 0x142b6(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0xfc00, %eax           # imm = 0xFC00
shrl $0xa, %eax
movl %eax, -0x80(%rbp)
cmpl $0x0, -0x70(%rbp)
jne 0x9f57
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x74(%rbp), %edx
movl -0x78(%rbp), %ecx
movl -0x7c(%rbp), %r8d
callq 0x18a0
jmp 0x9f92
cmpl $0x1, -0x70(%rbp)
jne 0x9f64
callq 0x3010
jmp 0x9f90
cmpl $0x2, -0x70(%rbp)
jne 0x9f81
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x74(%rbp), %edx
movl -0x78(%rbp), %ecx
movl -0x7c(%rbp), %r8d
callq 0x21d0
jmp 0x9f8e
cmpl $0x3, -0x70(%rbp)
jne 0x9f8c
callq 0x3010
jmp 0x9f8e
jmp 0x9f90
jmp 0x9f92
jmp 0xa00d
cmpl $0x59, -0x58(%rbp)
je 0x9fac
cmpl $0x5b, -0x58(%rbp)
je 0x9fac
cmpl $0x5d, -0x58(%rbp)
je 0x9fac
cmpl $0x5f, -0x58(%rbp)
jne 0x9fbc
leaq 0x1fe5(%rip), %rdi      # 0xbf98
movb $0x0, %al
callq 0x1030
jmp 0xa00b
cmpl $0xd0, -0x58(%rbp)
jne 0x9fd5
leaq 0x1ffc(%rip), %rdi      # 0xbfc8
movb $0x0, %al
callq 0x1030
jmp 0xa009
cmpl $0xd2, -0x58(%rbp)
jne 0x9fee
leaq 0x2007(%rip), %rdi      # 0xbfec
movb $0x0, %al
callq 0x1030
jmp 0xa007
cmpl $0xd4, -0x58(%rbp)
jne 0xa005
leaq 0x202c(%rip), %rdi      # 0xc02a
movb $0x0, %al
callq 0x1030
jmp 0xa007
jmp 0xa009
jmp 0xa00b
jmp 0xa00d
jmp 0xa00f
jmp 0xa49d
cmpl $0xa, -0x8(%rbp)
je 0xa024
cmpl $0xb, -0x8(%rbp)
jne 0xa42a
leaq 0x141b5(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x7e000000, %eax       # imm = 0x7E000000
shrl $0x19, %eax
movl %eax, -0x84(%rbp)
cmpl $0xa, -0x84(%rbp)
je 0xa054
cmpl $0xb, -0x84(%rbp)
jne 0xa125
testb $0x1, 0x141a2(%rip)     # 0x1e1fd
je 0xa070
leaq 0x1def(%rip), %rdi      # 0xbe53
movb $0x0, %al
callq 0x1030
jmp 0xa49f
movl -0x4(%rbp), %eax
movl %eax, -0x88(%rbp)
leaq 0x14160(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x3ffffff, %eax        # imm = 0x3FFFFFF
movl %eax, %eax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
movl $0x19, %esi
callq 0x1350
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
subq $0x1, %rax
shlq $0x2, %rax
movq %rax, -0xf0(%rbp)
leaq 0x14120(%rip), %rdi     # 0x1e1e8
callq 0xa6c0
movq %rax, %rcx
movq -0xf0(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq 0x140f2(%rip), %rdi     # 0x1e1e8
callq 0xa6c0
movq %rax, %rcx
movq -0xe8(%rbp), %rax
subq %rcx, %rax
movl %eax, 0x140ea(%rip)     # 0x1e1f8
movl -0x88(%rbp), %edi
movq -0x98(%rbp), %rsi
callq 0x1520
jmp 0xa428
cmpl $0x2a, -0x84(%rbp)
jne 0xa222
testb $0x1, 0x140c4(%rip)     # 0x1e1fd
je 0xa14e
leaq 0x1d11(%rip), %rdi      # 0xbe53
movb $0x0, %al
callq 0x1030
jmp 0xa49f
cmpl $0x1, -0x4(%rbp)
jne 0xa15e
callq 0x13e0
jmp 0xa49f
leaq 0x1407b(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0xffffe0, %eax         # imm = 0xFFFFE0
shrl $0x5, %eax
movl %eax, %eax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
movl $0x19, %esi
callq 0x1350
movq %rax, -0xa0(%rbp)
leaq 0x14046(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0xf, %eax
movl %eax, -0xa4(%rbp)
movq -0xa0(%rbp), %rax
subq $0x1, %rax
shlq $0x2, %rax
movq %rax, -0x100(%rbp)
leaq 0x14023(%rip), %rdi     # 0x1e1e8
callq 0xa6c0
movq %rax, %rcx
movq -0x100(%rbp), %rax
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq 0x13ff5(%rip), %rdi     # 0x1e1e8
callq 0xa6c0
movq %rax, %rcx
movq -0xf8(%rbp), %rax
subq %rcx, %rax
movl %eax, 0x13fed(%rip)     # 0x1e1f8
movq -0xb0(%rbp), %rdi
movl -0xa4(%rbp), %esi
callq 0x15d0
jmp 0xa426
cmpl $0x2b, -0x84(%rbp)
jne 0xa2c9
leaq 0x13faa(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x600000, %eax         # imm = 0x600000
shrl $0x15, %eax
movl %eax, -0xb4(%rbp)
leaq 0x13f90(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x3e0, %eax            # imm = 0x3E0
shrl $0x5, %eax
movl %eax, -0xb8(%rbp)
cmpl $0x1, -0xb4(%rbp)
je 0xa275
cmpl $0x0, -0xb4(%rbp)
jne 0xa2a4
testb $0x1, 0x13f81(%rip)     # 0x1e1fd
je 0xa291
leaq 0x1bce(%rip), %rdi      # 0xbe53
movb $0x0, %al
callq 0x1030
jmp 0xa49f
movl -0xb4(%rbp), %edi
movl -0xb8(%rbp), %esi
callq 0x1400
jmp 0xa2c4
cmpl $0x2, -0xb4(%rbp)
jne 0xa2c2
movl $0x1e, -0xb8(%rbp)
movl -0xb8(%rbp), %edi
callq 0x17c0
jmp 0xa2c4
jmp 0xa424
cmpl $0x1a, -0x84(%rbp)
jne 0xa422
testb $0x1, 0x13f20(%rip)     # 0x1e1fd
je 0xa2f2
leaq 0x1b6d(%rip), %rdi      # 0xbe53
movb $0x0, %al
callq 0x1030
jmp 0xa49f
leaq 0x13ee7(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1000000, %eax        # imm = 0x1000000
shrl $0x18, %eax
movl %eax, -0xbc(%rbp)
leaq 0x13ecd(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0xffffe0, %eax         # imm = 0xFFFFE0
shrl $0x5, %eax
movl %eax, %eax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rdi
movl $0x19, %esi
callq 0x1350
movq %rax, -0xc8(%rbp)
leaq 0x13e98(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x1f, %eax
movl %eax, -0xcc(%rbp)
movq -0xc8(%rbp), %rax
subq $0x1, %rax
shlq $0x2, %rax
movq %rax, -0x110(%rbp)
leaq 0x13e75(%rip), %rdi     # 0x1e1e8
callq 0xa6c0
movq %rax, %rcx
movq -0x110(%rbp), %rax
addq %rcx, %rax
movq %rax, -0xd8(%rbp)
xorl %eax, %eax
cmpl $0x0, -0xcc(%rbp)
movb %al, -0x101(%rbp)
jl 0xa3ad
cmpl $0x1f, -0xcc(%rbp)
setle %al
movb %al, -0x101(%rbp)
movb -0x101(%rbp), %al
testb $0x1, %al
jne 0xa3b9
jmp 0xa3bb
jmp 0xa3da
leaq 0x1c8e(%rip), %rdi      # 0xc050
leaq 0x175e(%rip), %rsi      # 0xbb27
movl $0x23a, %edx            # imm = 0x23A
leaq 0x1c8e(%rip), %rcx      # 0xc063
callq 0x1060
movq -0xd8(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq 0x13df9(%rip), %rdi     # 0x1e1e8
callq 0xa6c0
movq %rax, %rcx
movq -0x118(%rbp), %rax
subq %rcx, %rax
movl %eax, 0x13df1(%rip)     # 0x1e1f8
movl -0x4(%rbp), %edi
movl -0xbc(%rbp), %esi
movl -0xcc(%rbp), %edx
movq -0xd8(%rbp), %rcx
callq 0x1700
jmp 0xa424
jmp 0xa426
jmp 0xa428
jmp 0xa49b
leaq 0x13daf(%rip), %rdi     # 0x1e1e0
callq 0xa6e0
andl $0x10000000, %eax       # imm = 0x10000000
shrl $0x1c, %eax
movl %eax, -0xdc(%rbp)
testb $0x1, 0x13db2(%rip)     # 0x1e1fd
je 0xa45d
leaq 0x19ff(%rip), %rdi      # 0xbe53
movb $0x0, %al
callq 0x1030
jmp 0xa49f
cmpl $0x0, -0xdc(%rbp)
jne 0xa47b
leaq 0x1c04(%rip), %rdi      # 0xc071
movb $0x0, %al
callq 0x1030
callq 0x4010
jmp 0xa499
cmpl $0x1, -0xdc(%rbp)
jne 0xa497
leaq 0x1c03(%rip), %rdi      # 0xc08e
movb $0x0, %al
callq 0x1030
callq 0x7250
jmp 0xa499
jmp 0xa49b
jmp 0xa49d
jmp 0xa49f
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopl (%rax,%rax)