#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 */
char *decryptViginere(char *, char *);
char *encryptViginere(char *, char *);
char getchar();
char *malloc(int);
int /*<<< orphan*/ normalizeKey(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
main() {
  char *txt = malloc(128 * sizeof(char)), *key = malloc(128 * sizeof(char)),
       *out = malloc(128 * sizeof(char));
  char prompt = 0;
loop:
  printf("Enter plain text:: ");
  scanf("%127[^\n]s", txt);
  while (getchar() != '\n')
    ;
  printf("Enter key:: ");
  scanf("%127[^\n]s", key);
  while (getchar() != '\n')
    ;
  normalizeKey(key);
  out = encryptViginere(txt, key);
  printf("Encrypted:: %s\n", out);
  txt = decryptViginere(out, key);
  printf("Decrypted:: %s\nContinue(Y/N)", txt);
  scanf("%c", &prompt);
  getchar();
  if (prompt == 'Y' || prompt == 'y')
    goto loop;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x80,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x80,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x80,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe4e(%rip),%rdi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     11e3 <main+0x73>
jmp    11cb <main+0x5b>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe18(%rip),%rdi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1219 <main+0xa9>
jmp    1201 <main+0x91>
mov    -0x18(%rbp),%rdi
call   1050 <normalizeKey@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <encryptViginere@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <decryptViginere@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xde9(%rip),%rdi
lea    -0x21(%rbp),%rsi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsbl -0x21(%rbp),%eax
cmp    $0x59,%eax
je     1299 <main+0x129>
movsbl -0x21(%rbp),%eax
cmp    $0x79,%eax
jne    129e <main+0x12e>
jmp    11ad <main+0x3d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x80,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    $0x80,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
movb   $0x0,0x7(%rsp)
lea    0xe73(%rip),%r15
lea    0xeb0(%rip),%r14
lea    0x7(%rsp),%r12
nopl   (%rax)
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1080 <scanf@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    11d0 <main+0x60>
lea    0xe3c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1200 <main+0x90>
mov    %rbx,%rdi
call   1050 <normalizeKey@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <encryptViginere@plt>
mov    %rax,%rbp
lea    0xe03(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1090 <decryptViginere@plt>
mov    %rax,%r13
lea    0xdf4(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x7(%rsp),%al
and    $0xdf,%al
cmp    $0x59,%al
je     11b0 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter plain text:: \00"
@.str.1 = [10 x i8] c"%127[^\0A]s\00"
@.str.2 = [13 x i8] c"Enter key:: \00"
@.str.3 = [16 x i8] c"Encrypted:: %s\0A\00"
@.str.4 = [29 x i8] c"Decrypted:: %s\0AContinue(Y/N)\00"
@.str.5 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
store i32 0, i32* %1
%6 = call i8* @malloc(i32 128)
store i8* %6, i8** %2
%7 = call i8* @malloc(i32 128)
store i8* %7, i8** %3
%8 = call i8* @malloc(i32 128)
store i8* %8, i8** %4
store i8 0, i8* %5
br label %9
9: ; preds = %49, %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %2
%12 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %17, %9
%14 = call signext i8 (...) @getchar()
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 10
br i1 %16, label %17, label %18
17: ; preds = %13
br label %13
18: ; preds = %13
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%20 = load i8*, i8** %3
%21 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %26, %18
%23 = call signext i8 (...) @getchar()
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 10
br i1 %25, label %26, label %27
26: ; preds = %22
br label %22
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = call i32 @normalizeKey(i8* %28)
%30 = load i8*, i8** %2
%31 = load i8*, i8** %3
%32 = call i8* @encryptViginere(i8* %30, i8* %31)
store i8* %32, i8** %4
%33 = load i8*, i8** %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %33)
%35 = load i8*, i8** %4
%36 = load i8*, i8** %3
%37 = call i8* @decryptViginere(i8* %35, i8* %36)
store i8* %37, i8** %2
%38 = load i8*, i8** %2
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %5)
%41 = call signext i8 (...) @getchar()
%42 = load i8, i8* %5
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 89
br i1 %44, label %49, label %45
45: ; preds = %27
%46 = load i8, i8* %5
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 121
br i1 %48, label %49, label %50
49: ; preds = %45, %27
br label %9
50: ; preds = %45
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter plain text:: \00"
@.str.1 = [10 x i8] c"%127[^\0A]s\00"
@.str.2 = [13 x i8] c"Enter key:: \00"
@.str.3 = [16 x i8] c"Encrypted:: %s\0A\00"
@.str.4 = [29 x i8] c"Decrypted:: %s\0AContinue(Y/N)\00"
@.str.5 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i8
%2 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%3 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
store i8 0, i8* %1
br label %4
4: ; preds = %17, %0
%5 = phi i8* [ %2, %0 ], [ %21, %17 ]
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %8
8: ; preds = %8, %4
%9 = call signext i8 (...) @getchar()
%10 = icmp eq i8 %9, 10
br i1 %10, label %11, label %8
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %14
14: ; preds = %14, %11
%15 = call signext i8 (...) @getchar()
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %14
17: ; preds = %14
%18 = call i32 @normalizeKey(i8* %3)
%19 = call i8* @encryptViginere(i8* %5, i8* %3)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = call i8* @decryptViginere(i8* %19, i8* %3)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i8* %21)
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %1)
%24 = call signext i8 (...) @getchar()
%25 = load i8, i8* %1
%26 = and i8 %25, -33
%27 = icmp eq i8 %26, 89
br i1 %27, label %4, label %28
28: ; preds = %17
ret i32 0
}