/********************************************************************
* This C program was generated by spl2c, the Shakespeare to C *
* converter by Jon Åslund and Karl Hasselström. *
********************************************************************/
/* libspl definitions and function prototypes */
#include "spl.h"
int main(void)
{
/******************************************************************
* MUCH ADO ABOUT HACKING *
******************************************************************/
CHARACTER *benedick; /* a budding young hacker */
CHARACTER *beatrice; /* a veteran exploiter */
CHARACTER *don_pedro; /* a good friend of the others */
CHARACTER *don_john; /* he is just kinda there */
CHARACTER *achilles; /* I thought he was from Greece */
CHARACTER *cleopatra; /* now this is just getting ridiculous */
int comp1, comp2;
global_initialize();
benedick = initialize_character("Benedick");
beatrice = initialize_character("Beatrice");
don_pedro = initialize_character("Don Pedro");
don_john = initialize_character("Don John");
achilles = initialize_character("Achilles");
cleopatra = initialize_character("Cleopatra");
act_i: /* Also the last act */
act_i_scene_i: /* Benedick learns his place */
// don_john.value = 0
enter_scene(15, beatrice);
enter_scene(15, don_john);
activate_character(20, beatrice);
assign(18, second_person, 0);
exit_scene(20, don_john);
// don_pedro.value = 0
enter_scene(21, don_pedro);
activate_character(26, beatrice);
assign(24, second_person, 0);
exit_scene(26, don_pedro);
// achilles.value = 32
enter_scene(27, achilles);
activate_character(32, beatrice);
assign(30, second_person, 2*2*2*2*2*1);
exit_scene(32, achilles);
// cleopatra.value = 128 - achilles
enter_scene(33, cleopatra);
activate_character(38, beatrice);
assign(36, second_person, int_sub(36, 2*2*2*2*2*2*2*1, achilles->value));
exit_scene(38, cleopatra);
// benedick.value = 0
enter_scene(39, benedick);
activate_character(44, beatrice);
assign(42, second_person, 0);
act_i_scene_ii: /* Benedick strengthens his memory */
// benedick.value = <input>
// benedick.push(benedick.value)
activate_character(49, beatrice);
char_input(47, second_person);
push(47, second_person, value_of(47, second_person));
// beatrice.value = beatrice.value + 1
activate_character(53, benedick);
assign(50, second_person, int_add(50, value_of(50, second_person), 1));
// flag = benedick.value == 32
comp1 = value_of(51, first_person);
comp2 = 2*2*2*2*2*1;
truth_flag = (comp1 == comp2);
// if not flag: goto act_i_scene_ii
activate_character(56, beatrice);
if (!truth_flag) {
goto act_i_scene_ii;
}
// beatrice.value = beatrice.value - 1
activate_character(59, benedick);
assign(57, second_person, int_add(57, value_of(57, second_person), (-1)));
// benedick.value = benedick.pop()
activate_character(62, beatrice);
pop(60, second_person);
act_i_scene_iii: /* Benedick teaches his friends about hacking */
// benedick.value = benedick.pop()
// benedick.value = benedick.value - achilles.value
activate_character(67, beatrice);
pop(65, second_person);
assign(65, second_person, int_sub(65, value_of(65, second_person), achilles->value));
// beatrice.value = beatrice.value - 1
activate_character(70, benedick);
assign(68, second_person, int_add(68, value_of(68, second_person), (-1)));
exit_scene(70, beatrice);
enter_scene(71, don_john);
// don_john.value = benedick.value
activate_character(76, benedick);
assign(74, second_person, value_of(74, first_person));
exit_scene(76, don_john);
enter_scene(77, don_pedro);
// benedick.value = benedick.value + don_pedro.value
// benedick.value = benedick.value % cleopatra.value
activate_character(83, don_pedro);
assign(80, second_person, int_add(80, value_of(80, second_person), value_of(80, first_person)));
assign(81, second_person, int_mod(81, value_of(81, second_person), cleopatra->value));
exit_scene(83, benedick);
enter_scene(84, don_john);
// don_pedro.value = don_john.value
activate_character(89, don_john);
assign(87, second_person, value_of(87, first_person));
exit_scene_all(89);
enter_scene(90, beatrice);
enter_scene(90, benedick);
// benedick.value = benedick.value + achilles.value
// print (char) benedick.value
activate_character(95, beatrice);
assign(93, second_person, int_add(93, value_of(93, second_person), achilles->value));
char_output(93, second_person);
// flag = beatrice.value > 0
activate_character(98, benedick);
comp1 = value_of(96, second_person);
comp2 = 0;
truth_flag = (comp1 > comp2);
// if flag: goto act_i_scene_iii
activate_character(101, beatrice);
if (truth_flag) {
goto act_i_scene_iii;
}
exit_scene_all(101);
return 0;
}
benedick = initialize_character("Benedick");
beatrice = initialize_character("Beatrice");
don_pedro = initialize_character("Don Pedro");
don_john = initialize_character("Don John");
act_i:
act_i_scene_i:
// initialize variables to zero
don_john.value = 0
don_pedro.value = 0
benedick.value = 0
act_i_scene_ii:
// get input string and stroe in benedick stack; terminate with space
// store space character in benedick value
// store input string length in beatrice value exclusive of space
benedick.value = read()
benedick.push(benedick.value)
beatrice.value++
if not benedick.value == 32:
goto act_i_scene_ii
beatrice.value--
benedick.value = benedick.pop()
act_i_scene_iii:
// pop last character and decrease string length
// adjust character
benedick.value = benedick.pop()
benedick.value-= 32
beatrice.value--
// remember original adjusted value of current character
don_john.value = benedick.value
// add current adjusted character to previous adjusted character and modulo by 96
benedick.value+= don_pedro.value
benedick.value%= 96
// remember original value of current adjusted character for next operation
don_pedro.value = don_john.value
// unadjust character
benedick.value+= 32
// print the value of the current character after manipulation
print (char) benedick.value
// if some characters are remaining, handle them in another iteration
if beatrice.value > 0:
goto act_i_scene_iii
// DESIRED RESULT: tu1|\h+&g\OP7@% :BH7M6m3g=
// FORMULA: <output> = (((<input>-32) + (<previous>-32)) % 96) + 32
// 't' ; 116 = (((<input>-32) + 0) % 96) + 32 ; input = 116 ; input = 't' ;
// 'u' ; 117 = (((<input>-32) + (116-32)) % 96) + 32 ; input = 033 ; input = '!' ;
// '1' ; 049 = (((<input>-32) + (033-32)) % 96) + 32 ; input = 048 ; input = '0' ;
// '|' ; 124 = (((<input>-32) + (048-32)) % 96) + 32 ; input = 108 ; input = 'l' ;
// '\' ; 092 = (((<input>-32) + (108-32)) % 96) + 32 ; input = 112 ; input = 'p' ;
// 'h' ; 104 = (((<input>-32) + (112-32)) % 96) + 32 ; input = 120 ; input = 'x' ;
// '+' ; 043 = (((<input>-32) + (120-32)) % 96) + 32 ; input = 051 ; input = '3' ;
// '&' ; 038 = (((<input>-32) + (051-32)) % 96) + 32 ; input = 115 ; input = 's' ;
// 'g' ; 103 = (((<input>-32) + (115-32)) % 96) + 32 ; input = 116 ; input = 't' ;
// '\' ; 092 = (((<input>-32) + (116-32)) % 96) + 32 ; input = 104 ; input = 'h' ;
// 'O' ; 079 = (((<input>-32) + (104-32)) % 96) + 32 ; input = 103 ; input = 'g' ;
// 'P' ; 080 = (((<input>-32) + (103-32)) % 96) + 32 ; input = 105 ; input = 'i' ;
// '7' ; 055 = (((<input>-32) + (105-32)) % 96) + 32 ; input = 078 ; input = 'N' ;
// '@' ; 064 = (((<input>-32) + (078-32)) % 96) + 32 ; input = 114 ; input = 'r' ;
// '%' ; 037 = (((<input>-32) + (114-32)) % 96) + 32 ; input = 051 ; input = '3' ;
// ' ' ; 032 = (((<input>-32) + (051-32)) % 96) + 32 ; input = 109 ; input = 'm' ;
// ':' ; 058 = (((<input>-32) + (109-32)) % 96) + 32 ; input = 077 ; input = 'M' ;
// 'B' ; 066 = (((<input>-32) + (077-32)) % 96) + 32 ; input = 117 ; input = 'u' ;
// 'H' ; 072 = (((<input>-32) + (117-32)) % 96) + 32 ; input = 083 ; input = 'S' ;
// '7' ; 055 = (((<input>-32) + (083-32)) % 96) + 32 ; input = 100 ; input = 'd' ;
// 'M' ; 077 = (((<input>-32) + (100-32)) % 96) + 32 ; input = 105 ; input = 'i' ;
// '6' ; 054 = (((<input>-32) + (105-32)) % 96) + 32 ; input = 077 ; input = 'M' ;
// 'm' ; 109 = (((<input>-32) + (077-32)) % 96) + 32 ; input = 064 ; input = '@' ;
// '3' ; 051 = (((<input>-32) + (064-32)) % 96) + 32 ; input = 115 ; input = 's' ;
// 'g' ; 103 = (((<input>-32) + (115-32)) % 96) + 32 ; input = 116 ; input = 't' ;
// '=' ; 061 = (((<input>-32) + (116-32)) % 96) + 32 ; input = 073 ; input = 'I' ;
// ANSWER: Its@MidSuMm3rNights3xpl0!t