#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 /*<<< orphan*/ SEEK_END;
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int shift_count(char *, char *, int, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  FILE *in, *out;
  char outFileName[255];
  int size = -1;
  int val;
  char *fileData;
  char *fileDataTemp;
  int round = 0;
  int count;
  int forcount = 0;
  int running_max_count = 0;
  if (argc != 2 && argc != 3) {
    printf("Usage: xoranal inputfile [outfile]\n");
    return -1;
  }
  if ((in = fopen(argv[1], "rb")) == NULL) {
    printf("Cant't open file name %s\n", argv[1]);
    return -1;
  }
  if (argc == 2) {
    snprintf(outFileName, 200, "%s.xoranal.txt", argv[1]);
  } else {
    strcpy(outFileName, argv[2]);
  }
  if ((out = fopen(outFileName, "wb")) == NULL) {
    printf("Cant't open file name %s\n", outFileName);
    fclose(in);
    return -1;
  }
  fseek(in, 0, SEEK_END);
  size = ftell(in);
  printf("filesize %i bytes\n", size);
  fileData = (char *)calloc(size, sizeof(char));
  fileDataTemp = (char *)calloc(size, sizeof(char));
  rewind(in);
  forcount = 0;
  while ((val = fgetc(in)) != EOF) {
    fileData[forcount++] = val;
  }
  fclose(in);
  while (++round <= 5000) {
    count = shift_count(fileData, fileDataTemp, size, round);
    fprintf(out, "%10i %10i %f%%\n", round, count,
            100 * (float)count / (float)size);
    if (count > running_max_count) {
      printf("new max @ %10i %10i %f%%\n", round, count,
             100 * (float)count / (float)size);
      running_max_count = count;
    }
    if (round % 10 == 0)
      printf("round %4i / %4i finished\n", round, 5000);
  }
  fclose(out);
  printf("finished, see %s for results\n", outFileName);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x124(%rbp)
ff ff ff
movl   $0x0,-0x13c(%rbp)
movl   $0x0,-0x144(%rbp)
movl   $0x0,-0x148(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     122f <main+0x6f>
cmpl   $0x3,-0x8(%rbp)
je     122f <main+0x6f>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1501 <main+0x341>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdea(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1273 <main+0xb3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1501 <main+0x341>
cmpl   $0x2,-0x8(%rbp)
jne    12a2 <main+0xe2>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0xc8,%esi
lea    0xdad(%rip),%rdx
call   1070 <snprintf@plt>
jmp    12b6 <main+0xf6>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rdi
lea    0xd90(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1301 <main+0x141>
lea    -0x120(%rbp),%rsi
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1501 <main+0x341>
mov    -0x18(%rbp),%rdi
mov    0x2cdc(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   10c0 <ftell@plt>
mov    %eax,-0x124(%rbp)
mov    -0x124(%rbp),%esi
lea    0xd26(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x124(%rbp),%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,-0x130(%rbp)
mov    -0x124(%rbp),%edi
mov    $0x1,%esi
call   10a0 <calloc@plt>
mov    %rax,-0x138(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <rewind@plt>
movl   $0x0,-0x144(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %eax,-0x128(%rbp)
mov    0x2c51(%rip),%rcx
cmp    (%rcx),%eax
je     13c2 <main+0x202>
mov    -0x128(%rbp),%eax
mov    %al,%dl
mov    -0x130(%rbp),%rax
mov    -0x144(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x144(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1379 <main+0x1b9>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x13c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13c(%rbp)
cmp    $0x1388,%eax
jg     14dc <main+0x31c>
mov    -0x130(%rbp),%rdi
mov    -0x138(%rbp),%rsi
mov    -0x124(%rbp),%edx
mov    -0x13c(%rbp),%ecx
call   1090 <shift_count@plt>
mov    %eax,-0x140(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x13c(%rbp),%edx
mov    -0x140(%rbp),%ecx
cvtsi2ssl -0x140(%rbp),%xmm1
ff
movss  0xbd6(%rip),%xmm0
mulss  %xmm1,%xmm0
cvtsi2ssl -0x124(%rbp),%xmm1
ff
divss  %xmm1,%xmm0
cvttss2si %xmm0,%r8d
lea    0xc2e(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0x140(%rbp),%eax
cmp    -0x148(%rbp),%eax
jle    14a7 <main+0x2e7>
mov    -0x13c(%rbp),%esi
mov    -0x140(%rbp),%edx
cvtsi2ssl -0x140(%rbp),%xmm1
ff
movss  0xb87(%rip),%xmm0
mulss  %xmm1,%xmm0
cvtsi2ssl -0x124(%rbp),%xmm1
ff
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbd6(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x140(%rbp),%eax
mov    %eax,-0x148(%rbp)
mov    -0x13c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    14d7 <main+0x317>
mov    -0x13c(%rbp),%esi
lea    0xbb9(%rip),%rdi
mov    $0x1388,%edx
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13cb <main+0x20b>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x120(%rbp),%rsi
lea    0xbab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    1229 <main+0x59>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe09(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     123a <main+0x6a>
mov    %rax,%r12
cmp    $0x2,%ebp
jne    1251 <main+0x81>
mov    0x8(%rbx),%rcx
lea    0xe09(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0xc8,%esi
call   1080 <snprintf@plt>
jmp    125f <main+0x8f>
lea    0xe68(%rip),%rdi
call   1040 <puts@plt>
jmp    1434 <main+0x264>
mov    0x8(%rbx),%rsi
lea    0xdc2(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1434 <main+0x264>
mov    0x10(%rbx),%rsi
lea    0x20(%rsp),%rdi
call   1030 <strcpy@plt>
lea    0xdca(%rip),%rsi
lea    0x20(%rsp),%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1419 <main+0x249>
mov    %rax,%r15
mov    0x2d65(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10e0 <fseek@plt>
mov    %r12,%rdi
call   10d0 <ftell@plt>
mov    %eax,%ebp
lea    0xd93(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%ebx
mov    %ebp,%edi
mov    $0x1,%esi
call   10b0 <calloc@plt>
mov    %rax,0x18(%rsp)
mov    %ebp,0xc(%rsp)
mov    %ebp,%edi
mov    $0x1,%esi
call   10b0 <calloc@plt>
mov    %rax,%r13
mov    %r12,%rdi
call   1070 <rewind@plt>
mov    %r12,%rdi
call   1090 <fgetc@plt>
mov    0x2cf7(%rip),%r14
cmp    (%r14),%eax
je     1314 <main+0x144>
mov    0x18(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %al,0x0(%rbp)
mov    %r12,%rdi
call   1090 <fgetc@plt>
add    $0x1,%rbp
cmp    (%r14),%eax
jne    1300 <main+0x130>
mov    %r12,%rdi
call   1050 <fclose@plt>
cvtsi2ssl 0xc(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
xor    %r14d,%r14d
mov    %r15,%rbp
jmp    1349 <main+0x179>
add    %bx,%r15w
je     13e0 <main+0x210>
add    $0x1,%ebx
cmp    $0x1389,%ebx
je     13fa <main+0x22a>
movzwl %bx,%eax
imul   $0xcccd,%eax,%eax
shr    $0x12,%eax
and    $0xfffffffe,%eax
lea    (%rax,%rax,4),%r15d
neg    %r15d
mov    0x18(%rsp),%rdi
mov    %r13,%rsi
mov    0xc(%rsp),%edx
mov    %ebx,%ecx
call   10a0 <shift_count@plt>
mov    %eax,%r12d
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0xc7c(%rip),%xmm0
divss  0x10(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
cvttss2si %xmm0,%r8d
mov    %rbp,%rdi
lea    0xcb1(%rip),%rsi
mov    %ebx,%edx
mov    %eax,%ecx
call   10c0 <fprintf@plt>
cmp    %r14d,%r12d
jle    1330 <main+0x160>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc88(%rip),%rdi
mov    %ebx,%esi
mov    %r12d,%edx
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r12d,%r14d
jmp    1330 <main+0x160>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xc79(%rip),%rdi
mov    %ebx,%esi
mov    $0x1388,%edx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    133a <main+0x16a>
mov    %rbp,%rdi
call   1050 <fclose@plt>
lea    0xc71(%rip),%rdi
xor    %ebx,%ebx
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1439 <main+0x269>
lea    0xbe7(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Usage: xoranal inputfile [outfile]\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [26 x i8] c"Cant't open file name %s\0A\00"
@.str.3 = [15 x i8] c"%s.xoranal.txt\00"
@.str.4 = [3 x i8] c"wb\00"
@SEEK_END = global i32 0
@.str.5 = [19 x i8] c"filesize %i bytes\0A\00"
@EOF = global i32 0
@.str.6 = [16 x i8] c"%10i %10i %f%%\0A\00"
@.str.7 = [26 x i8] c"new max @ %10i %10i %f%%\0A\00"
@.str.8 = [26 x i8] c"round %4i / %4i finished\0A\00"
@.str.9 = [30 x i8] c"finished, see %s for results\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 [255 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %9
store i32 0, i32* %13
store i32 0, i32* %15
store i32 0, i32* %16
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 2
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 3
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %140
24: ; preds = %19, %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %6
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %35
30: ; preds = %24
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %33)
store i32 -1, i32* %3
br label %140
35: ; preds = %24
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 2
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 @snprintf(i8* %39, i32 200, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %42)
br label %50
44: ; preds = %35
%45 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = call i32 @strcpy(i8* %45, i8* %48)
br label %50
50: ; preds = %44, %38
%51 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %52, i32** %7
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %59
54: ; preds = %50
%55 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %55)
%57 = load i32*, i32** %6
%58 = call i32 @fclose(i32* %57)
store i32 -1, i32* %3
br label %140
59: ; preds = %50
%60 = load i32*, i32** %6
%61 = load i32, i32* @SEEK_END
%62 = call i32 @fseek(i32* %60, i32 0, i32 %61)
%63 = load i32*, i32** %6
%64 = call i32 @ftell(i32* %63)
store i32 %64, i32* %9
%65 = load i32, i32* %9
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %65)
%67 = load i32, i32* %9
%68 = call i64 @calloc(i32 %67, i32 1)
%69 = inttoptr i64 %68 to i8*
store i8* %69, i8** %11
%70 = load i32, i32* %9
%71 = call i64 @calloc(i32 %70, i32 1)
%72 = inttoptr i64 %71 to i8*
store i8* %72, i8** %12
%73 = load i32*, i32** %6
%74 = call i32 @rewind(i32* %73)
store i32 0, i32* %15
br label %75
75: ; preds = %80, %59
%76 = load i32*, i32** %6
%77 = call i32 @fgetc(i32* %76)
store i32 %77, i32* %10
%78 = load i32, i32* @EOF
%79 = icmp ne i32 %77, %78
br i1 %79, label %80, label %88
80: ; preds = %75
%81 = load i32, i32* %10
%82 = trunc i32 %81 to i8
%83 = load i8*, i8** %11
%84 = load i32, i32* %15
%85 = add nsw i32 %84, 1
store i32 %85, i32* %15
%86 = sext i32 %84 to i64
%87 = getelementptr inbounds i8, i8* %83, i64 %86
store i8 %82, i8* %87
br label %75
88: ; preds = %75
%89 = load i32*, i32** %6
%90 = call i32 @fclose(i32* %89)
br label %91
91: ; preds = %134, %88
%92 = load i32, i32* %13
%93 = add nsw i32 %92, 1
store i32 %93, i32* %13
%94 = icmp sle i32 %93, 5000
br i1 %94, label %95, label %135
95: ; preds = %91
%96 = load i8*, i8** %11
%97 = load i8*, i8** %12
%98 = load i32, i32* %9
%99 = load i32, i32* %13
%100 = call i32 @shift_count(i8* %96, i8* %97, i32 %98, i32 %99)
store i32 %100, i32* %14
%101 = load i32*, i32** %7
%102 = load i32, i32* %13
%103 = load i32, i32* %14
%104 = load i32, i32* %14
%105 = sitofp i32 %104 to float
%106 = fmul float 1.000000e+02, %105
%107 = load i32, i32* %9
%108 = sitofp i32 %107 to float
%109 = fdiv float %106, %108
%110 = fptosi float %109 to i32
%111 = call i32 @fprintf(i32* %101, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %102, i32 %103, i32 %110)
%112 = load i32, i32* %14
%113 = load i32, i32* %16
%114 = icmp sgt i32 %112, %113
br i1 %114, label %115, label %127
115: ; preds = %95
%116 = load i32, i32* %13
%117 = load i32, i32* %14
%118 = load i32, i32* %14
%119 = sitofp i32 %118 to float
%120 = fmul float 1.000000e+02, %119
%121 = load i32, i32* %9
%122 = sitofp i32 %121 to float
%123 = fdiv float %120, %122
%124 = fpext float %123 to double
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %116, i32 %117, double %124)
%126 = load i32, i32* %14
store i32 %126, i32* %16
br label %127
127: ; preds = %115, %95
%128 = load i32, i32* %13
%129 = srem i32 %128, 10
%130 = icmp eq i32 %129, 0
br i1 %130, label %131, label %134
131: ; preds = %127
%132 = load i32, i32* %13
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %132, i32 5000)
br label %134
134: ; preds = %131, %127
br label %91
135: ; preds = %91
%136 = load i32*, i32** %7
%137 = call i32 @fclose(i32* %136)
%138 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* %138)
store i32 0, i32* %3
br label %140
140: ; preds = %135, %54, %30, %22
%141 = load i32, i32* %3
ret i32 %141
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [26 x i8] c"Cant't open file name %s\0A\00"
@.str.3 = [15 x i8] c"%s.xoranal.txt\00"
@.str.4 = [3 x i8] c"wb\00"
@SEEK_END = global i32 0
@.str.5 = [19 x i8] c"filesize %i bytes\0A\00"
@EOF = global i32 0
@.str.6 = [16 x i8] c"%10i %10i %f%%\0A\00"
@.str.7 = [26 x i8] c"new max @ %10i %10i %f%%\0A\00"
@.str.8 = [26 x i8] c"round %4i / %4i finished\0A\00"
@.str.9 = [30 x i8] c"finished, see %s for results\0A\00"
@str = [35 x i8] c"Usage: xoranal inputfile [outfile]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = and i32 %0, -2
%6 = icmp eq i32 %5, 2
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %83
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load i8*, i8** %10
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %83
17: ; preds = %9
%18 = icmp eq i32 %0, 2
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = load i8*, i8** %10
%21 = call i32 @snprintf(i8* %4, i32 200, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %20)
br label %26
22: ; preds = %17
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @strcpy(i8* %4, i8* %24)
br label %26
26: ; preds = %22, %19
%27 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%31 = call i32 @fclose(i32* %12)
br label %83
32: ; preds = %26
%33 = load i32, i32* @SEEK_END
%34 = call i32 @fseek(i32* %12, i32 0, i32 %33)
%35 = call i32 @ftell(i32* %12)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = call i64 @calloc(i32 %35, i32 1)
%38 = inttoptr i64 %37 to i8*
%39 = call i64 @calloc(i32 %35, i32 1)
%40 = inttoptr i64 %39 to i8*
%41 = call i32 @rewind(i32* %12)
%42 = call i32 @fgetc(i32* %12)
%43 = load i32, i32* @EOF
%44 = icmp eq i32 %42, %43
br i1 %44, label %54, label %45
45: ; preds = %32, %45
%46 = phi i64 [ %49, %45 ], [ 0, %32 ]
%47 = phi i32 [ %51, %45 ], [ %42, %32 ]
%48 = trunc i32 %47 to i8
%49 = add nuw i64 %46, 1
%50 = getelementptr inbounds i8, i8* %38, i64 %46
store i8 %48, i8* %50
%51 = call i32 @fgetc(i32* %12)
%52 = load i32, i32* @EOF
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %45
54: ; preds = %45, %32
%55 = call i32 @fclose(i32* %12)
%56 = sitofp i32 %35 to float
br label %57
57: ; preds = %54, %77
%58 = phi i32 [ 1, %54 ], [ %78, %77 ]
%59 = phi i32 [ 0, %54 ], [ %71, %77 ]
%60 = call i32 @shift_count(i8* %38, i8* %40, i32 %35, i32 %58)
%61 = sitofp i32 %60 to float
%62 = fmul float %61, 1.000000e+02
%63 = fdiv float %62, %56
%64 = fptosi float %63 to i32
%65 = call i32 @fprintf(i32* %27, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %58, i32 %60, i32 %64)
%66 = icmp sgt i32 %60, %59
br i1 %66, label %67, label %70
67: ; preds = %57
%68 = fpext float %63 to double
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %58, i32 %60, double %68)
br label %70
70: ; preds = %67, %57
%71 = phi i32 [ %60, %67 ], [ %59, %57 ]
%72 = trunc i32 %58 to i16
%73 = urem i16 %72, 10
%74 = icmp eq i16 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %70
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 %58, i32 5000)
br label %77
77: ; preds = %75, %70
%78 = add nuw nsw i32 %58, 1
%79 = icmp eq i32 %78, 5001
br i1 %79, label %80, label %57
80: ; preds = %77
%81 = call i32 @fclose(i32* %27)
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* %4)
br label %83
83: ; preds = %80, %29, %14, %7
%84 = phi i32 [ -1, %7 ], [ -1, %14 ], [ -1, %29 ], [ 0, %80 ]
ret i32 %84
}