#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 EOF;
int EXIT_FAILURE;
int EXIT_SUCCESS;
char _rotr(char, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputc(unsigned char, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int getopt(int, char **, char *);
char *malloc(unsigned int);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
unsigned int strlen(int /*<<< orphan*/);
int /*<<< orphan*/ strncpy(char *, char *, unsigned int);
char *strndup(int /*<<< orphan*/, int);
int main(int argc, char *argv[]) {
  FILE *in = stdin;
  FILE *out = stdout;
  char *key;
  char *newkey;
  unsigned int key_index = 0;
  unsigned int key_length = 0;
  int readed_byte;
  unsigned char read_byte;
  unsigned short int silent = 0;
  int c;
  while ((c = getopt(argc, argv, "i:o:k:hs")) != -1) {
    switch (c) {
    case 'i':
      if (in != stdin) {
        fclose(in);
      }
      in = fopen(optarg, "rb");
      break;
    case 'o':
      if (out != stdout) {
        fclose(out);
      }
      out = fopen(optarg, "wb");
      break;
    case 'k':
      key = strndup(optarg, 255);
      key_length = strlen(optarg);
      if (key_length > 255) {
        key_length = 255;
        fprintf(stderr, "too long truncated\n");
      }
      break;
    case 's':
      silent = 1;
      break;
    case 'h':
      return EXIT_SUCCESS;
    }
  }
  if (key == NULL) {
    fprintf(stderr, "WTF ?\n");
    return EXIT_FAILURE;
  }
  if (silent == 1) {
    char *oldkey;
    oldkey = (char *)malloc(255);
    if (key_length > 8) {
      key_length = 8;
    }
    strncpy(oldkey, key, key_length);
    newkey = malloc(key_length * 8);
    for (int i = 0; i < (key_length * 8); i++) {
      newkey[i] = (unsigned char)((oldkey[i % key_length] ^
                                   (_rotr(oldkey[i % key_length], (i % 8)))) &
                                  0xFF);
    }
    newkey[0x00] = oldkey[0];
    newkey[0x08] = oldkey[1];
    newkey[0x10] = oldkey[2];
    newkey[0x18] = oldkey[3];
    newkey[0x20] = oldkey[4];
    newkey[0x28] = oldkey[5];
    newkey[0x30] = oldkey[6];
    newkey[0x38] = oldkey[7];
    key_length = key_length * 8;
    free(oldkey);
  }
  while ((readed_byte = fgetc(in)) != EOF) {
    read_byte = (unsigned char)readed_byte;
    if (silent == 1) {
      fputc(read_byte ^ (unsigned char)newkey[key_index], out);
    } else {
      fputc(read_byte ^ (unsigned char)key[key_index], out);
    }
    key_index++;
    key_index = key_index % key_length;
  }
  return EXIT_SUCCESS;
}


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)
mov    0x2e00(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2dca(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movw   $0x0,-0x40(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe19(%rip),%rdx
call   10e0 <getopt@plt>
mov    %eax,-0x44(%rbp)
cmp    $0xffffffff,%eax
je     133e <main+0x17e>
mov    -0x44(%rbp),%eax
add    $0xffffff98,%eax
mov    %eax,%ecx
mov    %rcx,-0x60(%rbp)
sub    $0xb,%eax
ja     1339 <main+0x179>
mov    -0x60(%rbp),%rax
lea    0xdb8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
mov    0x2d84(%rip),%rcx
cmp    (%rcx),%rax
je     126e <main+0xae>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
lea    0xdbb(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
jmp    1339 <main+0x179>
mov    -0x20(%rbp),%rax
mov    0x2d21(%rip),%rcx
cmp    (%rcx),%rax
je     12a9 <main+0xe9>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x20(%rbp)
jmp    1339 <main+0x179>
mov    0x2d2a(%rip),%rax
mov    (%rax),%edi
mov    $0xff,%esi
call   10a0 <strndup@plt>
mov    %rax,-0x28(%rbp)
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
call   1060 <strlen@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xff,-0x38(%rbp)
jbe    1318 <main+0x158>
movl   $0xff,-0x38(%rbp)
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
lea    0xd2c(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    1339 <main+0x179>
movw   $0x1,-0x40(%rbp)
jmp    1339 <main+0x179>
mov    0x2c81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1564 <main+0x3a4>
jmp    1209 <main+0x49>
cmpq   $0x0,-0x28(%rbp)
jne    136f <main+0x1af>
mov    0x2c78(%rip),%rax
mov    (%rax),%edi
lea    0xcfa(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2c5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1564 <main+0x3a4>
movzwl -0x40(%rbp),%eax
cmp    $0x1,%eax
jne    14cd <main+0x30d>
mov    $0xff,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpl   $0x8,-0x38(%rbp)
jbe    139b <main+0x1db>
movl   $0x8,-0x38(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x38(%rbp),%edi
shl    $0x3,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    -0x38(%rbp),%ecx
shl    $0x3,%ecx
cmp    %ecx,%eax
jae    144d <main+0x28d>
mov    -0x50(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x54(%rbp),%eax
xor    %edx,%edx
divl   -0x38(%rbp)
mov    -0x78(%rbp),%rax
mov    %edx,%ecx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x64(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x54(%rbp),%eax
xor    %edx,%edx
divl   -0x38(%rbp)
mov    -0x70(%rbp),%rax
mov    %edx,%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x65(%rbp)
mov    -0x54(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x65(%rbp),%al
mov    %edx,%esi
movsbl %al,%edi
call   1070 <_rotr@plt>
mov    %al,%cl
mov    -0x64(%rbp),%eax
movsbl %cl,%ecx
xor    %ecx,%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    13c1 <main+0x201>
mov    -0x50(%rbp),%rax
mov    (%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
mov    -0x50(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,0x8(%rax)
mov    -0x50(%rbp),%rax
mov    0x2(%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,0x10(%rax)
mov    -0x50(%rbp),%rax
mov    0x3(%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,0x18(%rax)
mov    -0x50(%rbp),%rax
mov    0x4(%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,0x20(%rax)
mov    -0x50(%rbp),%rax
mov    0x5(%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,0x28(%rax)
mov    -0x50(%rbp),%rax
mov    0x6(%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,0x30(%rax)
mov    -0x50(%rbp),%rax
mov    0x7(%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,0x38(%rax)
mov    -0x38(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x38(%rbp)
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
jmp    14d2 <main+0x312>
mov    -0x18(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %eax,-0x3c(%rbp)
mov    0x2af3(%rip),%rcx
cmp    (%rcx),%eax
je     1558 <main+0x398>
mov    -0x3c(%rbp),%eax
mov    %al,-0x3d(%rbp)
movzwl -0x40(%rbp),%eax
cmp    $0x1,%eax
jne    1522 <main+0x362>
movzbl -0x3d(%rbp),%eax
mov    -0x30(%rbp),%rcx
mov    -0x34(%rbp),%edx
movzbl (%rcx,%rdx,1),%ecx
xor    %ecx,%eax
mov    -0x20(%rbp),%rsi
movzbl %al,%edi
call   1090 <fputc@plt>
jmp    153f <main+0x37f>
movzbl -0x3d(%rbp),%eax
mov    -0x28(%rbp),%rcx
mov    -0x34(%rbp),%edx
movzbl (%rcx,%rdx,1),%ecx
xor    %ecx,%eax
mov    -0x20(%rbp),%rsi
movzbl %al,%edi
call   1090 <fputc@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
xor    %edx,%edx
divl   -0x38(%rbp)
mov    %edx,-0x34(%rbp)
jmp    14d2 <main+0x312>
mov    0x2a51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-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    $0x18,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
mov    0x2e06(%rip),%rax
mov    (%rax),%r12
mov    0x2dd4(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
lea    0xe3b(%rip),%r14
lea    0xe04(%rip),%r15
movl   $0x0,0x8(%rsp)
mov    %eax,0x4(%rsp)
jmp    1219 <main+0x59>
nopw   0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     12f6 <main+0x136>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r14,%rdx
call   10e0 <getopt@plt>
lea    -0x68(%rax),%ecx
cmp    $0xb,%ecx
ja     1210 <main+0x50>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
mov    0x2da2(%rip),%rax
cmp    (%rax),%r12
je     124b <main+0x8b>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
lea    0xdde(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%r12
jmp    1219 <main+0x59>
mov    0x2d8c(%rip),%r13
mov    0x0(%r13),%edi
mov    $0xff,%esi
call   10a0 <strndup@plt>
mov    0x0(%r13),%edi
mov    %rax,%r13
call   1060 <strlen@plt>
cmp    $0x100,%eax
jb     1204 <main+0x44>
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
lea    0xd9e(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0xff,%eax
mov    %eax,0x4(%rsp)
jmp    1219 <main+0x59>
mov    0x10(%rsp),%rdi
mov    0x2cf8(%rip),%rax
cmp    (%rax),%rdi
je     12ca <main+0x10a>
call   1050 <fclose@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
lea    0xd62(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,0x10(%rsp)
jmp    1219 <main+0x59>
mov    $0x1,%ax
mov    %eax,0x8(%rsp)
jmp    1219 <main+0x59>
test   %r13,%r13
je     1453 <main+0x293>
cmpw   $0x1,0x8(%rsp)
jne    13e5 <main+0x225>
mov    %r12,0x8(%rsp)
mov    $0xff,%edi
call   10c0 <malloc@plt>
mov    %rax,%r14
mov    0x4(%rsp),%eax
cmp    $0x8,%eax
mov    $0x8,%ebp
cmovb  %eax,%ebp
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1040 <strncpy@plt>
lea    0x0(,%rbp,8),%edi
mov    %edi,0x4(%rsp)
call   10c0 <malloc@plt>
mov    %rax,%r13
test   %ebp,%ebp
je     1399 <main+0x1d9>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
mov    $0x1,%r12d
cmovae %eax,%r12d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
movsbl (%r14,%rdx,1),%r15d
mov    %ebx,%esi
and    $0x7,%esi
mov    %r15d,%edi
call   1070 <_rotr@plt>
xor    %r15b,%al
mov    %al,0x0(%r13,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1370 <main+0x1b0>
mov    (%r14),%al
mov    %al,0x0(%r13)
mov    0x1(%r14),%al
mov    %al,0x8(%r13)
mov    0x2(%r14),%al
mov    %al,0x10(%r13)
mov    0x3(%r14),%al
mov    %al,0x18(%r13)
mov    0x4(%r14),%al
mov    %al,0x20(%r13)
mov    0x5(%r14),%al
mov    %al,0x28(%r13)
mov    0x6(%r14),%al
mov    %al,0x30(%r13)
mov    0x7(%r14),%al
mov    %al,0x38(%r13)
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%r12
mov    0x10(%rsp),%rbp
mov    %r12,%rdi
call   1080 <fgetc@plt>
mov    0x2bdf(%rip),%r15
mov    0x2bb0(%rip),%rcx
cmp    (%r15),%eax
je     1442 <main+0x282>
xor    %ebx,%ebx
mov    0x4(%rsp),%r14d
nopl   0x0(%rax)
mov    %ebx,%ecx
xor    0x0(%r13,%rcx,1),%al
movzbl %al,%edi
mov    %rbp,%rsi
call   1090 <fputc@plt>
add    $0x1,%ebx
mov    %ebx,%eax
xor    %edx,%edx
div    %r14d
mov    %edx,%ebx
mov    %r12,%rdi
call   1080 <fgetc@plt>
cmp    (%r15),%eax
jne    1410 <main+0x250>
mov    0x2b6e(%rip),%rcx
mov    (%rcx),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b6e(%rip),%rax
mov    (%rax),%edi
lea    0xbf0(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2b51(%rip),%rcx
jmp    1442 <main+0x282>

LLVM IR (-O0):
@stdin = global i32* null
@stdout = global i32* null
@.str = [9 x i8] c"i:o:k:hs\00"
@optarg = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.3 = [20 x i8] c"too long truncated\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [7 x i8] c"WTF ?\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
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*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
%14 = alloca i16
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32*, i32** @stdin
store i32* %18, i32** %6
%19 = load i32*, i32** @stdout
store i32* %19, i32** %7
store i32 0, i32* %10
store i32 0, i32* %11
store i16 0, i16* %14
br label %20
20: ; preds = %61, %2
%21 = load i32, i32* %4
%22 = load i8**, i8*** %5
%23 = call i32 @getopt(i32 %21, i8** %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 %23, i32* %15
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %62
25: ; preds = %20
%26 = load i32, i32* %15
switch i32 %26, label %61 [
i32 105, label %27
i32 111, label %37
i32 107, label %47
i32 115, label %58
i32 104, label %59
]
27: ; preds = %25
%28 = load i32*, i32** %6
%29 = load i32*, i32** @stdin
%30 = icmp ne i32* %28, %29
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32*, i32** %6
%33 = call i32 @fclose(i32* %32)
br label %34
34: ; preds = %31, %27
%35 = load i32, i32* @optarg
%36 = call i32* @fopen(i32 %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %36, i32** %6
br label %61
37: ; preds = %25
%38 = load i32*, i32** %7
%39 = load i32*, i32** @stdout
%40 = icmp ne i32* %38, %39
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32*, i32** %7
%43 = call i32 @fclose(i32* %42)
br label %44
44: ; preds = %41, %37
%45 = load i32, i32* @optarg
%46 = call i32* @fopen(i32 %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %46, i32** %7
br label %61
47: ; preds = %25
%48 = load i32, i32* @optarg
%49 = call i8* @strndup(i32 %48, i32 255)
store i8* %49, i8** %8
%50 = load i32, i32* @optarg
%51 = call i32 @strlen(i32 %50)
store i32 %51, i32* %11
%52 = load i32, i32* %11
%53 = icmp ugt i32 %52, 255
br i1 %53, label %54, label %57
54: ; preds = %47
store i32 255, i32* %11
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %57
57: ; preds = %54, %47
br label %61
58: ; preds = %25
store i16 1, i16* %14
br label %61
59: ; preds = %25
%60 = load i32, i32* @EXIT_SUCCESS
store i32 %60, i32* %3
br label %212
61: ; preds = %25, %58, %57, %44, %34
br label %20
62: ; preds = %20
%63 = load i8*, i8** %8
%64 = icmp eq i8* %63, null
br i1 %64, label %65, label %69
65: ; preds = %62
%66 = load i32, i32* @stderr
%67 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%68 = load i32, i32* @EXIT_FAILURE
store i32 %68, i32* %3
br label %212
69: ; preds = %62
%70 = load i16, i16* %14
%71 = zext i16 %70 to i32
%72 = icmp eq i32 %71, 1
br i1 %72, label %73, label %166
73: ; preds = %69
%74 = call i8* @malloc(i32 255)
store i8* %74, i8** %16
%75 = load i32, i32* %11
%76 = icmp ugt i32 %75, 8
br i1 %76, label %77, label %78
77: ; preds = %73
store i32 8, i32* %11
br label %78
78: ; preds = %77, %73
%79 = load i8*, i8** %16
%80 = load i8*, i8** %8
%81 = load i32, i32* %11
%82 = call i32 @strncpy(i8* %79, i8* %80, i32 %81)
%83 = load i32, i32* %11
%84 = mul i32 %83, 8
%85 = call i8* @malloc(i32 %84)
store i8* %85, i8** %9
store i32 0, i32* %17
br label %86
86: ; preds = %118, %78
%87 = load i32, i32* %17
%88 = load i32, i32* %11
%89 = mul i32 %88, 8
%90 = icmp ult i32 %87, %89
br i1 %90, label %91, label %121
91: ; preds = %86
%92 = load i8*, i8** %16
%93 = load i32, i32* %17
%94 = load i32, i32* %11
%95 = urem i32 %93, %94
%96 = zext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %92, i64 %96
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = load i8*, i8** %16
%101 = load i32, i32* %17
%102 = load i32, i32* %11
%103 = urem i32 %101, %102
%104 = zext i32 %103 to i64
%105 = getelementptr inbounds i8, i8* %100, i64 %104
%106 = load i8, i8* %105
%107 = load i32, i32* %17
%108 = srem i32 %107, 8
%109 = call signext i8 @_rotr(i8 signext %106, i32 %108)
%110 = sext i8 %109 to i32
%111 = xor i32 %99, %110
%112 = and i32 %111, 255
%113 = trunc i32 %112 to i8
%114 = load i8*, i8** %9
%115 = load i32, i32* %17
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %114, i64 %116
store i8 %113, i8* %117
br label %118
118: ; preds = %91
%119 = load i32, i32* %17
%120 = add nsw i32 %119, 1
store i32 %120, i32* %17
br label %86
121: ; preds = %86
%122 = load i8*, i8** %16
%123 = getelementptr inbounds i8, i8* %122, i64 0
%124 = load i8, i8* %123
%125 = load i8*, i8** %9
%126 = getelementptr inbounds i8, i8* %125, i64 0
store i8 %124, i8* %126
%127 = load i8*, i8** %16
%128 = getelementptr inbounds i8, i8* %127, i64 1
%129 = load i8, i8* %128
%130 = load i8*, i8** %9
%131 = getelementptr inbounds i8, i8* %130, i64 8
store i8 %129, i8* %131
%132 = load i8*, i8** %16
%133 = getelementptr inbounds i8, i8* %132, i64 2
%134 = load i8, i8* %133
%135 = load i8*, i8** %9
%136 = getelementptr inbounds i8, i8* %135, i64 16
store i8 %134, i8* %136
%137 = load i8*, i8** %16
%138 = getelementptr inbounds i8, i8* %137, i64 3
%139 = load i8, i8* %138
%140 = load i8*, i8** %9
%141 = getelementptr inbounds i8, i8* %140, i64 24
store i8 %139, i8* %141
%142 = load i8*, i8** %16
%143 = getelementptr inbounds i8, i8* %142, i64 4
%144 = load i8, i8* %143
%145 = load i8*, i8** %9
%146 = getelementptr inbounds i8, i8* %145, i64 32
store i8 %144, i8* %146
%147 = load i8*, i8** %16
%148 = getelementptr inbounds i8, i8* %147, i64 5
%149 = load i8, i8* %148
%150 = load i8*, i8** %9
%151 = getelementptr inbounds i8, i8* %150, i64 40
store i8 %149, i8* %151
%152 = load i8*, i8** %16
%153 = getelementptr inbounds i8, i8* %152, i64 6
%154 = load i8, i8* %153
%155 = load i8*, i8** %9
%156 = getelementptr inbounds i8, i8* %155, i64 48
store i8 %154, i8* %156
%157 = load i8*, i8** %16
%158 = getelementptr inbounds i8, i8* %157, i64 7
%159 = load i8, i8* %158
%160 = load i8*, i8** %9
%161 = getelementptr inbounds i8, i8* %160, i64 56
store i8 %159, i8* %161
%162 = load i32, i32* %11
%163 = mul i32 %162, 8
store i32 %163, i32* %11
%164 = load i8*, i8** %16
%165 = call i32 @free(i8* %164)
br label %166
166: ; preds = %121, %69
br label %167
167: ; preds = %204, %166
%168 = load i32*, i32** %6
%169 = call i32 @fgetc(i32* %168)
store i32 %169, i32* %12
%170 = load i32, i32* @EOF
%171 = icmp ne i32 %169, %170
br i1 %171, label %172, label %210
172: ; preds = %167
%173 = load i32, i32* %12
%174 = trunc i32 %173 to i8
store i8 %174, i8* %13
%175 = load i16, i16* %14
%176 = zext i16 %175 to i32
%177 = icmp eq i32 %176, 1
br i1 %177, label %178, label %191
178: ; preds = %172
%179 = load i8, i8* %13
%180 = zext i8 %179 to i32
%181 = load i8*, i8** %9
%182 = load i32, i32* %10
%183 = zext i32 %182 to i64
%184 = getelementptr inbounds i8, i8* %181, i64 %183
%185 = load i8, i8* %184
%186 = zext i8 %185 to i32
%187 = xor i32 %180, %186
%188 = trunc i32 %187 to i8
%189 = load i32*, i32** %7
%190 = call i32 @fputc(i8 zeroext %188, i32* %189)
br label %204
191: ; preds = %172
%192 = load i8, i8* %13
%193 = zext i8 %192 to i32
%194 = load i8*, i8** %8
%195 = load i32, i32* %10
%196 = zext i32 %195 to i64
%197 = getelementptr inbounds i8, i8* %194, i64 %196
%198 = load i8, i8* %197
%199 = zext i8 %198 to i32
%200 = xor i32 %193, %199
%201 = trunc i32 %200 to i8
%202 = load i32*, i32** %7
%203 = call i32 @fputc(i8 zeroext %201, i32* %202)
br label %204
204: ; preds = %191, %178
%205 = load i32, i32* %10
%206 = add i32 %205, 1
store i32 %206, i32* %10
%207 = load i32, i32* %10
%208 = load i32, i32* %11
%209 = urem i32 %207, %208
store i32 %209, i32* %10
br label %167
210: ; preds = %167
%211 = load i32, i32* @EXIT_SUCCESS
store i32 %211, i32* %3
br label %212
212: ; preds = %210, %65, %59
%213 = load i32, i32* %3
ret i32 %213
}

LLVM IR (-O2):
@stdin = global i32* null
@stdout = global i32* null
@.str = [9 x i8] c"i:o:k:hs\00"
@optarg = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [3 x i8] c"wb\00"
@stderr = global i32 0
@.str.3 = [20 x i8] c"too long truncated\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [7 x i8] c"WTF ?\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = load i32*, i32** @stdin
%4 = load i32*, i32** @stdout
br label %5
5: ; preds = %47, %2
%6 = phi i32 [ 0, %2 ], [ %48, %47 ]
%7 = phi i8* [ undef, %2 ], [ %40, %47 ]
%8 = phi i32* [ %4, %2 ], [ %12, %47 ]
%9 = phi i16 [ 0, %2 ], [ %16, %47 ]
%10 = phi i32* [ %3, %2 ], [ %19, %47 ]
br label %11
11: ; preds = %5, %35
%12 = phi i32* [ %8, %5 ], [ %37, %35 ]
%13 = phi i16 [ %9, %5 ], [ %16, %35 ]
%14 = phi i32* [ %10, %5 ], [ %19, %35 ]
br label %15
15: ; preds = %20, %11
%16 = phi i16 [ %13, %11 ], [ 1, %20 ]
%17 = phi i32* [ %14, %11 ], [ %19, %20 ]
br label %18
18: ; preds = %15, %27
%19 = phi i32* [ %17, %15 ], [ %29, %27 ]
br label %20
20: ; preds = %18, %20
%21 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
switch i32 %21, label %20 [
i32 -1, label %49
i32 105, label %22
i32 111, label %30
i32 107, label %38
i32 115, label %15
i32 104, label %124
]
22: ; preds = %20
%23 = load i32*, i32** @stdin
%24 = icmp eq i32* %19, %23
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 @fclose(i32* %19)
br label %27
27: ; preds = %25, %22
%28 = load i32, i32* @optarg
%29 = tail call i32* @fopen(i32 %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %18
30: ; preds = %20
%31 = load i32*, i32** @stdout
%32 = icmp eq i32* %12, %31
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = tail call i32 @fclose(i32* %12)
br label %35
35: ; preds = %33, %30
%36 = load i32, i32* @optarg
%37 = tail call i32* @fopen(i32 %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %11
38: ; preds = %20
%39 = load i32, i32* @optarg
%40 = tail call i8* @strndup(i32 %39, i32 255)
%41 = load i32, i32* @optarg
%42 = tail call i32 @strlen(i32 %41)
%43 = icmp ugt i32 %42, 255
br i1 %43, label %44, label %47
44: ; preds = %38
%45 = load i32, i32* @stderr
%46 = tail call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %44, %38
%48 = phi i32 [ %42, %38 ], [ 255, %44 ]
br label %5
49: ; preds = %20
%50 = icmp eq i8* %7, null
br i1 %50, label %51, label %54
51: ; preds = %49
%52 = load i32, i32* @stderr
%53 = tail call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %124
54: ; preds = %49
%55 = icmp eq i16 %16, 1
br i1 %55, label %56, label %104
56: ; preds = %54
%57 = tail call dereferenceable_or_null(255) i8* @malloc(i32 255)
%58 = icmp ult i32 %6, 8
%59 = select i1 %58, i32 %6, i32 8
%60 = tail call i32 @strncpy(i8* %57, i8* %7, i32 %59)
%61 = shl nuw nsw i32 %59, 3
%62 = tail call i8* @malloc(i32 %61)
%63 = icmp eq i32 %59, 0
br i1 %63, label %67, label %64
64: ; preds = %56
%65 = call i32 @llvm.umax.i32(i32 %61, i32 1)
%66 = zext i32 %65 to i64
br label %91
67: ; preds = %91, %56
%68 = load i8, i8* %57
store i8 %68, i8* %62
%69 = getelementptr inbounds i8, i8* %57, i64 1
%70 = load i8, i8* %69
%71 = getelementptr inbounds i8, i8* %62, i64 8
store i8 %70, i8* %71
%72 = getelementptr inbounds i8, i8* %57, i64 2
%73 = load i8, i8* %72
%74 = getelementptr inbounds i8, i8* %62, i64 16
store i8 %73, i8* %74
%75 = getelementptr inbounds i8, i8* %57, i64 3
%76 = load i8, i8* %75
%77 = getelementptr inbounds i8, i8* %62, i64 24
store i8 %76, i8* %77
%78 = getelementptr inbounds i8, i8* %57, i64 4
%79 = load i8, i8* %78
%80 = getelementptr inbounds i8, i8* %62, i64 32
store i8 %79, i8* %80
%81 = getelementptr inbounds i8, i8* %57, i64 5
%82 = load i8, i8* %81
%83 = getelementptr inbounds i8, i8* %62, i64 40
store i8 %82, i8* %83
%84 = getelementptr inbounds i8, i8* %57, i64 6
%85 = load i8, i8* %84
%86 = getelementptr inbounds i8, i8* %62, i64 48
store i8 %85, i8* %86
%87 = getelementptr inbounds i8, i8* %57, i64 7
%88 = load i8, i8* %87
%89 = getelementptr inbounds i8, i8* %62, i64 56
store i8 %88, i8* %89
%90 = tail call i32 @free(i8* %57)
br label %104
91: ; preds = %64, %91
%92 = phi i64 [ 0, %64 ], [ %102, %91 ]
%93 = trunc i64 %92 to i32
%94 = urem i32 %93, %59
%95 = zext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %57, i64 %95
%97 = load i8, i8* %96
%98 = and i32 %93, 7
%99 = tail call signext i8 @_rotr(i8 signext %97, i32 %98)
%100 = xor i8 %99, %97
%101 = getelementptr inbounds i8, i8* %62, i64 %92
store i8 %100, i8* %101
%102 = add nuw nsw i64 %92, 1
%103 = icmp eq i64 %102, %66
br i1 %103, label %67, label %91
104: ; preds = %67, %54
%105 = phi i8* [ %62, %67 ], [ %7, %54 ]
%106 = phi i32 [ %61, %67 ], [ %6, %54 ]
%107 = tail call i32 @fgetc(i32* %19)
%108 = load i32, i32* @EOF
%109 = icmp eq i32 %107, %108
br i1 %109, label %124, label %110
110: ; preds = %104, %110
%111 = phi i32 [ %121, %110 ], [ %107, %104 ]
%112 = phi i32 [ %120, %110 ], [ 0, %104 ]
%113 = zext i32 %112 to i64
%114 = getelementptr inbounds i8, i8* %105, i64 %113
%115 = load i8, i8* %114
%116 = trunc i32 %111 to i8
%117 = xor i8 %115, %116
%118 = tail call i32 @fputc(i8 zeroext %117, i32* %12)
%119 = add i32 %112, 1
%120 = urem i32 %119, %106
%121 = tail call i32 @fgetc(i32* %19)
%122 = load i32, i32* @EOF
%123 = icmp eq i32 %121, %122
br i1 %123, label %124, label %110
124: ; preds = %20, %110, %104, %51
%125 = phi i32* [ @EXIT_FAILURE, %51 ], [ @EXIT_SUCCESS, %104 ], [ @EXIT_SUCCESS, %110 ], [ @EXIT_SUCCESS, %20 ]
%126 = load i32, i32* %125
ret i32 %126
}