// File: /workspace/github_c_makefile_star2_O0/salextpuru[P]speccy-toochain/src/hex2bin/mot2bin.c
// Function: main
int main (int argc, char *argv[])
{
  /* line inputted from file */
  char Line[MAX_LINE_SIZE];

  /* flag that a file was read */
  boolean Fileread;
  boolean Enable_Checksum_Error = FALSE;
  boolean Status_Checksum_Error = FALSE;

  /* cmd-line parameter # */
  char *c, *p;

  unsigned int Param;
  unsigned int i;

  /* Application specific */

  unsigned int 	Nb_Bytes;
  unsigned int 	Address, Lowest_Address, Highest_Address, Starting_Address;
  unsigned int 	Phys_Addr, Type;
  unsigned int 	temp;

  boolean Starting_Address_Setted = FALSE;

  int temp2;

  byte	Data_Str[MAX_LINE_SIZE];
  byte 	Checksum = 0;

#define CKS_8     0
#define CKS_16LE  1
#define CKS_16BE  2

  unsigned short int wCKS;
  unsigned short int w;
  unsigned int Cks_Type = CKS_8;
  unsigned int Cks_Start, Cks_End, Cks_Addr, Cks_Value;
  boolean Cks_range_set = FALSE;
  boolean Cks_Addr_set = FALSE;

  /* This will hold binary codes translated from hex file. */
  byte *Memory_Block;

  fprintf (stdout,PROGRAM" v"VERSION", Copyright (C) 1998 Jacques Pelletier\n"
		   "checksum extensions Copyright (C) 2004 Rockwell Automation\n"
		   "improved P.G. 2007\n\n");

  if (argc == 1)
	usage();

  strcpy(Extension, "bin"); /* default is for binary file extension */

  /* read file */
  Param = 1;

  for (Param = 1; Param < argc; Param++)
	{
	  c = p = argv[Param];
//#ifdef __linux__
	  /* We don't accept an option beginning with a '/' because it could be a file name. */
//	  if(*c == '-')
//#else
//        if((*c == '-') || (*c == '/'))
//#endif
		  if ( _COND_(c) ) {
            p = c + 2;
            /* Parameter may follow immediately after option */
            /* Skips after parameter to next option */
            if (*p == '\0')
			  p = argv[Param + 1];
			if ( !_COND_(p) )
				Param++;
				
			switch(tolower (*(++c)))
			  {
			  case 'e':
				/* Last parameter was -E, so this parameter is the filename extension. */
				if (strlen(p) > MAX_EXTENSION_SIZE)
				  usage();

				/* Check to see if the user put a period in the filename extension */
				if (strchr(p, '.') == NULL)
				  strcpy(Extension, p);
				else
				  strcpy(Extension, p+1);
				break;

			  case 'c':
				Enable_Checksum_Error = TRUE;
				break;
			  case 's':
				sscanf(p,"%x",&Starting_Address);
				Starting_Address_Setted = TRUE;
				break;
			  case 'p':
				sscanf(p,"%x",&PadByte);
				break;
			  case 'h':
				usage();
				break;
				/* New Checksum parameters */
			  case 'k':
				sscanf(p,"%x",&Cks_Type);
				if (Cks_Type != CKS_8 &&
					Cks_Type != CKS_16LE &&
					Cks_Type != CKS_16BE )
				  usage();
				break;
			  case 'r':
				sscanf(p,"%x",&Cks_Start);
				p = argv[ ++Param ];
				if ( _COND_(p) ) break;
				sscanf(p,"%x",&Cks_End );
				Cks_range_set = TRUE;
				break;
			  case 'f':
				sscanf(p,"%x",&Cks_Addr);
				p = argv[ ++Param ];
				if ( _COND_(p) ) break;
				sscanf( p, "%x",&Cks_Value );
				Cks_Addr_set = TRUE;
				break;
			  default:
				usage();
			  } /* switch */
		  } else
			break;
	  /* if option */

	} /* for Param */

  /* when user enters input file name */

  /* Assume last parameter is filename */
  strcpy(Filename,argv[argc -1]);

  /* Just a normal file name */
  NoFailOpenInputFile (Filename);
  PutExtension(Filename, Extension);
  NoFailOpenOutputFile(Filename);
  Fileread = TRUE;

  /* allocate a buffer */
  Memory_Block = (byte *) NoFailMalloc(MEMORY_SIZE);

  /* For EPROM or FLASH memory types, fill unused bytes with the padding byte (FF by default) */
  memset (Memory_Block,PadByte,MEMORY_SIZE);

  /* To begin, assume the lowest address is at the end of the memory.
	 subsequent addresses will lower this number. At the end of the input
	 file, this value will be the lowest address. */
  Lowest_Address = MEMORY_SIZE - 1;
  Highest_Address = 0;

  /* Now read the file & process the lines. */
  do /* repeat until EOF(Filin) */
    {
	  /* Read a line from input file. */
	  fgets(Line,MAX_LINE_SIZE,Filin);

	  /* Remove carriage return/line feed at the end of line. */
	  i = strlen(Line)-1;

	  if (Line[i] == '\n') Line[i] = '\0';

	  /* Scan starting address and nb of bytes. */
	  /* Look at the record type after the 'S' */
	  switch(Line[1])
        {
		  /* 16 bits address */
        case '1':
		  sscanf (Line,"S%1x%2x%4x%s",&Type,&Nb_Bytes,&Address,Data_Str);
		  Checksum = Nb_Bytes + (Address >> 8) + (Address & 0xFF);

		  /* Adjust Nb_Bytes for the number of data bytes */
		  Nb_Bytes = Nb_Bytes - 3;
		  break;

		  /* 24 bits address */
        case '2':
		  sscanf (Line,"S%1x%2x%6x%s",&Type,&Nb_Bytes,&Address,Data_Str);
		  Checksum = Nb_Bytes + (Address >> 16) + (Address >> 8) + (Address & 0xFF);

		  /* Adjust Nb_Bytes for the number of data bytes */
		  Nb_Bytes = Nb_Bytes - 4;
		  break;

		  /* 32 bits address */
        case '3':
		  sscanf (Line,"S%1x%2x%8x%s",&Type,&Nb_Bytes,&Address,Data_Str);
		  Checksum = Nb_Bytes + (Address >> 24) + (Address >> 16) + (Address >> 8) + (Address & 0xFF);

		  /* Adjust Nb_Bytes for the number of data bytes */
		  Nb_Bytes = Nb_Bytes - 5;
		  break;

        default:
		  break; // 20040617+ Added to remove GNU compiler warning about label at end of compound statement
        }

	  p = Data_Str;

	  /* If we're reading the last record, ignore it. */
	  switch (Type)
        {
		  /* Data record */
        case 1:
        case 2:
        case 3:
		  if (Nb_Bytes == 0)
		    {
			  fprintf(stderr,"0 byte length Data record ignored\n");
			  break;
		    }

		  Phys_Addr = Address & ADDRESS_MASK;

		  /* Check that the physical address stays in the buffer's range. */
		  if ((Phys_Addr + Nb_Bytes) <= MEMORY_SIZE)
            {
			  /* Set the lowest address as base pointer. */
			  if (Phys_Addr < Lowest_Address)
				Lowest_Address = Phys_Addr;

			  /* Same for the top address. */
			  temp = Phys_Addr + Nb_Bytes -1;

			  if (temp > Highest_Address)
				Highest_Address = temp;

			  /* Read the Data bytes. */
			  i = Nb_Bytes;
			  
			  do
                {
				  sscanf (p, "%2x",&temp2);
				  p += 2;
				  Memory_Block[Phys_Addr++] = temp2;
				  Checksum = (Checksum + temp2) & 0xFF;
                }
              while (--i != 0);

			  /* Read the Checksum value. */
			  sscanf (Data_Str, "%2x",&temp2);

			  /* Verify Checksum value. */
			  Checksum = (0xFF - Checksum) & 0xFF;

			  if ((temp2 != Checksum) && Enable_Checksum_Error)
                {
				  Status_Checksum_Error = TRUE;
                }
            }
		  else
            {
			  fprintf(stderr,"Data record skipped at %8X\n",Phys_Addr);
            }
		  break;

		  /* Ignore all other records */
        default:
		  break; // 20040617+ Added to remove GNU compiler warning about label at end of compound statement
        }
    } while (!feof (Filin));
  /*-----------------------------------------------------------------------------*/

  fprintf(stdout,"Lowest address  = %08X\n",Lowest_Address);
  fprintf(stdout,"Highest address = %08X\n",Highest_Address);
  fprintf(stdout,"Pad Byte        = %X\n",  PadByte);

  wCKS = 0;
  if( !Cks_range_set )
	{
	  Cks_Start = Lowest_Address;
	  Cks_End = Highest_Address;
	}
  switch (Cks_Type)
	{
	case CKS_8:

	  for (i=Cks_Start; i<=Cks_End; i++)
		{
		  wCKS += Memory_Block[i];
		}

	  fprintf(stdout,"8-bit Checksum = %02X\n",wCKS & 0xff);
	  if( Cks_Addr_set )
		{
		  wCKS = Cks_Value - (wCKS - Memory_Block[Cks_Addr]);
		  Memory_Block[Cks_Addr] = (byte)(wCKS & 0xff);
		  fprintf(stdout,"Addr %08X set to %02X\n",Cks_Addr, wCKS & 0xff);
		}
	  break;

	case CKS_16BE:

	  for (i=Cks_Start; i<=Cks_End; i+=2)
		{
		  w =  Memory_Block[i+1] | ((word)Memory_Block[i] << 8);
		  wCKS += w;
		}

	  fprintf(stdout,"16-bit Checksum = %04X\n",wCKS);
	  if( Cks_Addr_set )
		{
		  w = Memory_Block[Cks_Addr+1] | ((word)Memory_Block[Cks_Addr] << 8);
		  wCKS = Cks_Value - (wCKS - w);
		  Memory_Block[Cks_Addr] = (byte)(wCKS >> 8);
		  Memory_Block[Cks_Addr+1] = (byte)(wCKS & 0xff);
		  fprintf(stdout,"Addr %08X set to %04X\n",Cks_Addr, wCKS);
		}
	  break;

	case CKS_16LE:

	  for (i=Cks_Start; i<=Cks_End; i+=2)
		{
		  w =  Memory_Block[i] | ((word)Memory_Block[i+1] << 8);
		  wCKS += w;
		}

	  fprintf(stdout,"16-bit Checksum = %04X\n",wCKS);
	  if( Cks_Addr_set )
		{
		  w = Memory_Block[Cks_Addr] | ((word)Memory_Block[Cks_Addr+1] << 8);
		  wCKS = Cks_Value - (wCKS - w);
		  Memory_Block[Cks_Addr+1] = (byte)(wCKS >> 8);
		  Memory_Block[Cks_Addr] = (byte)(wCKS & 0xff);
		  fprintf(stdout,"Addr %08X set to %04X\n",Cks_Addr, wCKS);
		}

	default:
	  ;
	}

  if(Starting_Address_Setted)
    {
	  Lowest_Address = Starting_Address;
    }

  /* write binary file */
  fwrite (&Memory_Block[Lowest_Address],
		  1,
		  Highest_Address - Lowest_Address +1,
		  Filout);

  free (Memory_Block);

#ifdef USE_FILE_BUFFERS
  free (FilinBuf);
  free (FiloutBuf);
#endif

  fclose (Filin);
  fclose (Filout);

  if (Status_Checksum_Error && Enable_Checksum_Error)
    {
	  fprintf(stderr,"Checksum error detected.\n");
	  return 1;
    }

  if (!Fileread)
	usage();
  return 0;
}

