#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 atoi(char *);
char *encriptarchave(char *, int *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  if (argc < 3) {
    printf("quantidades de arquivos insulficiente\n");
    system("pause");
    return -1;
  }
  FILE *cripto;
  FILE *textoclaro;
  FILE *chave;
  cripto = fopen("cripto.txt", "w");
  textoclaro = fopen(argv[1], "r");
  chave = fopen(argv[2], "r");
  int i = 0;
  int textochave[8];
  char letrasclaro[8];
  char letra = '1';
  letra = getc(chave);
  while (letra != EOF) {
    textochave[i] = atoi(&letra);
    letra = getc(chave);
    i++;
  }
  letra = getc(textoclaro);
  while (letra != EOF) {
    for (i = 0; i < 8; i++) {
      letrasclaro[i] = letra;
      letra = getc(textoclaro);
    }
    printf("\n%s", letrasclaro);
    printf("\n%s\n", encriptarchave(letrasclaro, textochave));
    for (i = 0; i < 8; i++) {
      fprintf(cripto, "%c", letrasclaro[i]);
    }
  }
  fclose(cripto);
  fclose(textoclaro);
  fclose(chave);
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11c6 <main+0x46>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe72(%rip),%rdi
call   1050 <system@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    135a <main+0x1da>
lea    0xe60(%rip),%rdi
lea    0xe64(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe36(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movb   $0x31,-0x59(%rbp)
mov    -0x28(%rbp),%rdi
call   10a0 <getc@plt>
mov    %al,-0x59(%rbp)
movsbl -0x59(%rbp),%eax
mov    0x2db9(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1267 <main+0xe7>
lea    -0x59(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,%ecx
movslq -0x2c(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x28(%rbp),%rdi
call   10a0 <getc@plt>
mov    %al,-0x59(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1224 <main+0xa4>
mov    -0x20(%rbp),%rdi
call   10a0 <getc@plt>
mov    %al,-0x59(%rbp)
movsbl -0x59(%rbp),%eax
mov    0x2d6a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     132c <main+0x1ac>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x8,-0x2c(%rbp)
jge    12bf <main+0x13f>
mov    -0x59(%rbp),%cl
movslq -0x2c(%rbp),%rax
mov    %cl,-0x58(%rbp,%rax,1)
mov    -0x20(%rbp),%rdi
call   10a0 <getc@plt>
mov    %al,-0x59(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1290 <main+0x110>
lea    -0x58(%rbp),%rsi
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x58(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <encriptarchave@plt>
mov    %rax,%rsi
lea    0xd58(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x8,-0x2c(%rbp)
jge    1327 <main+0x1a7>
mov    -0x18(%rbp),%rdi
movslq -0x2c(%rbp),%rax
lea    0xd36(%rip),%rsi
movsbl -0x58(%rbp,%rax,1),%edx
call   1070 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12f6 <main+0x176>
jmp    1273 <main+0xf3>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xcd9(%rip),%rdi
call   1050 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x2,%edi
jg     11c5 <main+0x35>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4a(%rip),%rdi
call   1060 <system@plt>
mov    $0xffffffff,%eax
jmp    139a <main+0x20a>
mov    %rsi,%rbp
lea    0xe37(%rip),%rdi
lea    0xe3b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
mov    0x8(%rbp),%rdi
lea    0xe2a(%rip),%r15
mov    %r15,%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
mov    %r15,%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   10b0 <getc@plt>
mov    %al,0x7(%rsp)
mov    0x2dd2(%rip),%r12
cmp    (%r12),%al
je     1251 <main+0xc1>
lea    0x10(%rsp),%rbp
lea    0x7(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
call   10a0 <atoi@plt>
mov    %eax,0x0(%rbp)
mov    %r15,%rdi
call   10b0 <getc@plt>
mov    %al,0x7(%rsp)
add    $0x4,%rbp
cmp    (%r12),%al
jne    1230 <main+0xa0>
mov    %rbx,%rdi
call   10b0 <getc@plt>
cmp    (%r12),%al
je     1374 <main+0x1e4>
mov    %eax,%ebp
lea    0x8(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    %bpl,0x8(%rsp)
mov    %rbx,%rdi
call   10b0 <getc@plt>
mov    %al,0x9(%rsp)
mov    %rbx,%rdi
call   10b0 <getc@plt>
mov    %al,0xa(%rsp)
mov    %rbx,%rdi
call   10b0 <getc@plt>
mov    %al,0xb(%rsp)
mov    %rbx,%rdi
call   10b0 <getc@plt>
mov    %al,0xc(%rsp)
mov    %rbx,%rdi
call   10b0 <getc@plt>
mov    %al,0xd(%rsp)
mov    %rbx,%rdi
call   10b0 <getc@plt>
mov    %al,0xe(%rsp)
mov    %rbx,%rdi
call   10b0 <getc@plt>
mov    %al,0xf(%rsp)
mov    %rbx,%rdi
call   10b0 <getc@plt>
mov    %eax,%ebp
lea    0xd3b(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
lea    0x10(%rsp),%rsi
call   1050 <encriptarchave@plt>
lea    0xd21(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x8(%rsp),%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
movsbl 0x9(%rsp),%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
movsbl 0xa(%rsp),%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
movsbl 0xb(%rsp),%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
movsbl 0xc(%rsp),%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
movsbl 0xd(%rsp),%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
movsbl 0xe(%rsp),%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
movsbl 0xf(%rsp),%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
cmp    (%r12),%bpl
jne    1270 <main+0xe0>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xc6d(%rip),%rdi
call   1060 <system@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"quantidades de arquivos insulficiente\0A\00"
@.str.1 = [6 x i8] c"pause\00"
@.str.2 = [11 x i8] c"cripto.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.5 = [4 x i8] c"\0A%s\00"
@.str.6 = [5 x i8] c"\0A%s\0A\00"
@.str.7 = [3 x i8] c"%c\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 [8 x i32]
%11 = alloca [8 x i8]
%12 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %97
18: ; preds = %2
%19 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %19, i32** %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %23, i32** %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %27, i32** %8
store i32 0, i32* %9
store i8 49, i8* %12
%28 = load i32*, i32** %8
%29 = call signext i8 @getc(i32* %28)
store i8 %29, i8* %12
br label %30
30: ; preds = %36, %18
%31 = load i8, i8* %12
%32 = sext i8 %31 to i32
%33 = load i8, i8* @EOF
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %32, %34
br i1 %35, label %36, label %45
36: ; preds = %30
%37 = call i32 @atoi(i8* %12)
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [8 x i32], [8 x i32]* %10, i64 0, i64 %39
store i32 %37, i32* %40
%41 = load i32*, i32** %8
%42 = call signext i8 @getc(i32* %41)
store i8 %42, i8* %12
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %30
45: ; preds = %30
%46 = load i32*, i32** %7
%47 = call signext i8 @getc(i32* %46)
store i8 %47, i8* %12
br label %48
48: ; preds = %88, %45
%49 = load i8, i8* %12
%50 = sext i8 %49 to i32
%51 = load i8, i8* @EOF
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %50, %52
br i1 %53, label %54, label %89
54: ; preds = %48
store i32 0, i32* %9
br label %55
55: ; preds = %65, %54
%56 = load i32, i32* %9
%57 = icmp slt i32 %56, 8
br i1 %57, label %58, label %68
58: ; preds = %55
%59 = load i8, i8* %12
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 %61
store i8 %59, i8* %62
%63 = load i32*, i32** %7
%64 = call signext i8 @getc(i32* %63)
store i8 %64, i8* %12
br label %65
65: ; preds = %58
%66 = load i32, i32* %9
%67 = add nsw i32 %66, 1
store i32 %67, i32* %9
br label %55
68: ; preds = %55
%69 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %69)
%71 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%72 = getelementptr inbounds [8 x i32], [8 x i32]* %10, i64 0, i64 0
%73 = call i8* @encriptarchave(i8* %71, i32* %72)
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %73)
store i32 0, i32* %9
br label %75
75: ; preds = %85, %68
%76 = load i32, i32* %9
%77 = icmp slt i32 %76, 8
br i1 %77, label %78, label %88
78: ; preds = %75
%79 = load i32*, i32** %6
%80 = load i32, i32* %9
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 %81
%83 = load i8, i8* %82
%84 = call i32 @fprintf(i32* %79, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8 signext %83)
br label %85
85: ; preds = %78
%86 = load i32, i32* %9
%87 = add nsw i32 %86, 1
store i32 %87, i32* %9
br label %75
88: ; preds = %75
br label %48
89: ; preds = %48
%90 = load i32*, i32** %6
%91 = call i32 @fclose(i32* %90)
%92 = load i32*, i32** %7
%93 = call i32 @fclose(i32* %92)
%94 = load i32*, i32** %8
%95 = call i32 @fclose(i32* %94)
%96 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %97
97: ; preds = %89, %15
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"pause\00"
@.str.2 = [11 x i8] c"cripto.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.5 = [4 x i8] c"\0A%s\00"
@.str.6 = [5 x i8] c"\0A%s\0A\00"
@str = [38 x i8] c"quantidades de arquivos insulficiente\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8 x i32]
%4 = alloca [8 x i8]
%5 = alloca i8
%6 = icmp slt i32 %0, 3
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %88
10: ; preds = %2
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%18 = bitcast [8 x i32]* %3 to i8*
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%20 = tail call signext i8 @getc(i32* %17)
store i8 %20, i8* %5
%21 = load i8, i8* @EOF
%22 = icmp eq i8 %20, %21
br i1 %22, label %31, label %23
23: ; preds = %10, %23
%24 = phi i64 [ %28, %23 ], [ 0, %10 ]
%25 = call i32 @atoi(i8* %5)
%26 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %24
store i32 %25, i32* %26
%27 = tail call signext i8 @getc(i32* %17)
store i8 %27, i8* %5
%28 = add nuw i64 %24, 1
%29 = load i8, i8* @EOF
%30 = icmp eq i8 %27, %29
br i1 %30, label %31, label %23
31: ; preds = %23, %10
%32 = tail call signext i8 @getc(i32* %14)
%33 = load i8, i8* @EOF
%34 = icmp eq i8 %32, %33
br i1 %34, label %83, label %35
35: ; preds = %31
%36 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%37 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 1
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 2
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 3
%40 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 4
%41 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 5
%42 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 6
%43 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 7
br label %44
44: ; preds = %35, %44
%45 = phi i8 [ %32, %35 ], [ %53, %44 ]
store i8 %45, i8* %19
%46 = call signext i8 @getc(i32* %14)
store i8 %46, i8* %37
%47 = call signext i8 @getc(i32* %14)
store i8 %47, i8* %38
%48 = call signext i8 @getc(i32* %14)
store i8 %48, i8* %39
%49 = call signext i8 @getc(i32* %14)
store i8 %49, i8* %40
%50 = call signext i8 @getc(i32* %14)
store i8 %50, i8* %41
%51 = call signext i8 @getc(i32* %14)
store i8 %51, i8* %42
%52 = call signext i8 @getc(i32* %14)
store i8 %52, i8* %43
%53 = call signext i8 @getc(i32* %14)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%55 = call i8* @encriptarchave(i8* %19, i32* %36)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %55)
%57 = load i8, i8* %19
%58 = sext i8 %57 to i32
%59 = call i32 @fputc(i32 %58, i32* %11)
%60 = load i8, i8* %37
%61 = sext i8 %60 to i32
%62 = call i32 @fputc(i32 %61, i32* %11)
%63 = load i8, i8* %38
%64 = sext i8 %63 to i32
%65 = call i32 @fputc(i32 %64, i32* %11)
%66 = load i8, i8* %39
%67 = sext i8 %66 to i32
%68 = call i32 @fputc(i32 %67, i32* %11)
%69 = load i8, i8* %40
%70 = sext i8 %69 to i32
%71 = call i32 @fputc(i32 %70, i32* %11)
%72 = load i8, i8* %41
%73 = sext i8 %72 to i32
%74 = call i32 @fputc(i32 %73, i32* %11)
%75 = load i8, i8* %42
%76 = sext i8 %75 to i32
%77 = call i32 @fputc(i32 %76, i32* %11)
%78 = load i8, i8* %43
%79 = sext i8 %78 to i32
%80 = call i32 @fputc(i32 %79, i32* %11)
%81 = load i8, i8* @EOF
%82 = icmp eq i8 %53, %81
br i1 %82, label %83, label %44
83: ; preds = %44, %31
%84 = call i32 @fclose(i32* %11)
%85 = call i32 @fclose(i32* %14)
%86 = call i32 @fclose(i32* %17)
%87 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %88
88: ; preds = %83, %7
%89 = phi i32 [ -1, %7 ], [ 0, %83 ]
ret i32 %89
}