#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 */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  FILE *infPtr;
  FILE *outfPtr;
  int key;
  int choice;
  char c;
  printf("Enter 0 to copy plaintext to plaintext.txt \nand output ciphertext "
         "to ciphertext.txt\n");
  printf("Enter 1 to encipher from plaintext.txt\n");
  printf("Enter 2 to decipher from ciphertext.txt\n");
  scanf("%d", &choice);
  getchar();
  if (choice == 0) {
    printf("Enter key:");
    scanf("%d", &key);
    getchar();
    if ((infPtr = fopen("plaintext.txt", "w+")) == NULL) {
      puts("File could not be opened!");
      exit(0);
    } else {
      c = getchar();
      while (c != '\n') {
        fputc(c, infPtr);
        c = getchar();
      }
      rewind(infPtr);
    }
    if ((outfPtr = fopen("ciphertext.txt", "w+")) == NULL) {
      puts("File could not be opened!");
      exit(0);
    } else {
      c = fgetc(infPtr);
      if (c == ' ') {
      } else if (c + key - 'z' >= 0) {
        c = 'a' + (c + key - 'z' - 1);
      } else
        (c += key);
      while (!feof(infPtr)) {
        printf("%c", c);
        fprintf(outfPtr, "%c", c);
        c = fgetc(infPtr);
        if (c == ' ') {
        } else if (c + key - 'z' >= 0) {
          c = 'a' + (c + key - 'z' - 1);
        } else
          (c += key);
      }
    }
    fclose(outfPtr);
    fclose(infPtr);
    puts("");
  } else if (choice == 1) {
    printf("Enter key:");
    scanf("%d", &key);
    getchar();
    if ((infPtr = fopen("plaintext.txt", "r+")) == NULL) {
      puts("File could not be opened!");
      exit(0);
    }
    printf("%s\n", "Output:");
    if ((outfPtr = fopen("ciphertext.txt", "w+")) == NULL) {
      puts("File could not be opened!");
      exit(0);
    } else {
      c = fgetc(infPtr);
      if (c == ' ') {
      } else if (c + key - 'z' >= 0) {
        c = 'a' + (c + key - 'z' - 1);
      } else
        (c += key);
      while (!feof(infPtr)) {
        printf("%c", c);
        fprintf(outfPtr, "%c", c);
        c = fgetc(infPtr);
        if (c == ' ') {
        } else if (c + key - 'z' >= 0) {
          c = 'a' + (c + key - 'z' - 1);
        } else
          (c += key);
      }
    }
    puts("");
    fclose(outfPtr);
    fclose(infPtr);
  } else if (choice == 2) {
    printf("Enter key:");
    scanf("%d", &key);
    getchar();
    if ((infPtr = fopen("ciphertext.txt", "r+")) == NULL) {
      puts("File could not be opened!");
      exit(0);
    }
    printf("%s\n", "Output:");
    if ((outfPtr = fopen("plaintext.txt", "w+")) == NULL) {
      puts("File could not be opened!");
      exit(0);
    } else {
      c = fgetc(infPtr);
      if (c == ' ') {
      } else if ('a' - (c - key) > 0) {
        c = 'z' + ('a' - (c - key) - 1);
      } else
        (c -= key);
      while (!feof(infPtr)) {
        printf("%c", c);
        fprintf(outfPtr, "%c", c);
        c = fgetc(infPtr);
        if (c == ' ') {
        } else if ('a' - (c - key) > 0) {
          c = 'z' + ('a' - (c - key) - 1);
        } else
          (c -= key);
      }
    }
    puts("");
    fclose(outfPtr);
    fclose(infPtr);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   10c0 <scanf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
cmpl   $0x0,-0x28(%rbp)
jne    1416 <main+0x256>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe70(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   10c0 <scanf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
lea    0xe67(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    127a <main+0xba>
lea    0xe57(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0xa,%eax
je     12af <main+0xef>
mov    -0x29(%rbp),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1080 <fputc@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
mov    %al,-0x29(%rbp)
jmp    1284 <main+0xc4>
mov    -0x18(%rbp),%rdi
call   1060 <rewind@plt>
lea    0xe20(%rip),%rdi
lea    0xdfc(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    12ec <main+0x12c>
lea    0xde5(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x20,%eax
jne    130a <main+0x14a>
jmp    1346 <main+0x186>
movsbl -0x29(%rbp),%eax
add    -0x24(%rbp),%eax
sub    $0x7a,%eax
cmp    $0x0,%eax
jl     1335 <main+0x175>
movsbl -0x29(%rbp),%eax
add    -0x24(%rbp),%eax
sub    $0x7a,%eax
sub    $0x1,%eax
add    $0x61,%eax
mov    %al,-0x29(%rbp)
jmp    1341 <main+0x181>
mov    -0x24(%rbp),%ecx
movsbl -0x29(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x29(%rbp)
jmp    1346 <main+0x186>
jmp    134b <main+0x18b>
mov    -0x18(%rbp),%rdi
call   10b0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1369 <main+0x1a9>
jmp    13ee <main+0x22e>
movsbl -0x29(%rbp),%esi
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    0xd68(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x20,%eax
jne    13ad <main+0x1ed>
jmp    13e9 <main+0x229>
movsbl -0x29(%rbp),%eax
add    -0x24(%rbp),%eax
sub    $0x7a,%eax
cmp    $0x0,%eax
jl     13d8 <main+0x218>
movsbl -0x29(%rbp),%eax
add    -0x24(%rbp),%eax
sub    $0x7a,%eax
sub    $0x1,%eax
add    $0x61,%eax
mov    %al,-0x29(%rbp)
jmp    13e4 <main+0x224>
mov    -0x24(%rbp),%ecx
movsbl -0x29(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x29(%rbp)
jmp    13e9 <main+0x229>
jmp    134b <main+0x18b>
jmp    13f3 <main+0x233>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xceb(%rip),%rdi
call   1030 <puts@plt>
jmp    17d7 <main+0x617>
cmpl   $0x1,-0x28(%rbp)
jne    15ec <main+0x42c>
lea    0xc82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc71(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   10c0 <scanf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
lea    0xc68(%rip),%rdi
lea    0xc9e(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1479 <main+0x2b9>
lea    0xc58(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0xc74(%rip),%rdi
lea    0xc71(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc4a(%rip),%rdi
lea    0xc26(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    14c2 <main+0x302>
lea    0xc0f(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x20,%eax
jne    14e0 <main+0x320>
jmp    151c <main+0x35c>
movsbl -0x29(%rbp),%eax
add    -0x24(%rbp),%eax
sub    $0x7a,%eax
cmp    $0x0,%eax
jl     150b <main+0x34b>
movsbl -0x29(%rbp),%eax
add    -0x24(%rbp),%eax
sub    $0x7a,%eax
sub    $0x1,%eax
add    $0x61,%eax
mov    %al,-0x29(%rbp)
jmp    1517 <main+0x357>
mov    -0x24(%rbp),%ecx
movsbl -0x29(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x29(%rbp)
jmp    151c <main+0x35c>
jmp    1521 <main+0x361>
mov    -0x18(%rbp),%rdi
call   10b0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    153f <main+0x37f>
jmp    15c4 <main+0x404>
movsbl -0x29(%rbp),%esi
lea    0xba4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    0xb92(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x20,%eax
jne    1583 <main+0x3c3>
jmp    15bf <main+0x3ff>
movsbl -0x29(%rbp),%eax
add    -0x24(%rbp),%eax
sub    $0x7a,%eax
cmp    $0x0,%eax
jl     15ae <main+0x3ee>
movsbl -0x29(%rbp),%eax
add    -0x24(%rbp),%eax
sub    $0x7a,%eax
sub    $0x1,%eax
add    $0x61,%eax
mov    %al,-0x29(%rbp)
jmp    15ba <main+0x3fa>
mov    -0x24(%rbp),%ecx
movsbl -0x29(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x29(%rbp)
jmp    15bf <main+0x3ff>
jmp    1521 <main+0x361>
jmp    15c9 <main+0x409>
lea    0xb27(%rip),%rdi
call   1030 <puts@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    17d2 <main+0x612>
cmpl   $0x2,-0x28(%rbp)
jne    17cd <main+0x60d>
lea    0xaac(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xa9b(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   10c0 <scanf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
lea    0xabd(%rip),%rdi
lea    0xac8(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    164f <main+0x48f>
lea    0xa82(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0xa9e(%rip),%rdi
lea    0xa9b(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xa49(%rip),%rdi
lea    0xa50(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1698 <main+0x4d8>
lea    0xa39(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x20,%eax
jne    16b6 <main+0x4f6>
jmp    16fa <main+0x53a>
movsbl -0x29(%rbp),%ecx
sub    -0x24(%rbp),%ecx
mov    $0x61,%eax
sub    %ecx,%eax
cmp    $0x0,%eax
jle    16e9 <main+0x529>
movsbl -0x29(%rbp),%ecx
sub    -0x24(%rbp),%ecx
mov    $0x61,%eax
sub    %ecx,%eax
sub    $0x1,%eax
add    $0x7a,%eax
mov    %al,-0x29(%rbp)
jmp    16f5 <main+0x535>
mov    -0x24(%rbp),%ecx
movsbl -0x29(%rbp),%eax
sub    %ecx,%eax
mov    %al,-0x29(%rbp)
jmp    16fa <main+0x53a>
jmp    16ff <main+0x53f>
mov    -0x18(%rbp),%rdi
call   10b0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    171d <main+0x55d>
jmp    17aa <main+0x5ea>
movsbl -0x29(%rbp),%esi
lea    0x9c6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    0x9b4(%rip),%rsi
movsbl -0x29(%rbp),%edx
call   10a0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x20,%eax
jne    1761 <main+0x5a1>
jmp    17a5 <main+0x5e5>
movsbl -0x29(%rbp),%ecx
sub    -0x24(%rbp),%ecx
mov    $0x61,%eax
sub    %ecx,%eax
cmp    $0x0,%eax
jle    1794 <main+0x5d4>
movsbl -0x29(%rbp),%ecx
sub    -0x24(%rbp),%ecx
mov    $0x61,%eax
sub    %ecx,%eax
sub    $0x1,%eax
add    $0x7a,%eax
mov    %al,-0x29(%rbp)
jmp    17a0 <main+0x5e0>
mov    -0x24(%rbp),%ecx
movsbl -0x29(%rbp),%eax
sub    %ecx,%eax
mov    %al,-0x29(%rbp)
jmp    17a5 <main+0x5e5>
jmp    16ff <main+0x53f>
jmp    17af <main+0x5ef>
lea    0x941(%rip),%rdi
call   1030 <puts@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
jmp    17d2 <main+0x612>
jmp    17d7 <main+0x617>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
lea    0xeca(%rip),%rdi
call   1040 <puts@plt>
lea    0xe0d(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10c0 <scanf@plt>
xor    %eax,%eax
call   10a0 <getchar@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
je     134c <main+0x18c>
cmp    $0x1,%eax
je     128c <main+0xcc>
test   %eax,%eax
jne    14b2 <main+0x2f2>
lea    0xdde(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdcd(%rip),%rdi
lea    0x8(%rsp),%rsi
call   10c0 <scanf@plt>
xor    %eax,%eax
call   10a0 <getchar@plt>
lea    0xe58(%rip),%rdi
lea    0xdbc(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     14bd <main+0x2fd>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   10a0 <getchar@plt>
cmp    $0xa,%al
je     1427 <main+0x267>
movsbl %al,%edi
mov    %rbx,%rsi
call   1090 <fputc@plt>
jmp    1270 <main+0xb0>
lea    0xd70(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd5f(%rip),%rdi
lea    0x8(%rsp),%rsi
call   10c0 <scanf@plt>
xor    %eax,%eax
call   10a0 <getchar@plt>
lea    0xdea(%rip),%rdi
lea    0xd6b(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     14bd <main+0x2fd>
mov    %rax,%rbx
lea    0xd56(%rip),%rdi
call   1040 <puts@plt>
lea    0xde6(%rip),%rdi
lea    0xd23(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     14bd <main+0x2fd>
mov    %rax,%r14
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    $0x20,%ebp
cmp    $0x20,%al
je     1325 <main+0x165>
movsbl %al,%eax
mov    0x8(%rsp),%ecx
lea    (%rcx,%rax,1),%edx
cmp    $0x7a,%edx
lea    -0x1a(%rcx,%rax,1),%ebp
cmovl  %edx,%ebp
mov    %rbx,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
jne    1408 <main+0x248>
movsbl %bpl,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1090 <fputc@plt>
jmp    1300 <main+0x140>
lea    0xcb0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xc9f(%rip),%rdi
lea    0x8(%rsp),%rsi
call   10c0 <scanf@plt>
xor    %eax,%eax
call   10a0 <getchar@plt>
lea    0xd51(%rip),%rdi
lea    0xcab(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     14bd <main+0x2fd>
mov    %rax,%rbx
lea    0xc96(%rip),%rdi
call   1040 <puts@plt>
lea    0xcff(%rip),%rdi
lea    0xc63(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     14bd <main+0x2fd>
mov    %rax,%r14
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    $0x20,%ebp
cmp    $0x20,%al
je     13e5 <main+0x225>
movsbl %al,%eax
sub    0x8(%rsp),%eax
mov    $0xffffffda,%ebp
sub    %eax,%ebp
cmp    $0x61,%eax
cmovge %eax,%ebp
mov    %rbx,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
jne    1408 <main+0x248>
movsbl %bpl,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1090 <fputc@plt>
jmp    13c0 <main+0x200>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    14b2 <main+0x2f2>
mov    %rbx,%rdi
call   1070 <rewind@plt>
lea    0xc94(%rip),%rdi
lea    0xbd1(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     14bd <main+0x2fd>
mov    %rax,%r14
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1080 <fgetc@plt>
mov    $0x20,%ebp
cmp    $0x20,%al
je     1475 <main+0x2b5>
movsbl %al,%eax
mov    0x8(%rsp),%ecx
lea    (%rcx,%rax,1),%edx
cmp    $0x7a,%edx
lea    -0x1a(%rcx,%rax,1),%ebp
cmovl  %edx,%ebp
mov    %rbx,%rdi
call   10b0 <feof@plt>
test   %eax,%eax
jne    1498 <main+0x2d8>
movsbl %bpl,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1090 <fputc@plt>
jmp    1450 <main+0x290>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xb4d(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [85 x i8] c"Enter 0 to copy plaintext to plaintext.txt \0Aand output ciphertext to ciphertext.txt\0A\00"
@.str.1 = [40 x i8] c"Enter 1 to encipher from plaintext.txt\0A\00"
@.str.2 = [41 x i8] c"Enter 2 to decipher from ciphertext.txt\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [11 x i8] c"Enter key:\00"
@.str.5 = [14 x i8] c"plaintext.txt\00"
@.str.6 = [3 x i8] c"w+\00"
@.str.7 = [26 x i8] c"File could not be opened!\00"
@.str.8 = [15 x i8] c"ciphertext.txt\00"
@.str.9 = [3 x i8] c"%c\00"
@.str.10 = [1 x i8] zeroinitializer
@.str.11 = [3 x i8] c"r+\00"
@.str.12 = [4 x i8] c"%s\0A\00"
@.str.13 = [8 x i8] c"Output:\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 i32
%9 = alloca i32
%10 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%15 = call signext i8 (...) @getchar()
%16 = load i32, i32* %9
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %127
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%21 = call signext i8 (...) @getchar()
%22 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %22, i32** %6
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %18
%28 = call signext i8 (...) @getchar()
store i8 %28, i8* %10
br label %29
29: ; preds = %33, %27
%30 = load i8, i8* %10
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 10
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i8, i8* %10
%35 = load i32*, i32** %6
%36 = call i32 @fputc(i8 signext %34, i32* %35)
%37 = call signext i8 (...) @getchar()
store i8 %37, i8* %10
br label %29
38: ; preds = %29
%39 = load i32*, i32** %6
%40 = call i32 @rewind(i32* %39)
br label %41
41: ; preds = %38
%42 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %42, i32** %7
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%46 = call i32 @exit(i32 0)
unreachable
47: ; preds = %41
%48 = load i32*, i32** %6
%49 = call signext i8 @fgetc(i32* %48)
store i8 %49, i8* %10
%50 = load i8, i8* %10
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 32
br i1 %52, label %53, label %54
53: ; preds = %47
br label %77
54: ; preds = %47
%55 = load i8, i8* %10
%56 = sext i8 %55 to i32
%57 = load i32, i32* %8
%58 = add nsw i32 %56, %57
%59 = sub nsw i32 %58, 122
%60 = icmp sge i32 %59, 0
br i1 %60, label %61, label %70
61: ; preds = %54
%62 = load i8, i8* %10
%63 = sext i8 %62 to i32
%64 = load i32, i32* %8
%65 = add nsw i32 %63, %64
%66 = sub nsw i32 %65, 122
%67 = sub nsw i32 %66, 1
%68 = add nsw i32 97, %67
%69 = trunc i32 %68 to i8
store i8 %69, i8* %10
br label %76
70: ; preds = %54
%71 = load i32, i32* %8
%72 = load i8, i8* %10
%73 = sext i8 %72 to i32
%74 = add nsw i32 %73, %71
%75 = trunc i32 %74 to i8
store i8 %75, i8* %10
br label %76
76: ; preds = %70, %61
br label %77
77: ; preds = %76, %53
br label %78
78: ; preds = %119, %77
%79 = load i32*, i32** %6
%80 = call i32 @feof(i32* %79)
%81 = icmp ne i32 %80, 0
%82 = xor i1 %81, true
br i1 %82, label %83, label %120
83: ; preds = %78
%84 = load i8, i8* %10
%85 = sext i8 %84 to i32
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %85)
%87 = load i32*, i32** %7
%88 = load i8, i8* %10
%89 = call i32 @fprintf(i32* %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8 signext %88)
%90 = load i32*, i32** %6
%91 = call signext i8 @fgetc(i32* %90)
store i8 %91, i8* %10
%92 = load i8, i8* %10
%93 = sext i8 %92 to i32
%94 = icmp eq i32 %93, 32
br i1 %94, label %95, label %96
95: ; preds = %83
br label %119
96: ; preds = %83
%97 = load i8, i8* %10
%98 = sext i8 %97 to i32
%99 = load i32, i32* %8
%100 = add nsw i32 %98, %99
%101 = sub nsw i32 %100, 122
%102 = icmp sge i32 %101, 0
br i1 %102, label %103, label %112
103: ; preds = %96
%104 = load i8, i8* %10
%105 = sext i8 %104 to i32
%106 = load i32, i32* %8
%107 = add nsw i32 %105, %106
%108 = sub nsw i32 %107, 122
%109 = sub nsw i32 %108, 1
%110 = add nsw i32 97, %109
%111 = trunc i32 %110 to i8
store i8 %111, i8* %10
br label %118
112: ; preds = %96
%113 = load i32, i32* %8
%114 = load i8, i8* %10
%115 = sext i8 %114 to i32
%116 = add nsw i32 %115, %113
%117 = trunc i32 %116 to i8
store i8 %117, i8* %10
br label %118
118: ; preds = %112, %103
br label %119
119: ; preds = %118, %95
br label %78
120: ; preds = %78
br label %121
121: ; preds = %120
%122 = load i32*, i32** %7
%123 = call i32 @fclose(i32* %122)
%124 = load i32*, i32** %6
%125 = call i32 @fclose(i32* %124)
%126 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
br label %327
127: ; preds = %2
%128 = load i32, i32* %9
%129 = icmp eq i32 %128, 1
br i1 %129, label %130, label %226
130: ; preds = %127
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%132 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%133 = call signext i8 (...) @getchar()
%134 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
store i32* %134, i32** %6
%135 = icmp eq i32* %134, null
br i1 %135, label %136, label %139
136: ; preds = %130
%137 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%138 = call i32 @exit(i32 0)
unreachable
139: ; preds = %130
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%141 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %141, i32** %7
%142 = icmp eq i32* %141, null
br i1 %142, label %143, label %146
143: ; preds = %139
%144 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%145 = call i32 @exit(i32 0)
unreachable
146: ; preds = %139
%147 = load i32*, i32** %6
%148 = call signext i8 @fgetc(i32* %147)
store i8 %148, i8* %10
%149 = load i8, i8* %10
%150 = sext i8 %149 to i32
%151 = icmp eq i32 %150, 32
br i1 %151, label %152, label %153
152: ; preds = %146
br label %176
153: ; preds = %146
%154 = load i8, i8* %10
%155 = sext i8 %154 to i32
%156 = load i32, i32* %8
%157 = add nsw i32 %155, %156
%158 = sub nsw i32 %157, 122
%159 = icmp sge i32 %158, 0
br i1 %159, label %160, label %169
160: ; preds = %153
%161 = load i8, i8* %10
%162 = sext i8 %161 to i32
%163 = load i32, i32* %8
%164 = add nsw i32 %162, %163
%165 = sub nsw i32 %164, 122
%166 = sub nsw i32 %165, 1
%167 = add nsw i32 97, %166
%168 = trunc i32 %167 to i8
store i8 %168, i8* %10
br label %175
169: ; preds = %153
%170 = load i32, i32* %8
%171 = load i8, i8* %10
%172 = sext i8 %171 to i32
%173 = add nsw i32 %172, %170
%174 = trunc i32 %173 to i8
store i8 %174, i8* %10
br label %175
175: ; preds = %169, %160
br label %176
176: ; preds = %175, %152
br label %177
177: ; preds = %218, %176
%178 = load i32*, i32** %6
%179 = call i32 @feof(i32* %178)
%180 = icmp ne i32 %179, 0
%181 = xor i1 %180, true
br i1 %181, label %182, label %219
182: ; preds = %177
%183 = load i8, i8* %10
%184 = sext i8 %183 to i32
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %184)
%186 = load i32*, i32** %7
%187 = load i8, i8* %10
%188 = call i32 @fprintf(i32* %186, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8 signext %187)
%189 = load i32*, i32** %6
%190 = call signext i8 @fgetc(i32* %189)
store i8 %190, i8* %10
%191 = load i8, i8* %10
%192 = sext i8 %191 to i32
%193 = icmp eq i32 %192, 32
br i1 %193, label %194, label %195
194: ; preds = %182
br label %218
195: ; preds = %182
%196 = load i8, i8* %10
%197 = sext i8 %196 to i32
%198 = load i32, i32* %8
%199 = add nsw i32 %197, %198
%200 = sub nsw i32 %199, 122
%201 = icmp sge i32 %200, 0
br i1 %201, label %202, label %211
202: ; preds = %195
%203 = load i8, i8* %10
%204 = sext i8 %203 to i32
%205 = load i32, i32* %8
%206 = add nsw i32 %204, %205
%207 = sub nsw i32 %206, 122
%208 = sub nsw i32 %207, 1
%209 = add nsw i32 97, %208
%210 = trunc i32 %209 to i8
store i8 %210, i8* %10
br label %217
211: ; preds = %195
%212 = load i32, i32* %8
%213 = load i8, i8* %10
%214 = sext i8 %213 to i32
%215 = add nsw i32 %214, %212
%216 = trunc i32 %215 to i8
store i8 %216, i8* %10
br label %217
217: ; preds = %211, %202
br label %218
218: ; preds = %217, %194
br label %177
219: ; preds = %177
br label %220
220: ; preds = %219
%221 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%222 = load i32*, i32** %7
%223 = call i32 @fclose(i32* %222)
%224 = load i32*, i32** %6
%225 = call i32 @fclose(i32* %224)
br label %326
226: ; preds = %127
%227 = load i32, i32* %9
%228 = icmp eq i32 %227, 2
br i1 %228, label %229, label %325
229: ; preds = %226
%230 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%231 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%232 = call signext i8 (...) @getchar()
%233 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
store i32* %233, i32** %6
%234 = icmp eq i32* %233, null
br i1 %234, label %235, label %238
235: ; preds = %229
%236 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%237 = call i32 @exit(i32 0)
unreachable
238: ; preds = %229
%239 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%240 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %240, i32** %7
%241 = icmp eq i32* %240, null
br i1 %241, label %242, label %245
242: ; preds = %238
%243 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%244 = call i32 @exit(i32 0)
unreachable
245: ; preds = %238
%246 = load i32*, i32** %6
%247 = call signext i8 @fgetc(i32* %246)
store i8 %247, i8* %10
%248 = load i8, i8* %10
%249 = sext i8 %248 to i32
%250 = icmp eq i32 %249, 32
br i1 %250, label %251, label %252
251: ; preds = %245
br label %275
252: ; preds = %245
%253 = load i8, i8* %10
%254 = sext i8 %253 to i32
%255 = load i32, i32* %8
%256 = sub nsw i32 %254, %255
%257 = sub nsw i32 97, %256
%258 = icmp sgt i32 %257, 0
br i1 %258, label %259, label %268
259: ; preds = %252
%260 = load i8, i8* %10
%261 = sext i8 %260 to i32
%262 = load i32, i32* %8
%263 = sub nsw i32 %261, %262
%264 = sub nsw i32 97, %263
%265 = sub nsw i32 %264, 1
%266 = add nsw i32 122, %265
%267 = trunc i32 %266 to i8
store i8 %267, i8* %10
br label %274
268: ; preds = %252
%269 = load i32, i32* %8
%270 = load i8, i8* %10
%271 = sext i8 %270 to i32
%272 = sub nsw i32 %271, %269
%273 = trunc i32 %272 to i8
store i8 %273, i8* %10
br label %274
274: ; preds = %268, %259
br label %275
275: ; preds = %274, %251
br label %276
276: ; preds = %317, %275
%277 = load i32*, i32** %6
%278 = call i32 @feof(i32* %277)
%279 = icmp ne i32 %278, 0
%280 = xor i1 %279, true
br i1 %280, label %281, label %318
281: ; preds = %276
%282 = load i8, i8* %10
%283 = sext i8 %282 to i32
%284 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 %283)
%285 = load i32*, i32** %7
%286 = load i8, i8* %10
%287 = call i32 @fprintf(i32* %285, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8 signext %286)
%288 = load i32*, i32** %6
%289 = call signext i8 @fgetc(i32* %288)
store i8 %289, i8* %10
%290 = load i8, i8* %10
%291 = sext i8 %290 to i32
%292 = icmp eq i32 %291, 32
br i1 %292, label %293, label %294
293: ; preds = %281
br label %317
294: ; preds = %281
%295 = load i8, i8* %10
%296 = sext i8 %295 to i32
%297 = load i32, i32* %8
%298 = sub nsw i32 %296, %297
%299 = sub nsw i32 97, %298
%300 = icmp sgt i32 %299, 0
br i1 %300, label %301, label %310
301: ; preds = %294
%302 = load i8, i8* %10
%303 = sext i8 %302 to i32
%304 = load i32, i32* %8
%305 = sub nsw i32 %303, %304
%306 = sub nsw i32 97, %305
%307 = sub nsw i32 %306, 1
%308 = add nsw i32 122, %307
%309 = trunc i32 %308 to i8
store i8 %309, i8* %10
br label %316
310: ; preds = %294
%311 = load i32, i32* %8
%312 = load i8, i8* %10
%313 = sext i8 %312 to i32
%314 = sub nsw i32 %313, %311
%315 = trunc i32 %314 to i8
store i8 %315, i8* %10
br label %316
316: ; preds = %310, %301
br label %317
317: ; preds = %316, %293
br label %276
318: ; preds = %276
br label %319
319: ; preds = %318
%320 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.10, i64 0, i64 0))
%321 = load i32*, i32** %7
%322 = call i32 @fclose(i32* %321)
%323 = load i32*, i32** %6
%324 = call i32 @fclose(i32* %323)
br label %325
325: ; preds = %319, %226
br label %326
326: ; preds = %325, %220
br label %327
327: ; preds = %326, %121
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [11 x i8] c"Enter key:\00"
@.str.5 = [14 x i8] c"plaintext.txt\00"
@.str.6 = [3 x i8] c"w+\00"
@.str.7 = [26 x i8] c"File could not be opened!\00"
@.str.8 = [15 x i8] c"ciphertext.txt\00"
@.str.11 = [3 x i8] c"r+\00"
@.str.13 = [8 x i8] c"Output:\00"
@str = [84 x i8] c"Enter 0 to copy plaintext to plaintext.txt \0Aand output ciphertext to ciphertext.txt\00"
@str.14 = [39 x i8] c"Enter 1 to encipher from plaintext.txt\00"
@str.15 = [40 x i8] c"Enter 2 to decipher from ciphertext.txt\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([84 x i8], [84 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.14, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.15, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%11 = call signext i8 (...) @getchar()
%12 = load i32, i32* %4
switch i32 %12, label %180 [
i32 0, label %13
i32 1, label %74
i32 2, label %127
]
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%16 = call signext i8 (...) @getchar()
%17 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %13
%23 = call signext i8 (...) @getchar()
%24 = icmp eq i8 %23, 10
br i1 %24, label %30, label %25
25: ; preds = %22, %25
%26 = phi i8 [ %28, %25 ], [ %23, %22 ]
%27 = call i32 @fputc(i8 signext %26, i32* %17)
%28 = call signext i8 (...) @getchar()
%29 = icmp eq i8 %28, 10
br i1 %29, label %30, label %25
30: ; preds = %25, %22
%31 = call i32 @rewind(i32* %17)
%32 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %30
%38 = call signext i8 @fgetc(i32* %17)
%39 = icmp eq i8 %38, 32
br i1 %39, label %47, label %40
40: ; preds = %37
%41 = sext i8 %38 to i32
%42 = load i32, i32* %3
%43 = add nsw i32 %42, %41
%44 = icmp sgt i32 %43, 121
%45 = add i32 %43, -26
%46 = select i1 %44, i32 %45, i32 %43
br label %47
47: ; preds = %40, %37
%48 = phi i32 [ 32, %37 ], [ %46, %40 ]
%49 = call i32 @feof(i32* %17)
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %70
51: ; preds = %47, %66
%52 = phi i32 [ %67, %66 ], [ %48, %47 ]
%53 = shl i32 %52, 24
%54 = ashr exact i32 %53, 24
%55 = call i32 @putchar(i32 %54)
%56 = call i32 bitcast (i32 (i8, i32*)* @fputc to i32 (i32, i32*)*)(i32 %54, i32* %32)
%57 = call signext i8 @fgetc(i32* %17)
%58 = icmp eq i8 %57, 32
br i1 %58, label %66, label %59
59: ; preds = %51
%60 = sext i8 %57 to i32
%61 = load i32, i32* %3
%62 = add nsw i32 %61, %60
%63 = icmp sgt i32 %62, 121
%64 = add i32 %62, -26
%65 = select i1 %63, i32 %64, i32 %62
br label %66
66: ; preds = %59, %51
%67 = phi i32 [ 32, %51 ], [ %65, %59 ]
%68 = call i32 @feof(i32* %17)
%69 = icmp eq i32 %68, 0
br i1 %69, label %51, label %70
70: ; preds = %66, %47
%71 = call i32 @fclose(i32* %32)
%72 = call i32 @fclose(i32* %17)
%73 = call i32 @putchar(i32 10)
br label %180
74: ; preds = %2
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%76 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%77 = call signext i8 (...) @getchar()
%78 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%79 = icmp eq i32* %78, null
br i1 %79, label %80, label %83
80: ; preds = %74
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%82 = call i32 @exit(i32 0)
unreachable
83: ; preds = %74
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%85 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%86 = icmp eq i32* %85, null
br i1 %86, label %87, label %90
87: ; preds = %83
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%89 = call i32 @exit(i32 0)
unreachable
90: ; preds = %83
%91 = call signext i8 @fgetc(i32* %78)
%92 = icmp eq i8 %91, 32
br i1 %92, label %100, label %93
93: ; preds = %90
%94 = sext i8 %91 to i32
%95 = load i32, i32* %3
%96 = add nsw i32 %95, %94
%97 = icmp sgt i32 %96, 121
%98 = add i32 %96, -26
%99 = select i1 %97, i32 %98, i32 %96
br label %100
100: ; preds = %93, %90
%101 = phi i32 [ 32, %90 ], [ %99, %93 ]
%102 = call i32 @feof(i32* %78)
%103 = icmp eq i32 %102, 0
br i1 %103, label %104, label %123
104: ; preds = %100, %119
%105 = phi i32 [ %120, %119 ], [ %101, %100 ]
%106 = shl i32 %105, 24
%107 = ashr exact i32 %106, 24
%108 = call i32 @putchar(i32 %107)
%109 = call i32 bitcast (i32 (i8, i32*)* @fputc to i32 (i32, i32*)*)(i32 %107, i32* %85)
%110 = call signext i8 @fgetc(i32* %78)
%111 = icmp eq i8 %110, 32
br i1 %111, label %119, label %112
112: ; preds = %104
%113 = sext i8 %110 to i32
%114 = load i32, i32* %3
%115 = add nsw i32 %114, %113
%116 = icmp sgt i32 %115, 121
%117 = add i32 %115, -26
%118 = select i1 %116, i32 %117, i32 %115
br label %119
119: ; preds = %112, %104
%120 = phi i32 [ 32, %104 ], [ %118, %112 ]
%121 = call i32 @feof(i32* %78)
%122 = icmp eq i32 %121, 0
br i1 %122, label %104, label %123
123: ; preds = %119, %100
%124 = call i32 @putchar(i32 10)
%125 = call i32 @fclose(i32* %85)
%126 = call i32 @fclose(i32* %78)
br label %180
127: ; preds = %2
%128 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%129 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%130 = call signext i8 (...) @getchar()
%131 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%132 = icmp eq i32* %131, null
br i1 %132, label %133, label %136
133: ; preds = %127
%134 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%135 = call i32 @exit(i32 0)
unreachable
136: ; preds = %127
%137 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%138 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%139 = icmp eq i32* %138, null
br i1 %139, label %140, label %143
140: ; preds = %136
%141 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%142 = call i32 @exit(i32 0)
unreachable
143: ; preds = %136
%144 = call signext i8 @fgetc(i32* %131)
%145 = icmp eq i8 %144, 32
br i1 %145, label %153, label %146
146: ; preds = %143
%147 = sext i8 %144 to i32
%148 = load i32, i32* %3
%149 = sub nsw i32 %147, %148
%150 = icmp slt i32 %149, 97
%151 = sub i32 -38, %149
%152 = select i1 %150, i32 %151, i32 %149
br label %153
153: ; preds = %146, %143
%154 = phi i32 [ 32, %143 ], [ %152, %146 ]
%155 = call i32 @feof(i32* %131)
%156 = icmp eq i32 %155, 0
br i1 %156, label %157, label %176
157: ; preds = %153, %172
%158 = phi i32 [ %173, %172 ], [ %154, %153 ]
%159 = shl i32 %158, 24
%160 = ashr exact i32 %159, 24
%161 = call i32 @putchar(i32 %160)
%162 = call i32 bitcast (i32 (i8, i32*)* @fputc to i32 (i32, i32*)*)(i32 %160, i32* %138)
%163 = call signext i8 @fgetc(i32* %131)
%164 = icmp eq i8 %163, 32
br i1 %164, label %172, label %165
165: ; preds = %157
%166 = sext i8 %163 to i32
%167 = load i32, i32* %3
%168 = sub nsw i32 %166, %167
%169 = icmp slt i32 %168, 97
%170 = sub i32 -38, %168
%171 = select i1 %169, i32 %170, i32 %168
br label %172
172: ; preds = %165, %157
%173 = phi i32 [ 32, %157 ], [ %171, %165 ]
%174 = call i32 @feof(i32* %131)
%175 = icmp eq i32 %174, 0
br i1 %175, label %157, label %176
176: ; preds = %172, %153
%177 = call i32 @putchar(i32 10)
%178 = call i32 @fclose(i32* %138)
%179 = call i32 @fclose(i32* %131)
br label %180
180: ; preds = %2, %123, %176, %70
ret i32 0
}