#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 */
struct stat {
  int st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int MCL_CURRENT;
int MCL_FUTURE;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ fstat(int /*<<< orphan*/, struct stat *);
scalar_t__ geteuid();
scalar_t__ malloc(int);
scalar_t__ mlockall(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ remove(char *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ stdin;
char tolower(char);
int main(int argc, char **argv) {
  struct stat statbuf, keybuf;
  char buffer[20];
  char ans;
  int key = 0, data = 0, output = 0, count = 0;
  int *buf;
  FILE *keyfile, *sourcefile, *destfile;
  if (geteuid()) {
    puts("Root access is required to run this program.");
    return -1;
  }
  if (argc != 4) {
    puts("OTP-Encryptor 1.2 \n");
    puts("Licenced under the GNU GeneralPublic Licence v.2\n");
    puts("This program encrypts a  file using a random key");
    puts("and  generates an output file with the resulting");
    puts("cipher.  Decryption is achieved  by  running the");
    puts("output file as source file  with the same key.\n");
    puts("WARNING: The security of the encryption provided");
    puts("by this program is entirely dependent on the key");
    puts("file.  The keyfile should meet the  requirements");
    puts("below:");
    puts("    - Be of the same size or larger than the");
    puts("      source file.");
    puts("    - Be completely random, preferably generated");
    puts("      by a Hardware Random Number Generator.");
    puts("    - NEVER be reused!\n");
    puts("The  author takes no  responsibility  for use of");
    puts("this program.\n");
    puts("Usage: OTP <source file> <output file> <keyfile>");
    return (0);
  }
  buf = (int *)malloc(sizeof(int));
  if (!buf) {
    perror("Error");
    free(buf);
    return -3;
  }
  puts("Locking down processes.");
  if (mlockall(MCL_CURRENT | MCL_FUTURE) < 0) {
    perror("mlockall");
    free(buf);
    return -4;
  }
  if ((sourcefile = fopen(argv[1], "rb")) == NULL) {
    puts("Can't open source file.");
    perror("Error");
    free(buf);
    return -5;
  }
  fstat(fileno(sourcefile), &statbuf);
  if ((keyfile = fopen(argv[3], "rb")) == NULL) {
    puts("Can't open keyfile.");
    perror("Error");
    free(buf);
    return -6;
  }
  fstat(fileno(keyfile), &keybuf);
  if ((keybuf.st_size) < (statbuf.st_size)) {
    puts("Source file is larger than keyfile.");
    puts("Action not allowed.");
    puts("Exiting...");
    free(buf);
    return -7;
  }
  if ((destfile = fopen(argv[2], "wb")) == NULL) {
    puts("Can't open output file.");
    perror("Error");
    free(buf);
    return -8;
  }
  puts("Encrypting/Decrypting...");
  while (count < (statbuf.st_size)) {
    key = fgetc(keyfile);
    data = fgetc(sourcefile);
    output = (key ^ data);
    fputc(output, destfile);
    count++;
  }
  fclose(keyfile);
  fclose(sourcefile);
  fclose(destfile);
  puts("Encryption/Decryption Complete.");
  puts("Do you wish to delete the source file? (Y/N)");
  fgets(buffer, 20, stdin);
  sscanf(buffer, "%c", &ans);
  if (tolower(ans) == 'y') {
    if (remove(argv[1]) == 0)
      puts("File deleted successfully.");
    else {
      puts("Unable to delete the file.");
      perror("Error");
      free(buf);
      return -9;
    }
  }
  puts("Do you wish to delete the keyfile? (Y/N)");
  fgets(buffer, 20, stdin);
  sscanf(buffer, "%c", &ans);
  if (tolower(ans) == 'y') {
    if (remove(argv[3]) == 0)
      puts("File deleted successfully.");
    else {
      puts("Unable to delete the file.");
      perror("Error");
      free(buf);
      return -10;
    }
  }
  puts("Releasing memory.");
  free(buf);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    $0x0,%al
call   1070 <geteuid@plt>
cmp    $0x0,%rax
je     125e <main+0x5e>
lea    0xdb3(%rip),%rdi
call   1050 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1710 <main+0x510>
cmpl   $0x4,-0x8(%rbp)
je     134c <main+0x14c>
lea    0xdbe(%rip),%rdi
call   1050 <puts@plt>
lea    0xdc6(%rip),%rdi
call   1050 <puts@plt>
lea    0xdec(%rip),%rdi
call   1050 <puts@plt>
lea    0xe11(%rip),%rdi
call   1050 <puts@plt>
lea    0xe36(%rip),%rdi
call   1050 <puts@plt>
lea    0xe5b(%rip),%rdi
call   1050 <puts@plt>
lea    0xe7f(%rip),%rdi
call   1050 <puts@plt>
lea    0xea4(%rip),%rdi
call   1050 <puts@plt>
lea    0xec9(%rip),%rdi
call   1050 <puts@plt>
lea    0xeee(%rip),%rdi
call   1050 <puts@plt>
lea    0xee9(%rip),%rdi
call   1050 <puts@plt>
lea    0xf0a(%rip),%rdi
call   1050 <puts@plt>
lea    0xf11(%rip),%rdi
call   1050 <puts@plt>
lea    0xf36(%rip),%rdi
call   1050 <puts@plt>
lea    0xf57(%rip),%rdi
call   1050 <puts@plt>
lea    0xf63(%rip),%rdi
call   1050 <puts@plt>
lea    0xf88(%rip),%rdi
call   1050 <puts@plt>
lea    0xf8b(%rip),%rdi
call   1050 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1710 <main+0x510>
mov    $0x4,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    1386 <main+0x186>
lea    0xf8b(%rip),%rdi
call   1110 <perror@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1710 <main+0x510>
lea    0xf70(%rip),%rdi
call   1050 <puts@plt>
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
mov    0x2c4e(%rip),%rax
or     (%rax),%edi
call   10f0 <mlockall@plt>
cmp    $0x0,%rax
jge    13d4 <main+0x1d4>
lea    0xf5b(%rip),%rdi
call   1110 <perror@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    1710 <main+0x510>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xf3b(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x70(%rbp)
cmp    $0x0,%rax
jne    1423 <main+0x223>
lea    0xf24(%rip),%rdi
call   1050 <puts@plt>
lea    0xeee(%rip),%rdi
call   1110 <perror@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffffb,-0x4(%rbp)
jmp    1710 <main+0x510>
mov    -0x70(%rbp),%rdi
call   10b0 <fileno@plt>
mov    %eax,%edi
lea    -0x18(%rbp),%rsi
call   1120 <fstat@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xed8(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x68(%rbp)
cmp    $0x0,%rax
jne    1486 <main+0x286>
lea    0xed9(%rip),%rdi
call   1050 <puts@plt>
lea    0xe8b(%rip),%rdi
call   1110 <perror@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffffa,-0x4(%rbp)
jmp    1710 <main+0x510>
mov    -0x68(%rbp),%rdi
call   10b0 <fileno@plt>
mov    %eax,%edi
lea    -0x20(%rbp),%rsi
call   1120 <fstat@plt>
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    14df <main+0x2df>
lea    0xea0(%rip),%rdi
call   1050 <puts@plt>
lea    0xeb8(%rip),%rdi
call   1050 <puts@plt>
lea    0xec0(%rip),%rdi
call   1050 <puts@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffff9,-0x4(%rbp)
jmp    1710 <main+0x510>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xea2(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmp    $0x0,%rax
jne    152e <main+0x32e>
lea    0xe8b(%rip),%rdi
call   1050 <puts@plt>
lea    0xde3(%rip),%rdi
call   1110 <perror@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffff8,-0x4(%rbp)
jmp    1710 <main+0x510>
lea    0xe76(%rip),%rdi
call   1050 <puts@plt>
mov    -0x54(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1581 <main+0x381>
mov    -0x68(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %eax,-0x48(%rbp)
mov    -0x70(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%eax
xor    -0x4c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%edi
mov    -0x78(%rbp),%rsi
call   1090 <fputc@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    153a <main+0x33a>
mov    -0x68(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x70(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x78(%rbp),%rdi
call   1060 <fclose@plt>
lea    0xe21(%rip),%rdi
call   1050 <puts@plt>
lea    0xe35(%rip),%rdi
call   1050 <puts@plt>
lea    -0x40(%rbp),%rdi
mov    0x2a21(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   10a0 <fgets@plt>
lea    -0x40(%rbp),%rdi
lea    0xe3b(%rip),%rsi
lea    -0x41(%rbp),%rdx
call   10e0 <sscanf@plt>
movsbl -0x41(%rbp),%edi
call   10c0 <tolower@plt>
movsbl %al,%eax
cmp    $0x79,%eax
jne    164e <main+0x44e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <remove@plt>
cmp    $0x0,%rax
jne    161c <main+0x41c>
lea    0xe02(%rip),%rdi
call   1050 <puts@plt>
jmp    1649 <main+0x449>
lea    0xe0c(%rip),%rdi
call   1050 <puts@plt>
lea    0xcc8(%rip),%rdi
call   1110 <perror@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffff7,-0x4(%rbp)
jmp    1710 <main+0x510>
jmp    164e <main+0x44e>
lea    0xdf5(%rip),%rdi
call   1050 <puts@plt>
lea    -0x40(%rbp),%rdi
mov    0x297b(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   10a0 <fgets@plt>
lea    -0x40(%rbp),%rdi
lea    0xd95(%rip),%rsi
lea    -0x41(%rbp),%rdx
call   10e0 <sscanf@plt>
movsbl -0x41(%rbp),%edi
call   10c0 <tolower@plt>
movsbl %al,%eax
cmp    $0x79,%eax
jne    16f4 <main+0x4f4>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <remove@plt>
cmp    $0x0,%rax
jne    16c2 <main+0x4c2>
lea    0xd5c(%rip),%rdi
call   1050 <puts@plt>
jmp    16ef <main+0x4ef>
lea    0xd66(%rip),%rdi
call   1050 <puts@plt>
lea    0xc22(%rip),%rdi
call   1110 <perror@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffff6,-0x4(%rbp)
jmp    1710 <main+0x510>
jmp    16f4 <main+0x4f4>
lea    0xd78(%rip),%rdi
call   1050 <puts@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r15
mov    %edi,%ebx
xor    %eax,%eax
call   1070 <geteuid@plt>
test   %rax,%rax
je     1235 <main+0x35>
lea    0xdda(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%eax
jmp    156c <main+0x36c>
cmp    $0x4,%ebx
jne    1326 <main+0x126>
mov    $0x4,%edi
call   10d0 <malloc@plt>
test   %rax,%rax
je     157b <main+0x37b>
mov    %rax,%rbp
lea    0x10a2(%rip),%rdi
call   1050 <puts@plt>
mov    0x2d69(%rip),%rax
mov    0x2d82(%rip),%rcx
mov    (%rcx),%edi
or     (%rax),%edi
call   10f0 <mlockall@plt>
test   %rax,%rax
js     1595 <main+0x395>
mov    0x8(%r15),%rdi
lea    0x1093(%rip),%rsi
call   1100 <fopen@plt>
test   %rax,%rax
je     15b0 <main+0x3b0>
mov    %rax,%r12
mov    %rax,%rdi
call   10b0 <fileno@plt>
lea    0x10(%rsp),%rsi
mov    %eax,%edi
call   1120 <fstat@plt>
mov    0x18(%r15),%rdi
lea    0x1063(%rip),%rsi
call   1100 <fopen@plt>
test   %rax,%rax
je     15d7 <main+0x3d7>
mov    %rax,%r13
mov    %rax,%rdi
call   10b0 <fileno@plt>
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1120 <fstat@plt>
mov    0x10(%rsp),%r14d
cmp    %r14d,0x8(%rsp)
jge    1403 <main+0x203>
lea    0x1056(%rip),%rdi
call   1050 <puts@plt>
lea    0x106e(%rip),%rdi
call   1050 <puts@plt>
lea    0x1076(%rip),%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0xfffffff9,%eax
jmp    156c <main+0x36c>
lea    0xd00(%rip),%rdi
call   1050 <puts@plt>
lea    0xd08(%rip),%rdi
call   1050 <puts@plt>
lea    0xd2e(%rip),%rdi
call   1050 <puts@plt>
lea    0xd53(%rip),%rdi
call   1050 <puts@plt>
lea    0xd78(%rip),%rdi
call   1050 <puts@plt>
lea    0xd9d(%rip),%rdi
call   1050 <puts@plt>
lea    0xdc1(%rip),%rdi
call   1050 <puts@plt>
lea    0xde6(%rip),%rdi
call   1050 <puts@plt>
lea    0xe0b(%rip),%rdi
call   1050 <puts@plt>
lea    0xe30(%rip),%rdi
call   1050 <puts@plt>
lea    0xe2b(%rip),%rdi
call   1050 <puts@plt>
lea    0xe4c(%rip),%rdi
call   1050 <puts@plt>
lea    0xe53(%rip),%rdi
call   1050 <puts@plt>
lea    0xe78(%rip),%rdi
call   1050 <puts@plt>
lea    0xe99(%rip),%rdi
call   1050 <puts@plt>
lea    0xea5(%rip),%rdi
call   1050 <puts@plt>
lea    0xeca(%rip),%rdi
call   1050 <puts@plt>
lea    0xecd(%rip),%rdi
call   1050 <puts@plt>
jmp    156a <main+0x36a>
mov    0x10(%r15),%rdi
lea    0xf82(%rip),%rsi
call   1100 <fopen@plt>
test   %rax,%rax
je     1601 <main+0x401>
mov    %rax,%rbx
mov    %rbp,0x18(%rsp)
lea    0xf80(%rip),%rdi
call   1050 <puts@plt>
test   %r14d,%r14d
jle    1464 <main+0x264>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
call   1080 <fgetc@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1080 <fgetc@plt>
xor    %eax,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
call   1090 <fputc@plt>
add    $0xffffffff,%r14d
jne    1440 <main+0x240>
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xf41(%rip),%rdi
call   1050 <puts@plt>
lea    0xf55(%rip),%rdi
call   1050 <puts@plt>
mov    0x2b45(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   10a0 <fgets@plt>
lea    0xf5a(%rip),%rsi
lea    0x7(%rsp),%rdx
mov    %rbx,%rdi
call   10e0 <sscanf@plt>
movsbl 0x7(%rsp),%edi
call   10c0 <tolower@plt>
cmp    $0x79,%al
jne    14f0 <main+0x2f0>
mov    0x8(%r15),%rdi
call   1040 <remove@plt>
test   %rax,%rax
jne    162b <main+0x42b>
lea    0xf29(%rip),%rdi
call   1050 <puts@plt>
lea    0xf53(%rip),%rdi
call   1050 <puts@plt>
mov    0x0(%rbp),%edx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
call   10a0 <fgets@plt>
lea    0xef9(%rip),%rsi
lea    0x7(%rsp),%rdx
mov    %rbx,%rdi
call   10e0 <sscanf@plt>
movsbl 0x7(%rsp),%edi
call   10c0 <tolower@plt>
cmp    $0x79,%al
mov    0x18(%rsp),%rbx
jne    1556 <main+0x356>
mov    0x18(%r15),%rdi
call   1040 <remove@plt>
test   %rax,%rax
jne    1657 <main+0x457>
lea    0xec3(%rip),%rdi
call   1050 <puts@plt>
lea    0xf16(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd75(%rip),%rdi
call   1110 <perror@plt>
xor    %edi,%edi
call   1030 <free@plt>
mov    $0xfffffffd,%eax
jmp    156c <main+0x36c>
lea    0xd79(%rip),%rdi
call   1110 <perror@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0xfffffffc,%eax
jmp    156c <main+0x36c>
lea    0xd6a(%rip),%rdi
call   1050 <puts@plt>
lea    0xd34(%rip),%rdi
call   1110 <perror@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0xfffffffb,%eax
jmp    156c <main+0x36c>
lea    0xd5b(%rip),%rdi
call   1050 <puts@plt>
lea    0xd0d(%rip),%rdi
call   1110 <perror@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0xfffffffa,%eax
jmp    156c <main+0x36c>
lea    0xd8b(%rip),%rdi
call   1050 <puts@plt>
lea    0xce3(%rip),%rdi
call   1110 <perror@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0xfffffff8,%eax
jmp    156c <main+0x36c>
lea    0xdfd(%rip),%rdi
call   1050 <puts@plt>
lea    0xcb9(%rip),%rdi
call   1110 <perror@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    $0xfffffff7,%eax
jmp    156c <main+0x36c>
lea    0xdd1(%rip),%rdi
call   1050 <puts@plt>
lea    0xc8d(%rip),%rdi
call   1110 <perror@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0xfffffff6,%eax
jmp    156c <main+0x36c>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [45 x i8] c"Root access is required to run this program.\00"
@.str.1 = [20 x i8] c"OTP-Encryptor 1.2 \0A\00"
@.str.2 = [50 x i8] c"Licenced under the GNU GeneralPublic Licence v.2\0A\00"
@.str.3 = [49 x i8] c"This program encrypts a file using a random key\00"
@.str.4 = [49 x i8] c"and generates an output file with the resulting\00"
@.str.5 = [49 x i8] c"cipher. Decryption is achieved by running the\00"
@.str.6 = [48 x i8] c"output file as source file with the same key.\0A\00"
@.str.7 = [49 x i8] c"WARNING: The security of the encryption provided\00"
@.str.8 = [49 x i8] c"by this program is entirely dependent on the key\00"
@.str.9 = [49 x i8] c"file. The keyfile should meet the requirements\00"
@.str.10 = [7 x i8] c"below:\00"
@.str.11 = [45 x i8] c" - Be of the same size or larger than the\00"
@.str.12 = [19 x i8] c" source file.\00"
@.str.13 = [49 x i8] c" - Be completely random, preferably generated\00"
@.str.14 = [45 x i8] c" by a Hardware Random Number Generator.\00"
@.str.15 = [24 x i8] c" - NEVER be reused!\0A\00"
@.str.16 = [49 x i8] c"The author takes no responsibility for use of\00"
@.str.17 = [15 x i8] c"this program.\0A\00"
@.str.18 = [49 x i8] c"Usage: OTP <source file> <output file> <keyfile>\00"
@.str.19 = [6 x i8] c"Error\00"
@.str.20 = [24 x i8] c"Locking down processes.\00"
@MCL_CURRENT = global i32 0
@MCL_FUTURE = global i32 0
@.str.21 = [9 x i8] c"mlockall\00"
@.str.22 = [3 x i8] c"rb\00"
@.str.23 = [24 x i8] c"Can't open source file.\00"
@.str.24 = [20 x i8] c"Can't open keyfile.\00"
@.str.25 = [36 x i8] c"Source file is larger than keyfile.\00"
@.str.26 = [20 x i8] c"Action not allowed.\00"
@.str.27 = [11 x i8] c"Exiting...\00"
@.str.28 = [3 x i8] c"wb\00"
@.str.29 = [24 x i8] c"Can't open output file.\00"
@.str.30 = [25 x i8] c"Encrypting/Decrypting...\00"
@.str.31 = [32 x i8] c"Encryption/Decryption Complete.\00"
@.str.32 = [45 x i8] c"Do you wish to delete the source file? (Y/N)\00"
@stdin = global i32 0
@.str.33 = [3 x i8] c"%c\00"
@.str.34 = [27 x i8] c"File deleted successfully.\00"
@.str.35 = [27 x i8] c"Unable to delete the file.\00"
@.str.36 = [41 x i8] c"Do you wish to delete the keyfile? (Y/N)\00"
@.str.37 = [18 x i8] c"Releasing memory.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca %struct.stat
%8 = alloca [20 x i8]
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
%18 = call i64 (...) @geteuid()
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %196
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 4
br i1 %24, label %25, label %44
25: ; preds = %22
%26 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @puts(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%31 = call i32 @puts(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
%32 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0))
%33 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0))
%34 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0))
%35 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%36 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
%37 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
%38 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.13, i64 0, i64 0))
%39 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.14, i64 0, i64 0))
%40 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0))
%41 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.16, i64 0, i64 0))
%42 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0))
%43 = call i32 @puts(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.18, i64 0, i64 0))
store i32 0, i32* %3
br label %196
44: ; preds = %22
%45 = call i64 @malloc(i32 4)
%46 = inttoptr i64 %45 to i32*
store i32* %46, i32** %14
%47 = load i32*, i32** %14
%48 = icmp ne i32* %47, null
br i1 %48, label %53, label %49
49: ; preds = %44
%50 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%51 = load i32*, i32** %14
%52 = call i32 @free(i32* %51)
store i32 -3, i32* %3
br label %196
53: ; preds = %44
%54 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.20, i64 0, i64 0))
%55 = load i32, i32* @MCL_CURRENT
%56 = load i32, i32* @MCL_FUTURE
%57 = or i32 %55, %56
%58 = call i64 @mlockall(i32 %57)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %53
%61 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.21, i64 0, i64 0))
%62 = load i32*, i32** %14
%63 = call i32 @free(i32* %62)
store i32 -4, i32* %3
br label %196
64: ; preds = %53
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 1
%67 = load i8*, i8** %66
%68 = call i32* @fopen(i8* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0))
store i32* %68, i32** %16
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %75
70: ; preds = %64
%71 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.23, i64 0, i64 0))
%72 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%73 = load i32*, i32** %14
%74 = call i32 @free(i32* %73)
store i32 -5, i32* %3
br label %196
75: ; preds = %64
%76 = load i32*, i32** %16
%77 = call i32 @fileno(i32* %76)
%78 = call i32 @fstat(i32 %77, %struct.stat* %6)
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 3
%81 = load i8*, i8** %80
%82 = call i32* @fopen(i8* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0))
store i32* %82, i32** %15
%83 = icmp eq i32* %82, null
br i1 %83, label %84, label %89
84: ; preds = %75
%85 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.24, i64 0, i64 0))
%86 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%87 = load i32*, i32** %14
%88 = call i32 @free(i32* %87)
store i32 -6, i32* %3
br label %196
89: ; preds = %75
%90 = load i32*, i32** %15
%91 = call i32 @fileno(i32* %90)
%92 = call i32 @fstat(i32 %91, %struct.stat* %7)
%93 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%94 = load i32, i32* %93
%95 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%96 = load i32, i32* %95
%97 = icmp slt i32 %94, %96
br i1 %97, label %98, label %104
98: ; preds = %89
%99 = call i32 @puts(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.25, i64 0, i64 0))
%100 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.26, i64 0, i64 0))
%101 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.27, i64 0, i64 0))
%102 = load i32*, i32** %14
%103 = call i32 @free(i32* %102)
store i32 -7, i32* %3
br label %196
104: ; preds = %89
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 2
%107 = load i8*, i8** %106
%108 = call i32* @fopen(i8* %107, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.28, i64 0, i64 0))
store i32* %108, i32** %17
%109 = icmp eq i32* %108, null
br i1 %109, label %110, label %115
110: ; preds = %104
%111 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.29, i64 0, i64 0))
%112 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%113 = load i32*, i32** %14
%114 = call i32 @free(i32* %113)
store i32 -8, i32* %3
br label %196
115: ; preds = %104
%116 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.30, i64 0, i64 0))
br label %117
117: ; preds = %122, %115
%118 = load i32, i32* %13
%119 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%120 = load i32, i32* %119
%121 = icmp slt i32 %118, %120
br i1 %121, label %122, label %135
122: ; preds = %117
%123 = load i32*, i32** %15
%124 = call i32 @fgetc(i32* %123)
store i32 %124, i32* %10
%125 = load i32*, i32** %16
%126 = call i32 @fgetc(i32* %125)
store i32 %126, i32* %11
%127 = load i32, i32* %10
%128 = load i32, i32* %11
%129 = xor i32 %127, %128
store i32 %129, i32* %12
%130 = load i32, i32* %12
%131 = load i32*, i32** %17
%132 = call i32 @fputc(i32 %130, i32* %131)
%133 = load i32, i32* %13
%134 = add nsw i32 %133, 1
store i32 %134, i32* %13
br label %117
135: ; preds = %117
%136 = load i32*, i32** %15
%137 = call i32 @fclose(i32* %136)
%138 = load i32*, i32** %16
%139 = call i32 @fclose(i32* %138)
%140 = load i32*, i32** %17
%141 = call i32 @fclose(i32* %140)
%142 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.31, i64 0, i64 0))
%143 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.32, i64 0, i64 0))
%144 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%145 = load i32, i32* @stdin
%146 = call i32 @fgets(i8* %144, i32 20, i32 %145)
%147 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%148 = call i32 @sscanf(i8* %147, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.33, i64 0, i64 0), i8* %9)
%149 = load i8, i8* %9
%150 = call signext i8 @tolower(i8 signext %149)
%151 = sext i8 %150 to i32
%152 = icmp eq i32 %151, 121
br i1 %152, label %153, label %167
153: ; preds = %135
%154 = load i8**, i8*** %5
%155 = getelementptr inbounds i8*, i8** %154, i64 1
%156 = load i8*, i8** %155
%157 = call i64 @remove(i8* %156)
%158 = icmp eq i64 %157, 0
br i1 %158, label %159, label %161
159: ; preds = %153
%160 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.34, i64 0, i64 0))
br label %166
161: ; preds = %153
%162 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.35, i64 0, i64 0))
%163 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%164 = load i32*, i32** %14
%165 = call i32 @free(i32* %164)
store i32 -9, i32* %3
br label %196
166: ; preds = %159
br label %167
167: ; preds = %166, %135
%168 = call i32 @puts(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.36, i64 0, i64 0))
%169 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%170 = load i32, i32* @stdin
%171 = call i32 @fgets(i8* %169, i32 20, i32 %170)
%172 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%173 = call i32 @sscanf(i8* %172, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.33, i64 0, i64 0), i8* %9)
%174 = load i8, i8* %9
%175 = call signext i8 @tolower(i8 signext %174)
%176 = sext i8 %175 to i32
%177 = icmp eq i32 %176, 121
br i1 %177, label %178, label %192
178: ; preds = %167
%179 = load i8**, i8*** %5
%180 = getelementptr inbounds i8*, i8** %179, i64 3
%181 = load i8*, i8** %180
%182 = call i64 @remove(i8* %181)
%183 = icmp eq i64 %182, 0
br i1 %183, label %184, label %186
184: ; preds = %178
%185 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.34, i64 0, i64 0))
br label %191
186: ; preds = %178
%187 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.35, i64 0, i64 0))
%188 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%189 = load i32*, i32** %14
%190 = call i32 @free(i32* %189)
store i32 -10, i32* %3
br label %196
191: ; preds = %184
br label %192
192: ; preds = %191, %167
%193 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.37, i64 0, i64 0))
%194 = load i32*, i32** %14
%195 = call i32 @free(i32* %194)
store i32 0, i32* %3
br label %196
196: ; preds = %192, %186, %161, %110, %98, %84, %70, %60, %49, %25, %20
%197 = load i32, i32* %3
ret i32 %197
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [45 x i8] c"Root access is required to run this program.\00"
@.str.1 = [20 x i8] c"OTP-Encryptor 1.2 \0A\00"
@.str.2 = [50 x i8] c"Licenced under the GNU GeneralPublic Licence v.2\0A\00"
@.str.3 = [49 x i8] c"This program encrypts a file using a random key\00"
@.str.4 = [49 x i8] c"and generates an output file with the resulting\00"
@.str.5 = [49 x i8] c"cipher. Decryption is achieved by running the\00"
@.str.6 = [48 x i8] c"output file as source file with the same key.\0A\00"
@.str.7 = [49 x i8] c"WARNING: The security of the encryption provided\00"
@.str.8 = [49 x i8] c"by this program is entirely dependent on the key\00"
@.str.9 = [49 x i8] c"file. The keyfile should meet the requirements\00"
@.str.10 = [7 x i8] c"below:\00"
@.str.11 = [45 x i8] c" - Be of the same size or larger than the\00"
@.str.12 = [19 x i8] c" source file.\00"
@.str.13 = [49 x i8] c" - Be completely random, preferably generated\00"
@.str.14 = [45 x i8] c" by a Hardware Random Number Generator.\00"
@.str.15 = [24 x i8] c" - NEVER be reused!\0A\00"
@.str.16 = [49 x i8] c"The author takes no responsibility for use of\00"
@.str.17 = [15 x i8] c"this program.\0A\00"
@.str.18 = [49 x i8] c"Usage: OTP <source file> <output file> <keyfile>\00"
@.str.19 = [6 x i8] c"Error\00"
@.str.20 = [24 x i8] c"Locking down processes.\00"
@MCL_CURRENT = global i32 0
@MCL_FUTURE = global i32 0
@.str.21 = [9 x i8] c"mlockall\00"
@.str.22 = [3 x i8] c"rb\00"
@.str.23 = [24 x i8] c"Can't open source file.\00"
@.str.24 = [20 x i8] c"Can't open keyfile.\00"
@.str.25 = [36 x i8] c"Source file is larger than keyfile.\00"
@.str.26 = [20 x i8] c"Action not allowed.\00"
@.str.27 = [11 x i8] c"Exiting...\00"
@.str.28 = [3 x i8] c"wb\00"
@.str.29 = [24 x i8] c"Can't open output file.\00"
@.str.30 = [25 x i8] c"Encrypting/Decrypting...\00"
@.str.31 = [32 x i8] c"Encryption/Decryption Complete.\00"
@.str.32 = [45 x i8] c"Do you wish to delete the source file? (Y/N)\00"
@stdin = global i32 0
@.str.33 = [3 x i8] c"%c\00"
@.str.34 = [27 x i8] c"File deleted successfully.\00"
@.str.35 = [27 x i8] c"Unable to delete the file.\00"
@.str.36 = [41 x i8] c"Do you wish to delete the keyfile? (Y/N)\00"
@.str.37 = [18 x i8] c"Releasing memory.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = alloca [20 x i8]
%6 = alloca i8
%7 = bitcast %struct.stat* %3 to i8*
%8 = bitcast %struct.stat* %4 to i8*
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%10 = tail call i64 (...) @geteuid()
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
br label %148
14: ; preds = %2
%15 = icmp eq i32 %0, 4
br i1 %15, label %35, label %16
16: ; preds = %14
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.6, i64 0, i64 0))
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0))
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0))
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.13, i64 0, i64 0))
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.14, i64 0, i64 0))
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0))
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.16, i64 0, i64 0))
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0))
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.18, i64 0, i64 0))
br label %148
35: ; preds = %14
%36 = tail call i64 @malloc(i32 4)
%37 = inttoptr i64 %36 to i32*
%38 = icmp eq i64 %36, 0
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%41 = tail call i32 @free(i32* null)
br label %148
42: ; preds = %35
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.20, i64 0, i64 0))
%44 = load i32, i32* @MCL_CURRENT
%45 = load i32, i32* @MCL_FUTURE
%46 = or i32 %45, %44
%47 = tail call i64 @mlockall(i32 %46)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %42
%50 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.21, i64 0, i64 0))
%51 = tail call i32 @free(i32* %37)
br label %148
52: ; preds = %42
%53 = getelementptr inbounds i8*, i8** %1, i64 1
%54 = load i8*, i8** %53
%55 = tail call i32* @fopen(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0))
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %61
57: ; preds = %52
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.23, i64 0, i64 0))
%59 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%60 = tail call i32 @free(i32* %37)
br label %148
61: ; preds = %52
%62 = tail call i32 @fileno(i32* %55)
%63 = call i32 @fstat(i32 %62, %struct.stat* %3)
%64 = getelementptr inbounds i8*, i8** %1, i64 3
%65 = load i8*, i8** %64
%66 = tail call i32* @fopen(i8* %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0))
%67 = icmp eq i32* %66, null
br i1 %67, label %68, label %72
68: ; preds = %61
%69 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.24, i64 0, i64 0))
%70 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%71 = tail call i32 @free(i32* %37)
br label %148
72: ; preds = %61
%73 = tail call i32 @fileno(i32* %66)
%74 = call i32 @fstat(i32 %73, %struct.stat* %4)
%75 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%76 = load i32, i32* %75
%77 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%78 = load i32, i32* %77
%79 = icmp slt i32 %76, %78
br i1 %79, label %80, label %85
80: ; preds = %72
%81 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.25, i64 0, i64 0))
%82 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.26, i64 0, i64 0))
%83 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.27, i64 0, i64 0))
%84 = tail call i32 @free(i32* %37)
br label %148
85: ; preds = %72
%86 = getelementptr inbounds i8*, i8** %1, i64 2
%87 = load i8*, i8** %86
%88 = tail call i32* @fopen(i8* %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.28, i64 0, i64 0))
%89 = icmp eq i32* %88, null
br i1 %89, label %90, label %94
90: ; preds = %85
%91 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.29, i64 0, i64 0))
%92 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%93 = tail call i32 @free(i32* %37)
br label %148
94: ; preds = %85
%95 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.30, i64 0, i64 0))
%96 = icmp sgt i32 %78, 0
br i1 %96, label %97, label %105
97: ; preds = %94, %97
%98 = phi i32 [ %103, %97 ], [ 0, %94 ]
%99 = tail call i32 @fgetc(i32* %66)
%100 = tail call i32 @fgetc(i32* %55)
%101 = xor i32 %100, %99
%102 = tail call i32 @fputc(i32 %101, i32* %88)
%103 = add nuw nsw i32 %98, 1
%104 = icmp eq i32 %103, %78
br i1 %104, label %105, label %97
105: ; preds = %97, %94
%106 = tail call i32 @fclose(i32* %66)
%107 = tail call i32 @fclose(i32* %55)
%108 = tail call i32 @fclose(i32* %88)
%109 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.31, i64 0, i64 0))
%110 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.32, i64 0, i64 0))
%111 = load i32, i32* @stdin
%112 = call i32 @fgets(i8* %9, i32 20, i32 %111)
%113 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.33, i64 0, i64 0), i8* %6)
%114 = load i8, i8* %6
%115 = call signext i8 @tolower(i8 signext %114)
%116 = icmp eq i8 %115, 121
br i1 %116, label %117, label %127
117: ; preds = %105
%118 = load i8*, i8** %53
%119 = call i64 @remove(i8* %118)
%120 = icmp eq i64 %119, 0
br i1 %120, label %121, label %123
121: ; preds = %117
%122 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.34, i64 0, i64 0))
br label %127
123: ; preds = %117
%124 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.35, i64 0, i64 0))
%125 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%126 = call i32 @free(i32* %37)
br label %148
127: ; preds = %121, %105
%128 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.36, i64 0, i64 0))
%129 = load i32, i32* @stdin
%130 = call i32 @fgets(i8* %9, i32 20, i32 %129)
%131 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.33, i64 0, i64 0), i8* %6)
%132 = load i8, i8* %6
%133 = call signext i8 @tolower(i8 signext %132)
%134 = icmp eq i8 %133, 121
br i1 %134, label %135, label %145
135: ; preds = %127
%136 = load i8*, i8** %64
%137 = call i64 @remove(i8* %136)
%138 = icmp eq i64 %137, 0
br i1 %138, label %139, label %141
139: ; preds = %135
%140 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.34, i64 0, i64 0))
br label %145
141: ; preds = %135
%142 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.35, i64 0, i64 0))
%143 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i64 0, i64 0))
%144 = call i32 @free(i32* %37)
br label %148
145: ; preds = %139, %127
%146 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.37, i64 0, i64 0))
%147 = call i32 @free(i32* %37)
br label %148
148: ; preds = %145, %141, %123, %90, %80, %68, %57, %49, %39, %16, %12
%149 = phi i32 [ -1, %12 ], [ 0, %16 ], [ -4, %49 ], [ -5, %57 ], [ -6, %68 ], [ -7, %80 ], [ -8, %90 ], [ 0, %145 ], [ -10, %141 ], [ -9, %123 ], [ -3, %39 ]
ret i32 %149
}