// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
andl $0x0, 0x2c(%rsp)
movq %rsi, %rbx
movl %edi, %ebp
movq 0x2b8d(%rip), %rax      # 0x3fc0
movq (%rax), %rcx
leaq 0xee0(%rip), %rdi       # 0x231d
pushq $0x1
popq %rdx
movl $0x84, %esi
callq 0x1140
movl %ebp, 0x4(%rsp)
cmpl $0x1, %ebp
je 0x1b87
movl $0x6e6962, 0x2c7f(%rip) # imm = 0x6E6962
pushq $0x1
popq %rax
movl %eax, %r13d
movl $0x0, 0x3c(%rsp)
movl $0x0, 0x38(%rsp)
movl $0x0, 0xc(%rsp)
movl $0x0, 0x20(%rsp)
cmpl 0x4(%rsp), %r13d
jae 0x161e
movl %r13d, %ecx
movq (%rbx,%rcx,8), %r12
cmpb $0x2d, (%r12)
jne 0x161e
movb 0x2(%r12), %al
testb %al, %al
je 0x14b4
leaq 0x2(%r12), %r15
jmp 0x14bc
movq 0x8(%rbx,%rcx,8), %r15
movb (%r15), %al
xorl %r14d, %r14d
cmpb $0x2d, %al
setne %bpl
callq 0x1030
movq (%rax), %rax
movsbq 0x1(%r12), %rcx
movl (%rax,%rcx,4), %eax
addl $-0x63, %eax
cmpl $0x10, %eax
ja 0x1b87
movb %bpl, %r14b
addl %r14d, %r13d
leaq 0xb15(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
pushq $0x1
popq %rax
movl %eax, 0x20(%rsp)
jmp 0x1616
movq %r15, %rdi
leaq 0xe94(%rip), %rsi       # 0x23a2
leaq 0x4c(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
pushq $0x1
popq %rax
movl %eax, 0x3c(%rsp)
jmp 0x1616
movq %r15, %rdi
leaq 0xe72(%rip), %rsi       # 0x23a2
leaq 0x2b81(%rip), %rdx      # 0x40b8
xorl %eax, %eax
callq 0x1080
jmp 0x1616
movq %r15, %rdi
callq 0x1050
cmpq $0x11, %rax
jae 0x1b87
movq %r15, %rdi
pushq $0x2e
popq %rsi
callq 0x1040
testq %rax, %rax
je 0x1568
incq %r15
leaq 0x2b71(%rip), %rdi      # 0x40e0
movq %r15, %rsi
callq 0x1070
jmp 0x1616
movq %r15, %rdi
leaq 0xe1c(%rip), %r14       # 0x23a2
movq %r14, %rsi
leaq 0x14(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
incl %r13d
movq (%rbx,%r13,8), %rdi
cmpb $0x2d, (%rdi)
je 0x1616
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
pushq $0x1
popq %rax
movl %eax, 0x38(%rsp)
jmp 0x1616
movq %r15, %rdi
leaq 0xddf(%rip), %rsi       # 0x23a2
leaq 0x2c(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
cmpl $0x3, 0x2c(%rsp)
jb 0x1616
jmp 0x1b87
movq %r15, %rdi
leaq 0xdbd(%rip), %r14       # 0x23a2
movq %r14, %rsi
leaq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
incl %r13d
movq (%rbx,%r13,8), %rdi
cmpb $0x2d, (%rdi)
je 0x1616
movq %r14, %rsi
leaq 0x24(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
pushq $0x1
popq %rax
movl %eax, 0xc(%rsp)
incl %r13d
jmp 0x1487
movslq 0x4(%rsp), %rax
movq -0x8(%rbx,%rax,8), %rsi
leaq 0x2ac1(%rip), %rbx      # 0x40f0
movq %rbx, %rdi
callq 0x1070
movq %rbx, %rdi
callq 0x12a4
leaq 0x2a9a(%rip), %rsi      # 0x40e0
movq %rbx, %rdi
callq 0x13a2
movq %rbx, %rdi
callq 0x1323
movl $0x400000, %edi         # imm = 0x400000
callq 0x1273
movq %rax, %r15
movl 0x2a4f(%rip), %esi      # 0x40b8
movl $0x400000, %edx         # imm = 0x400000
movq %rax, %rdi
callq 0x1060
leaq 0x60(%rsp), %rbp
leaq 0xd6d(%rip), %r14       # 0x23ef
movl $0x3fffff, %eax         # imm = 0x3FFFFF
movq %rax, 0x40(%rsp)
xorl %r13d, %r13d
xorl %r12d, %r12d
movl $0x0, 0x4(%rsp)
movq %r15, 0x18(%rsp)
movq 0x2a2a(%rip), %rdx      # 0x40d0
movq %rbp, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x1120
movq %rbp, %rdi
callq 0x1050
decl %eax
cmpb $0xa, 0x60(%rsp,%rax)
jne 0x16c9
movb $0x0, 0x60(%rsp,%rax)
movzbl 0x61(%rsp), %eax
cmpl $0x33, %eax
je 0x176f
cmpl $0x32, %eax
je 0x1727
cmpl $0x31, %eax
jne 0x17c0
movq %rbp, %rdi
leaq 0xcb6(%rip), %rsi       # 0x23a5
leaq 0x34(%rsp), %rdx
movq %rsp, %rcx
leaq 0x8(%rsp), %r8
leaq 0x160(%rsp), %r9
xorl %eax, %eax
callq 0x1080
movl (%rsp), %eax
movl 0x8(%rsp), %r12d
movl %r12d, %ecx
shrl $0x8, %ecx
addl %eax, %r12d
addl %ecx, %r12d
addl $-0x3, %eax
jmp 0x17bd
movq %rbp, %rdi
leaq 0xc81(%rip), %rsi       # 0x23b2
leaq 0x34(%rsp), %rdx
movq %rsp, %rcx
leaq 0x8(%rsp), %r8
leaq 0x160(%rsp), %r9
xorl %eax, %eax
callq 0x1080
movl (%rsp), %eax
movl 0x8(%rsp), %r12d
movl %r12d, %ecx
shrl $0x10, %ecx
movl %r12d, %edx
shrl $0x8, %edx
addl %eax, %r12d
addl %ecx, %r12d
addl %edx, %r12d
addl $-0x4, %eax
jmp 0x17bd
movq %rbp, %rdi
leaq 0xc46(%rip), %rsi       # 0x23bf
leaq 0x34(%rsp), %rdx
movq %rsp, %rcx
leaq 0x8(%rsp), %r8
leaq 0x160(%rsp), %r9
xorl %eax, %eax
callq 0x1080
movl (%rsp), %eax
movl 0x8(%rsp), %r12d
movl %r12d, %ecx
shrl $0x18, %ecx
movl %r12d, %edx
shrl $0x10, %edx
movl %r12d, %esi
shrl $0x8, %esi
addl %edx, %esi
addl %eax, %r12d
addl %ecx, %r12d
addl %esi, %r12d
addl $-0x5, %eax
movl %eax, (%rsp)
movl 0x34(%rsp), %eax
decl %eax
cmpl $0x2, %eax
ja 0x18a4
movl (%rsp), %ebx
testl %ebx, %ebx
je 0x18ba
movl 0x8(%rsp), %edx
movl $0x3fffff, %eax         # imm = 0x3FFFFF
andl %eax, %edx
leal (%rdx,%rbx), %eax
cmpl $0x400000, %eax         # imm = 0x400000
ja 0x18d8
movq %r13, 0x58(%rsp)
decl %eax
movl %eax, 0x48(%rsp)
leaq 0x160(%rsp), %r13
movq %rdx, 0x50(%rsp)
movl %edx, %r15d
movq 0x18(%rsp), %rbp
movq %r13, %rdi
movq %r14, %rsi
leaq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
addq $0x2, %r13
movb 0x30(%rsp), %al
movl %r15d, %ecx
incl %r15d
movb %al, (%rbp,%rcx)
addb %al, %r12b
decl %ebx
jne 0x1813
movq 0x40(%rsp), %rax
movq 0x50(%rsp), %rcx
cmpl %eax, %ecx
cmovbl %ecx, %eax
movq %rax, 0x40(%rsp)
movq 0x58(%rsp), %r13
movl 0x48(%rsp), %eax
cmpl %r13d, %eax
cmoval %eax, %r13d
leaq 0x160(%rsp), %rdi
movq %r14, %rsi
leaq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
cmpl $0x0, 0x20(%rsp)
notb %r12b
movzbl %r12b, %eax
movl 0x4(%rsp), %esi
movl %esi, %ecx
pushq $0x1
popq %rdx
cmovnel %edx, %ecx
cmpl %eax, 0x30(%rsp)
cmovnel %ecx, %esi
movl %esi, 0x4(%rsp)
movq %rbp, %r15
leaq 0x60(%rsp), %rbp
movq 0x2825(%rip), %rdi      # 0x40d0
callq 0x1110
testl %eax, %eax
je 0x169f
jmp 0x18f7
movq 0x271f(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0xb01(%rip), %rdi       # 0x23cc
pushq $0x22
popq %rsi
pushq $0x1
popq %rdx
callq 0x1140
jmp 0x18a4
movq 0x2701(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
leaq 0xb0a(%rip), %rsi       # 0x23f3
xorl %eax, %eax
callq 0x1100
movq 0x18(%rsp), %r15
jmp 0x189f
movq 0x26c2(%rip), %rbx      # 0x3fc0
movq (%rbx), %rdi
leaq 0xb07(%rip), %rsi       # 0x240f
movq 0x40(%rsp), %r12
movl %r12d, %edx
xorl %eax, %eax
callq 0x1100
movq (%rbx), %rdi
leaq 0xb06(%rip), %rsi       # 0x2427
movl %r13d, %edx
xorl %eax, %eax
callq 0x1100
movq (%rbx), %rdi
movl 0x2784(%rip), %edx      # 0x40b8
leaq 0xb04(%rip), %rsi       # 0x243f
xorl %eax, %eax
callq 0x1100
cmpl $0x0, 0x38(%rsp)
jne 0x1953
movl %r12d, 0x14(%rsp)
movl %r13d, 0x10(%rsp)
movl 0x2c(%rsp), %eax
cmpl $0x2, %eax
je 0x1a0b
cmpl $0x1, %eax
je 0x1990
testl %eax, %eax
jne 0x1aed
movl 0x14(%rsp), %ecx
movl 0x10(%rsp), %edx
xorl %eax, %eax
movq 0x18(%rsp), %rdi
cmpl %edx, %ecx
ja 0x1a97
movl %ecx, %esi
movzbl (%rdi,%rsi), %esi
addl %esi, %eax
incl %ecx
jmp 0x197c
movl 0x14(%rsp), %ecx
movl 0x10(%rsp), %edx
xorl %eax, %eax
cmpl %edx, %ecx
ja 0x19b9
movl %ecx, %esi
movzbl (%r15,%rsi), %esi
leal 0x1(%rcx), %edi
movzbl (%r15,%rdi), %edi
shll $0x8, %edi
orl %esi, %edi
addl %edi, %eax
addl $0x2, %ecx
jmp 0x199a
movq 0x2600(%rip), %rcx      # 0x3fc0
movq (%rcx), %rdi
movzwl %ax, %ebp
leaq 0xab6(%rip), %rsi       # 0x2483
movl %ebp, %edx
xorl %eax, %eax
callq 0x1100
cmpl $0x0, 0xc(%rsp)
je 0x1aed
movl 0x28(%rsp), %edx
movq 0x18(%rsp), %rdi
movzbl (%rdi,%rdx), %ecx
leal 0x1(%rdx), %esi
movzbl (%rdi,%rsi), %eax
shll $0x8, %eax
orl %ecx, %eax
subl %ebp, %eax
addl 0x24(%rsp), %eax
movzwl %ax, %ecx
movb %ah, (%rdi,%rsi)
movb %al, (%rdi,%rdx)
jmp 0x1a84
movl 0x14(%rsp), %ecx
movl 0x10(%rsp), %edx
xorl %eax, %eax
cmpl %edx, %ecx
ja 0x1a34
leal 0x1(%rcx), %esi
movzbl (%r15,%rsi), %esi
movl %ecx, %edi
movzbl (%r15,%rdi), %edi
shll $0x8, %edi
orl %esi, %edi
addl %edi, %eax
addl $0x2, %ecx
jmp 0x1a15
movq 0x2585(%rip), %rcx      # 0x3fc0
movq (%rcx), %rdi
movzwl %ax, %ebp
leaq 0xa3b(%rip), %rsi       # 0x2483
movl %ebp, %edx
xorl %eax, %eax
callq 0x1100
cmpl $0x0, 0xc(%rsp)
je 0x1aed
movl 0x28(%rsp), %edx
leal 0x1(%rdx), %esi
movq 0x18(%rsp), %rdi
movzbl (%rdi,%rsi), %ecx
movzbl (%rdi,%rdx), %eax
shll $0x8, %eax
orl %ecx, %eax
subl %ebp, %eax
addl 0x24(%rsp), %eax
movzwl %ax, %ecx
movb %ah, (%rdi,%rdx)
movb %al, (%rdi,%rsi)
movq 0x2535(%rip), %rax      # 0x3fc0
movq (%rax), %rdi
leaq 0xa06(%rip), %rsi       # 0x249b
jmp 0x1ae6
movq 0x2522(%rip), %rcx      # 0x3fc0
movq (%rcx), %rdi
movzwl %ax, %ebx
movzbl %bl, %edx
leaq 0x9a7(%rip), %rsi       # 0x2455
xorl %eax, %eax
callq 0x1100
cmpl $0x0, 0xc(%rsp)
je 0x1aed
movl 0x28(%rsp), %edx
movq 0x18(%rsp), %rsi
movzbl (%rsi,%rdx), %eax
subl %ebx, %eax
addl 0x24(%rsp), %eax
movzbl %al, %ecx
movb %cl, (%rsi,%rdx)
movq 0x24e4(%rip), %rax      # 0x3fc0
movq (%rax), %rdi
leaq 0x986(%rip), %rsi       # 0x246c
xorl %eax, %eax
callq 0x1100
cmpl $0x0, 0x20(%rsp)
setne %bl
cmpl $0x0, 0x3c(%rsp)
cmovnel 0x4c(%rsp), %r12d
movq 0x18(%rsp), %r14
movq %r14, %rdi
addq %r12, %rdi
subl %r12d, %r13d
incl %r13d
movq 0x25c0(%rip), %rcx      # 0x40d8
pushq $0x1
popq %rsi
movq %r13, %rdx
callq 0x1140
movq %r14, %rdi
callq 0x10c0
movq 0x259e(%rip), %rdi      # 0x40d0
callq 0x1090
movq 0x259a(%rip), %rdi      # 0x40d8
callq 0x1090
cmpl $0x0, 0x4(%rsp)
setne %cl
andb %bl, %cl
xorl %eax, %eax
cmpb $0x1, %cl
je 0x1b66
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2473(%rip), %rax      # 0x3fe0
movq (%rax), %rcx
leaq 0x93b(%rip), %rdi       # 0x24b2
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
callq 0x1140
pushq $0x1
popq %rax
jmp 0x1b54
callq 0x124c