#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 */
typedef int /*<<< orphan*/ str;
typedef int /*<<< orphan*/ input;

/* Variables and functions */
int encode(int, int, int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *, char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
char *strtok(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  char str[8];
  char enter;
  char input[1000];
  int choice, key, i;
  short int sickMode = 0;
  short int cowboyMode = 0;
  int atoi(const char *str);
  int rand(void);
  int srand();
  srand(time(NULL));
  printf("\nYou may:\n");
  printf("  (1) Encrypt a message \n");
  printf("  (2) Decrypt a message \n");
  printf("\n  What is your selection: ");
  fgets(str, sizeof(str), stdin);
  sscanf(str, "%d", &choice);
  if (choice != 1 && choice != 2) {
    printf("\n Invalid input. Please enter 1 or 2.\n");
    printf("\n  what is your selection: ");
    fgets(str, sizeof(str), stdin);
    sscanf(str, "%d", &choice);
  }
  switch (choice) {
  case 1:
    printf("\nEnter a plaintext message:  ");
    fgets(input, sizeof(input), stdin);
    printf("\nEnter a numerical key <= 255 and >=0:  ");
    while (scanf("%d%c", &key, &enter) != 2 || enter != '\n' || key > 255 ||
           key <= 0)
      printf("\nEnter a numerical key <= 255 and >=0:  ");
    i = 0;
    while (input[i + 1] != 0) {
      printf("%d ", encode(input[i], key, i));
      i++;
    }
    break;
  case 2:
    printf("\nEnter ciphertext:  ");
    fgets(input, sizeof(input), stdin);
    printf("\nEnter the key:  ");
    while (scanf("%d%c", &key, &enter) != 2 || enter != '\n' || key > 255 ||
           key <= 0)
      printf("\nThe key has to be an integer <= 255 and >=0:  ");
    int temp;
    char *parsedInt;
    parsedInt = strtok(input, " ");
    temp = atoi(parsedInt);
    i = 0;
    do {
      if (sickMode) {
        if (encode(temp, key, i) == ' ') {
          if (rand() % 7 == 1)
            printf(" *cough*");
          if (rand() % 20 == 1)
            printf(" *ACHOOOO*");
          if (rand() % 9 == 1)
            printf(" *sniff*");
        }
      }
      if (cowboyMode) {
        if (encode(temp, key, i) == ' ') {
          if (rand() % 5 == 1)
            printf(" -YEEEHAW-");
        }
      }
      printf("%c", encode(temp, key, i));
      i++;
      parsedInt = strtok(NULL, " ");
      temp = atoi(parsedInt);
    } while (temp != -1);
    break;
  default:
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0x0,-0x40e(%rbp)
movw   $0x0,-0x410(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1050 <srand@plt>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xc(%rbp),%rdi
mov    0x2dcf(%rip),%rax
mov    (%rax),%edx
mov    $0x8,%esi
call   1060 <fgets@plt>
lea    -0xc(%rbp),%rdi
lea    0xe2b(%rip),%rsi
lea    -0x404(%rbp),%rdx
call   1080 <sscanf@plt>
cmpl   $0x1,-0x404(%rbp)
je     12a0 <main+0x100>
cmpl   $0x2,-0x404(%rbp)
je     12a0 <main+0x100>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xc(%rbp),%rdi
mov    0x2d6b(%rip),%rax
mov    (%rax),%edx
mov    $0x8,%esi
call   1060 <fgets@plt>
lea    -0xc(%rbp),%rdi
lea    0xdc7(%rip),%rsi
lea    -0x404(%rbp),%rdx
call   1080 <sscanf@plt>
mov    -0x404(%rbp),%eax
mov    %eax,-0x424(%rbp)
sub    $0x1,%eax
je     12ce <main+0x12e>
jmp    12ba <main+0x11a>
mov    -0x424(%rbp),%eax
sub    $0x2,%eax
je     1400 <main+0x260>
jmp    166a <main+0x4ca>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x400(%rbp),%rdi
mov    0x2cfe(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1060 <fgets@plt>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xddd(%rip),%rdi
lea    -0x408(%rbp),%rsi
lea    -0xd(%rbp),%rdx
call   1090 <scanf@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x2,%ecx
mov    %al,-0x425(%rbp)
jne    136b <main+0x1cb>
movsbl -0xd(%rbp),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x425(%rbp)
jne    136b <main+0x1cb>
mov    $0x1,%al
cmpl   $0xff,-0x408(%rbp)
mov    %al,-0x425(%rbp)
jg     136b <main+0x1cb>
cmpl   $0x0,-0x408(%rbp)
setle  %al
mov    %al,-0x425(%rbp)
mov    -0x425(%rbp),%al
test   $0x1,%al
jne    137e <main+0x1de>
jmp    1391 <main+0x1f1>
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1304 <main+0x164>
movl   $0x0,-0x40c(%rbp)
mov    -0x40c(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     13fb <main+0x25b>
movslq -0x40c(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%edi
ff
mov    -0x408(%rbp),%esi
mov    -0x40c(%rbp),%edx
call   1030 <encode@plt>
mov    %eax,%esi
lea    0xd0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40c(%rbp)
jmp    139b <main+0x1fb>
jmp    166f <main+0x4cf>
lea    0xcea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x400(%rbp),%rdi
mov    0x2bcc(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1060 <fgets@plt>
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcab(%rip),%rdi
lea    -0x408(%rbp),%rsi
lea    -0xd(%rbp),%rdx
call   1090 <scanf@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x2,%ecx
mov    %al,-0x426(%rbp)
jne    149d <main+0x2fd>
movsbl -0xd(%rbp),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x426(%rbp)
jne    149d <main+0x2fd>
mov    $0x1,%al
cmpl   $0xff,-0x408(%rbp)
mov    %al,-0x426(%rbp)
jg     149d <main+0x2fd>
cmpl   $0x0,-0x408(%rbp)
setle  %al
mov    %al,-0x426(%rbp)
mov    -0x426(%rbp),%al
test   $0x1,%al
jne    14b0 <main+0x310>
jmp    14c3 <main+0x323>
lea    0xc61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1436 <main+0x296>
lea    -0x400(%rbp),%rdi
lea    0xc75(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x414(%rbp)
movl   $0x0,-0x40c(%rbp)
cmpw   $0x0,-0x40e(%rbp)
je     159d <main+0x3fd>
mov    -0x414(%rbp),%edi
mov    -0x408(%rbp),%esi
mov    -0x40c(%rbp),%edx
call   1030 <encode@plt>
cmp    $0x20,%eax
jne    1598 <main+0x3f8>
call   10c0 <rand@plt>
mov    $0x7,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    154b <main+0x3ab>
lea    0xc04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
call   10c0 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    156f <main+0x3cf>
lea    0xbe9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
call   10c0 <rand@plt>
mov    $0x9,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1593 <main+0x3f3>
lea    0xbd0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1598 <main+0x3f8>
jmp    159d <main+0x3fd>
cmpw   $0x0,-0x410(%rbp)
je     15f9 <main+0x459>
mov    -0x414(%rbp),%edi
mov    -0x408(%rbp),%esi
mov    -0x40c(%rbp),%edx
call   1030 <encode@plt>
cmp    $0x20,%eax
jne    15f4 <main+0x454>
call   10c0 <rand@plt>
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    15ef <main+0x44f>
lea    0xb7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    15f4 <main+0x454>
jmp    15f9 <main+0x459>
mov    -0x414(%rbp),%edi
mov    -0x408(%rbp),%esi
mov    -0x40c(%rbp),%edx
call   1030 <encode@plt>
mov    %eax,%esi
lea    0xad1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xb0c(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x414(%rbp)
cmpl   $0xffffffff,-0x414(%rbp)
jne    14f9 <main+0x359>
jmp    166f <main+0x4cf>
jmp    166f <main+0x4cf>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
xor    %eax,%eax
call   1070 <srand@plt>
lea    0xf0d(%rip),%rdi
call   1050 <puts@plt>
lea    0xf0b(%rip),%rdi
call   1050 <puts@plt>
lea    0xf18(%rip),%rdi
call   1050 <puts@plt>
lea    0xe07(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2de1(%rip),%r14
mov    (%r14),%edx
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1080 <fgets@plt>
lea    0xdf9(%rip),%rsi
lea    0x14(%rsp),%rdx
mov    %rbx,%rdi
call   10a0 <sscanf@plt>
mov    0x14(%rsp),%eax
lea    -0x3(%rax),%ecx
cmp    $0xfffffffd,%ecx
ja     1283 <main+0xd3>
lea    0xedb(%rip),%rdi
call   1050 <puts@plt>
lea    0xdd0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r14),%edx
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1080 <fgets@plt>
lea    0xdaa(%rip),%rsi
lea    0x14(%rsp),%rdx
mov    %rbx,%rdi
call   10a0 <sscanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x2,%eax
je     136c <main+0x1bc>
cmp    $0x1,%eax
jne    147e <main+0x2ce>
lea    0xd9f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r14),%edx
lea    0x20(%rsp),%rdi
mov    $0x3e8,%esi
call   1080 <fgets@plt>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xd92(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdad(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xf(%rsp),%rdx
call   10b0 <scanf@plt>
cmp    $0x2,%eax
jne    12c0 <main+0x110>
cmpb   $0xa,0xf(%rsp)
jne    12c0 <main+0x110>
mov    0x10(%rsp),%esi
cmp    $0xff,%esi
jg     12c0 <main+0x110>
test   %esi,%esi
jle    12c0 <main+0x110>
cmpb   $0x0,0x21(%rsp)
je     147e <main+0x2ce>
movsbl 0x20(%rsp),%edi
xor    %edx,%edx
call   1040 <encode@plt>
lea    0xd69(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x0,0x22(%rsp)
je     147e <main+0x2ce>
mov    $0x1,%ebx
lea    0xd49(%rip),%r14
xchg   %ax,%ax
mov    0x10(%rsp),%esi
movsbl 0x20(%rsp,%rbx,1),%edi
mov    %ebx,%edx
call   1040 <encode@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x0,0x22(%rsp,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1340 <main+0x190>
jmp    147e <main+0x2ce>
lea    0xd18(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r14),%edx
lea    0x20(%rsp),%rdi
mov    $0x3e8,%esi
call   1080 <fgets@plt>
lea    0xd0d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xce1(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xf(%rsp),%rdx
call   10b0 <scanf@plt>
cmp    $0x2,%eax
jne    13cb <main+0x21b>
cmpb   $0xa,0xf(%rsp)
jne    13cb <main+0x21b>
mov    0x10(%rsp),%eax
cmp    $0xff,%eax
jg     13cb <main+0x21b>
test   %eax,%eax
jg     1423 <main+0x273>
lea    0xce0(%rip),%r14
lea    0xca9(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xf(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   10b0 <scanf@plt>
cmp    $0x2,%eax
jne    13f0 <main+0x240>
cmpb   $0xa,0xf(%rsp)
jne    13f0 <main+0x240>
mov    0x10(%rsp),%eax
cmp    $0xff,%eax
jg     13f0 <main+0x240>
test   %eax,%eax
jle    13f0 <main+0x240>
lea    0xcb6(%rip),%r14
lea    0x20(%rsp),%rdi
mov    %r14,%rsi
call   10c0 <strtok@plt>
mov    %rax,%rdi
call   10d0 <atoi@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%esi
mov    %eax,%edi
mov    %ebx,%edx
call   1040 <encode@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
xor    %edi,%edi
mov    %r14,%rsi
call   10c0 <strtok@plt>
mov    %rax,%rdi
call   10d0 <atoi@plt>
cmp    $0xffffffff,%eax
jne    1450 <main+0x2a0>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"\0AYou may:\0A\00"
@.str.1 = [26 x i8] c" (1) Encrypt a message \0A\00"
@.str.2 = [26 x i8] c" (2) Decrypt a message \0A\00"
@.str.3 = [28 x i8] c"\0A What is your selection: \00"
@stdin = global i32 0
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [39 x i8] c"\0A Invalid input. Please enter 1 or 2.\0A\00"
@.str.6 = [28 x i8] c"\0A what is your selection: \00"
@.str.7 = [30 x i8] c"\0AEnter a plaintext message: \00"
@.str.8 = [41 x i8] c"\0AEnter a numerical key <= 255 and >=0: \00"
@.str.9 = [5 x i8] c"%d%c\00"
@.str.10 = [4 x i8] c"%d \00"
@.str.11 = [21 x i8] c"\0AEnter ciphertext: \00"
@.str.12 = [18 x i8] c"\0AEnter the key: \00"
@.str.13 = [48 x i8] c"\0AThe key has to be an integer <= 255 and >=0: \00"
@.str.14 = [2 x i8] c" \00"
@.str.15 = [9 x i8] c" *cough*\00"
@.str.16 = [11 x i8] c" *ACHOOOO*\00"
@.str.17 = [9 x i8] c" *sniff*\00"
@.str.18 = [11 x i8] c" -YEEEHAW-\00"
@.str.19 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca i8
%4 = alloca [1000 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i16
%9 = alloca i16
%10 = alloca i32
%11 = alloca i8*
store i32 0, i32* %1
store i16 0, i16* %8
store i16 0, i16* %9
%12 = call i32 @time(i32* null)
%13 = call i32 (i32, ...) bitcast (i32 (...)* @srand to i32 (i32, ...)*)(i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%19 = load i32, i32* @stdin
%20 = call i32 @fgets(i8* %18, i32 8, i32 %19)
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
%23 = load i32, i32* %5
%24 = icmp ne i32 %23, 1
br i1 %24, label %25, label %36
25: ; preds = %0
%26 = load i32, i32* %5
%27 = icmp ne i32 %26, 2
br i1 %27, label %28, label %36
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%32 = load i32, i32* @stdin
%33 = call i32 @fgets(i8* %31, i32 8, i32 %32)
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%35 = call i32 @sscanf(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
br label %36
36: ; preds = %28, %25, %0
%37 = load i32, i32* %5
switch i32 %37, label %172 [
i32 1, label %38
i32 2, label %83
]
38: ; preds = %36
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%40 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%41 = load i32, i32* @stdin
%42 = call i32 @fgets(i8* %40, i32 1000, i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
br label %44
44: ; preds = %59, %38
%45 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32* %6, i8* %3)
%46 = icmp ne i32 %45, 2
br i1 %46, label %57, label %47
47: ; preds = %44
%48 = load i8, i8* %3
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 10
br i1 %50, label %57, label %51
51: ; preds = %47
%52 = load i32, i32* %6
%53 = icmp sgt i32 %52, 255
br i1 %53, label %57, label %54
54: ; preds = %51
%55 = load i32, i32* %6
%56 = icmp sle i32 %55, 0
br label %57
57: ; preds = %54, %51, %47, %44
%58 = phi i1 [ true, %51 ], [ true, %47 ], [ true, %44 ], [ %56, %54 ]
br i1 %58, label %59, label %61
59: ; preds = %57
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
br label %44
61: ; preds = %57
store i32 0, i32* %7
br label %62
62: ; preds = %70, %61
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %82
70: ; preds = %62
%71 = load i32, i32* %7
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %72
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = load i32, i32* %6
%77 = load i32, i32* %7
%78 = call i32 @encode(i32 %75, i32 %76, i32 %77)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %78)
%80 = load i32, i32* %7
%81 = add nsw i32 %80, 1
store i32 %81, i32* %7
br label %62
82: ; preds = %62
br label %173
83: ; preds = %36
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%85 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%86 = load i32, i32* @stdin
%87 = call i32 @fgets(i8* %85, i32 1000, i32 %86)
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
br label %89
89: ; preds = %104, %83
%90 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32* %6, i8* %3)
%91 = icmp ne i32 %90, 2
br i1 %91, label %102, label %92
92: ; preds = %89
%93 = load i8, i8* %3
%94 = sext i8 %93 to i32
%95 = icmp ne i32 %94, 10
br i1 %95, label %102, label %96
96: ; preds = %92
%97 = load i32, i32* %6
%98 = icmp sgt i32 %97, 255
br i1 %98, label %102, label %99
99: ; preds = %96
%100 = load i32, i32* %6
%101 = icmp sle i32 %100, 0
br label %102
102: ; preds = %99, %96, %92, %89
%103 = phi i1 [ true, %96 ], [ true, %92 ], [ true, %89 ], [ %101, %99 ]
br i1 %103, label %104, label %106
104: ; preds = %102
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.13, i64 0, i64 0))
br label %89
106: ; preds = %102
%107 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%108 = call i8* @strtok(i8* %107, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i8* %108, i8** %11
%109 = load i8*, i8** %11
%110 = call i32 @atoi(i8* %109)
store i32 %110, i32* %10
store i32 0, i32* %7
br label %111
111: ; preds = %168, %106
%112 = load i16, i16* %8
%113 = icmp ne i16 %112, 0
br i1 %113, label %114, label %140
114: ; preds = %111
%115 = load i32, i32* %10
%116 = load i32, i32* %6
%117 = load i32, i32* %7
%118 = call i32 @encode(i32 %115, i32 %116, i32 %117)
%119 = icmp eq i32 %118, 32
br i1 %119, label %120, label %139
120: ; preds = %114
%121 = call i32 @rand()
%122 = srem i32 %121, 7
%123 = icmp eq i32 %122, 1
br i1 %123, label %124, label %126
124: ; preds = %120
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.15, i64 0, i64 0))
br label %126
126: ; preds = %124, %120
%127 = call i32 @rand()
%128 = srem i32 %127, 20
%129 = icmp eq i32 %128, 1
br i1 %129, label %130, label %132
130: ; preds = %126
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.16, i64 0, i64 0))
br label %132
132: ; preds = %130, %126
%133 = call i32 @rand()
%134 = srem i32 %133, 9
%135 = icmp eq i32 %134, 1
br i1 %135, label %136, label %138
136: ; preds = %132
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.17, i64 0, i64 0))
br label %138
138: ; preds = %136, %132
br label %139
139: ; preds = %138, %114
br label %140
140: ; preds = %139, %111
%141 = load i16, i16* %9
%142 = icmp ne i16 %141, 0
br i1 %142, label %143, label %157
143: ; preds = %140
%144 = load i32, i32* %10
%145 = load i32, i32* %6
%146 = load i32, i32* %7
%147 = call i32 @encode(i32 %144, i32 %145, i32 %146)
%148 = icmp eq i32 %147, 32
br i1 %148, label %149, label %156
149: ; preds = %143
%150 = call i32 @rand()
%151 = srem i32 %150, 5
%152 = icmp eq i32 %151, 1
br i1 %152, label %153, label %155
153: ; preds = %149
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0))
br label %155
155: ; preds = %153, %149
br label %156
156: ; preds = %155, %143
br label %157
157: ; preds = %156, %140
%158 = load i32, i32* %10
%159 = load i32, i32* %6
%160 = load i32, i32* %7
%161 = call i32 @encode(i32 %158, i32 %159, i32 %160)
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i64 0, i64 0), i32 %161)
%163 = load i32, i32* %7
%164 = add nsw i32 %163, 1
store i32 %164, i32* %7
%165 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
store i8* %165, i8** %11
%166 = load i8*, i8** %11
%167 = call i32 @atoi(i8* %166)
store i32 %167, i32* %10
br label %168
168: ; preds = %157
%169 = load i32, i32* %10
%170 = icmp ne i32 %169, -1
br i1 %170, label %111, label %171
171: ; preds = %168
br label %173
172: ; preds = %36
br label %173
173: ; preds = %172, %171, %82
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [28 x i8] c"\0A What is your selection: \00"
@stdin = global i32 0
@.str.4 = [3 x i8] c"%d\00"
@.str.6 = [28 x i8] c"\0A what is your selection: \00"
@.str.7 = [30 x i8] c"\0AEnter a plaintext message: \00"
@.str.8 = [41 x i8] c"\0AEnter a numerical key <= 255 and >=0: \00"
@.str.9 = [5 x i8] c"%d%c\00"
@.str.10 = [4 x i8] c"%d \00"
@.str.11 = [21 x i8] c"\0AEnter ciphertext: \00"
@.str.12 = [18 x i8] c"\0AEnter the key: \00"
@.str.13 = [48 x i8] c"\0AThe key has to be an integer <= 255 and >=0: \00"
@.str.14 = [2 x i8] c" \00"
@str = [10 x i8] c"\0AYou may:\00"
@str.20 = [25 x i8] c" (1) Encrypt a message \00"
@str.21 = [25 x i8] c" (2) Decrypt a message \00"
@str.22 = [38 x i8] c"\0A Invalid input. Please enter 1 or 2.\00"
define i32 @main() {
%1 = alloca [8 x i8]
%2 = alloca i8
%3 = alloca [1000 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = tail call i32 @time(i32* null)
%11 = tail call i32 (i32, ...) bitcast (i32 (...)* @srand to i32 (i32, ...)*)(i32 %10)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.20, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.21, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %6, i32 8, i32 %16)
%18 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%19 = load i32, i32* %4
%20 = add i32 %19, -3
%21 = icmp ult i32 %20, -2
br i1 %21, label %22, label %29
22: ; preds = %0
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.22, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%25 = load i32, i32* @stdin
%26 = call i32 @fgets(i8* %6, i32 8, i32 %25)
%27 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%28 = load i32, i32* %4
br label %29
29: ; preds = %22, %0
%30 = phi i32 [ %28, %22 ], [ %19, %0 ]
switch i32 %30, label %127 [
i32 1, label %31
i32 2, label %87
]
31: ; preds = %29
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%33 = load i32, i32* @stdin
%34 = call i32 @fgets(i8* %7, i32 1000, i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32* %5, i8* %2)
%37 = icmp ne i32 %36, 2
%38 = load i8, i8* %2
%39 = icmp ne i8 %38, 10
%40 = select i1 %37, i1 true, i1 %39
%41 = load i32, i32* %5
%42 = icmp sgt i32 %41, 255
%43 = select i1 %40, i1 true, i1 %42
%44 = icmp slt i32 %41, 1
%45 = select i1 %43, i1 true, i1 %44
br i1 %45, label %60, label %46
46: ; preds = %60, %31
%47 = phi i32 [ %41, %31 ], [ %67, %60 ]
%48 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 1
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 0
br i1 %50, label %127, label %51
51: ; preds = %46
%52 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = call i32 @encode(i32 %54, i32 %47, i32 0)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %55)
%57 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 2
%58 = load i8, i8* %57
%59 = icmp eq i8 %58, 0
br i1 %59, label %127, label %72
60: ; preds = %31, %60
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%62 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32* %5, i8* %2)
%63 = icmp ne i32 %62, 2
%64 = load i8, i8* %2
%65 = icmp ne i8 %64, 10
%66 = select i1 %63, i1 true, i1 %65
%67 = load i32, i32* %5
%68 = icmp sgt i32 %67, 255
%69 = select i1 %66, i1 true, i1 %68
%70 = icmp slt i32 %67, 1
%71 = select i1 %69, i1 true, i1 %70
br i1 %71, label %60, label %46
72: ; preds = %51, %72
%73 = phi i64 [ %83, %72 ], [ 2, %51 ]
%74 = phi i64 [ %75, %72 ], [ 0, %51 ]
%75 = add nuw nsw i64 %74, 1
%76 = load i32, i32* %5
%77 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %75
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = trunc i64 %75 to i32
%81 = call i32 @encode(i32 %79, i32 %76, i32 %80)
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %81)
%83 = add nuw i64 %73, 1
%84 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %83
%85 = load i8, i8* %84
%86 = icmp eq i8 %85, 0
br i1 %86, label %127, label %72
87: ; preds = %29
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%89 = load i32, i32* @stdin
%90 = call i32 @fgets(i8* %7, i32 1000, i32 %89)
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.12, i64 0, i64 0))
%92 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32* %5, i8* %2)
%93 = icmp ne i32 %92, 2
%94 = load i8, i8* %2
%95 = icmp ne i8 %94, 10
%96 = select i1 %93, i1 true, i1 %95
%97 = load i32, i32* %5
%98 = icmp sgt i32 %97, 255
%99 = select i1 %96, i1 true, i1 %98
%100 = icmp slt i32 %97, 1
%101 = select i1 %99, i1 true, i1 %100
br i1 %101, label %102, label %114
102: ; preds = %87, %102
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.13, i64 0, i64 0))
%104 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32* %5, i8* %2)
%105 = icmp ne i32 %104, 2
%106 = load i8, i8* %2
%107 = icmp ne i8 %106, 10
%108 = select i1 %105, i1 true, i1 %107
%109 = load i32, i32* %5
%110 = icmp sgt i32 %109, 255
%111 = select i1 %108, i1 true, i1 %110
%112 = icmp slt i32 %109, 1
%113 = select i1 %111, i1 true, i1 %112
br i1 %113, label %102, label %114
114: ; preds = %102, %87
%115 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%116 = call i32 @atoi(i8* %115)
br label %117
117: ; preds = %117, %114
%118 = phi i32 [ 0, %114 ], [ %123, %117 ]
%119 = phi i32 [ %116, %114 ], [ %125, %117 ]
%120 = load i32, i32* %5
%121 = call i32 @encode(i32 %119, i32 %120, i32 %118)
%122 = call i32 @putchar(i32 %121)
%123 = add nuw nsw i32 %118, 1
%124 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
%125 = call i32 @atoi(i8* %124)
%126 = icmp eq i32 %125, -1
br i1 %126, label %127, label %117
127: ; preds = %117, %72, %51, %46, %29
ret i32 0
}