#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 *);
int getline(char **, size_t *, int /*<<< orphan*/);
scalar_t__ isalpha(char);
scalar_t__ islower(char);
scalar_t__ isupper(char);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
char tolower(char);
char toupper(char);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("Incorrect usage. Usage: ./vigenere <key>\n");
    return 1;
  }
  char *key = argv[1];
  for (int i = 0; i < strlen(argv[1]); i++) {
    if (!isalpha(argv[1][i])) {
      printf("Invalid keyword. Use only alphabetical characters.\n");
      return 1;
    }
  }
  int bytes_read = -1;
  size_t nbytes = 100;
  char *plaintext = (char *)malloc(nbytes + 1);
  while (bytes_read <= 0) {
    printf("Please enter text to be encrypted, up to 100 characters long: ");
    bytes_read = getline(&plaintext, &nbytes, stdin);
    if (bytes_read <= 0) {
      printf("Error.\n");
    }
  }
  unsigned long text_len = strlen(plaintext);
  char encrypted[text_len];
  plaintext[text_len - 1] = '\0';
  encrypted[text_len] = '\0';
  int letter_counter = 0;
  char tempc;
  for (int i = 0; i < text_len; i++) {
    if (isalpha(plaintext[i])) {
      if (isupper(plaintext[i])) {
        if (islower(key[letter_counter % strlen(key)])) {
          tempc = toupper(key[letter_counter % strlen(key)]);
          encrypted[i] = (((plaintext[i] - 'A') + (tempc - 'A')) % 26) + 'A';
        } else {
          encrypted[i] = (((plaintext[i] - 'A') +
                           (key[letter_counter % strlen(key)] - 'A')) %
                          26) +
                         'A';
        }
      } else {
        if (isupper(key[letter_counter % strlen(key)])) {
          tempc = tolower(key[letter_counter % strlen(key)]);
          encrypted[i] = (((plaintext[i] - 'a') + (tempc - 'a')) % 26) + 'a';
        } else {
          encrypted[i] = (((plaintext[i] - 'a') +
                           (key[letter_counter % strlen(key)] - 'a')) %
                          26) +
                         'a';
        }
      }
      letter_counter++;
    } else {
      encrypted[i] = plaintext[i];
    }
  }
  printf("Encrypting \"%s\" with a keyword of \"%s\", using Vigenère’s cipher, "
         "yields the ciphertext \"%s\".\n",
         plaintext, key, encrypted);
  free(plaintext);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11dd <main+0x3d>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1602 <main+0x462>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