// Assembly:
subq $0x2a8, %rsp            # imm = 0x2A8
movl $0x0, 0x2a4(%rsp)
movl %edi, 0x2a0(%rsp)
movq %rsi, 0x298(%rsp)
movl $0x0, 0x188(%rsp)
movl $0x0, 0x184(%rsp)
movl $0x0, 0x144(%rsp)
movb $0x0, 0x3f(%rsp)
movl $0x0, 0x34(%rsp)
movl $0x0, 0x20(%rsp)
movl $0x0, 0x1c(%rsp)
movq 0x3afa(%rip), %rax      # 0x4fc0
movq (%rax), %rdi
leaq 0x1e4d(%rip), %rsi      # 0x331d
movb $0x0, %al
callq 0x10f0
cmpl $0x1, 0x2a0(%rsp)
jne 0x14e6
callq 0x1250
leaq 0x3bf3(%rip), %rdi      # 0x50e0
leaq 0x1eae(%rip), %rsi      # 0x33a2
callq 0x1060
movl $0x1, 0x16c(%rsp)
movl $0x1, 0x16c(%rsp)
movl 0x16c(%rsp), %eax
cmpl 0x2a0(%rsp), %eax
jae 0x1823
movq 0x298(%rsp), %rax
movl 0x16c(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x170(%rsp)
movq %rax, 0x178(%rsp)
movq 0x178(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x1809
movq 0x178(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x170(%rsp)
movq 0x170(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x159e
movq 0x298(%rsp), %rax
movl 0x16c(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x170(%rsp)
movq 0x170(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x15bf
movl 0x16c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x16c(%rsp)
movq 0x178(%rsp), %rax
movq %rax, %rcx
incq %rcx
movq %rcx, 0x178(%rsp)
movsbl 0x1(%rax), %edi
callq 0x1100
addl $-0x63, %eax
movl %eax, %ecx
movq %rcx, 0x8(%rsp)
subl $0x10, %eax
ja 0x1802
movq 0x8(%rsp), %rax
leaq 0x1a07(%rip), %rcx      # 0x3004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x170(%rsp), %rdi
callq 0x1040
cmpq $0x10, %rax
jbe 0x161e
callq 0x1250
movq 0x170(%rsp), %rdi
movl $0x2e, %esi
callq 0x1030
cmpq $0x0, %rax
jne 0x164c
movq 0x170(%rsp), %rsi
leaq 0x3a9b(%rip), %rdi      # 0x50e0
callq 0x1060
jmp 0x1664
movq 0x170(%rsp), %rsi
addq $0x1, %rsi
leaq 0x3a81(%rip), %rdi      # 0x50e0
callq 0x1060
jmp 0x1807
movl $0x1, 0x188(%rsp)
jmp 0x1807
movq 0x170(%rsp), %rdi
leaq 0x1d1e(%rip), %rsi      # 0x33a6
leaq 0x154(%rsp), %rdx
movb $0x0, %al
callq 0x1070
movl $0x1, 0x144(%rsp)
jmp 0x1807
movq 0x170(%rsp), %rdi
leaq 0x1cf0(%rip), %rsi      # 0x33a6
leaq 0x39fb(%rip), %rdx      # 0x50b8
movb $0x0, %al
callq 0x1070
jmp 0x1807
callq 0x1250
jmp 0x1807
movq 0x170(%rsp), %rdi
leaq 0x1cc4(%rip), %rsi      # 0x33a6
leaq 0x34(%rsp), %rdx
movb $0x0, %al
callq 0x1070
cmpl $0x0, 0x34(%rsp)
je 0x1708
cmpl $0x1, 0x34(%rsp)
je 0x1708
cmpl $0x2, 0x34(%rsp)
je 0x1708
callq 0x1250
jmp 0x1807
movq 0x170(%rsp), %rdi
leaq 0x1c8a(%rip), %rsi      # 0x33a6
leaq 0x30(%rsp), %rdx
movb $0x0, %al
callq 0x1070
movq 0x298(%rsp), %rax
movl 0x16c(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, 0x16c(%rsp)
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x170(%rsp)
movq 0x170(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x1764
jmp 0x1807
movq 0x170(%rsp), %rdi
leaq 0x1c33(%rip), %rsi      # 0x33a6
leaq 0x2c(%rsp), %rdx
movb $0x0, %al
callq 0x1070
movl $0x1, 0x20(%rsp)
jmp 0x1807
movq 0x170(%rsp), %rdi
leaq 0x1c0e(%rip), %rsi      # 0x33a6
leaq 0x28(%rsp), %rdx
movb $0x0, %al
callq 0x1070
movq 0x298(%rsp), %rax
movl 0x16c(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, 0x16c(%rsp)
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x170(%rsp)
movq 0x170(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x17dd
jmp 0x1807
movq 0x170(%rsp), %rdi
leaq 0x1bba(%rip), %rsi      # 0x33a6
leaq 0x24(%rsp), %rdx
movb $0x0, %al
callq 0x1070
movl $0x1, 0x1c(%rsp)
jmp 0x1807
callq 0x1250
jmp 0x180b
jmp 0x1823
jmp 0x180d
movl 0x16c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x16c(%rsp)
jmp 0x150f
movq 0x298(%rsp), %rax
movl 0x2a0(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x38ad(%rip), %rdi      # 0x50f0
callq 0x1060
leaq 0x38a1(%rip), %rdi      # 0x50f0
callq 0x12d0
leaq 0x3895(%rip), %rdi      # 0x50f0
leaq 0x387e(%rip), %rsi      # 0x50e0
callq 0x13b0
leaq 0x3882(%rip), %rdi      # 0x50f0
callq 0x1340
movl $0x1, 0x18c(%rsp)
movl $0x400000, %edi         # imm = 0x400000
callq 0x1280
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rdi
movl 0x3820(%rip), %eax      # 0x50b8
movl $0x400000, %edx         # imm = 0x400000
movzbl %al, %esi
callq 0x1050
movl $0x3fffff, 0x15c(%rsp) # imm = 0x3FFFFF
movl $0x0, 0x158(%rsp)
leaq 0x190(%rsp), %rdi
movq 0x3806(%rip), %rdx      # 0x50d0
movl $0x100, %esi            # imm = 0x100
callq 0x1120
leaq 0x190(%rsp), %rdi
callq 0x1040
subq $0x1, %rax
movl %eax, 0x168(%rsp)
movl 0x168(%rsp), %eax
movsbl 0x190(%rsp,%rax), %eax
cmpl $0xa, %eax
jne 0x190f
movl 0x168(%rsp), %eax
movb $0x0, 0x190(%rsp,%rax)
movsbl 0x191(%rsp), %eax
movl %eax, 0x4(%rsp)
subl $0x31, %eax
je 0x1943
jmp 0x1922
movl 0x4(%rsp), %eax
subl $0x32, %eax
je 0x19b2
jmp 0x1931
movl 0x4(%rsp), %eax
subl $0x33, %eax
je 0x1a2d
jmp 0x1ab1
leaq 0x190(%rsp), %rdi
leaq 0x40(%rsp), %r9
leaq 0x1a52(%rip), %rsi      # 0x33a9
leaq 0x14c(%rsp), %rdx
leaq 0x164(%rsp), %rcx
leaq 0x160(%rsp), %r8
movb $0x0, %al
callq 0x1070
movl 0x164(%rsp), %eax
movl 0x160(%rsp), %ecx
shrl $0x8, %ecx
addl %ecx, %eax
movl 0x160(%rsp), %ecx
andl $0xff, %ecx
addl %ecx, %eax
movb %al, 0x3f(%rsp)
movl 0x164(%rsp), %eax
subl $0x3, %eax
movl %eax, 0x164(%rsp)
jmp 0x1ab3
leaq 0x190(%rsp), %rdi
leaq 0x40(%rsp), %r9
leaq 0x19f0(%rip), %rsi      # 0x33b6
leaq 0x14c(%rsp), %rdx
leaq 0x164(%rsp), %rcx
leaq 0x160(%rsp), %r8
movb $0x0, %al
callq 0x1070
movl 0x164(%rsp), %eax
movl 0x160(%rsp), %ecx
shrl $0x10, %ecx
addl %ecx, %eax
movl 0x160(%rsp), %ecx
shrl $0x8, %ecx
addl %ecx, %eax
movl 0x160(%rsp), %ecx
andl $0xff, %ecx
addl %ecx, %eax
movb %al, 0x3f(%rsp)
movl 0x164(%rsp), %eax
subl $0x4, %eax
movl %eax, 0x164(%rsp)
jmp 0x1ab3
leaq 0x190(%rsp), %rdi
leaq 0x40(%rsp), %r9
leaq 0x1982(%rip), %rsi      # 0x33c3
leaq 0x14c(%rsp), %rdx
leaq 0x164(%rsp), %rcx
leaq 0x160(%rsp), %r8
movb $0x0, %al
callq 0x1070
movl 0x164(%rsp), %eax
movl 0x160(%rsp), %ecx
shrl $0x18, %ecx
addl %ecx, %eax
movl 0x160(%rsp), %ecx
shrl $0x10, %ecx
addl %ecx, %eax
movl 0x160(%rsp), %ecx
shrl $0x8, %ecx
addl %ecx, %eax
movl 0x160(%rsp), %ecx
andl $0xff, %ecx
addl %ecx, %eax
movb %al, 0x3f(%rsp)
movl 0x164(%rsp), %eax
subl $0x5, %eax
movl %eax, 0x164(%rsp)
jmp 0x1ab3
jmp 0x1ab3
leaq 0x40(%rsp), %rax
movq %rax, 0x170(%rsp)
movl 0x14c(%rsp), %eax
decl %eax
subl $0x2, %eax
ja 0x1c88
jmp 0x1ad4
cmpl $0x0, 0x164(%rsp)
jne 0x1afb
movq 0x34fb(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
leaq 0x18e1(%rip), %rsi      # 0x33d0
movb $0x0, %al
callq 0x10f0
jmp 0x1c8a
movl 0x160(%rsp), %eax
andl $0x3fffff, %eax         # imm = 0x3FFFFF
movl %eax, 0x150(%rsp)
movl 0x150(%rsp), %eax
addl 0x164(%rsp), %eax
cmpl $0x400000, %eax         # imm = 0x400000
ja 0x1c67
movl 0x150(%rsp), %eax
cmpl 0x15c(%rsp), %eax
jae 0x1b45
movl 0x150(%rsp), %eax
movl %eax, 0x15c(%rsp)
movl 0x150(%rsp), %eax
addl 0x164(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x148(%rsp)
movl 0x148(%rsp), %eax
cmpl 0x158(%rsp), %eax
jbe 0x1b7b
movl 0x148(%rsp), %eax
movl %eax, 0x158(%rsp)
movl 0x164(%rsp), %eax
movl %eax, 0x168(%rsp)
movq 0x170(%rsp), %rdi
leaq 0x185b(%rip), %rsi      # 0x33f3
leaq 0x140(%rsp), %rdx
movb $0x0, %al
callq 0x1070
movq 0x170(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x170(%rsp)
movl 0x140(%rsp), %eax
movb %al, %dl
movq 0x10(%rsp), %rax
movl 0x150(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x150(%rsp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movzbl 0x3f(%rsp), %eax
addl 0x140(%rsp), %eax
andl $0xff, %eax
movb %al, 0x3f(%rsp)
movl 0x168(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x168(%rsp)
cmpl $0x0, %eax
jne 0x1b89
leaq 0x40(%rsp), %rdi
leaq 0x17d7(%rip), %rsi      # 0x33f3
leaq 0x140(%rsp), %rdx
movb $0x0, %al
callq 0x1070
movzbl 0x3f(%rsp), %ecx
movl $0xff, %eax
subl %ecx, %eax
andl $0xff, %eax
movb %al, 0x3f(%rsp)
movl 0x140(%rsp), %eax
movzbl 0x3f(%rsp), %ecx
cmpl %ecx, %eax
je 0x1c65
cmpl $0x0, 0x188(%rsp)
je 0x1c65
movl $0x1, 0x184(%rsp)
jmp 0x1c86
movq 0x3372(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
movl 0x150(%rsp), %edx
leaq 0x1778(%rip), %rsi      # 0x33f7
movb $0x0, %al
callq 0x10f0
jmp 0x1c8a
jmp 0x1c8a
jmp 0x1c8c
movq 0x343d(%rip), %rdi      # 0x50d0
callq 0x1110
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x18bb
movq 0x3311(%rip), %rax      # 0x4fc0
movq (%rax), %rdi
movl 0x15c(%rsp), %edx
leaq 0x1753(%rip), %rsi      # 0x3413
movb $0x0, %al
callq 0x10f0
movq 0x32f2(%rip), %rax      # 0x4fc0
movq (%rax), %rdi
movl 0x158(%rsp), %edx
leaq 0x174c(%rip), %rsi      # 0x342b
movb $0x0, %al
callq 0x10f0
movq 0x32d3(%rip), %rax      # 0x4fc0
movq (%rax), %rdi
movl 0x33c2(%rip), %edx      # 0x50b8
leaq 0x1746(%rip), %rsi      # 0x3443
movb $0x0, %al
callq 0x10f0
movw $0x0, 0x3c(%rsp)
cmpl $0x0, 0x20(%rsp)
jne 0x1d28
movl 0x15c(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x158(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl 0x34(%rsp), %eax
movl %eax, (%rsp)
testl %eax, %eax
je 0x1d54
jmp 0x1d35
movl (%rsp), %eax
subl $0x1, %eax
je 0x1f5a
jmp 0x1d43
movl (%rsp), %eax
subl $0x2, %eax
je 0x1e28
jmp 0x2089
movl 0x30(%rsp), %eax
movl %eax, 0x168(%rsp)
movl 0x168(%rsp), %eax
cmpl 0x2c(%rsp), %eax
ja 0x1d9b
movq 0x10(%rsp), %rax
movl 0x168(%rsp), %ecx
movzbl (%rax,%rcx), %ecx
movzwl 0x3c(%rsp), %eax
addl %ecx, %eax
movw %ax, 0x3c(%rsp)
movl 0x168(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x168(%rsp)
jmp 0x1d5f
movq 0x321e(%rip), %rax      # 0x4fc0
movq (%rax), %rdi
movzwl 0x3c(%rsp), %edx
andl $0xff, %edx
leaq 0x16a2(%rip), %rsi      # 0x3459
movb $0x0, %al
callq 0x10f0
cmpl $0x0, 0x1c(%rsp)
je 0x1e23
movl 0x24(%rsp), %eax
movzwl 0x3c(%rsp), %ecx
movq 0x10(%rsp), %rdx
movl 0x28(%rsp), %esi
movzbl (%rdx,%rsi), %edx
subl %edx, %ecx
subl %ecx, %eax
movw %ax, 0x3c(%rsp)
movzwl 0x3c(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq 0x10(%rsp), %rax
movl 0x28(%rsp), %ecx
movb %dl, (%rax,%rcx)
movq 0x31bd(%rip), %rax      # 0x4fc0
movq (%rax), %rdi
movl 0x28(%rsp), %edx
movzwl 0x3c(%rsp), %ecx
andl $0xff, %ecx
leaq 0x1654(%rip), %rsi      # 0x3470
movb $0x0, %al
callq 0x10f0
jmp 0x208b
movl 0x30(%rsp), %eax
movl %eax, 0x168(%rsp)
movl 0x168(%rsp), %eax
cmpl 0x2c(%rsp), %eax
ja 0x1e96
movq 0x10(%rsp), %rax
movl 0x168(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movq 0x10(%rsp), %rcx
movl 0x168(%rsp), %edx
movzbl (%rcx,%rdx), %ecx
movzwl %cx, %ecx
shll $0x8, %ecx
orl %ecx, %eax
movw %ax, 0x3a(%rsp)
movzwl 0x3a(%rsp), %ecx
movzwl 0x3c(%rsp), %eax
addl %ecx, %eax
movw %ax, 0x3c(%rsp)
movl 0x168(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x168(%rsp)
jmp 0x1e33
movq 0x3123(%rip), %rax      # 0x4fc0
movq (%rax), %rdi
movzwl 0x3c(%rsp), %edx
leaq 0x15db(%rip), %rsi      # 0x3487
movb $0x0, %al
callq 0x10f0
cmpl $0x0, 0x1c(%rsp)
je 0x1f55
movq 0x10(%rsp), %rax
movl 0x28(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movq 0x10(%rsp), %rcx
movl 0x28(%rsp), %edx
movzbl (%rcx,%rdx), %ecx
movzwl %cx, %ecx
shll $0x8, %ecx
orl %ecx, %eax
movw %ax, 0x3a(%rsp)
movl 0x24(%rsp), %eax
movzwl 0x3c(%rsp), %ecx
movzwl 0x3a(%rsp), %edx
subl %edx, %ecx
subl %ecx, %eax
movw %ax, 0x3c(%rsp)
movzwl 0x3c(%rsp), %eax
sarl $0x8, %eax
movb %al, %dl
movq 0x10(%rsp), %rax
movl 0x28(%rsp), %ecx
movb %dl, (%rax,%rcx)
movzwl 0x3c(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq 0x10(%rsp), %rax
movl 0x28(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movq 0x3085(%rip), %rax      # 0x4fc0
movq (%rax), %rdi
movl 0x28(%rsp), %edx
movzwl 0x3c(%rsp), %ecx
leaq 0x1551(%rip), %rsi      # 0x349f
movb $0x0, %al
callq 0x10f0
jmp 0x208b
movl 0x30(%rsp), %eax
movl %eax, 0x168(%rsp)
movl 0x168(%rsp), %eax
cmpl 0x2c(%rsp), %eax
ja 0x1fc8
movq 0x10(%rsp), %rax
movl 0x168(%rsp), %ecx
movzbl (%rax,%rcx), %eax
movq 0x10(%rsp), %rcx
movl 0x168(%rsp), %edx
addl $0x1, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
movzwl %cx, %ecx
shll $0x8, %ecx
orl %ecx, %eax
movw %ax, 0x3a(%rsp)
movzwl 0x3a(%rsp), %ecx
movzwl 0x3c(%rsp), %eax
addl %ecx, %eax
movw %ax, 0x3c(%rsp)
movl 0x168(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x168(%rsp)
jmp 0x1f65
movq 0x2ff1(%rip), %rax      # 0x4fc0
movq (%rax), %rdi
movzwl 0x3c(%rsp), %edx
leaq 0x14a9(%rip), %rsi      # 0x3487
movb $0x0, %al
callq 0x10f0
cmpl $0x0, 0x1c(%rsp)
je 0x2087
movq 0x10(%rsp), %rax
movl 0x28(%rsp), %ecx
movzbl (%rax,%rcx), %eax
movq 0x10(%rsp), %rcx
movl 0x28(%rsp), %edx
addl $0x1, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
movzwl %cx, %ecx
shll $0x8, %ecx
orl %ecx, %eax
movw %ax, 0x3a(%rsp)
movl 0x24(%rsp), %eax
movzwl 0x3c(%rsp), %ecx
movzwl 0x3a(%rsp), %edx
subl %edx, %ecx
subl %ecx, %eax
movw %ax, 0x3c(%rsp)
movzwl 0x3c(%rsp), %eax
sarl $0x8, %eax
movb %al, %dl
movq 0x10(%rsp), %rax
movl 0x28(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movzwl 0x3c(%rsp), %eax
andl $0xff, %eax
movb %al, %dl
movq 0x10(%rsp), %rax
movl 0x28(%rsp), %ecx
movb %dl, (%rax,%rcx)
movq 0x2f53(%rip), %rax      # 0x4fc0
movq (%rax), %rdi
movl 0x28(%rsp), %edx
movzwl 0x3c(%rsp), %ecx
leaq 0x141f(%rip), %rsi      # 0x349f
movb $0x0, %al
callq 0x10f0
jmp 0x2089
jmp 0x208b
cmpl $0x0, 0x144(%rsp)
je 0x20a3
movl 0x154(%rsp), %eax
movl %eax, 0x15c(%rsp)
movq 0x10(%rsp), %rdi
movl 0x15c(%rsp), %eax
addq %rax, %rdi
movl 0x158(%rsp), %eax
subl 0x15c(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movq 0x300a(%rip), %rcx      # 0x50d8
movl $0x1, %esi
callq 0x1140
movq 0x10(%rsp), %rdi
callq 0x10b0
movq 0x2fe7(%rip), %rdi      # 0x50d0
callq 0x1080
movq 0x2fe3(%rip), %rdi      # 0x50d8
callq 0x1080
cmpl $0x0, 0x184(%rsp)
je 0x2133
cmpl $0x0, 0x188(%rsp)
je 0x2133
movq 0x2ecb(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
leaq 0x1397(%rip), %rsi      # 0x34b6
movb $0x0, %al
callq 0x10f0
movl $0x1, 0x2a4(%rsp)
jmp 0x214d
cmpl $0x0, 0x18c(%rsp)
jne 0x2142
callq 0x1250
movl $0x0, 0x2a4(%rsp)
movl 0x2a4(%rsp), %eax
addq $0x2a8, %rsp            # imm = 0x2A8
retq