#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*/ autokeycipher(char **, char, int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ flush_stdin();
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char key, *plaintext;
  printf("Enter the Single Key word: ");
  scanf("%c", &key);
  int length;
  printf("Enter the length of Plain Text: ");
  scanf("%d", &length);
  plaintext = (char *)malloc((length + 1) * sizeof(char));
  flush_stdin();
  printf("Enter the Plain Text: ");
  fgets(plaintext, length + 1, stdin);
  flush_stdin();
  printf("\nThe Plain Text is: %s", plaintext);
  autokeycipher(&plaintext, key, 1);
  printf("\nThe Text after Encryption(Cipher text) is: %s", plaintext);
  autokeycipher(&plaintext, key, 0);
  printf("\nAfter Decryption the Text is: %s", plaintext);
  free(plaintext);
  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),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe81(%rip),%rdi
lea    -0x11(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe85(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <flush_stdin@plt>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
add    $0x1,%esi
mov    0x2de5(%rip),%rax
mov    (%rax),%edx
call   1060 <fgets@plt>
mov    $0x0,%al
call   1030 <flush_stdin@plt>
mov    -0x20(%rbp),%rsi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x1,%edx
movsbl -0x11(%rbp),%esi
call   1090 <autokeycipher@plt>
mov    -0x20(%rbp),%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
xor    %edx,%edx
movsbl -0x11(%rbp),%esi
call   1090 <autokeycipher@plt>
mov    -0x20(%rbp),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe92(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe95(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1080 <scanf@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x8(%rsp)
xor    %eax,%eax
call   1030 <flush_stdin@plt>
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
add    $0x1,%esi
mov    0x2dfa(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1060 <fgets@plt>
xor    %eax,%eax
call   1030 <flush_stdin@plt>
lea    0xe54(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x3(%rsp),%esi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%edx
call   1090 <autokeycipher@plt>
mov    0x8(%rsp),%rsi
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsbl 0x3(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
call   1090 <autokeycipher@plt>
mov    0x8(%rsp),%rsi
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Enter the Single Key word: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [33 x i8] c"Enter the length of Plain Text: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [23 x i8] c"Enter the Plain Text: \00"
@stdin = global i32 0
@.str.5 = [23 x i8] c"\0AThe Plain Text is: %s\00"
@.str.6 = [47 x i8] c"\0AThe Text after Encryption(Cipher text) is: %s\00"
@.str.7 = [34 x i8] c"\0AAfter Decryption the Text is: %s\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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%13 = load i32, i32* %8
%14 = add nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 1
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %7
%20 = call i32 (...) @flush_stdin()
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%22 = load i8*, i8** %7
%23 = load i32, i32* %8
%24 = add nsw i32 %23, 1
%25 = load i32, i32* @stdin
%26 = call i32 @fgets(i8* %22, i32 %24, i32 %25)
%27 = call i32 (...) @flush_stdin()
%28 = load i8*, i8** %7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %28)
%30 = load i8, i8* %6
%31 = call i32 @autokeycipher(i8** %7, i8 signext %30, i32 1)
%32 = load i8*, i8** %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i8* %32)
%34 = load i8, i8* %6
%35 = call i32 @autokeycipher(i8** %7, i8 signext %34, i32 0)
%36 = load i8*, i8** %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i8* %36)
%38 = load i8*, i8** %7
%39 = call i32 @free(i8* %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Enter the Single Key word: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [33 x i8] c"Enter the length of Plain Text: \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [23 x i8] c"Enter the Plain Text: \00"
@stdin = global i32 0
@.str.5 = [23 x i8] c"\0AThe Plain Text is: %s\00"
@.str.6 = [47 x i8] c"\0AThe Text after Encryption(Cipher text) is: %s\00"
@.str.7 = [34 x i8] c"\0AAfter Decryption the Text is: %s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i32
%6 = bitcast i8** %4 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%9 = bitcast i32* %5 to i8*
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 1
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %4
%16 = call i32 (...) @flush_stdin()
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
%20 = load i32, i32* @stdin
%21 = call i32 @fgets(i8* %15, i32 %19, i32 %20)
%22 = call i32 (...) @flush_stdin()
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %15)
%24 = load i8, i8* %3
%25 = call i32 @autokeycipher(i8** %4, i8 signext %24, i32 1)
%26 = load i8*, i8** %4
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i8* %26)
%28 = load i8, i8* %3
%29 = call i32 @autokeycipher(i8** %4, i8 signext %28, i32 0)
%30 = load i8*, i8** %4
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %4
%33 = call i32 @free(i8* %32)
ret i32 0
}