cmp    %ecx,%eax
jge    125c <main+0xbc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   10a0 <isalpha@plt>
cmp    $0x0,%rax
jne    1249 <main+0xa9>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1602 <main+0x462>
jmp    124e <main+0xae>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f0 <main+0x50>
movl   $0xffffffff,-0x20(%rbp)
movq   $0x64,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpl   $0x0,-0x20(%rbp)
jg     12ca <main+0x12a>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%edx
lea    -0x30(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   10c0 <getline@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jg     12c5 <main+0x125>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    127c <main+0xdc>
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
cltq
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
mov    %rsp,%rax
mov    %rax,-0x40(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x60(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x48(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
sub    $0x1,%rdx
movb   $0x0,(%rcx,%rdx,1)
mov    -0x38(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x54(%rbp)
movslq -0x54(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    15d1 <main+0x431>
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   10a0 <isalpha@plt>
cmp    $0x0,%rax
je     15a8 <main+0x408>
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   10b0 <isupper@plt>
cmp    $0x0,%rax
je     1473 <main+0x2d3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
cltd
idiv   %ecx
mov    -0x68(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     1408 <main+0x268>
mov    -0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x7c(%rbp),%eax
cltd
idiv   %ecx
mov    -0x78(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <toupper@plt>
mov    %al,-0x4d(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x41,%eax
movsbl -0x4d(%rbp),%ecx
sub    $0x41,%ecx
add    %ecx,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    -0x60(%rbp),%rax
add    $0x41,%edx
movslq -0x54(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    146e <main+0x2ce>
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x41,%eax
mov    %eax,-0x80(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x90(%rbp),%rcx
mov    %eax,%esi
mov    -0x84(%rbp),%eax
cltd
idiv   %esi
mov    -0x80(%rbp),%eax
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
sub    $0x41,%ecx
add    %ecx,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    -0x60(%rbp),%rax
add    $0x41,%edx
movslq -0x54(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    159a <main+0x3fa>
mov    -0x18(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x9c(%rbp),%eax
cltd
idiv   %ecx
mov    -0x98(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%edi
call   10b0 <isupper@plt>
cmp    $0x0,%rax
je     1529 <main+0x389>
mov    -0x18(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xac(%rbp),%eax
cltd
idiv   %ecx
mov    -0xa8(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1080 <tolower@plt>
mov    %al,-0x4d(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x61,%eax
movsbl -0x4d(%rbp),%ecx
sub    $0x61,%ecx
add    %ecx,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    -0x60(%rbp),%rax
add    $0x61,%edx
movslq -0x54(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1595 <main+0x3f5>
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x61,%eax
mov    %eax,-0xb0(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0xb4(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xc0(%rbp),%rcx
mov    %eax,%esi
mov    -0xb4(%rbp),%eax
cltd
idiv   %esi
mov    -0xb0(%rbp),%eax
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
sub    $0x61,%ecx
add    %ecx,%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    -0x60(%rbp),%rax
add    $0x61,%edx
movslq -0x54(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    159a <main+0x3fa>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    15be <main+0x41e>
mov    -0x60(%rbp),%rax
mov    -0x30(%rbp),%rcx
movslq -0x54(%rbp),%rdx
mov    (%rcx,%rdx,1),%dl
movslq -0x54(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    15c3 <main+0x423>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1326 <main+0x186>
mov    -0x60(%rbp),%rcx
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xac1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x2,%edi
jne    1443 <main+0x293>
mov    %rsi,%r14
mov    0x8(%rsi),%r15
mov    %r15,%rdi
call   1070 <strlen@plt>
test   %eax,%eax
jle    120a <main+0x5a>
xor    %ebx,%ebx
nop
mov    0x8(%r14),%rax
movsbl (%rax,%rbx,1),%edi
call   10b0 <isalpha@plt>
test   %rax,%rax
je     1475 <main+0x2c5>
add    $0x1,%rbx
mov    0x8(%r14),%rdi
call   1070 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11e0 <main+0x30>
movq   $0x64,-0x38(%rbp)
mov    $0x65,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
lea    0xdd9(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%edx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10d0 <getline@plt>
test   %eax,%eax
jg     128a <main+0xda>
lea    0xe51(%rip),%r14
lea    0xdaa(%rip),%r12
lea    -0x30(%rbp),%r13
lea    -0x38(%rbp),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
call   1060 <puts@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %rbx,%rsi
call   10d0 <getline@plt>
test   %eax,%eax
jle    1260 <main+0xb0>
mov    -0x30(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rsp,-0x40(%rbp)
cltq
mov    %rsp,%r14
lea    0xf(%rax),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r14
mov    %r14,%rsp
mov    -0x30(%rbp),%rcx
movb   $0x0,-0x1(%rax,%rcx,1)
movb   $0x0,(%rax,%r14,1)
test   %eax,%eax
je     144c <main+0x29c>
cmp    $0x2,%rax
mov    $0x1,%ecx
cmovae %rax,%rcx
mov    %rcx,-0x48(%rbp)
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    12f2 <main+0x142>
nopl   0x0(%rax)
mov    %cl,(%r14,%r13,1)
add    $0x1,%r13
cmp    %r13,-0x48(%rbp)
je     144c <main+0x29c>
mov    -0x30(%rbp),%rax
movsbl (%rax,%r13,1),%edi
call   10b0 <isalpha@plt>
mov    -0x30(%rbp),%rcx
movzbl (%rcx,%r13,1),%ecx
test   %rax,%rax
je     12e0 <main+0x130>
movsbl %cl,%edi
call   10c0 <isupper@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    %r12d,%eax
cltd
idiv   %ecx
movslq %edx,%rax
movzbl (%r15,%rax,1),%eax
movsbl %al,%edi
test   %rbx,%rbx
je     1380 <main+0x1d0>
call   1040 <islower@plt>
test   %rax,%rax
je     13bd <main+0x20d>
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    %r12d,%eax
cltd
idiv   %ecx
movslq %edx,%rax
movsbl (%r15,%rax,1),%edi
call   1050 <toupper@plt>
mov    -0x30(%rbp),%rcx
movsbl (%rcx,%r13,1),%ecx
movsbl %al,%eax
add    %eax,%ecx
add    $0xffffff7e,%ecx
jmp    13e7 <main+0x237>
cs nopw 0x0(%rax,%rax,1)
call   10c0 <isupper@plt>
test   %rax,%rax
je     13eb <main+0x23b>
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    %r12d,%eax
cltd
idiv   %ecx
movslq %edx,%rax
movsbl (%r15,%rax,1),%edi
call   1090 <tolower@plt>
mov    -0x30(%rbp),%rcx
movsbl (%rcx,%r13,1),%ecx
movsbl %al,%eax
add    %eax,%ecx
add    $0xffffff3e,%ecx
jmp    1415 <main+0x265>
mov    -0x30(%rbp),%rax
movsbl (%rax,%r13,1),%ebx
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    %r12d,%eax
cltd
idiv   %ecx
movslq %edx,%rax
movsbl (%r15,%rax,1),%eax
lea    (%rbx,%rax,1),%ecx
add    $0xffffff7e,%ecx
mov    $0x41,%al
jmp    1417 <main+0x267>
mov    -0x30(%rbp),%rax
movsbl (%rax,%r13,1),%ebx
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    %r12d,%eax
cltd
idiv   %ecx
movslq %edx,%rax
movsbl (%r15,%rax,1),%eax
lea    (%rbx,%rax,1),%ecx
add    $0xffffff3e,%ecx
mov    $0x61,%al
movswl %cx,%ecx
imul   $0x4ec5,%ecx,%edx
mov    %edx,%esi
shr    $0x1f,%esi
shr    $0x13,%edx
add    %esi,%edx
lea    (%rdx,%rdx,4),%esi
lea    (%rsi,%rsi,4),%esi
add    %edx,%esi
sub    %esi,%ecx
add    %al,%cl
mov    %cl,(%r14,%r13,1)
add    $0x1,%r12d
jmp    12e4 <main+0x134>
lea    0xc90(%rip),%rdi
jmp    147c <main+0x2cc>
mov    -0x30(%rbp),%rsi
lea    0xbe8(%rip),%rdi
xor    %ebx,%ebx
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1080 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rsp
jmp    1486 <main+0x2d6>
lea    0xc2b(%rip),%rdi
call   1060 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Incorrect usage. Usage: ./vigenere <key>\0A\00"
@.str.1 = [52 x i8] c"Invalid keyword. Use only alphabetical characters.\0A\00"
@.str.2 = [63 x i8] c"Please enter text to be encrypted, up to 100 characters long: \00"
@stdin = global i32 0
@.str.3 = [8 x i8] c"Error.\0A\00"
@.str.4 = [97 x i8] c"Encrypting \22%s\22 with a keyword of \22%s\22, using Vigen\C3\A8re\E2\80\99s cipher, yields the ciphertext \22%s\22.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32
%15 = alloca i8
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 2
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %250
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
store i8* %24, i8** %6
store i32 0, i32* %7
br label %25
25: ; preds = %45, %21
%26 = load i32, i32* %7
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @strlen(i8* %29)
%31 = icmp slt i32 %26, %30
br i1 %31, label %32, label %48
32: ; preds = %25
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = call i64 @isalpha(i8 signext %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %32
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %250
44: ; preds = %32
br label %45
45: ; preds = %44
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %25
48: ; preds = %25
store i32 -1, i32* %8
store i64 100, i64* %9
%49 = load i64, i64* %9
%50 = add i64 %49, 1
%51 = call i64 @malloc(i64 %50)
%52 = inttoptr i64 %51 to i8*
store i8* %52, i8** %10
br label %53
53: ; preds = %64, %48
%54 = load i32, i32* %8
%55 = icmp sle i32 %54, 0
br i1 %55, label %56, label %65
56: ; preds = %53
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
%58 = load i32, i32* @stdin
%59 = call i32 @getline(i8** %10, i64* %9, i32 %58)
store i32 %59, i32* %8
%60 = load i32, i32* %8
%61 = icmp sle i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %56
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %64
64: ; preds = %62, %56
br label %53
65: ; preds = %53
%66 = load i8*, i8** %10
%67 = call i32 @strlen(i8* %66)
%68 = sext i32 %67 to i64
store i64 %68, i64* %11
%69 = load i64, i64* %11
%70 = call i8* @llvm.stacksave()
store i8* %70, i8** %12
%71 = alloca i8, i64 %69
store i64 %69, i64* %13
%72 = load i8*, i8** %10
%73 = load i64, i64* %11
%74 = sub i64 %73, 1
%75 = getelementptr inbounds i8, i8* %72, i64 %74
store i8 0, i8* %75
%76 = load i64, i64* %11
%77 = getelementptr inbounds i8, i8* %71, i64 %76
store i8 0, i8* %77
store i32 0, i32* %14
store i32 0, i32* %16
br label %78
78: ; preds = %240, %65
%79 = load i32, i32* %16
%80 = sext i32 %79 to i64
%81 = load i64, i64* %11
%82 = icmp ult i64 %80, %81
br i1 %82, label %83, label %243
83: ; preds = %78
%84 = load i8*, i8** %10
%85 = load i32, i32* %16
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %84, i64 %86
%88 = load i8, i8* %87
%89 = call i64 @isalpha(i8 signext %88)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %230
91: ; preds = %83
%92 = load i8*, i8** %10
%93 = load i32, i32* %16
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8, i8* %92, i64 %94
%96 = load i8, i8* %95
%97 = call i64 @isupper(i8 signext %96)
%98 = icmp ne i64 %97, 0
br i1 %98, label %99, label %163
99: ; preds = %91
%100 = load i8*, i8** %6
%101 = load i32, i32* %14
%102 = load i8*, i8** %6
%103 = call i32 @strlen(i8* %102)
%104 = srem i32 %101, %103
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %100, i64 %105
%107 = load i8, i8* %106
%108 = call i64 @islower(i8 signext %107)
%109 = icmp ne i64 %108, 0
br i1 %109, label %110, label %137
110: ; preds = %99
%111 = load i8*, i8** %6
%112 = load i32, i32* %14
%113 = load i8*, i8** %6
%114 = call i32 @strlen(i8* %113)
%115 = srem i32 %112, %114
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %111, i64 %116
%118 = load i8, i8* %117
%119 = call signext i8 @toupper(i8 signext %118)
store i8 %119, i8* %15
%120 = load i8*, i8** %10
%121 = load i32, i32* %16
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds i8, i8* %120, i64 %122
%124 = load i8, i8* %123
%125 = sext i8 %124 to i32
%126 = sub nsw i32 %125, 65
%127 = load i8, i8* %15
%128 = sext i8 %127 to i32
%129 = sub nsw i32 %128, 65
%130 = add nsw i32 %126, %129
%131 = srem i32 %130, 26
%132 = add nsw i32 %131, 65
%133 = trunc i32 %132 to i8
%134 = load i32, i32* %16
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds i8, i8* %71, i64 %135
store i8 %133, i8* %136
br label %162
137: ; preds = %99
%138 = load i8*, i8** %10
%139 = load i32, i32* %16
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8, i8* %138, i64 %140
%142 = load i8, i8* %141
%143 = sext i8 %142 to i32
%144 = sub nsw i32 %143, 65
%145 = load i8*, i8** %6
%146 = load i32, i32* %14
%147 = load i8*, i8** %6
%148 = call i32 @strlen(i8* %147)
%149 = srem i32 %146, %148
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds i8, i8* %145, i64 %150
%152 = load i8, i8* %151
%153 = sext i8 %152 to i32
%154 = sub nsw i32 %153, 65
%155 = add nsw i32 %144, %154
%156 = srem i32 %155, 26
%157 = add nsw i32 %156, 65
%158 = trunc i32 %157 to i8
%159 = load i32, i32* %16
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds i8, i8* %71, i64 %160
store i8 %158, i8* %161
br label %162
162: ; preds = %137, %110
br label %227
163: ; preds = %91
%164 = load i8*, i8** %6
%165 = load i32, i32* %14
%166 = load i8*, i8** %6
%167 = call i32 @strlen(i8* %166)
%168 = srem i32 %165, %167
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds i8, i8* %164, i64 %169
%171 = load i8, i8* %170
%172 = call i64 @isupper(i8 signext %171)
%173 = icmp ne i64 %172, 0
br i1 %173, label %174, label %201
174: ; preds = %163
%175 = load i8*, i8** %6
%176 = load i32, i32* %14
%177 = load i8*, i8** %6
%178 = call i32 @strlen(i8* %177)
%179 = srem i32 %176, %178
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds i8, i8* %175, i64 %180
%182 = load i8, i8* %181
%183 = call signext i8 @tolower(i8 signext %182)
store i8 %183, i8* %15
%184 = load i8*, i8** %10
%185 = load i32, i32* %16
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds i8, i8* %184, i64 %186
%188 = load i8, i8* %187
%189 = sext i8 %188 to i32
%190 = sub nsw i32 %189, 97
%191 = load i8, i8* %15
%192 = sext i8 %191 to i32
%193 = sub nsw i32 %192, 97
%194 = add nsw i32 %190, %193
%195 = srem i32 %194, 26
%196 = add nsw i32 %195, 97
%197 = trunc i32 %196 to i8
%198 = load i32, i32* %16
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds i8, i8* %71, i64 %199
store i8 %197, i8* %200
br label %226
201: ; preds = %163
%202 = load i8*, i8** %10
%203 = load i32, i32* %16
%204 = sext i32 %203 to i64
%205 = getelementptr inbounds i8, i8* %202, i64 %204
%206 = load i8, i8* %205
%207 = sext i8 %206 to i32
%208 = sub nsw i32 %207, 97
%209 = load i8*, i8** %6
%210 = load i32, i32* %14
%211 = load i8*, i8** %6
%212 = call i32 @strlen(i8* %211)
%213 = srem i32 %210, %212
%214 = sext i32 %213 to i64
%215 = getelementptr inbounds i8, i8* %209, i64 %214
%216 = load i8, i8* %215
%217 = sext i8 %216 to i32
%218 = sub nsw i32 %217, 97
%219 = add nsw i32 %208, %218
%220 = srem i32 %219, 26
%221 = add nsw i32 %220, 97
%222 = trunc i32 %221 to i8
%223 = load i32, i32* %16
%224 = sext i32 %223 to i64
%225 = getelementptr inbounds i8, i8* %71, i64 %224
store i8 %222, i8* %225
br label %226
226: ; preds = %201, %174
br label %227
227: ; preds = %226, %162
%228 = load i32, i32* %14
%229 = add nsw i32 %228, 1
store i32 %229, i32* %14
br label %239
230: ; preds = %83
%231 = load i8*, i8** %10
%232 = load i32, i32* %16
%233 = sext i32 %232 to i64
%234 = getelementptr inbounds i8, i8* %231, i64 %233
%235 = load i8, i8* %234
%236 = load i32, i32* %16
%237 = sext i32 %236 to i64
%238 = getelementptr inbounds i8, i8* %71, i64 %237
store i8 %235, i8* %238
br label %239
239: ; preds = %230, %227
br label %240
240: ; preds = %239
%241 = load i32, i32* %16
%242 = add nsw i32 %241, 1
store i32 %242, i32* %16
br label %78
243: ; preds = %78
%244 = load i8*, i8** %10
%245 = load i8*, i8** %6
%246 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str.4, i64 0, i64 0), i8* %244, i8* %245, i8* %71)
%247 = load i8*, i8** %10
%248 = call i32 @free(i8* %247)
store i32 0, i32* %3
%249 = load i8*, i8** %12
br label %250
250: ; preds = %243, %42, %19
%251 = load i32, i32* %3
ret i32 %251
}

LLVM IR (-O2):
@.str.2 = [63 x i8] c"Please enter text to be encrypted, up to 100 characters long: \00"
@stdin = global i32 0
@.str.4 = [97 x i8] c"Encrypting \22%s\22 with a keyword of \22%s\22, using Vigen\C3\A8re\E2\80\99s cipher, yields the ciphertext \22%s\22.\0A\00"
@str = [7 x i8] c"Error.\00"
@str.5 = [51 x i8] c"Invalid keyword. Use only alphabetical characters.\00"
@str.6 = [41 x i8] c"Incorrect usage. Usage: ./vigenere <key>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.6, i64 0, i64 0))
br label %154
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strlen(i8* %10)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %18, label %28
13: ; preds = %18
%14 = load i8*, i8** %9
%15 = tail call i32 @strlen(i8* %14)
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %25, %16
br i1 %17, label %18, label %28
18: ; preds = %8, %13
%19 = phi i64 [ %25, %13 ], [ 0, %8 ]
%20 = load i8*, i8** %9
%21 = getelementptr inbounds i8, i8* %20, i64 %19
%22 = load i8, i8* %21
%23 = tail call i64 @isalpha(i8 signext %22)
%24 = icmp eq i64 %23, 0
%25 = add nuw nsw i64 %19, 1
br i1 %24, label %26, label %13
26: ; preds = %18
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.5, i64 0, i64 0))
br label %154
28: ; preds = %13, %8
%29 = bitcast i64* %3 to i8*
store i64 100, i64* %3
%30 = bitcast i8** %4 to i8*
%31 = tail call i64 @malloc(i64 101)
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %4
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
%34 = load i32, i32* @stdin
%35 = call i32 @getline(i8** %4, i64* %3, i32 %34)
%36 = icmp slt i32 %35, 1
br i1 %36, label %37, label %43
37: ; preds = %28, %37
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
%40 = load i32, i32* @stdin
%41 = call i32 @getline(i8** %4, i64* %3, i32 %40)
%42 = icmp slt i32 %41, 1
br i1 %42, label %37, label %43
43: ; preds = %37, %28
%44 = load i8*, i8** %4
%45 = call i32 @strlen(i8* %44)
%46 = sext i32 %45 to i64
%47 = call i8* @llvm.stacksave()
%48 = alloca i8, i64 %46
%49 = load i8*, i8** %4
%50 = add nsw i64 %46, -1
%51 = getelementptr inbounds i8, i8* %49, i64 %50
store i8 0, i8* %51
%52 = getelementptr inbounds i8, i8* %48, i64 %46
store i8 0, i8* %52
%53 = icmp eq i32 %45, 0
br i1 %53, label %56, label %54
54: ; preds = %43
%55 = call i64 @llvm.umax.i64(i64 %46, i64 1)
br label %61
56: ; preds = %150, %43
%57 = load i8*, i8** %4
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([97 x i8], [97 x i8]* @.str.4, i64 0, i64 0), i8* %57, i8* %10, i8* %48)
%59 = load i8*, i8** %4
%60 = call i32 @free(i8* %59)
br label %154
61: ; preds = %54, %150
%62 = phi i64 [ 0, %54 ], [ %152, %150 ]
%63 = phi i32 [ 0, %54 ], [ %151, %150 ]
%64 = load i8*, i8** %4
%65 = getelementptr inbounds i8, i8* %64, i64 %62
%66 = load i8, i8* %65
%67 = call i64 @isalpha(i8 signext %66)
%68 = icmp eq i64 %67, 0
%69 = load i8*, i8** %4
%70 = getelementptr inbounds i8, i8* %69, i64 %62
%71 = load i8, i8* %70
br i1 %68, label %148, label %72
72: ; preds = %61
%73 = call i64 @isupper(i8 signext %71)
%74 = icmp eq i64 %73, 0
%75 = call i32 @strlen(i8* %10)
%76 = srem i32 %63, %75
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %10, i64 %77
%79 = load i8, i8* %78
br i1 %74, label %110, label %80
80: ; preds = %72
%81 = call i64 @islower(i8 signext %79)
%82 = icmp eq i64 %81, 0
br i1 %82, label %97, label %83
83: ; preds = %80
%84 = call i32 @strlen(i8* %10)
%85 = srem i32 %63, %84
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %10, i64 %86
%88 = load i8, i8* %87
%89 = call signext i8 @toupper(i8 signext %88)
%90 = load i8*, i8** %4
%91 = getelementptr inbounds i8, i8* %90, i64 %62
%92 = load i8, i8* %91
%93 = sext i8 %92 to i16
%94 = sext i8 %89 to i16
%95 = add nsw i16 %94, -130
%96 = add nsw i16 %95, %93
br label %140
97: ; preds = %80
%98 = load i8*, i8** %4
%99 = getelementptr inbounds i8, i8* %98, i64 %62
%100 = load i8, i8* %99
%101 = sext i8 %100 to i16
%102 = call i32 @strlen(i8* %10)
%103 = srem i32 %63, %102
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i8, i8* %10, i64 %104
%106 = load i8, i8* %105
%107 = sext i8 %106 to i16
%108 = add nsw i16 %101, -130
%109 = add nsw i16 %108, %107
br label %140
110: ; preds = %72
%111 = call i64 @isupper(i8 signext %79)
%112 = icmp eq i64 %111, 0
br i1 %112, label %127, label %113
113: ; preds = %110
%114 = call i32 @strlen(i8* %10)
%115 = srem i32 %63, %114
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %10, i64 %116
%118 = load i8, i8* %117
%119 = call signext i8 @tolower(i8 signext %118)
%120 = load i8*, i8** %4
%121 = getelementptr inbounds i8, i8* %120, i64 %62
%122 = load i8, i8* %121
%123 = sext i8 %122 to i16
%124 = sext i8 %119 to i16
%125 = add nsw i16 %124, -194
%126 = add nsw i16 %125, %123
br label %140
127: ; preds = %110
%128 = load i8*, i8** %4
%129 = getelementptr inbounds i8, i8* %128, i64 %62
%130 = load i8, i8* %129
%131 = sext i8 %130 to i16
%132 = call i32 @strlen(i8* %10)
%133 = srem i32 %63, %132
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i8, i8* %10, i64 %134
%136 = load i8, i8* %135
%137 = sext i8 %136 to i16
%138 = add nsw i16 %131, -194
%139 = add nsw i16 %138, %137
br label %140
140: ; preds = %113, %127, %83, %97
%141 = phi i16 [ %126, %113 ], [ %139, %127 ], [ %96, %83 ], [ %109, %97 ]
%142 = phi i8 [ 97, %113 ], [ 97, %127 ], [ 65, %83 ], [ 65, %97 ]
%143 = srem i16 %141, 26
%144 = trunc i16 %143 to i8
%145 = add nsw i8 %142, %144
%146 = getelementptr inbounds i8, i8* %48, i64 %62
store i8 %145, i8* %146
%147 = add nsw i32 %63, 1
br label %150
148: ; preds = %61
%149 = getelementptr inbounds i8, i8* %48, i64 %62
store i8 %71, i8* %149
br label %150
150: ; preds = %140, %148
%151 = phi i32 [ %147, %140 ], [ %63, %148 ]
%152 = add nuw i64 %62, 1
%153 = icmp eq i64 %152, %55
br i1 %153, label %56, label %61
154: ; preds = %26, %56, %6
%155 = phi i32 [ 1, %6 ], [ 0, %56 ], [ 1, %26 ]
ret i32 %155
}