#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*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
char fgetc(int /*<<< orphan*/ *);
scalar_t__ fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ gets(char *);
scalar_t__ isalpha(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ stdin;
char tolower(char);
char toupper(char);
main(int argc, char **argv) {
  FILE *outf, *inf;
  char ch;
  char k[129];
  int num;
  char replace;
  if (argc != 3) {
    printf("\nsyntax ERROR!\nerror#1\nsyntax:  command inputFile outputFile\n");
    exit(1);
  }
  if ((inf = fopen(argv[1], "rb")) == NULL) {
    printf("get info ERROR\nFile NOT found!\nerror#2");
    exit(2);
  }
  if (fopen(argv[2], "rb") != 0) {
    printf(
        "\nThere already is a file named \"%s\".\nDo you wanna replace it?\n",
        argv[2]);
    do {
      printf("(y/n): ");
      scanf(" %c", &replace);
      fflush(stdin);
    } while (tolower(replace) != 'y' && tolower(replace) != 'n');
    if (tolower(replace) == 'n') {
      printf("\nOperation aborted...\n");
      exit(4);
    }
  }
  if ((outf = fopen(argv[2], "wb")) == NULL) {
    printf("create file ERROR\nerror#3");
    exit(3);
  }
  printf("\n\tChoose an option:\n\n");
  printf("0- Encrypt\n");
  printf("1- Decrypt\n\n");
  do {
    printf(">");
    scanf(" %d", &num);
    fflush(stdin);
  } while (num != 0 && num != 1);
  printf("\nShared-key: ");
  fflush(stdin);
  gets(k);
  printf("\n");
  int i, j, n = 0;
  if (num == 0) {
    while ((ch = fgetc(inf)) != EOF) {
      if (k[n] == '\0')
        n = 0;
      if (isalpha(ch)) {
        for (j = 1; j <= ((int)toupper(k[n]) - 65); j++) {
          if (toupper(ch) == 'Z')
            if (ch > 96 && ch < 123)
              ch = 'a' - 1;
            else
              ch = 'A' - 1;
          ch++;
        }
        n++;
      }
      fputc(ch, outf);
    }
    printf("Encryption file completed!");
  } else {
    while ((ch = fgetc(inf)) != EOF) {
      if (k[n] == '\0')
        n = 0;
      if (isalpha(ch)) {
        for (j = 1; j <= ((int)toupper(k[n]) - 65); j++) {
          if (toupper(ch) == 'A')
            if (ch > 96 && ch < 123)
              ch = 'z' + 1;
            else
              ch = 'Z' + 1;
          ch--;
        }
        n++;
      }
      fputc(ch, outf);
    }
    printf("Decryption file completed!");
  }
  fclose(inf);
  fclose(outf);
  puts("\n\n\nEncoded using the Vigenere Cipher encryption scheme\nCoded by "
       "prtpereira\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     120b <main+0x3b>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe24(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1245 <main+0x75>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x2,%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdea(%rip),%rsi
call   10e0 <fopen@plt>
cmp    $0x0,%rax
je     1328 <main+0x158>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe21(%rip),%rdi
lea    -0xb5(%rbp),%rsi
mov    $0x0,%al
call   10d0 <scanf@plt>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
movsbl -0xb5(%rbp),%edi
call   10a0 <tolower@plt>
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x79,%ecx
mov    %al,-0xc5(%rbp)
je     12e5 <main+0x115>
movsbl -0xb5(%rbp),%edi
call   10a0 <tolower@plt>
movsbl %al,%eax
cmp    $0x6e,%eax
setne  %al
mov    %al,-0xc5(%rbp)
mov    -0xc5(%rbp),%al
test   $0x1,%al
jne    1279 <main+0xa9>
movsbl -0xb5(%rbp),%edi
call   10a0 <tolower@plt>
movsbl %al,%eax
cmp    $0x6e,%eax
jne    1323 <main+0x153>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x4,%edi
call   10f0 <exit@plt>
jmp    1328 <main+0x158>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd93(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1362 <main+0x192>
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x3,%edi
call   10f0 <exit@plt>
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd77(%rip),%rdi
lea    -0xb4(%rbp),%rsi
mov    $0x0,%al
call   10d0 <scanf@plt>
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
xor    %eax,%eax
cmpl   $0x0,-0xb4(%rbp)
mov    %al,-0xc6(%rbp)
je     13e2 <main+0x212>
cmpl   $0x1,-0xb4(%rbp)
setne  %al
mov    %al,-0xc6(%rbp)
mov    -0xc6(%rbp),%al
test   $0x1,%al
jne    138c <main+0x1bc>
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2be3(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
lea    -0xb0(%rbp),%rdi
call   1090 <gets@plt>
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0xc4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jne    156b <main+0x39b>
jmp    1442 <main+0x272>
mov    -0x20(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2b88(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1558 <main+0x388>
movslq -0xc4(%rbp),%rax
movsbl -0xb0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    1485 <main+0x2b5>
movl   $0x0,-0xc4(%rbp)
movsbl -0x21(%rbp),%edi
call   10c0 <isalpha@plt>
cmp    $0x0,%rax
je     1544 <main+0x374>
movl   $0x1,-0xc0(%rbp)
mov    -0xc0(%rbp),%eax
mov    %eax,-0xcc(%rbp)
movslq -0xc4(%rbp),%rax
movsbl -0xb0(%rbp,%rax,1),%edi
ff
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0xcc(%rbp),%eax
movsbl %cl,%ecx
sub    $0x41,%ecx
cmp    %ecx,%eax
jg     1535 <main+0x365>
movsbl -0x21(%rbp),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
cmp    $0x5a,%eax
jne    1519 <main+0x349>
movsbl -0x21(%rbp),%eax
cmp    $0x60,%eax
jle    1510 <main+0x340>
movsbl -0x21(%rbp),%eax
cmp    $0x7b,%eax
jge    1510 <main+0x340>
movb   $0x60,-0x21(%rbp)
jmp    1514 <main+0x344>
movb   $0x40,-0x21(%rbp)
jmp    1519 <main+0x349>
mov    -0x21(%rbp),%al
add    $0x1,%al
mov    %al,-0x21(%rbp)
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
jmp    14a2 <main+0x2d2>
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
mov    -0x21(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1080 <fputc@plt>
jmp    1442 <main+0x272>
lea    0xbcb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1694 <main+0x4c4>
jmp    1570 <main+0x3a0>
mov    -0x20(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2a5a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1686 <main+0x4b6>
movslq -0xc4(%rbp),%rax
movsbl -0xb0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    15b3 <main+0x3e3>
movl   $0x0,-0xc4(%rbp)
movsbl -0x21(%rbp),%edi
call   10c0 <isalpha@plt>
cmp    $0x0,%rax
je     1672 <main+0x4a2>
movl   $0x1,-0xc0(%rbp)
mov    -0xc0(%rbp),%eax
mov    %eax,-0xd0(%rbp)
movslq -0xc4(%rbp),%rax
movsbl -0xb0(%rbp,%rax,1),%edi
ff
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0xd0(%rbp),%eax
movsbl %cl,%ecx
sub    $0x41,%ecx
cmp    %ecx,%eax
jg     1663 <main+0x493>
movsbl -0x21(%rbp),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
cmp    $0x41,%eax
jne    1647 <main+0x477>
movsbl -0x21(%rbp),%eax
cmp    $0x60,%eax
jle    163e <main+0x46e>
movsbl -0x21(%rbp),%eax
cmp    $0x7b,%eax
jge    163e <main+0x46e>
movb   $0x7b,-0x21(%rbp)
jmp    1642 <main+0x472>
movb   $0x5b,-0x21(%rbp)
jmp    1647 <main+0x477>
mov    -0x21(%rbp),%al
add    $0xff,%al
mov    %al,-0x21(%rbp)
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
jmp    15d0 <main+0x400>
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
mov    -0x21(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1080 <fputc@plt>
jmp    1570 <main+0x3a0>
lea    0xab8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xab3(%rip),%rdi
call   1040 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
cmp    $0x3,%edi
jne    154f <main+0x36f>
mov    %rsi,%r15
mov    0x8(%rsi),%rdi
lea    0xdf8(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     1565 <main+0x385>
mov    0x10(%r15),%rdi
lea    0xdda(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     12ac <main+0xcc>
mov    0x10(%r15),%rsi
lea    0xdeb(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe1c(%rip),%r12
lea    0xe1d(%rip),%r14
lea    0x3(%rsp),%rbp
mov    0x2d88(%rip),%rbx
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10e0 <scanf@plt>
mov    (%rbx),%edi
call   10c0 <fflush@plt>
movsbl 0x3(%rsp),%edi
call   10b0 <tolower@plt>
cmp    $0x79,%al
je     129a <main+0xba>
movsbl 0x3(%rsp),%edi
call   10b0 <tolower@plt>
cmp    $0x6e,%al
jne    1260 <main+0x80>
movsbl 0x3(%rsp),%edi
call   10b0 <tolower@plt>
cmp    $0x6e,%al
je     1595 <main+0x3b5>
mov    0x10(%r15),%rdi
lea    0xdbe(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     157d <main+0x39d>
mov    %rax,%r12
lea    0xe58(%rip),%rdi
call   1050 <puts@plt>
lea    0xe61(%rip),%rdi
call   1050 <puts@plt>
lea    0xe60(%rip),%rdi
call   1050 <puts@plt>
lea    0xd9f(%rip),%rbp
lea    0x4(%rsp),%rbx
mov    0x2ce9(%rip),%r14
nop
mov    $0x3e,%edi
call   1030 <putchar@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10e0 <scanf@plt>
mov    (%r14),%edi
call   10c0 <fflush@plt>
cmpl   $0x1,0x4(%rsp)
ja     1300 <main+0x120>
lea    0xd69(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%r14),%edi
call   10c0 <fflush@plt>
lea    0x10(%rsp),%rdi
call   10a0 <gets@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%ebx
mov    0x8(%rsp),%r14
mov    %r14,%rdi
call   1080 <fgetc@plt>
mov    %eax,%ebp
mov    0x2c76(%rip),%rax
mov    (%rax),%al
test   %ebx,%ebx
je     1437 <main+0x257>
lea    0xd44(%rip),%rdi
cmp    %al,%bpl
je     1518 <main+0x338>
xor    %r13d,%r13d
jmp    13ba <main+0x1da>
nopl   0x0(%rax)
add    $0x1,%r13d
movsbl %bpl,%edi
mov    %r12,%rsi
call   1090 <fputc@plt>
mov    %r14,%rdi
call   1080 <fgetc@plt>
mov    %eax,%ebp
mov    0x2c2f(%rip),%rax
cmp    (%rax),%bpl
je     1508 <main+0x328>
movslq %r13d,%r13
cmpb   $0x0,0x10(%rsp,%r13,1)
mov    $0x0,%eax
cmove  %eax,%r13d
movsbl %bpl,%edi
call   10d0 <isalpha@plt>
test   %rax,%rax
je     1394 <main+0x1b4>
movslq %r13d,%r15
movsbl 0x10(%rsp,%r15,1),%edi
call   1040 <toupper@plt>
cmp    $0x42,%al
jl     1390 <main+0x1b0>
xor    %ebx,%ebx
xchg   %ax,%ax
movsbl %bpl,%ebp
mov    %ebp,%edi
call   1040 <toupper@plt>
lea    -0x61(%rbp),%ecx
cmp    $0x1a,%cl
setb   %cl
shl    $0x5,%cl
or     $0x5b,%cl
cmp    $0x41,%al
movzbl %bpl,%eax
movzbl %cl,%ebp
cmovne %eax,%ebp
add    $0xff,%bpl
movsbl 0x10(%rsp,%r15,1),%edi
call   1040 <toupper@plt>
movsbl %al,%eax
add    $0xffffffbf,%eax
add    $0x1,%ebx
cmp    %eax,%ebx
jl     13f0 <main+0x210>
jmp    1390 <main+0x1b0>
lea    0xc66(%rip),%rdi
cmp    %al,%bpl
je     1518 <main+0x338>
xor    %r13d,%r13d
jmp    147f <main+0x29f>
nopl   0x0(%rax)
add    $0x1,%r13d
mov    0x8(%rsp),%r14
movsbl %bpl,%edi
mov    %r12,%rsi
call   1090 <fputc@plt>
mov    %r14,%rdi
call   1080 <fgetc@plt>
mov    %eax,%ebp
mov    0x2b6a(%rip),%rax
cmp    (%rax),%bpl
je     1511 <main+0x331>
movslq %r13d,%r13
cmpb   $0x0,0x10(%rsp,%r13,1)
mov    $0x0,%eax
cmove  %eax,%r13d
movsbl %bpl,%edi
call   10d0 <isalpha@plt>
test   %rax,%rax
je     1459 <main+0x279>
movslq %r13d,%r15
movsbl 0x10(%rsp,%r15,1),%edi
call   1040 <toupper@plt>
cmp    $0x42,%al
jl     1450 <main+0x270>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %bpl,%ebx
mov    %ebx,%edi
call   1040 <toupper@plt>
lea    -0x61(%rbx),%ecx
cmp    $0x1a,%cl
setb   %cl
shl    $0x5,%cl
or     $0x40,%cl
cmp    $0x5a,%al
movzbl %bl,%eax
movzbl %cl,%ebp
cmovne %eax,%ebp
add    $0x1,%bpl
movsbl 0x10(%rsp,%r15,1),%edi
call   1040 <toupper@plt>
movsbl %al,%eax
add    $0xffffffbf,%eax
add    $0x1,%r14d
cmp    %eax,%r14d
jl     14c0 <main+0x2e0>
jmp    1450 <main+0x270>
lea    0xbb0(%rip),%rdi
jmp    1518 <main+0x338>
lea    0xb8c(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
lea    0xba4(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc13(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xa97(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x2,%edi
call   1100 <exit@plt>
lea    0xaf4(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x3,%edi
call   1100 <exit@plt>
lea    0xbb7(%rip),%rdi
call   1050 <puts@plt>
mov    $0x4,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [62 x i8] c"\0Asyntax ERROR!\0Aerror\0Asyntax: command inputFile outputFile\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [39 x i8] c"get info ERROR\0AFile NOT found!\0Aerror\00"
@.str.3 = [63 x i8] c"\0AThere already is a file named \22%s\22.\0ADo you wanna replace it?\0A\00"
@.str.4 = [8 x i8] c"(y/n): \00"
@.str.5 = [4 x i8] c" %c\00"
@stdin = global i32 0
@.str.6 = [23 x i8] c"\0AOperation aborted...\0A\00"
@.str.7 = [3 x i8] c"wb\00"
@.str.8 = [26 x i8] c"create file ERROR\0Aerror\00"
@.str.9 = [22 x i8] c"\0A\09Choose an option:\0A\0A\00"
@.str.10 = [12 x i8] c"0- Encrypt\0A\00"
@.str.11 = [13 x i8] c"1- Decrypt\0A\0A\00"
@.str.12 = [2 x i8] c">\00"
@.str.13 = [4 x i8] c" %d\00"
@.str.14 = [14 x i8] c"\0AShared-key: \00"
@.str.15 = [2 x i8] c"\0A\00"
@EOF = global i8 0
@.str.16 = [27 x i8] c"Encryption file completed!\00"
@.str.17 = [27 x i8] c"Decryption file completed!\00"
@.str.18 = [77 x i8] c"\0A\0A\0AEncoded using the Vigenere Cipher encryption scheme\0ACoded by prtpereira\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8
%9 = alloca [129 x i8]
%10 = alloca i32
%11 = alloca i8
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = inttoptr i64 %24 to i32*
store i32* %25, i32** %7
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @exit(i32 2)
unreachable
30: ; preds = %20
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i64 @fopen(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %67
36: ; preds = %30
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %56, %36
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %11)
%44 = load i32, i32* @stdin
%45 = call i32 @fflush(i32 %44)
br label %46
46: ; preds = %41
%47 = load i8, i8* %11
%48 = call signext i8 @tolower(i8 signext %47)
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 121
br i1 %50, label %51, label %56
51: ; preds = %46
%52 = load i8, i8* %11
%53 = call signext i8 @tolower(i8 signext %52)
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %54, 110
br label %56
56: ; preds = %51, %46
%57 = phi i1 [ false, %46 ], [ %55, %51 ]
br i1 %57, label %41, label %58
58: ; preds = %56
%59 = load i8, i8* %11
%60 = call signext i8 @tolower(i8 signext %59)
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 110
br i1 %62, label %63, label %66
63: ; preds = %58
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%65 = call i32 @exit(i32 4)
unreachable
66: ; preds = %58
br label %67
67: ; preds = %66, %30
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 2
%70 = load i8*, i8** %69
%71 = call i64 @fopen(i8* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%72 = inttoptr i64 %71 to i32*
store i32* %72, i32** %6
%73 = icmp eq i32* %72, null
br i1 %73, label %74, label %77
74: ; preds = %67
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%76 = call i32 @exit(i32 3)
unreachable
77: ; preds = %67
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
br label %81
81: ; preds = %92, %77
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%83 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32* %10)
%84 = load i32, i32* @stdin
%85 = call i32 @fflush(i32 %84)
br label %86
86: ; preds = %81
%87 = load i32, i32* %10
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %86
%90 = load i32, i32* %10
%91 = icmp ne i32 %90, 1
br label %92
92: ; preds = %89, %86
%93 = phi i1 [ false, %86 ], [ %91, %89 ]
br i1 %93, label %81, label %94
94: ; preds = %92
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0))
%96 = load i32, i32* @stdin
%97 = call i32 @fflush(i32 %96)
%98 = getelementptr inbounds [129 x i8], [129 x i8]* %9, i64 0, i64 0
%99 = call i32 @gets(i8* %98)
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32 0, i32* %14
%101 = load i32, i32* %10
%102 = icmp eq i32 %101, 0
br i1 %102, label %103, label %165
103: ; preds = %94
br label %104
104: ; preds = %159, %103
%105 = load i32*, i32** %7
%106 = call signext i8 @fgetc(i32* %105)
store i8 %106, i8* %8
%107 = sext i8 %106 to i32
%108 = load i8, i8* @EOF
%109 = sext i8 %108 to i32
%110 = icmp ne i32 %107, %109
br i1 %110, label %111, label %163
111: ; preds = %104
%112 = load i32, i32* %14
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [129 x i8], [129 x i8]* %9, i64 0, i64 %113
%115 = load i8, i8* %114
%116 = sext i8 %115 to i32
%117 = icmp eq i32 %116, 0
br i1 %117, label %118, label %119
118: ; preds = %111
store i32 0, i32* %14
br label %119
119: ; preds = %118, %111
%120 = load i8, i8* %8
%121 = call i64 @isalpha(i8 signext %120)
%122 = icmp ne i64 %121, 0
br i1 %122, label %123, label %159
123: ; preds = %119
store i32 1, i32* %13
br label %124
124: ; preds = %153, %123
%125 = load i32, i32* %13
%126 = load i32, i32* %14
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [129 x i8], [129 x i8]* %9, i64 0, i64 %127
%129 = load i8, i8* %128
%130 = call signext i8 @toupper(i8 signext %129)
%131 = sext i8 %130 to i32
%132 = sub nsw i32 %131, 65
%133 = icmp sle i32 %125, %132
br i1 %133, label %134, label %156
134: ; preds = %124
%135 = load i8, i8* %8
%136 = call signext i8 @toupper(i8 signext %135)
%137 = sext i8 %136 to i32
%138 = icmp eq i32 %137, 90
br i1 %138, label %139, label %150
139: ; preds = %134
%140 = load i8, i8* %8
%141 = sext i8 %140 to i32
%142 = icmp sgt i32 %141, 96
br i1 %142, label %143, label %148
143: ; preds = %139
%144 = load i8, i8* %8
%145 = sext i8 %144 to i32
%146 = icmp slt i32 %145, 123
br i1 %146, label %147, label %148
147: ; preds = %143
store i8 96, i8* %8
br label %149
148: ; preds = %143, %139
store i8 64, i8* %8
br label %149
149: ; preds = %148, %147
br label %150
150: ; preds = %149, %134
%151 = load i8, i8* %8
%152 = add i8 %151, 1
store i8 %152, i8* %8
br label %153
153: ; preds = %150
%154 = load i32, i32* %13
%155 = add nsw i32 %154, 1
store i32 %155, i32* %13
br label %124
156: ; preds = %124
%157 = load i32, i32* %14
%158 = add nsw i32 %157, 1
store i32 %158, i32* %14
br label %159
159: ; preds = %156, %119
%160 = load i8, i8* %8
%161 = load i32*, i32** %6
%162 = call i32 @fputc(i8 signext %160, i32* %161)
br label %104
163: ; preds = %104
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0))
br label %227
165: ; preds = %94
br label %166
166: ; preds = %221, %165
%167 = load i32*, i32** %7
%168 = call signext i8 @fgetc(i32* %167)
store i8 %168, i8* %8
%169 = sext i8 %168 to i32
%170 = load i8, i8* @EOF
%171 = sext i8 %170 to i32
%172 = icmp ne i32 %169, %171
br i1 %172, label %173, label %225
173: ; preds = %166
%174 = load i32, i32* %14
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds [129 x i8], [129 x i8]* %9, i64 0, i64 %175
%177 = load i8, i8* %176
%178 = sext i8 %177 to i32
%179 = icmp eq i32 %178, 0
br i1 %179, label %180, label %181
180: ; preds = %173
store i32 0, i32* %14
br label %181
181: ; preds = %180, %173
%182 = load i8, i8* %8
%183 = call i64 @isalpha(i8 signext %182)
%184 = icmp ne i64 %183, 0
br i1 %184, label %185, label %221
185: ; preds = %181
store i32 1, i32* %13
br label %186
186: ; preds = %215, %185
%187 = load i32, i32* %13
%188 = load i32, i32* %14
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds [129 x i8], [129 x i8]* %9, i64 0, i64 %189
%191 = load i8, i8* %190
%192 = call signext i8 @toupper(i8 signext %191)
%193 = sext i8 %192 to i32
%194 = sub nsw i32 %193, 65
%195 = icmp sle i32 %187, %194
br i1 %195, label %196, label %218
196: ; preds = %186
%197 = load i8, i8* %8
%198 = call signext i8 @toupper(i8 signext %197)
%199 = sext i8 %198 to i32
%200 = icmp eq i32 %199, 65
br i1 %200, label %201, label %212
201: ; preds = %196
%202 = load i8, i8* %8
%203 = sext i8 %202 to i32
%204 = icmp sgt i32 %203, 96
br i1 %204, label %205, label %210
205: ; preds = %201
%206 = load i8, i8* %8
%207 = sext i8 %206 to i32
%208 = icmp slt i32 %207, 123
br i1 %208, label %209, label %210
209: ; preds = %205
store i8 123, i8* %8
br label %211
210: ; preds = %205, %201
store i8 91, i8* %8
br label %211
211: ; preds = %210, %209
br label %212
212: ; preds = %211, %196
%213 = load i8, i8* %8
%214 = add i8 %213, -1
store i8 %214, i8* %8
br label %215
215: ; preds = %212
%216 = load i32, i32* %13
%217 = add nsw i32 %216, 1
store i32 %217, i32* %13
br label %186
218: ; preds = %186
%219 = load i32, i32* %14
%220 = add nsw i32 %219, 1
store i32 %220, i32* %14
br label %221
221: ; preds = %218, %181
%222 = load i8, i8* %8
%223 = load i32*, i32** %6
%224 = call i32 @fputc(i8 signext %222, i32* %223)
br label %166
225: ; preds = %166
%226 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.17, i64 0, i64 0))
br label %227
227: ; preds = %225, %163
%228 = load i32*, i32** %7
%229 = call i32 @fclose(i32* %228)
%230 = load i32*, i32** %6
%231 = call i32 @fclose(i32* %230)
%232 = call i32 @puts(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.18, i64 0, i64 0))
%233 = load i32, i32* %3
ret i32 %233
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [39 x i8] c"get info ERROR\0AFile NOT found!\0Aerror\00"
@.str.3 = [63 x i8] c"\0AThere already is a file named \22%s\22.\0ADo you wanna replace it?\0A\00"
@.str.4 = [8 x i8] c"(y/n): \00"
@.str.5 = [4 x i8] c" %c\00"
@stdin = global i32 0
@.str.7 = [3 x i8] c"wb\00"
@.str.8 = [26 x i8] c"create file ERROR\0Aerror\00"
@.str.13 = [4 x i8] c" %d\00"
@.str.14 = [14 x i8] c"\0AShared-key: \00"
@EOF = global i8 0
@.str.16 = [27 x i8] c"Encryption file completed!\00"
@.str.17 = [27 x i8] c"Decryption file completed!\00"
@.str.18 = [77 x i8] c"\0A\0A\0AEncoded using the Vigenere Cipher encryption scheme\0ACoded by prtpereira\0A\0A\00"
@str = [21 x i8] c"\0A\09Choose an option:\0A\00"
@str.19 = [11 x i8] c"0- Encrypt\00"
@str.20 = [12 x i8] c"1- Decrypt\0A\00"
@str.21 = [22 x i8] c"\0AOperation aborted...\00"
@str.22 = [61 x i8] c"\0Asyntax ERROR!\0Aerror\0Asyntax: command inputFile outputFile\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [129 x i8]
%4 = alloca i32
%5 = alloca i8
%6 = getelementptr inbounds [129 x i8], [129 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = icmp eq i32 %0, 3
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.22, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = inttoptr i64 %15 to i32*
%17 = icmp eq i64 %15, 0
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%20 = tail call i32 @exit(i32 2)
unreachable
21: ; preds = %12
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i64 @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %48, label %26
26: ; preds = %21
%27 = load i8*, i8** %22
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %37, %26
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %5)
%32 = load i32, i32* @stdin
%33 = call i32 @fflush(i32 %32)
%34 = load i8, i8* %5
%35 = call signext i8 @tolower(i8 signext %34)
%36 = icmp eq i8 %35, 121
br i1 %36, label %41, label %37
37: ; preds = %29
%38 = load i8, i8* %5
%39 = call signext i8 @tolower(i8 signext %38)
%40 = icmp eq i8 %39, 110
br i1 %40, label %41, label %29
41: ; preds = %29, %37
%42 = load i8, i8* %5
%43 = call signext i8 @tolower(i8 signext %42)
%44 = icmp eq i8 %43, 110
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.21, i64 0, i64 0))
%47 = call i32 @exit(i32 4)
unreachable
48: ; preds = %41, %21
%49 = load i8*, i8** %22
%50 = call i64 @fopen(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%51 = inttoptr i64 %50 to i32*
%52 = icmp eq i64 %50, 0
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
%55 = call i32 @exit(i32 3)
unreachable
56: ; preds = %48
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.19, i64 0, i64 0))
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.20, i64 0, i64 0))
br label %60
60: ; preds = %60, %56
%61 = call i32 @putchar(i32 62)
%62 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32* %4)
%63 = load i32, i32* @stdin
%64 = call i32 @fflush(i32 %63)
%65 = load i32, i32* %4
%66 = icmp ult i32 %65, 2
br i1 %66, label %67, label %60
67: ; preds = %60
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0))
%69 = load i32, i32* @stdin
%70 = call i32 @fflush(i32 %69)
%71 = call i32 @gets(i8* %6)
%72 = call i32 @putchar(i32 10)
%73 = load i32, i32* %4
%74 = icmp eq i32 %73, 0
%75 = call signext i8 @fgetc(i32* %16)
%76 = load i8, i8* @EOF
%77 = icmp eq i8 %75, %76
br i1 %74, label %79, label %78
78: ; preds = %67
br i1 %77, label %164, label %122
79: ; preds = %67
br i1 %77, label %164, label %80
80: ; preds = %79, %115
%81 = phi i8 [ %119, %115 ], [ %75, %79 ]
%82 = phi i32 [ %117, %115 ], [ 0, %79 ]
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [129 x i8], [129 x i8]* %3, i64 0, i64 %83
%85 = load i8, i8* %84
%86 = icmp eq i8 %85, 0
%87 = select i1 %86, i32 0, i32 %82
%88 = call i64 @isalpha(i8 signext %81)
%89 = icmp eq i64 %88, 0
br i1 %89, label %115, label %90
90: ; preds = %80
%91 = sext i32 %87 to i64
%92 = getelementptr inbounds [129 x i8], [129 x i8]* %3, i64 0, i64 %91
%93 = load i8, i8* %92
%94 = call signext i8 @toupper(i8 signext %93)
%95 = icmp slt i8 %94, 66
br i1 %95, label %112, label %96
96: ; preds = %90, %96
%97 = phi i32 [ %106, %96 ], [ 1, %90 ]
%98 = phi i8 [ %105, %96 ], [ %81, %90 ]
%99 = call signext i8 @toupper(i8 signext %98)
%100 = icmp eq i8 %99, 90
%101 = add i8 %98, -97
%102 = icmp ult i8 %101, 26
%103 = select i1 %102, i8 96, i8 64
%104 = select i1 %100, i8 %103, i8 %98
%105 = add i8 %104, 1
%106 = add nuw nsw i32 %97, 1
%107 = load i8, i8* %92
%108 = call signext i8 @toupper(i8 signext %107)
%109 = sext i8 %108 to i32
%110 = add nsw i32 %109, -65
%111 = icmp slt i32 %97, %110
br i1 %111, label %96, label %112
112: ; preds = %96, %90
%113 = phi i8 [ %81, %90 ], [ %105, %96 ]
%114 = add nsw i32 %87, 1
br label %115
115: ; preds = %112, %80
%116 = phi i8 [ %113, %112 ], [ %81, %80 ]
%117 = phi i32 [ %114, %112 ], [ %87, %80 ]
%118 = call i32 @fputc(i8 signext %116, i32* %51)
%119 = call signext i8 @fgetc(i32* %16)
%120 = load i8, i8* @EOF
%121 = icmp eq i8 %119, %120
br i1 %121, label %164, label %80
122: ; preds = %78, %157
%123 = phi i8 [ %161, %157 ], [ %75, %78 ]
%124 = phi i32 [ %159, %157 ], [ 0, %78 ]
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds [129 x i8], [129 x i8]* %3, i64 0, i64 %125
%127 = load i8, i8* %126
%128 = icmp eq i8 %127, 0
%129 = select i1 %128, i32 0, i32 %124
%130 = call i64 @isalpha(i8 signext %123)
%131 = icmp eq i64 %130, 0
br i1 %131, label %157, label %132
132: ; preds = %122
%133 = sext i32 %129 to i64
%134 = getelementptr inbounds [129 x i8], [129 x i8]* %3, i64 0, i64 %133
%135 = load i8, i8* %134
%136 = call signext i8 @toupper(i8 signext %135)
%137 = icmp slt i8 %136, 66
br i1 %137, label %154, label %138
138: ; preds = %132, %138
%139 = phi i32 [ %148, %138 ], [ 1, %132 ]
%140 = phi i8 [ %147, %138 ], [ %123, %132 ]
%141 = call signext i8 @toupper(i8 signext %140)
%142 = icmp eq i8 %141, 65
%143 = add i8 %140, -97
%144 = icmp ult i8 %143, 26
%145 = select i1 %144, i8 123, i8 91
%146 = select i1 %142, i8 %145, i8 %140
%147 = add i8 %146, -1
%148 = add nuw nsw i32 %139, 1
%149 = load i8, i8* %134
%150 = call signext i8 @toupper(i8 signext %149)
%151 = sext i8 %150 to i32
%152 = add nsw i32 %151, -65
%153 = icmp slt i32 %139, %152
br i1 %153, label %138, label %154
154: ; preds = %138, %132
%155 = phi i8 [ %123, %132 ], [ %147, %138 ]
%156 = add nsw i32 %129, 1
br label %157
157: ; preds = %154, %122
%158 = phi i8 [ %155, %154 ], [ %123, %122 ]
%159 = phi i32 [ %156, %154 ], [ %129, %122 ]
%160 = call i32 @fputc(i8 signext %158, i32* %51)
%161 = call signext i8 @fgetc(i32* %16)
%162 = load i8, i8* @EOF
%163 = icmp eq i8 %161, %162
br i1 %163, label %164, label %122
164: ; preds = %157, %115, %78, %79
%165 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), %79 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.17, i64 0, i64 0), %78 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), %115 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.17, i64 0, i64 0), %157 ]
%166 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %165)
%167 = call i32 @fclose(i32* %16)
%168 = call i32 @fclose(i32* %51)
%169 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.18, i64 0, i64 0))
ret i32 0
}