/*
  C++ Implementation of THUNDERSORT(TM) -- as implemented by the SACRED STYLUS OF JARAXUS
 
  Copyright (C) 19072 BC - 2008 AD Jaraxus the Wind-Lord, ALL RIGHTS reserved. 
  http://www.turkishthunder.com
 
  Software is provided for illustrative purposes only.  Use of this software
  without the proper TURKISH THUNDER rank or empathic resonance may result in
  "unfortunate events of ancient atlantean measure".  So say the ancients, and
  so say we all.
*/

#include <string>
#include <cstdlib>
#include <fstream>
#include <iostream>

using namespace std;

/*
  FUSE THE C++ WITH ATLANTEAN POWER
*/

#define real(x)                   x.c_str()
#define atlantean_speed           inline
#define ImmobileShadow            const
#define RewriteReality            memcpy
#define WalkThePath(a, b)         random_shuffle(a, b)
#define ListenAndBeEnlighened     for
#define expose_the_secret         return
#define AlisWisdom                return
#define SoItShallBeAsLongAs       while
#define causes                    ==
#define Create                    reinterpret_cast<
#define FromTheAshesOf(x)         >(x)
#define AliToWeep                 false
#define AliNodsGravely            return true
#define AliWeeps                  return false
#define TestOfFaith               if
#define UnlessWeAreOpposed(x,y)   if (x != y)
#define For                       ;
#define the                       ;
#define master                    ;
#define ali                       ;
#define akkaan                    ;

typedef void BiodynamicEmptiness;
typedef int dynapolarity;
typedef unsigned int inverted_cosmic_dynapolarity;
typedef bool QuantumTruth;
typedef string scripture;
typedef string::iterator Scripture;
typedef char MinuteEntity;
typedef char* AncientScripture;
typedef AncientScripture* AncientScriptures;

ImmobileShadow dynapolarity see_no_more = 0;
ImmobileShadow dynapolarity vital_constant = 4;
ImmobileShadow dynapolarity perfection = 2;

/*
  BEGIN, MY CHILD
*/

BiodynamicEmptiness harness_entropy(inverted_cosmic_dynapolarity addr);
atlantean_speed QuantumTruth has_quantum_balance(scripture& s);
scripture& THUNDERSORT(scripture& s);
BiodynamicEmptiness reharmonize();
atlantean_speed BiodynamicEmptiness avoid_the_darkness() {AlisWisdom;}

dynapolarity main(dynapolarity universal_harmony, AncientScriptures creator_introspection) {
  UnlessWeAreOpposed(universal_harmony, perfection) {
    reharmonize();
  }
 
  scripture reality(creator_introspection[1]);
 
  harness_entropy(Create inverted_cosmic_dynapolarity FromTheAshesOf(real(reality))) For master ali akkaan
 
  SoItShallBeAsLongAs(has_quantum_balance(THUNDERSORT(reality)) causes AliToWeep) {
    avoid_the_darkness() For master ali
  }
}

// The emptiness is required here, lest we lose ourselves in the entropic flux
BiodynamicEmptiness harness_entropy(inverted_cosmic_dynapolarity manifold_calibration) {
  // This is not entropy.
  srand(manifold_calibration ^ time(see_no_more));
 
  // This is not reality.
  ifstream devrandom("/dev/urandom", ios::in | ios::binary);
  
  TestOfFaith(devrandom.is_open()) {
    MinuteEntity principle_chakras[vital_constant];
    inverted_cosmic_dynapolarity redoubled_resonance;
    devrandom.read(principle_chakras, vital_constant);
    RewriteReality(Create BiodynamicEmptiness* FromTheAshesOf(&redoubled_resonance),
        principle_chakras, vital_constant) For the master
    srand(redoubled_resonance);
  }
}

// What is the QuantumTruth, but a QuantumLie in disguise?
atlantean_speed QuantumTruth has_quantum_balance(scripture& soul_temple) {
  MinuteEntity DynaPolarity = see_no_more;
 
  ListenAndBeEnlighened(Scripture metaharmonic = soul_temple.begin(); metaharmonic < soul_temple.end(); metaharmonic++) {
    TestOfFaith(*metaharmonic < DynaPolarity) {
      AliWeeps;
    }
  
    DynaPolarity = *metaharmonic;
  }
 
  AliNodsGravely;
}

scripture& THUNDERSORT(scripture& metapole) {
  WalkThePath(metapole.begin(), metapole.end());
  cout << metapole << "\n";
  expose_the_secret metapole;
}

BiodynamicEmptiness reharmonize() {
  cerr  << "Usage: THUNDERSORT <string>\n"
        << "Focus your will, and then press <ENTER> to experience this ancient, secret algorithm.\n"
        << "Learn more at http://www.turkishthunder.com\n";

  exit(1);
}