#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*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  FILE *fdIn = NULL;
  FILE *fdOut = NULL;
  char fileIn[64] = "";
  char fileOut[64] = "";
  char key[1024] = "";
  int decode = 0;
  int c = 0;
  int b = 0;
  int i = 0;
  for (i = 1; i < argc; i++) {
    if (argv[i][0] == '-') {
      if (argv[i][1] == 'k') {
        strcpy(key, argv[i + 1]);
        i++;
      }
      if (argv[i][1] == 'd') {
        decode = 1;
      }
    } else {
      if (fileIn[0] == 0) {
        strcpy(fileIn, argv[i]);
      } else {
        strcpy(fileOut, argv[i]);
      }
    }
  }
  if (strlen(key) > 0 && strlen(fileIn) > 0 && strlen(fileOut) > 0) {
    if ((fdIn = fopen(fileIn, "r")) == NULL) {
      fprintf(stderr, "Error: input file not found.\n");
      return -1;
    }
    if ((fdOut = fopen(fileOut, "w")) == NULL) {
      fprintf(stderr, "Error: output file problem.\n");
      return -1;
    }
    i = 0;
    while (1 == 1) {
      c = fgetc(fdIn);
      if (c < 0) {
        break;
      }
      i++;
      if (decode < 1) {
        c = (c + b) % 256;
        b = c;
      } else {
        c = (c - b) % 256;
        b = (c + b);
      }
      if (strlen(key) > i) {
        b = b + key[i];
      }
      fputc(c, fdOut);
    }
    fclose(fdIn);
    fclose(fdOut);
  } else {
    printf("Copyright (C) 2013 by Ubaldo Porcheddu <ubaldo@eja.it>\n");
    printf("Usage: qua [OPTIONS] [FILE_IN] [FILE_OUT]\n\n");
    printf(" -k key  keycode\n");
    printf(" -d      decode\n");
    printf(" -h      this help\n\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    -0x4a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
movl   $0x0,-0x4a4(%rbp)
movl   $0x0,-0x4a8(%rbp)
movl   $0x0,-0x4ac(%rbp)
movl   $0x0,-0x4b0(%rbp)
movl   $0x1,-0x4b0(%rbp)
mov    -0x4b0(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1324 <main+0x194>
mov    -0x10(%rbp),%rax
movslq -0x4b0(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    12c1 <main+0x131>
mov    -0x10(%rbp),%rax
movslq -0x4b0(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6b,%eax
jne    1296 <main+0x106>
lea    -0x4a0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x4b0(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
mov    -0x4b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4b0(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x4b0(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x64,%eax
jne    12bc <main+0x12c>
movl   $0x1,-0x4a4(%rbp)
jmp    130b <main+0x17b>
movsbl -0x60(%rbp),%eax
cmp    $0x0,%eax
jne    12eb <main+0x15b>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x4b0(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
jmp    1306 <main+0x176>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x4b0(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
jmp    130b <main+0x17b>
jmp    1310 <main+0x180>
mov    -0x4b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4b0(%rbp)
jmp    1221 <main+0x91>
lea    -0x4a0(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
jle    14df <main+0x34f>
lea    -0x60(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
jle    14df <main+0x34f>
lea    -0xa0(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
jle    14df <main+0x34f>
lea    -0x60(%rbp),%rdi
lea    0xc95(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    139f <main+0x20f>
mov    0x2c5b(%rip),%rax
mov    (%rax),%edi
lea    0xc74(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1522 <main+0x392>
lea    -0xa0(%rbp),%rdi
lea    0xc73(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    13e1 <main+0x251>
mov    0x2c19(%rip),%rax
mov    (%rax),%edi
lea    0xc52(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1522 <main+0x392>
movl   $0x0,-0x4b0(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %eax,-0x4a8(%rbp)
cmpl   $0x0,-0x4a8(%rbp)
jge    140c <main+0x27c>
jmp    14c8 <main+0x338>
mov    -0x4b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4b0(%rbp)
cmpl   $0x1,-0x4a4(%rbp)
jge    1453 <main+0x2c3>
mov    -0x4a8(%rbp),%eax
add    -0x4ac(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4a8(%rbp)
mov    -0x4a8(%rbp),%eax
mov    %eax,-0x4ac(%rbp)
jmp    147f <main+0x2ef>
mov    -0x4a8(%rbp),%eax
sub    -0x4ac(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4a8(%rbp)
mov    -0x4a8(%rbp),%eax
add    -0x4ac(%rbp),%eax
mov    %eax,-0x4ac(%rbp)
lea    -0x4a0(%rbp),%rdi
call   1050 <strlen@plt>
cmp    -0x4b0(%rbp),%eax
jle    14b4 <main+0x324>
mov    -0x4ac(%rbp),%eax
movslq -0x4b0(%rbp),%rcx
movsbl -0x4a0(%rbp,%rcx,1),%ecx
ff
add    %ecx,%eax
mov    %eax,-0x4ac(%rbp)
mov    -0x4a8(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1090 <fputc@plt>
jmp    13eb <main+0x25b>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
jmp    151b <main+0x38b>
lea    0xb59(%rip),%rdi
call   1060 <printf@plt>
lea    0xb85(%rip),%rdi
call   1060 <printf@plt>
lea    0xba5(%rip),%rdi
call   1060 <printf@plt>
lea    0xbab(%rip),%rdi
call   1060 <printf@plt>
lea    0xbb0(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x488,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
lea    0x80(%rsp),%rdi
xor    %r13d,%r13d
mov    $0x400,%edx
xor    %esi,%esi
call   1070 <memset@plt>
cmp    $0x2,%ebp
jl     1267 <main+0xd7>
xor    %r13d,%r13d
mov    $0x1,%r15d
mov    $0x1,%r14d
jmp    120f <main+0x7f>
nopl   (%rax)
cmp    $0x64,%al
cmove  %r15d,%r13d
add    $0x1,%r14d
cmp    %ebp,%r14d
jge    1267 <main+0xd7>
movslq %r14d,%r12
mov    (%rbx,%r12,8),%rsi
cmpb   $0x2d,(%rsi)
jne    1250 <main+0xc0>
movzbl 0x1(%rsi),%eax
cmp    $0x6b,%al
jne    1200 <main+0x70>
lea    0x1(%r12),%r14d
mov    0x8(%rbx,%r12,8),%rsi
lea    0x80(%rsp),%rdi
call   1030 <strcpy@plt>
mov    0x8(%rbx,%r12,8),%rax
movzbl 0x1(%rax),%eax
jmp    1200 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x0,(%rsp)
je     125d <main+0xcd>
lea    0x40(%rsp),%rdi
jmp    1260 <main+0xd0>
mov    %rsp,%rdi
call   1030 <strcpy@plt>
jmp    1206 <main+0x76>
lea    0x80(%rsp),%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    1368 <main+0x1d8>
mov    %rsp,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    1368 <main+0x1d8>
lea    0x40(%rsp),%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    1368 <main+0x1d8>
lea    0xd5b(%rip),%rsi
mov    %rsp,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13ca <main+0x23a>
mov    %rax,%r12
lea    0xd60(%rip),%rsi
lea    0x40(%rsp),%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13dc <main+0x24c>
mov    %rax,%r14
mov    %r12,%rdi
call   1080 <fgetc@plt>
test   %eax,%eax
js     13b8 <main+0x228>
xor    %r15d,%r15d
mov    $0x1,%ebx
jmp    130e <main+0x17e>
mov    %ebp,%edi
mov    %r14,%rsi
call   1090 <fputc@plt>
mov    %r12,%rdi
call   1080 <fgetc@plt>
add    $0x1,%rbx
test   %eax,%eax
js     13b8 <main+0x228>
test   %r13d,%r13d
jle    1330 <main+0x1a0>
sub    %r15d,%eax
lea    0xff(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffff00,%ecx
sub    %ecx,%eax
add    %eax,%r15d
mov    %eax,%ebp
jmp    134a <main+0x1ba>
mov    %eax,%ebp
add    %r15d,%ebp
lea    0xff(%rax,%r15,1),%eax
cmovns %ebp,%eax
and    $0xffffff00,%eax
sub    %eax,%ebp
mov    %ebp,%r15d
lea    0x80(%rsp),%rdi
call   1060 <strlen@plt>
cmp    %ebx,%eax
jle    12f0 <main+0x160>
movsbl 0x80(%rsp,%rbx,1),%eax
add    %eax,%r15d
jmp    12f0 <main+0x160>
lea    0xcd0(%rip),%rdi
call   1040 <puts@plt>
lea    0xcfb(%rip),%rdi
call   1040 <puts@plt>
lea    0xd1a(%rip),%rdi
call   1040 <puts@plt>
lea    0xd1f(%rip),%rdi
call   1040 <puts@plt>
lea    0xd23(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x488,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
jmp    13a4 <main+0x214>
mov    0x2c0f(%rip),%rax
mov    (%rax),%edi
lea    0xc28(%rip),%rsi
jmp    13ec <main+0x25c>
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
lea    0xc36(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    13a6 <main+0x216>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Error: input file not found.\0A\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [29 x i8] c"Error: output file problem.\0A\00"
@.str.4 = [56 x i8] c"Copyright (C) 2013 by Ubaldo Porcheddu <ubaldo@eja.it>\0A\00"
@.str.5 = [44 x i8] c"Usage: qua [OPTIONS] [FILE_IN] [FILE_OUT]\0A\0A\00"
@.str.6 = [18 x i8] c" -k key keycode\0A\00"
@.str.7 = [17 x i8] c" -d decode\0A\00"
@.str.8 = [21 x i8] c" -h this help\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 [64 x i8]
%9 = alloca [64 x i8]
%10 = alloca [1024 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
store i32* null, i32** %7
%15 = bitcast [64 x i8]* %8 to i8*
%16 = bitcast [64 x i8]* %9 to i8*
%17 = bitcast [1024 x i8]* %10 to i8*
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 1, i32* %14
br label %18
18: ; preds = %88, %2
%19 = load i32, i32* %14
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %91
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = load i32, i32* %14
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 45
br i1 %31, label %32, label %65
32: ; preds = %22
%33 = load i8**, i8*** %5
%34 = load i32, i32* %14
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 107
br i1 %41, label %42, label %53
42: ; preds = %32
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%44 = load i8**, i8*** %5
%45 = load i32, i32* %14
%46 = add nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %44, i64 %47
%49 = load i8*, i8** %48
%50 = call i32 @strcpy(i8* %43, i8* %49)
%51 = load i32, i32* %14
%52 = add nsw i32 %51, 1
store i32 %52, i32* %14
br label %53
53: ; preds = %42, %32
%54 = load i8**, i8*** %5
%55 = load i32, i32* %14
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = getelementptr inbounds i8, i8* %58, i64 1
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 100
br i1 %62, label %63, label %64
63: ; preds = %53
store i32 1, i32* %11
br label %64
64: ; preds = %63, %53
br label %87
65: ; preds = %22
%66 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %78
70: ; preds = %65
%71 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%72 = load i8**, i8*** %5
%73 = load i32, i32* %14
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8*, i8** %72, i64 %74
%76 = load i8*, i8** %75
%77 = call i32 @strcpy(i8* %71, i8* %76)
br label %86
78: ; preds = %65
%79 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%80 = load i8**, i8*** %5
%81 = load i32, i32* %14
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8*, i8** %80, i64 %82
%84 = load i8*, i8** %83
%85 = call i32 @strcpy(i8* %79, i8* %84)
br label %86
86: ; preds = %78, %70
br label %87
87: ; preds = %86, %64
br label %88
88: ; preds = %87
%89 = load i32, i32* %14
%90 = add nsw i32 %89, 1
store i32 %90, i32* %14
br label %18
91: ; preds = %18
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%93 = call i32 @strlen(i8* %92)
%94 = icmp sgt i32 %93, 0
br i1 %94, label %95, label %165
95: ; preds = %91
%96 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%97 = call i32 @strlen(i8* %96)
%98 = icmp sgt i32 %97, 0
br i1 %98, label %99, label %165
99: ; preds = %95
%100 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%101 = call i32 @strlen(i8* %100)
%102 = icmp sgt i32 %101, 0
br i1 %102, label %103, label %165
103: ; preds = %99
%104 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%105 = call i32* @fopen(i8* %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %105, i32** %6
%106 = icmp eq i32* %105, null
br i1 %106, label %107, label %110
107: ; preds = %103
%108 = load i32, i32* @stderr
%109 = call i32 @fprintf(i32 %108, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %172
110: ; preds = %103
%111 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%112 = call i32* @fopen(i8* %111, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %112, i32** %7
%113 = icmp eq i32* %112, null
br i1 %113, label %114, label %117
114: ; preds = %110
%115 = load i32, i32* @stderr
%116 = call i32 @fprintf(i32 %115, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %172
117: ; preds = %110
store i32 0, i32* %14
br label %118
118: ; preds = %117, %156
%119 = load i32*, i32** %6
%120 = call i32 @fgetc(i32* %119)
store i32 %120, i32* %12
%121 = load i32, i32* %12
%122 = icmp slt i32 %121, 0
br i1 %122, label %123, label %124
123: ; preds = %118
br label %160
124: ; preds = %118
%125 = load i32, i32* %14
%126 = add nsw i32 %125, 1
store i32 %126, i32* %14
%127 = load i32, i32* %11
%128 = icmp slt i32 %127, 1
br i1 %128, label %129, label %135
129: ; preds = %124
%130 = load i32, i32* %12
%131 = load i32, i32* %13
%132 = add nsw i32 %130, %131
%133 = srem i32 %132, 256
store i32 %133, i32* %12
%134 = load i32, i32* %12
store i32 %134, i32* %13
br label %143
135: ; preds = %124
%136 = load i32, i32* %12
%137 = load i32, i32* %13
%138 = sub nsw i32 %136, %137
%139 = srem i32 %138, 256
store i32 %139, i32* %12
%140 = load i32, i32* %12
%141 = load i32, i32* %13
%142 = add nsw i32 %140, %141
store i32 %142, i32* %13
br label %143
143: ; preds = %135, %129
%144 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%145 = call i32 @strlen(i8* %144)
%146 = load i32, i32* %14
%147 = icmp sgt i32 %145, %146
br i1 %147, label %148, label %156
148: ; preds = %143
%149 = load i32, i32* %13
%150 = load i32, i32* %14
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 %151
%153 = load i8, i8* %152
%154 = sext i8 %153 to i32
%155 = add nsw i32 %149, %154
store i32 %155, i32* %13
br label %156
156: ; preds = %148, %143
%157 = load i32, i32* %12
%158 = load i32*, i32** %7
%159 = call i32 @fputc(i32 %157, i32* %158)
br label %118
160: ; preds = %123
%161 = load i32*, i32** %6
%162 = call i32 @fclose(i32* %161)
%163 = load i32*, i32** %7
%164 = call i32 @fclose(i32* %163)
br label %171
165: ; preds = %99, %95, %91
%166 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0))
%167 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
%168 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%169 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%170 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
br label %171
171: ; preds = %165, %160
store i32 0, i32* %3
br label %172
172: ; preds = %171, %114, %107
%173 = load i32, i32* %3
ret i32 %173
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Error: input file not found.\0A\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [29 x i8] c"Error: output file problem.\0A\00"
@str = [55 x i8] c"Copyright (C) 2013 by Ubaldo Porcheddu <ubaldo@eja.it>\00"
@str.9 = [43 x i8] c"Usage: qua [OPTIONS] [FILE_IN] [FILE_OUT]\0A\00"
@str.10 = [17 x i8] c" -k key keycode\00"
@str.11 = [16 x i8] c" -d decode\00"
@str.12 = [20 x i8] c" -h this help\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [64 x i8]
%4 = alloca [64 x i8]
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %48
10: ; preds = %2, %43
%11 = phi i32 [ %46, %43 ], [ 1, %2 ]
%12 = phi i32 [ %44, %43 ], [ 0, %2 ]
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 45
br i1 %17, label %18, label %36
18: ; preds = %10
%19 = getelementptr inbounds i8, i8* %15, i64 1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 107
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = add nsw i32 %11, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @strcpy(i8* %8, i8* %26)
%28 = load i8*, i8** %25
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8, i8* %29
br label %31
31: ; preds = %22, %18
%32 = phi i8 [ %30, %22 ], [ %20, %18 ]
%33 = phi i32 [ %23, %22 ], [ %11, %18 ]
%34 = icmp eq i8 %32, 100
%35 = select i1 %34, i32 1, i32 %12
br label %43
36: ; preds = %10
%37 = load i8, i8* %6
%38 = icmp eq i8 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 @strcpy(i8* %6, i8* %15)
br label %43
41: ; preds = %36
%42 = call i32 @strcpy(i8* %7, i8* %15)
br label %43
43: ; preds = %31, %41, %39
%44 = phi i32 [ %12, %39 ], [ %12, %41 ], [ %35, %31 ]
%45 = phi i32 [ %11, %39 ], [ %11, %41 ], [ %33, %31 ]
%46 = add nsw i32 %45, 1
%47 = icmp slt i32 %46, %0
br i1 %47, label %10, label %48
48: ; preds = %43, %2
%49 = phi i32 [ 0, %2 ], [ %44, %43 ]
%50 = call i32 @strlen(i8* %8)
%51 = icmp sgt i32 %50, 0
br i1 %51, label %52, label %106
52: ; preds = %48
%53 = call i32 @strlen(i8* %6)
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %106
55: ; preds = %52
%56 = call i32 @strlen(i8* %7)
%57 = icmp sgt i32 %56, 0
br i1 %57, label %58, label %106
58: ; preds = %55
%59 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%60 = icmp eq i32* %59, null
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %112
64: ; preds = %58
%65 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%66 = icmp eq i32* %65, null
br i1 %66, label %72, label %67
67: ; preds = %64
%68 = call i32 @fgetc(i32* %59)
%69 = icmp slt i32 %68, 0
br i1 %69, label %103, label %70
70: ; preds = %67
%71 = icmp slt i32 %49, 1
br label %75
72: ; preds = %64
%73 = load i32, i32* @stderr
%74 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %112
75: ; preds = %70, %98
%76 = phi i64 [ 0, %70 ], [ %79, %98 ]
%77 = phi i32 [ %68, %70 ], [ %101, %98 ]
%78 = phi i32 [ 0, %70 ], [ %99, %98 ]
%79 = add nuw i64 %76, 1
br i1 %71, label %80, label %83
80: ; preds = %75
%81 = add nsw i32 %77, %78
%82 = srem i32 %81, 256
br label %87
83: ; preds = %75
%84 = sub nsw i32 %77, %78
%85 = srem i32 %84, 256
%86 = add nsw i32 %85, %78
br label %87
87: ; preds = %83, %80
%88 = phi i32 [ %82, %80 ], [ %85, %83 ]
%89 = phi i32 [ %82, %80 ], [ %86, %83 ]
%90 = call i32 @strlen(i8* %8)
%91 = trunc i64 %79 to i32
%92 = icmp sgt i32 %90, %91
br i1 %92, label %93, label %98
93: ; preds = %87
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %79
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = add nsw i32 %89, %96
br label %98
98: ; preds = %93, %87
%99 = phi i32 [ %97, %93 ], [ %89, %87 ]
%100 = call i32 @fputc(i32 %88, i32* %65)
%101 = call i32 @fgetc(i32* %59)
%102 = icmp slt i32 %101, 0
br i1 %102, label %103, label %75
103: ; preds = %98, %67
%104 = call i32 @fclose(i32* %59)
%105 = call i32 @fclose(i32* %65)
br label %112
106: ; preds = %55, %52, %48
%107 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%108 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.9, i64 0, i64 0))
%109 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.10, i64 0, i64 0))
%110 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
%111 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.12, i64 0, i64 0))
br label %112
112: ; preds = %103, %106, %72, %61
%113 = phi i32 [ -1, %61 ], [ -1, %72 ], [ 0, %106 ], [ 0, %103 ]
ret i32 %113
}