#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*/ printf(char *, char *, char *, char *);
int /*<<< orphan*/ simplesub_decipher(char *, char *, char *);
int /*<<< orphan*/ simplesub_encipher(char *, char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  char *plaintext = "Defend the east wall of the castle.";
  char *ciphertext = malloc(strlen(plaintext) + 1);
  char *result = malloc(strlen(plaintext) + 1);
  simplesub_encipher("cdefghijklmnopqrstuvwxyzab", plaintext, ciphertext);
  simplesub_decipher("cdefghijklmnopqrstuvwxyzab", ciphertext, result);
  printf("-->original:   %s\n-->ciphertext: %s\n-->plaintext:  %s\n", plaintext,
         ciphertext, result);
  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    0xe73(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe52(%rip),%rdi
call   1080 <simplesub_encipher@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe3e(%rip),%rdi
call   1090 <simplesub_decipher@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe41(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
lea    0xe5a(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x24,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    $0x24,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
lea    0xe9b(%rip),%r15
lea    0xe70(%rip),%r12
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1070 <simplesub_encipher@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <simplesub_decipher@plt>
lea    0xe8c(%rip),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xe9e(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Defend the east wall of the castle.\00"
@.str.1 = [27 x i8] c"cdefghijklmnopqrstuvwxyzab\00"
@.str.2 = [55 x i8] c"-->original: %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*
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
%9 = load i8*, i8** %6
%10 = call i64 @strlen(i8* %9)
%11 = add nsw i64 %10, 1
%12 = call i8* @malloc(i64 %11)
store i8* %12, i8** %7
%13 = load i8*, i8** %6
%14 = call i64 @strlen(i8* %13)
%15 = add nsw i64 %14, 1
%16 = call i8* @malloc(i64 %15)
store i8* %16, i8** %8
%17 = load i8*, i8** %6
%18 = load i8*, i8** %7
%19 = call i32 @simplesub_encipher(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %18)
%20 = load i8*, i8** %7
%21 = load i8*, i8** %8
%22 = call i32 @simplesub_decipher(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* %21)
%23 = load i8*, i8** %6
%24 = load i8*, i8** %7
%25 = load i8*, i8** %8
%26 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* %23, i8* %24, i8* %25)
%27 = load i8*, i8** %7
%28 = call i32 @free(i8* %27)
%29 = load i8*, i8** %8
%30 = call i32 @free(i8* %29)
%31 = 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 = [27 x i8] c"cdefghijklmnopqrstuvwxyzab\00"
@.str.2 = [55 x i8] c"-->original: %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(36) i8* @malloc(i64 36)
%4 = tail call dereferenceable_or_null(36) i8* @malloc(i64 36)
%5 = tail call i32 @simplesub_encipher(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = tail call i32 @simplesub_decipher(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %4)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 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)
%8 = tail call i32 @free(i8* %3)
%9 = tail call i32 @free(i8* %4)
%10 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}