#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>
#include <signal.h>

static char* input_pw;
static char return_check_pw;



void check_pw(void) {
  uint8_t bVar1;
  char *pcVar2;
  char *pcVar3;

  bVar1 = 0;
  pcVar2 = input_pw;
  do {
    pcVar3 = pcVar2 + 2;
    bVar1 = bVar1 | ((pcVar2[1] - 14) - pcVar2[0]);
    pcVar2 = pcVar3;
  } while (input_pw + 12 != pcVar3);
  return_check_pw = (int)(char)bVar1;
  return;
}

void print_check_pw(void) {
  if (return_check_pw != 0) {
    fwrite("\nWrong password ! Try again...\n\n",1,0x20,stderr);
    return;
  }
  fprintf(stderr,"\nCongratulations ! A right password is indeed %s :-)\n\n",input_pw);
  return;
}


uint64_t main(int param_1,char* *param_2) {
  char *__s;
  size_t sVar1;

  if (param_1 == 2) {
    __s = (char *)param_2[1];
    sVar1 = strlen(__s);
    if (sVar1 == 12) {
      input_pw = __s;
      signal(10,check_pw);
      signal(12,print_check_pw);
      kill(0,10);
      kill(0,12);
      return 0;
    }
    fwrite("\nWrong password ! Try again...\n\n",1,0x20,stderr);
  } else {
    fwrite("\nMSE-SRE Challenge E4 --- Enjoy !\n",1,0x22,stderr);
    fwrite("\nWhat I need is 1024 passwords passing the check!\n",1,0x32,stderr);
    fprintf(stderr,"\nUsage: %s <password>\n\n",*param_2);
  }
  return 1;
}
