#line 1 "if2.c"
#line 1 "libc.c"
extern short putc();
extern short printf();
extern short print_short();
extern short getch();
extern short scanf();
extern short is_digit();
extern short atoi();
extern short strlen();
extern short strcpy();

short
is_digit(ch)
short ch;
{
   if(ch >= '0' && ch <= '9') {
      return 1;
   }
   return 0;
}

short
strlen(ptr)
char * ptr;
{
   short n;
   n = 0;
   while(*ptr) {
     n++;
     ptr++;
   }
   return n;
}

short
atoi(str)
char * str ;
{
   short ret;
   short i;
   short n;
   short off;
   short num[6];

   num[4] = 10000;
   num[3] = 1000;
   num[2] = 100;
   num[1] = 10;
   num[0] = 1;

   ret = 0;
   n = strlen(str);

   off = n - 1;

   for(i = 0; i < n; i++) {
      switch(str[i]) {
      case '0':
      break;
      case '1':
         ret = ret + 1 * num[off-i];
      break;
      case '2':
         ret = ret + 2 * num[off-i];
      break;
      case '3':
         ret = ret + 3 * num[off-i];
      break;
      case '4':
         ret = ret + 4 * num[off-i];
      break;
      case '5':
         ret = ret + 5 * num[off-i];
      break;
      case '6':
         ret = ret + 6 * num[off-i];
      break;
      case '7':
         ret = ret + 7 * num[off-i];
      break;
      case '8':
         ret = ret + 8 * num[off-i];
      break;
      case '9':
         ret = ret + 9 * num[off-i];
      break;
      }
   }

   return ret;
}


short
scanf(fmt)
char * fmt;
{
   char ** ptr;
   char * p;
   short * temp;
   char buffer[100];
   short offset;
   short ch;
   short count;

   offset = 0;
   count = 2;

   ptr = &fmt + count;

   for(p = fmt; *p; p++) {
      if(*p == '%') {
         p++;
         if(*p == 'd') {
            temp = (short*)(*ptr);

            ch = getch();
            putc(ch);

            offset = 0;

            while(is_digit(ch) && ch != '\r' && ch != '\n') {
               buffer[offset] = ch;
               offset++;
               ch = getch();
               putc(ch);
            }

            buffer[offset] = '\0';

            *temp = atoi(buffer); 

            count = count + 2;

            ptr = &fmt + count;
         }
         else if(*p == 'f') {
         }
         else if(*p == 's') {
         }
         else if(*p == 'c') {
         }
      }
      else {
      }
   }

   return 0;
}

short
print_short(number)
short number;
{
   short ret;
   short n;
   char byte_array[10];
   char buffer[10];
   short index;

   ret = 0;

   byte_array[0] = '0';
   byte_array[1] = '1';
   byte_array[2] = '2';
   byte_array[3] = '3';
   byte_array[4] = '4';
   byte_array[5] = '5';
   byte_array[6] = '6';
   byte_array[7] = '7';
   byte_array[8] = '8';
   byte_array[9] = '9';

   if(number == 0) {
      putc('0');
   }

   index = 0;
   while(number) {
      n = number % 10;
      number = number / 10;
      buffer[index] = byte_array[n];
      index++;
   }

   index--;
   while(index >= 0) {
      putc(buffer[index]);
      index--;
   }

   return ret;
}


short
printf(fmt)
char * fmt;
{
   char * ptr;
   short * ptr0;
   char * ptr1;
   short i,j;
   short ret;

   ret = 0;
   
   ptr = fmt;
   i = 2;

   while(*ptr) {
      if(*ptr == '%') {
         ptr++;
         if(*ptr == '%') {
            putc('%');
            ptr++;
         }
         else if(*ptr == 'x') {
            ptr0 = (&fmt) + i;
            tohex(*ptr0);
            i += 2;
            ptr++;
         }
         else if(*ptr == 'd') {
            ptr0 = &fmt + i;
            print_short(*ptr0);
            i += 2;
            ptr++;
         }
         else if(*ptr == 's') {
            ptr0 = &fmt + i;
            ptr1 = *ptr0;
            while(*ptr1) {
               putc(*ptr1);
               ptr1++;
            }
            i += 2;
            ptr++;
         }
         else {
            ptr++;
         }
      }
      else {
         putc(*ptr);
         ptr++;
      }
   }
   
   return 0;
}

void
strcpy(a,b)
char * a;
char * b;
{
   while(*a = *b) {
      a++;
      b++;
   }
}
#line 2 "if2.c"

int
main()
{
   if(1)
      printf("IF: Hello, Wordl!\r\n");
   else if(0) 
      printf("ELSE IF: Hello, World!\r\n");
   else
      printf("ELSE: Hello, World!\r\n");

   if(0)
      printf("IF: Hello, Wordl!\r\n");
   else if(1)  
      printf("ELSE IF: Hello, World!\r\n");
   else
      printf("ELSE: Hello, World!\r\n");

   if(0)
      printf("IF: Hello, Wordl!\r\n");
   else if(0)  
      printf("ELSE IF: Hello, World!\r\n");
   else
      printf("ELSE: Hello, World!\r\n");


   return 0;
}

