#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ error(char *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  FILE *fp_origem;
  FILE *fp_destino;
  char c;
  if ((argc > 3) || (argc == 1))
    usage();
  printf("\n");
  printf("-- crypt %s\n", "0.1 beta");
  printf("-- por: bleno vinicius\n");
  printf("-- mail : blenolopes@gmail.com\n");
  fp_origem = fopen(argv[1], "r");
  if (!fp_origem)
    error("arquivo de origem nao encontrado!\n");
  fp_destino = fopen(argv[2], "w");
  if (!fp_destino)
    error("impossivel criar arquivo de destino!\n");
  printf("\n[o] Processando... ");
  while ((c = fgetc(fp_origem)) != EOF) {
    fputc(~c, fp_destino);
  }
  printf("OK!\n\n");
  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)
cmpl   $0x3,-0x8(%rbp)
jg     118a <main+0x2a>
cmpl   $0x1,-0x8(%rbp)
jne    1191 <main+0x31>
mov    $0x0,%al
call   1060 <usage@plt>
lea    0xf1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ff <main+0x9f>
lea    0xe56(%rip),%rdi
call   1070 <error@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe65(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    122e <main+0xce>
lea    0xe4c(%rip),%rdi
call   1070 <error@plt>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2d96(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1275 <main+0x115>
movsbl -0x21(%rbp),%eax
xor    $0xffffffff,%eax
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
jmp    123c <main+0xdc>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x3,%edi
jg     1192 <main+0x12>
cmp    $0x1,%edi
jne    1199 <main+0x19>
xor    %eax,%eax
call   1080 <usage@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe56(%rip),%rdi
lea    0xe5c(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
lea    0xec4(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%r14),%rdi
lea    0xe3b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11f4 <main+0x74>
lea    0xe29(%rip),%rdi
call   1090 <error@plt>
mov    0x10(%r14),%rdi
lea    0xe3c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1218 <main+0x98>
lea    0xe2a(%rip),%rdi
call   1090 <error@plt>
lea    0xe44(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1060 <fgetc@plt>
mov    0x2db3(%rip),%r14
cmp    (%r14),%al
je     125a <main+0xda>
nopw   0x0(%rax,%rax,1)
not    %al
movsbl %al,%edi
mov    %rbx,%rsi
call   1070 <fputc@plt>
mov    %r15,%rdi
call   1060 <fgetc@plt>
cmp    (%r14),%al
jne    1240 <main+0xc0>
lea    0xe4d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [13 x i8] c"-- crypt %s\0A\00"
@.str.2 = [9 x i8] c"0.1 beta\00"
@.str.3 = [24 x i8] c"-- por: bleno vinicius\0A\00"
@.str.4 = [32 x i8] c"-- mail : blenolopes@gmail.com\0A\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [35 x i8] c"arquivo de origem nao encontrado!\0A\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [38 x i8] c"impossivel criar arquivo de destino!\0A\00"
@.str.9 = [21 x i8] c"\0A[o] Processando... \00"
@EOF = global i8 0
@.str.10 = [6 x i8] c"OK!\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 3
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %11, %2
%15 = call i32 (...) @usage()
br label %16
16: ; preds = %14, %11
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = icmp ne i32* %25, null
br i1 %26, label %29, label %27
27: ; preds = %16
%28 = call i32 @error(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %29
29: ; preds = %27, %16
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %33, i32** %7
%34 = load i32*, i32** %7
%35 = icmp ne i32* %34, null
br i1 %35, label %38, label %36
36: ; preds = %29
%37 = call i32 @error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
br label %38
38: ; preds = %36, %29
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
br label %40
40: ; preds = %47, %38
%41 = load i32*, i32** %6
%42 = call signext i8 @fgetc(i32* %41)
store i8 %42, i8* %8
%43 = sext i8 %42 to i32
%44 = load i8, i8* @EOF
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %43, %45
br i1 %46, label %47, label %54
47: ; preds = %40
%48 = load i8, i8* %8
%49 = sext i8 %48 to i32
%50 = xor i32 %49, -1
%51 = trunc i32 %50 to i8
%52 = load i32*, i32** %7
%53 = call i32 @fputc(i8 signext %51, i32* %52)
br label %40
54: ; preds = %40
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"-- crypt %s\0A\00"
@.str.2 = [9 x i8] c"0.1 beta\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [35 x i8] c"arquivo de origem nao encontrado!\0A\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [38 x i8] c"impossivel criar arquivo de destino!\0A\00"
@.str.9 = [21 x i8] c"\0A[o] Processando... \00"
@EOF = global i8 0
@str = [23 x i8] c"-- por: bleno vinicius\00"
@str.11 = [31 x i8] c"-- mail : blenolopes@gmail.com\00"
@str.12 = [5 x i8] c"OK!\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 3
%4 = icmp eq i32 %0, 1
%5 = or i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (...) @usage()
br label %8
8: ; preds = %2, %6
%9 = tail call i32 @putchar(i32 10)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.11, i64 0, i64 0))
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = tail call i32 @error(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %19
19: ; preds = %17, %8
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = tail call i32 @error(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
br label %26
26: ; preds = %24, %19
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%28 = tail call signext i8 @fgetc(i32* %15)
%29 = load i8, i8* @EOF
%30 = icmp eq i8 %28, %29
br i1 %30, label %38, label %31
31: ; preds = %26, %31
%32 = phi i8 [ %35, %31 ], [ %28, %26 ]
%33 = xor i8 %32, -1
%34 = tail call i32 @fputc(i8 signext %33, i32* %22)
%35 = tail call signext i8 @fgetc(i32* %15)
%36 = load i8, i8* @EOF
%37 = icmp eq i8 %35, %36
br i1 %37, label %38, label %31
38: ; preds = %31, %26
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.12, i64 0, i64 0))
ret i32 0
}