// File: /workspace/github_c_makefile_star2_O3/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 $0x258, %rsp            # imm = 0x258
movq %rsi, %rbx
movl %edi, %ebp
movl $0x0, 0x34(%rsp)
movq 0x2a70(%rip), %rax      # 0x3fc0
movq (%rax), %rcx
leaq 0xdc3(%rip), %rdi       # 0x231d
movl $0x84, %esi
movl $0x1, %edx
callq 0x1140
cmpl $0x1, %ebp
je 0x1cd0
movl $0x6e6962, 0x2b64(%rip) # imm = 0x6E6962
xorl %r15d, %r15d
testl %ebp, %ebp
je 0x1778
movl $0x1, %r12d
movl $0x0, 0x40(%rsp)
movl $0x0, 0x1c(%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x20(%rsp)
movl %ebp, 0x10(%rsp)
movl %r12d, %ecx
movq (%rbx,%rcx,8), %r15
cmpb $0x2d, (%r15)
jne 0x174f
movb 0x2(%r15), %al
testb %al, %al
je 0x15d0
leaq 0x2(%r15), %r14
jmp 0x15d8
movq 0x8(%rbx,%rcx,8), %r14
movb (%r14), %al
xorl %r13d, %r13d
cmpb $0x2d, %al
setne %bpl
callq 0x1030
movq (%rax), %rax
movsbq 0x1(%r15), %rcx
movl (%rax,%rcx,4), %eax
addl $-0x63, %eax
cmpl $0x10, %eax
ja 0x1ccb
movb %bpl, %r13b
addl %r13d, %r12d
leaq 0x9fa(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, 0x40(%rsp)
jmp 0x173f
movq %r14, %rdi
leaq 0xd78(%rip), %rsi       # 0x23a2
leaq 0x4c(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
movl $0x1, 0x20(%rsp)
jmp 0x173f
movq %r14, %rdi
leaq 0xd55(%rip), %rsi       # 0x23a2
leaq 0x2a64(%rip), %rdx      # 0x40b8
xorl %eax, %eax
callq 0x1080
jmp 0x173f
movq %r14, %rdi
callq 0x1050
cmpq $0x11, %rax
jae 0x1cc6
movq %r14, %rdi
movl $0x2e, %esi
callq 0x1040
testq %rax, %rax
movl 0x10(%rsp), %ebp
je 0x168b
incq %r14
leaq 0x2a4e(%rip), %rdi      # 0x40e0
movq %r14, %rsi
callq 0x1070
jmp 0x1743
movq %r14, %rdi
leaq 0xcf9(%rip), %r14       # 0x23a2
movq %r14, %rsi
leaq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
incl %r12d
movq (%rbx,%r12,8), %rdi
cmpb $0x2d, (%rdi)
je 0x173f
movq %r14, %rsi
leaq 0x24(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
movl $0x1, 0x8(%rsp)
jmp 0x173f
movq %r14, %rdi
leaq 0xcbb(%rip), %rsi       # 0x23a2
leaq 0x34(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
cmpl $0x3, 0x34(%rsp)
movl 0x10(%rsp), %ebp
jb 0x1743
jmp 0x1cc1
movq %r14, %rdi
leaq 0xc95(%rip), %r14       # 0x23a2
movq %r14, %rsi
leaq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
incl %r12d
movq (%rbx,%r12,8), %rdi
cmpb $0x2d, (%rdi)
je 0x173f
movq %r14, %rsi
leaq 0x2c(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
movl $0x1, 0x1c(%rsp)
movl 0x10(%rsp), %ebp
incl %r12d
cmpl %ebp, %r12d
jb 0x15b1
cmpl $0x0, 0x40(%rsp)
setne %r15b
cmpl $0x0, 0x8(%rsp)
sete 0x2(%rsp)
cmpl $0x0, 0x1c(%rsp)
sete 0x1(%rsp)
cmpl $0x0, 0x20(%rsp)
sete 0x3(%rsp)
jmp 0x1787
movb $0x1, 0x3(%rsp)
movb $0x1, 0x2(%rsp)
movb $0x1, 0x1(%rsp)
movslq %ebp, %rax
movq -0x8(%rbx,%rax,8), %rsi
leaq 0x295a(%rip), %rbx      # 0x40f0
movq %rbx, %rdi
callq 0x1070
movq %rbx, %rdi
callq 0x1467
leaq 0x2933(%rip), %rsi      # 0x40e0
movq %rbx, %rdi
callq 0x14d5
movq %rbx, %rdi
callq 0x149e
movl $0x400000, %edi         # imm = 0x400000
callq 0x1455
movl 0x28eb(%rip), %esi      # 0x40b8
movl $0x400000, %edx         # imm = 0x400000
movq %rax, 0x8(%rsp)
movq %rax, %rdi
callq 0x1060
leaq 0x50(%rsp), %r14
movl $0x3fffff, %ebp         # imm = 0x3FFFFF
movq $0x0, 0x40(%rsp)
xorl %r12d, %r12d
xorl %r13d, %r13d
movl %r15d, 0x48(%rsp)
movq 0x28cc(%rip), %rdx      # 0x40d0
movq %r14, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x1120
movq %r14, %rdi
callq 0x1050
decl %eax
cmpb $0xa, 0x50(%rsp,%rax)
jne 0x1827
movb $0x0, 0x50(%rsp,%rax)
movzbl 0x51(%rsp), %eax
cmpl $0x33, %eax
je 0x18d3
cmpl $0x32, %eax
je 0x1888
cmpl $0x31, %eax
jne 0x1928
movq %r14, %rdi
leaq 0xb58(%rip), %rsi       # 0x23a5
leaq 0x3c(%rsp), %rdx
leaq 0x4(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x150(%rsp), %r9
xorl %eax, %eax
callq 0x1080
movl 0x4(%rsp), %eax
movl 0x18(%rsp), %r12d
movl %r12d, %ecx
shrl $0x8, %ecx
addl %eax, %r12d
addl %ecx, %r12d
addl $-0x3, %eax
jmp 0x1924
movq %r14, %rdi
leaq 0xb20(%rip), %rsi       # 0x23b2
leaq 0x3c(%rsp), %rdx
leaq 0x4(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x150(%rsp), %r9
xorl %eax, %eax
callq 0x1080
movl 0x4(%rsp), %eax
movl 0x18(%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 0x1924
movq %r14, %rdi
leaq 0xae2(%rip), %rsi       # 0x23bf
leaq 0x3c(%rsp), %rdx
leaq 0x4(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x150(%rsp), %r9
xorl %eax, %eax
callq 0x1080
movl 0x4(%rsp), %eax
movl 0x18(%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, 0x4(%rsp)
movl 0x3c(%rsp), %eax
decl %eax
cmpl $0x2, %eax
ja 0x1a15
movl 0x4(%rsp), %ebx
testl %ebx, %ebx
je 0x1a2b
movl 0x18(%rsp), %r14d
movl $0x3fffff, %eax         # imm = 0x3FFFFF
andl %eax, %r14d
leal (%r14,%rbx), %eax
cmpl $0x400000, %eax         # imm = 0x400000
ja 0x1a32
movq %rbp, 0x10(%rsp)
movl %r13d, 0x20(%rsp)
decl %eax
movl %eax, 0x1c(%rsp)
leaq 0x150(%rsp), %r13
movl %r14d, %r15d
movq 0x8(%rsp), %rbp
movq %r13, %rdi
leaq 0xa66(%rip), %rsi       # 0x23ef
leaq 0x38(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
addq $0x2, %r13
movb 0x38(%rsp), %al
movl %r15d, %ecx
incl %r15d
movb %al, (%rbp,%rcx)
addb %al, %r12b
decl %ebx
jne 0x197f
movq 0x10(%rsp), %rbp
cmpl %ebp, %r14d
cmovbl %r14d, %ebp
movq 0x40(%rsp), %rax
movl 0x1c(%rsp), %ecx
cmpl %eax, %ecx
cmoval %ecx, %eax
movq %rax, 0x40(%rsp)
leaq 0x150(%rsp), %rdi
leaq 0xa13(%rip), %rsi       # 0x23ef
leaq 0x38(%rsp), %rdx
xorl %eax, %eax
callq 0x1080
notb %r12b
movzbl %r12b, %eax
movl 0x48(%rsp), %r15d
testb $0x1, %r15b
movl 0x20(%rsp), %r13d
movl %r13d, %ecx
movl $0x1, %edx
cmovnel %edx, %ecx
cmpl %eax, 0x38(%rsp)
cmovnel %ecx, %r13d
leaq 0x50(%rsp), %r14
movq 0x26b4(%rip), %rdi      # 0x40d0
callq 0x1110
testl %eax, %eax
je 0x17fd
jmp 0x1a4f
callq 0x12cb
jmp 0x1a15
movq 0x25a7(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
leaq 0x9b0(%rip), %rsi       # 0x23f3
movl %r14d, %edx
xorl %eax, %eax
callq 0x1100
jmp 0x1a10
movq 0x256a(%rip), %r14      # 0x3fc0
movq (%r14), %rdi
leaq 0x9af(%rip), %rsi       # 0x240f
movl %ebp, %edx
xorl %eax, %eax
callq 0x1100
movq (%r14), %rdi
leaq 0x9b4(%rip), %rsi       # 0x2427
movq 0x40(%rsp), %r12
movl %r12d, %edx
xorl %eax, %eax
callq 0x1100
movq (%r14), %rdi
movl 0x262d(%rip), %edx      # 0x40b8
leaq 0x9ad(%rip), %rsi       # 0x243f
xorl %eax, %eax
callq 0x1100
cmpb $0x0, 0x2(%rsp)
je 0x1aa9
movl %ebp, 0x28(%rsp)
movl %r12d, 0x24(%rsp)
movl 0x34(%rsp), %eax
cmpl $0x2, %eax
movq 0x8(%rsp), %rdi
movq %rbp, 0x10(%rsp)
je 0x1bb2
cmpl $0x1, %eax
je 0x1b35
testl %eax, %eax
jne 0x1c3f
movl 0x28(%rsp), %eax
movl 0x24(%rsp), %ecx
xorl %ebx, %ebx
cmpl %ecx, %eax
ja 0x1aee
xorl %edx, %edx
movl %eax, %esi
movzbl (%rdi,%rsi), %esi
addl %esi, %edx
incl %eax
cmpl %ecx, %eax
jbe 0x1add
movzwl %dx, %ebx
movq (%r14), %rdi
movzbl %bl, %edx
leaq 0x95a(%rip), %rsi       # 0x2455
xorl %eax, %eax
callq 0x1100
movq 0x8(%rsp), %rdi
cmpb $0x0, 0x1(%rsp)
jne 0x1c3f
movl 0x30(%rsp), %edx
movzbl (%rdi,%rdx), %eax
subl %ebx, %eax
addl 0x2c(%rsp), %eax
movzbl %al, %ecx
movb %cl, (%rdi,%rdx)
movq (%r14), %rdi
leaq 0x93c(%rip), %rsi       # 0x246c
jmp 0x1c33
movl 0x28(%rsp), %eax
movl 0x24(%rsp), %ecx
xorl %ebp, %ebp
cmpl %ecx, %eax
ja 0x1b6a
xorl %edx, %edx
movq 0x8(%rsp), %r8
movl %eax, %esi
movzbl (%r8,%rsi), %esi
leal 0x1(%rax), %edi
movzbl (%r8,%rdi), %edi
shll $0x8, %edi
orl %esi, %edi
addl %edi, %edx
addl $0x2, %eax
cmpl %ecx, %eax
jbe 0x1b4a
movzwl %dx, %ebp
movq (%r14), %rdi
leaq 0x90f(%rip), %rsi       # 0x2483
movl %ebp, %edx
xorl %eax, %eax
callq 0x1100
cmpb $0x0, 0x1(%rsp)
movq 0x8(%rsp), %rdi
jne 0x1c3f
movl 0x30(%rsp), %edx
movzbl (%rdi,%rdx), %ecx
leal 0x1(%rdx), %esi
movzbl (%rdi,%rsi), %eax
shll $0x8, %eax
orl %ecx, %eax
subl %ebp, %eax
addl 0x2c(%rsp), %eax
movzwl %ax, %ecx
movb %ah, (%rdi,%rsi)
movb %al, (%rdi,%rdx)
jmp 0x1c29
movl 0x28(%rsp), %eax
movl 0x24(%rsp), %ecx
xorl %ebp, %ebp
cmpl %ecx, %eax
ja 0x1be7
xorl %edx, %edx
movq 0x8(%rsp), %r8
leal 0x1(%rax), %esi
movzbl (%r8,%rsi), %esi
movl %eax, %edi
movzbl (%r8,%rdi), %edi
shll $0x8, %edi
orl %esi, %edi
addl %edi, %edx
addl $0x2, %eax
cmpl %ecx, %eax
jbe 0x1bc7
movzwl %dx, %ebp
movq (%r14), %rdi
leaq 0x892(%rip), %rsi       # 0x2483
movl %ebp, %edx
xorl %eax, %eax
callq 0x1100
cmpb $0x0, 0x1(%rsp)
movq 0x8(%rsp), %rdi
jne 0x1c3f
movl 0x30(%rsp), %edx
leal 0x1(%rdx), %esi
movzbl (%rdi,%rsi), %ecx
movzbl (%rdi,%rdx), %eax
shll $0x8, %eax
orl %ecx, %eax
subl %ebp, %eax
addl 0x2c(%rsp), %eax
movzwl %ax, %ecx
movb %ah, (%rdi,%rdx)
movb %al, (%rdi,%rsi)
movq (%r14), %rdi
leaq 0x868(%rip), %rsi       # 0x249b
xorl %eax, %eax
callq 0x1100
movq 0x8(%rsp), %rdi
cmpb $0x0, 0x3(%rsp)
movq 0x10(%rsp), %rax
cmovel 0x4c(%rsp), %eax
movq %rdi, %rbx
addq %rax, %rdi
subl %eax, %r12d
incl %r12d
movq 0x2477(%rip), %rcx      # 0x40d8
movl $0x1, %esi
movq %r12, %rdx
callq 0x1140
movq %rbx, %rdi
callq 0x10c0
movq 0x2453(%rip), %rdi      # 0x40d0
callq 0x1090
movq 0x244f(%rip), %rdi      # 0x40d8
callq 0x1090
testl %r13d, %r13d
setne %cl
andb %r15b, %cl
xorl %eax, %eax
cmpb $0x1, %cl
je 0x1cb0
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x12ed
movl $0x1, %eax
jmp 0x1c9e
callq 0x1256
callq 0x122f
callq 0x127d
callq 0x12a4
callq 0x130f