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

ulong SECRETPASSWORD;

int main(int param_1, int *param_2) {
  char* foo = "Hello";
  uint8_t string_equality;
  uint8_t output_value;
  size_t input_length;
  uint8_t local_20;
  uint8_t itr;

  local_20 = 1;
  if (true /*param_1 == 2*/) {

    itr = 0;
    while( true ) {
      //input_length = strlen((char *)param_2[1]); // 16
      input_length = strlen(foo); // 16
      if (16 <= itr) break;
      local_20 = (local_20 * 3) % 257;
      itr = itr + 1;
    }
    string_equality = strncmp(
      // SECRETPASSWORD = 00402e82
      // SECRETPASSWORD + ( (249+226)%257 ) * 8
      // SECRETPASSWORD + (475%257) * 8
      // SECRETPASSWORD + 218 * 8
      // SECRETPASSWORD + 1744
      *(char **)(SECRETPASSWORD + (ulong)((local_20 + 226) % 257) * 8),
      foo,
      16
    );
    // => DwMxRPg1cjmVTHdV
    if (string_equality == 0) {
      fprintf(stderr,"\nCongratulations ! The right password is indeed %s :-)\n\n",param_2[1]);
      output_value = 0;
    }
    else {
      fwrite("\nWrong password ! Try again...\n\n", 1, 32, stderr);
      output_value = 1;
    }
  }
  else {
    fwrite("\nMSE-SRE Challenge E1 --- Enjoy !\n", 1, 34, stderr);
    fprintf(stderr, "\nUsage: %s <password>\n\n", *param_2);
    output_value = 1;
  }
  return output_value;
}

