#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ playfair_decipher(char *, char *, char *);
int /*<<< orphan*/ playfair_encipher(char *, char *, char *);
int /*<<< orphan*/ prepare_for_playfair(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *, char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  char *originaltext = "Defend the east wall of the castle.";
  char *plaintext = malloc(strlen(originaltext) + 2);
  char *ciphertext = malloc(strlen(originaltext) + 2);
  char *result = malloc(strlen(originaltext) + 2);
  prepare_for_playfair(originaltext, plaintext);
  playfair_encipher("cdefghiklmnopqrstuvwxyzab", plaintext, ciphertext);
  playfair_decipher("cdefghiklmnopqrstuvwxyzab", ciphertext, result);
  printf("-->original:   %s\n-->cleaned:    %s\n-->ciphertext: "
         "%s\n-->plaintext:  %s\n",
         originaltext, plaintext, ciphertext, result);
  free(plaintext);
  free(ciphertext);
  free(result);
  system("PAUSE");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe63(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x2,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x2,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x2,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <prepare_for_playfair@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe1c(%rip),%rdi
call   1090 <playfair_encipher@plt>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xe08(%rip),%rdi
call   1050 <playfair_decipher@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xe06(%rip),%rdi
call   1080 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
lea    0xe28(%rip),%rdi
call   1070 <system@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x25,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    $0x25,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    $0x25,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
lea    0xe59(%rip),%r12
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <prepare_for_playfair@plt>
lea    0xe6b(%rip),%r13
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1080 <playfair_encipher@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <playfair_decipher@plt>
lea    0xe62(%rip),%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
call   1070 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
lea    0xe7b(%rip),%rdi
call   1060 <system@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Defend the east wall of the castle.\00"
@.str.1 = [26 x i8] c"cdefghiklmnopqrstuvwxyzab\00"
@.str.2 = [73 x i8] c"-->original: %s\0A-->cleaned: %s\0A-->ciphertext: %s\0A-->plaintext: %s\0A\00"
@.str.3 = [6 x i8] c"PAUSE\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8** %6
%10 = load i8*, i8** %6
%11 = call i64 @strlen(i8* %10)
%12 = add nsw i64 %11, 2
%13 = call i8* @malloc(i64 %12)
store i8* %13, i8** %7
%14 = load i8*, i8** %6
%15 = call i64 @strlen(i8* %14)
%16 = add nsw i64 %15, 2
%17 = call i8* @malloc(i64 %16)
store i8* %17, i8** %8
%18 = load i8*, i8** %6
%19 = call i64 @strlen(i8* %18)
%20 = add nsw i64 %19, 2
%21 = call i8* @malloc(i64 %20)
store i8* %21, i8** %9
%22 = load i8*, i8** %6
%23 = load i8*, i8** %7
%24 = call i32 @prepare_for_playfair(i8* %22, i8* %23)
%25 = load i8*, i8** %7
%26 = load i8*, i8** %8
%27 = call i32 @playfair_encipher(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %26)
%28 = load i8*, i8** %8
%29 = load i8*, i8** %9
%30 = call i32 @playfair_decipher(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %28, i8* %29)
%31 = load i8*, i8** %6
%32 = load i8*, i8** %7
%33 = load i8*, i8** %8
%34 = load i8*, i8** %9
%35 = call i32 @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %32, i8* %33, i8* %34)
%36 = load i8*, i8** %7
%37 = call i32 @free(i8* %36)
%38 = load i8*, i8** %8
%39 = call i32 @free(i8* %38)
%40 = load i8*, i8** %9
%41 = call i32 @free(i8* %40)
%42 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"Defend the east wall of the castle.\00"
@.str.1 = [26 x i8] c"cdefghiklmnopqrstuvwxyzab\00"
@.str.2 = [73 x i8] c"-->original: %s\0A-->cleaned: %s\0A-->ciphertext: %s\0A-->plaintext: %s\0A\00"
@.str.3 = [6 x i8] c"PAUSE\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(37) i8* @malloc(i64 37)
%4 = tail call dereferenceable_or_null(37) i8* @malloc(i64 37)
%5 = tail call dereferenceable_or_null(37) i8* @malloc(i64 37)
%6 = tail call i32 @prepare_for_playfair(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = tail call i32 @playfair_encipher(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %4)
%8 = tail call i32 @playfair_decipher(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %5)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4, i8* %5)
%10 = tail call i32 @free(i8* %3)
%11 = tail call i32 @free(i8* %4)
%12 = tail call i32 @free(i8* %5)
%13 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}