#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 getchar();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
scalar_t__ realloc(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int len, key, i;
  char *plainText, *cipherText, ch;
  plainText = NULL;
  len = 1;
  printf("Enter the plain text (delimited by '#'):\n");
  while ((ch = getchar()) != '#') {
    len++;
    plainText = (char *)realloc(plainText, sizeof(char) * len);
    plainText[len - 2] = ch;
  }
  plainText[len - 1] = '\0';
  printf("\nEnter the displacement key: ");
  scanf("%d", &key);
  key %= 26;
  printf("Effective key: %d\n\n", key);
  cipherText = (char *)malloc(sizeof(char) * len);
  for (i = 0; i < (len - 1); i++) {
    if (plainText[i] < 32) {
      cipherText[i] = plainText[i];
      continue;
    }
    ch = plainText[i] + key;
    if (ch > 126)
      ch = 31 + (ch - 126);
    cipherText[i] = ch;
  }
  cipherText[len - 1] = '\0';
  while (1) {
    printf("\n\tCipherText:\n%s", cipherText);
    printf("\nEnter the displacement key (negative to exit): ");
    scanf("%d", &key);
    if (key < 0)
      return 0;
    key %= 26;
    printf("\n\tPlain Text:\n");
    for (i = 0; i < (len - 1); i++) {
      ch = cipherText[i];
      if (ch < 32) {
        putchar(ch);
        continue;
      }
      ch -= key;
      if (ch < 32)
        ch = 126 - (31 - ch);
      putchar(ch);
    }
    printf("\n\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
cmp    $0x23,%eax
je     11da <main+0x7a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x8(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%esi
call   1070 <realloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x21(%rbp),%dl
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    118c <main+0x2c>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe48(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x8(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12cb <main+0x16b>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jge    1283 <main+0x123>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    12bd <main+0x15d>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    -0xc(%rbp),%eax
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0x7e,%eax
jle    12af <main+0x14f>
movsbl -0x21(%rbp),%eax
sub    $0x7e,%eax
add    $0x1f,%eax
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%dl
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1242 <main+0xe2>
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rsi
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd45(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1080 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    131e <main+0x1be>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret
mov    -0xc(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    13c0 <main+0x260>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0x20,%eax
jge    137b <main+0x21b>
movsbl -0x21(%rbp),%edi
call   1030 <putchar@plt>
jmp    13b2 <main+0x252>
mov    -0xc(%rbp),%ecx
movsbl -0x21(%rbp),%eax
sub    %ecx,%eax
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0x20,%eax
jge    13a9 <main+0x249>
movsbl -0x21(%rbp),%eax
mov    $0x1f,%ecx
sub    %eax,%ecx
mov    $0x7e,%eax
sub    %ecx,%eax
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1341 <main+0x1e1>
lea    0xc95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12dc <main+0x17c>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf15(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebx
xor    %ebp,%ebp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x2(%rbp),%esi
mov    %r14,%rdi
call   1080 <realloc@plt>
mov    %rax,%r14
mov    %bl,(%rax,%rbp,1)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebx
add    $0x1,%rbp
cmp    $0x23,%al
jne    11a0 <main+0x30>
lea    0x1(%rbp),%ebx
mov    %ebp,%r12d
movb   $0x0,(%r14,%r12,1)
lea    0xe4c(%rip),%rdi
xor    %r13d,%r13d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe59(%rip),%rdi
lea    0x4(%rsp),%r15
mov    %r15,%rsi
call   1090 <scanf@plt>
movslq 0x4(%rsp),%rsi
imul   $0x4ec4ec4f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
add    %eax,%ecx
sub    %ecx,%esi
mov    %esi,0x4(%rsp)
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
cmp    $0x2,%ebp
mov    $0x1,%edi
cmovae %ebp,%edi
cmp    $0x8,%edi
jb     1362 <main+0x1f2>
lea    (%r14,%rdi,1),%rcx
cmp    %rbx,%rcx
seta   %al
lea    (%rbx,%rdi,1),%rsi
cmp    %r14,%rsi
seta   %dl
lea    0x8(%rsp),%rcx
cmp    %rcx,%rbx
setb   %cl
cmp    %r15,%rsi
seta   %sil
xor    %r13d,%r13d
test   %dl,%al
jne    1362 <main+0x1f2>
and    %sil,%cl
jne    1362 <main+0x1f2>
mov    %edi,%r13d
and    $0xfffffff8,%r13d
movd   0x4(%rsp),%xmm0
punpcklbw %xmm0,%xmm0
pshuflw $0x0,%xmm0,%xmm9
cmp    $0x2,%ebp
mov    $0x1,%ecx
cmovae %ebp,%ecx
and    $0xfffffff8,%ecx
xor    %edx,%edx
movdqa 0xd51(%rip),%xmm10
movdqa 0xd58(%rip),%xmm8
nopl   0x0(%rax,%rax,1)
movd   (%r14,%rdx,1),%xmm0
movd   0x4(%r14,%rdx,1),%xmm11
movdqa %xmm10,%xmm3
pcmpgtb %xmm0,%xmm3
movdqa %xmm10,%xmm5
pcmpgtb %xmm11,%xmm5
movdqa %xmm0,%xmm6
paddb  %xmm9,%xmm6
movdqa %xmm11,%xmm2
paddb  %xmm9,%xmm2
movdqa %xmm6,%xmm7
pcmpeqb %xmm8,%xmm7
movdqa %xmm2,%xmm4
pcmpeqb %xmm8,%xmm4
movdqa %xmm7,%xmm1
pandn  %xmm6,%xmm1
pand   %xmm10,%xmm7
por    %xmm1,%xmm7
movdqa %xmm4,%xmm1
pandn  %xmm2,%xmm1
pand   %xmm10,%xmm4
por    %xmm1,%xmm4
pand   %xmm3,%xmm0
pandn  %xmm7,%xmm3
por    %xmm0,%xmm3
pand   %xmm5,%xmm11
pandn  %xmm4,%xmm5
por    %xmm11,%xmm5
movd   %xmm3,(%rbx,%rdx,1)
movd   %xmm5,0x4(%rbx,%rdx,1)
add    $0x8,%rdx
cmp    %rdx,%rcx
jne    12c0 <main+0x150>
cmp    %rdi,%r13
je     13f9 <main+0x289>
mov    %r13,%rcx
not    %rcx
test   $0x1,%dil
je     1394 <main+0x224>
movzbl (%r14,%r13,1),%edx
mov    0x4(%rsp),%al
add    %dl,%al
cmp    $0x7f,%al
movzbl %al,%eax
mov    $0x20,%esi
cmovne %eax,%esi
cmp    $0x20,%dl
cmovl  %edx,%esi
mov    %sil,(%rbx,%r13,1)
or     $0x1,%r13
add    %rdi,%rcx
je     13f9 <main+0x289>
cmp    $0x2,%ebp
mov    $0x1,%eax
cmovae %ebp,%eax
mov    $0x20,%esi
nopl   0x0(%rax)
movzbl (%r14,%r13,1),%edx
movzbl 0x4(%rsp),%ecx
add    %dl,%cl
cmp    $0x7f,%cl
movzbl %cl,%ecx
cmove  %esi,%ecx
cmp    $0x20,%dl
cmovl  %edx,%ecx
mov    %cl,(%rbx,%r13,1)
movzbl 0x1(%r14,%r13,1),%ecx
movzbl 0x4(%rsp),%edx
add    %cl,%dl
cmp    $0x7f,%dl
movzbl %dl,%edx
cmove  %esi,%edx
cmp    $0x20,%cl
cmovl  %ecx,%edx
mov    %dl,0x1(%rbx,%r13,1)
add    $0x2,%r13
cmp    %r13,%rax
jne    13b0 <main+0x240>
movb   $0x0,(%rbx,%r12,1)
lea    0xc50(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc50(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc1a(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     1502 <main+0x392>
cmp    $0x2,%ebp
mov    $0x1,%r15d
cmovae %ebp,%r15d
lea    0xc18(%rip),%r13
lea    0xbe9(%rip),%rbp
lea    0x4(%rsp),%r14
jmp    149a <main+0x32a>
nopl   0x0(%rax)
lea    0xbec(%rip),%rdi
call   1040 <puts@plt>
lea    0xbe2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     1502 <main+0x392>
mov    %eax,%ecx
imul   $0x4ec4ec4f,%rcx,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%eax
mov    %eax,0x4(%rsp)
lea    0xc04(%rip),%rdi
call   1040 <puts@plt>
xor    %r12d,%r12d
jmp    14e5 <main+0x375>
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
cmp    %r12,%r15
je     1460 <main+0x2f0>
movzbl (%rbx,%r12,1),%eax
cmp    $0x20,%al
jl     14d0 <main+0x360>
sub    0x4(%rsp),%al
lea    0x5f(%rax),%ecx
cmp    $0x20,%al
movzbl %al,%edx
movzbl %cl,%eax
cmovge %edx,%eax
jmp    14d0 <main+0x360>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Enter the plain text (delimited by '#'):\0A\00"
@.str.1 = [30 x i8] c"\0AEnter the displacement key: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [20 x i8] c"Effective key: %d\0A\0A\00"
@.str.4 = [17 x i8] c"\0A\09CipherText:\0A%s\00"
@.str.5 = [49 x i8] c"\0AEnter the displacement key (negative to exit): \00"
@.str.6 = [15 x i8] c"\0A\09Plain Text:\0A\00"
@.str.7 = [3 x i8] c"\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
store i32 0, i32* %1
store i8* null, i8** %5
store i32 1, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %13, %0
%10 = call signext i8 (...) @getchar()
store i8 %10, i8* %7
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 35
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
%16 = load i8*, i8** %5
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = mul i64 1, %18
%20 = trunc i64 %19 to i32
%21 = call i64 @realloc(i8* %16, i32 %20)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %5
%23 = load i8, i8* %7
%24 = load i8*, i8** %5
%25 = load i32, i32* %2
%26 = sub nsw i32 %25, 2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
store i8 %23, i8* %28
br label %9
29: ; preds = %9
%30 = load i8*, i8** %5
%31 = load i32, i32* %2
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %30, i64 %33
store i8 0, i8* %34
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%37 = load i32, i32* %3
%38 = srem i32 %37, 26
store i32 %38, i32* %3
%39 = load i32, i32* %3
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = mul i64 1, %42
%44 = trunc i64 %43 to i32
%45 = call i64 @malloc(i32 %44)
%46 = inttoptr i64 %45 to i8*
store i8* %46, i8** %6
store i32 0, i32* %4
br label %47
47: ; preds = %95, %29
%48 = load i32, i32* %4
%49 = load i32, i32* %2
%50 = sub nsw i32 %49, 1
%51 = icmp slt i32 %48, %50
br i1 %51, label %52, label %98
52: ; preds = %47
%53 = load i8*, i8** %5
%54 = load i32, i32* %4
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp slt i32 %58, 32
br i1 %59, label %60, label %70
60: ; preds = %52
%61 = load i8*, i8** %5
%62 = load i32, i32* %4
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
%65 = load i8, i8* %64
%66 = load i8*, i8** %6
%67 = load i32, i32* %4
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %66, i64 %68
store i8 %65, i8* %69
br label %95
70: ; preds = %52
%71 = load i8*, i8** %5
%72 = load i32, i32* %4
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = load i32, i32* %3
%78 = add nsw i32 %76, %77
%79 = trunc i32 %78 to i8
store i8 %79, i8* %7
%80 = load i8, i8* %7
%81 = sext i8 %80 to i32
%82 = icmp sgt i32 %81, 126
br i1 %82, label %83, label %89
83: ; preds = %70
%84 = load i8, i8* %7
%85 = sext i8 %84 to i32
%86 = sub nsw i32 %85, 126
%87 = add nsw i32 31, %86
%88 = trunc i32 %87 to i8
store i8 %88, i8* %7
br label %89
89: ; preds = %83, %70
%90 = load i8, i8* %7
%91 = load i8*, i8** %6
%92 = load i32, i32* %4
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %91, i64 %93
store i8 %90, i8* %94
br label %95
95: ; preds = %89, %60
%96 = load i32, i32* %4
%97 = add nsw i32 %96, 1
store i32 %97, i32* %4
br label %47
98: ; preds = %47
%99 = load i8*, i8** %6
%100 = load i32, i32* %2
%101 = sub nsw i32 %100, 1
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8, i8* %99, i64 %102
store i8 0, i8* %103
br label %104
104: ; preds = %98, %154
%105 = load i8*, i8** %6
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %105)
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%108 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%109 = load i32, i32* %3
%110 = icmp slt i32 %109, 0
br i1 %110, label %111, label %112
111: ; preds = %104
ret i32 0
112: ; preds = %104
%113 = load i32, i32* %3
%114 = srem i32 %113, 26
store i32 %114, i32* %3
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %4
br label %116
116: ; preds = %151, %112
%117 = load i32, i32* %4
%118 = load i32, i32* %2
%119 = sub nsw i32 %118, 1
%120 = icmp slt i32 %117, %119
br i1 %120, label %121, label %154
121: ; preds = %116
%122 = load i8*, i8** %6
%123 = load i32, i32* %4
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8, i8* %122, i64 %124
%126 = load i8, i8* %125
store i8 %126, i8* %7
%127 = load i8, i8* %7
%128 = sext i8 %127 to i32
%129 = icmp slt i32 %128, 32
br i1 %129, label %130, label %133
130: ; preds = %121
%131 = load i8, i8* %7
%132 = call i32 @putchar(i8 signext %131)
br label %151
133: ; preds = %121
%134 = load i32, i32* %3
%135 = load i8, i8* %7
%136 = sext i8 %135 to i32
%137 = sub nsw i32 %136, %134
%138 = trunc i32 %137 to i8
store i8 %138, i8* %7
%139 = load i8, i8* %7
%140 = sext i8 %139 to i32
%141 = icmp slt i32 %140, 32
br i1 %141, label %142, label %148
142: ; preds = %133
%143 = load i8, i8* %7
%144 = sext i8 %143 to i32
%145 = sub nsw i32 31, %144
%146 = sub nsw i32 126, %145
%147 = trunc i32 %146 to i8
store i8 %147, i8* %7
br label %148
148: ; preds = %142, %133
%149 = load i8, i8* %7
%150 = call i32 @putchar(i8 signext %149)
br label %151
151: ; preds = %148, %130
%152 = load i32, i32* %4
%153 = add nsw i32 %152, 1
store i32 %153, i32* %4
br label %116
154: ; preds = %116
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %104
}

LLVM IR (-O2):
@.str.1 = [30 x i8] c"\0AEnter the displacement key: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [20 x i8] c"Effective key: %d\0A\0A\00"
@.str.4 = [17 x i8] c"\0A\09CipherText:\0A%s\00"
@.str.5 = [49 x i8] c"\0AEnter the displacement key (negative to exit): \00"
@str = [41 x i8] c"Enter the plain text (delimited by '#'):\00"
@str.8 = [14 x i8] c"\0A\09Plain Text:\00"
@str.9 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%4 = tail call signext i8 (...) @getchar()
%5 = icmp ne i8 %4, 35
br label %6
6: ; preds = %0, %6
%7 = phi i64 [ 1, %0 ], [ %10, %6 ]
%8 = phi i8 [ %4, %0 ], [ %16, %6 ]
%9 = phi i8* [ null, %0 ], [ %13, %6 ]
%10 = add nuw i64 %7, 1
%11 = trunc i64 %10 to i32
%12 = tail call i64 @realloc(i8* %9, i32 %11)
%13 = inttoptr i64 %12 to i8*
%14 = add nsw i64 %7, -1
%15 = getelementptr inbounds i8, i8* %13, i64 %14
store i8 %8, i8* %15
%16 = tail call signext i8 (...) @getchar()
%17 = icmp eq i8 %16, 35
br i1 %17, label %18, label %6
18: ; preds = %6
%19 = trunc i64 %10 to i32
%20 = inttoptr i64 %12 to i8*
%21 = trunc i64 %7 to i32
%22 = and i64 %7, 4294967295
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 0, i8* %23
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%26 = load i32, i32* %1
%27 = srem i32 %26, 26
store i32 %27, i32* %1
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = call i64 @malloc(i32 %19)
%30 = inttoptr i64 %29 to i8*
%31 = call i32 @llvm.umax.i32(i32 %21, i32 1)
%32 = zext i32 %31 to i64
%33 = icmp ult i32 %31, 8
br i1 %33, label %81, label %34
34: ; preds = %18
%35 = getelementptr i8, i8* %30, i64 %32
%36 = getelementptr i8, i8* %20, i64 %32
%37 = getelementptr inbounds i32, i32* %1, i64 1
%38 = bitcast i32* %37 to i8*
%39 = icmp ugt i8* %36, %30
%40 = icmp ugt i8* %35, %20
%41 = and i1 %39, %40
%42 = icmp ult i8* %30, %38
%43 = icmp ugt i8* %35, %2
%44 = and i1 %42, %43
%45 = or i1 %41, %44
br i1 %45, label %81, label %46
46: ; preds = %34
%47 = and i64 %32, 4294967288
%48 = load i32, i32* %1
%49 = trunc i32 %48 to i8
%50 = insertelement <4 x i8> undef, i8 %49, i64 0
%51 = shufflevector <4 x i8> %50, <4 x i8> poison, <4 x i32> zeroinitializer
%52 = trunc i32 %48 to i8
%53 = insertelement <4 x i8> undef, i8 %52, i64 0
%54 = shufflevector <4 x i8> %53, <4 x i8> poison, <4 x i32> zeroinitializer
br label %55
55: ; preds = %55, %46
%56 = phi i64 [ 0, %46 ], [ %77, %55 ]
%57 = getelementptr inbounds i8, i8* %20, i64 %56
%58 = bitcast i8* %57 to <4 x i8>*
%59 = load <4 x i8>, <4 x i8>* %58
%60 = getelementptr inbounds i8, i8* %57, i64 4
%61 = bitcast i8* %60 to <4 x i8>*
%62 = load <4 x i8>, <4 x i8>* %61
%63 = icmp slt <4 x i8> %59, <i8 32, i8 32, i8 32, i8 32>
%64 = icmp slt <4 x i8> %62, <i8 32, i8 32, i8 32, i8 32>
%65 = add <4 x i8> %59, %51
%66 = add <4 x i8> %62, %54
%67 = icmp eq <4 x i8> %65, <i8 127, i8 127, i8 127, i8 127>
%68 = icmp eq <4 x i8> %66, <i8 127, i8 127, i8 127, i8 127>
%69 = select <4 x i1> %67, <4 x i8> <i8 32, i8 32, i8 32, i8 32>, <4 x i8> %65
%70 = select <4 x i1> %68, <4 x i8> <i8 32, i8 32, i8 32, i8 32>, <4 x i8> %66
%71 = select <4 x i1> %63, <4 x i8> %59, <4 x i8> %69
%72 = select <4 x i1> %64, <4 x i8> %62, <4 x i8> %70
%73 = getelementptr inbounds i8, i8* %30, i64 %56
%74 = bitcast i8* %73 to <4 x i8>*
store <4 x i8> %71, <4 x i8>* %74
%75 = getelementptr inbounds i8, i8* %73, i64 4
%76 = bitcast i8* %75 to <4 x i8>*
store <4 x i8> %72, <4 x i8>* %76
%77 = add nuw i64 %56, 8
%78 = icmp eq i64 %77, %47
br i1 %78, label %79, label %55
79: ; preds = %55
%80 = icmp eq i64 %47, %32
br i1 %80, label %127, label %81
81: ; preds = %34, %18, %79
%82 = phi i64 [ 0, %34 ], [ 0, %18 ], [ %47, %79 ]
%83 = xor i64 %82, -1
%84 = and i64 %32, 1
%85 = icmp eq i64 %84, 0
br i1 %85, label %98, label %86
86: ; preds = %81
%87 = getelementptr inbounds i8, i8* %20, i64 %82
%88 = load i8, i8* %87
%89 = icmp slt i8 %88, 32
%90 = load i32, i32* %1
%91 = trunc i32 %90 to i8
%92 = add i8 %88, %91
%93 = icmp eq i8 %92, 127
%94 = select i1 %93, i8 32, i8 %92
%95 = select i1 %89, i8 %88, i8 %94
%96 = getelementptr inbounds i8, i8* %30, i64 %82
store i8 %95, i8* %96
%97 = or i64 %82, 1
br label %98
98: ; preds = %86, %81
%99 = phi i64 [ %82, %81 ], [ %97, %86 ]
%100 = sub nsw i64 0, %32
%101 = icmp eq i64 %83, %100
br i1 %101, label %127, label %102
102: ; preds = %98, %102
%103 = phi i64 [ %125, %102 ], [ %99, %98 ]
%104 = getelementptr inbounds i8, i8* %20, i64 %103
%105 = load i8, i8* %104
%106 = icmp slt i8 %105, 32
%107 = load i32, i32* %1
%108 = trunc i32 %107 to i8
%109 = add i8 %105, %108
%110 = icmp eq i8 %109, 127
%111 = select i1 %110, i8 32, i8 %109
%112 = select i1 %106, i8 %105, i8 %111
%113 = getelementptr inbounds i8, i8* %30, i64 %103
store i8 %112, i8* %113
%114 = add nuw nsw i64 %103, 1
%115 = getelementptr inbounds i8, i8* %20, i64 %114
%116 = load i8, i8* %115
%117 = icmp slt i8 %116, 32
%118 = load i32, i32* %1
%119 = trunc i32 %118 to i8
%120 = add i8 %116, %119
%121 = icmp eq i8 %120, 127
%122 = select i1 %121, i8 32, i8 %120
%123 = select i1 %117, i8 %116, i8 %122
%124 = getelementptr inbounds i8, i8* %30, i64 %114
store i8 %123, i8* %124
%125 = add nuw nsw i64 %103, 2
%126 = icmp eq i64 %125, %32
br i1 %126, label %127, label %102
127: ; preds = %98, %102, %79
%128 = getelementptr inbounds i8, i8* %30, i64 %22
store i8 0, i8* %128
%129 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %30)
%130 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%131 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%132 = load i32, i32* %1
%133 = icmp slt i32 %132, 0
br i1 %133, label %137, label %134
134: ; preds = %127
%135 = call i32 @llvm.umax.i32(i32 %21, i32 1)
%136 = zext i32 %135 to i64
br label %138
137: ; preds = %159, %127
ret i32 0
138: ; preds = %159, %134
%139 = phi i32 [ %132, %134 ], [ %164, %159 ]
%140 = urem i32 %139, 26
store i32 %140, i32* %1
%141 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.8, i64 0, i64 0))
br label %142
142: ; preds = %138, %154
%143 = phi i64 [ 0, %138 ], [ %157, %154 ]
%144 = getelementptr inbounds i8, i8* %30, i64 %143
%145 = load i8, i8* %144
%146 = icmp slt i8 %145, 32
br i1 %146, label %154, label %147
147: ; preds = %142
%148 = load i32, i32* %1
%149 = trunc i32 %148 to i8
%150 = sub i8 %145, %149
%151 = icmp slt i8 %150, 32
%152 = add i8 %150, 95
%153 = select i1 %151, i8 %152, i8 %150
br label %154
154: ; preds = %142, %147
%155 = phi i8 [ %153, %147 ], [ %145, %142 ]
%156 = call i32 @putchar(i8 signext %155)
%157 = add nuw nsw i64 %143, 1
%158 = icmp eq i64 %157, %136
br i1 %158, label %159, label %142
159: ; preds = %154
%160 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%161 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %30)
%162 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%163 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%164 = load i32, i32* %1
%165 = icmp slt i32 %164, 0
br i1 %165, label %137, label %138
}