#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*/ cipher;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ analize2(char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char cipher[4000];
  int ncipher;
  FILE *fi = fopen("cipher1.txt", "rb");
  if (fi == NULL) {
    fprintf(stderr, "Can't open %s\n", "cipher1.txt");
    return -1;
  }
  ncipher = 0;
  memset(cipher, 0, sizeof(cipher));
  while (!feof(fi)) {
    int num = -1;
    int r = fscanf(fi, "%d,", &num);
    if (r == 0 || r == -1)
      break;
    cipher[ncipher++] = num;
  }
  analize2(cipher, ncipher);
  fclose(fi);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe70(%rip),%rdi
lea    0xe75(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0xfc0(%rbp)
cmpq   $0x0,-0xfc0(%rbp)
jne    11d9 <main+0x69>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe4e(%rip),%rsi
lea    0xe38(%rip),%rdx
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ac <main+0x13c>
movl   $0x0,-0xfb4(%rbp)
lea    -0xfb0(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1040 <memset@plt>
mov    -0xfc0(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1217 <main+0xa7>
jmp    1287 <main+0x117>
movl   $0xffffffff,-0xfc4(%rbp)
ff ff ff
mov    -0xfc0(%rbp),%rdi
lea    0xdef(%rip),%rsi
lea    -0xfc4(%rbp),%rdx
call   1050 <fscanf@plt>
mov    %eax,-0xfc8(%rbp)
cmpl   $0x0,-0xfc8(%rbp)
je     125b <main+0xeb>
cmpl   $0xffffffff,-0xfc8(%rbp)
jne    1260 <main+0xf0>
jmp    1287 <main+0x117>
mov    -0xfc4(%rbp),%eax
mov    %al,%cl
mov    -0xfb4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xfb4(%rbp)
cltq
mov    %cl,-0xfb0(%rbp,%rax,1)
jmp    11f6 <main+0x86>
lea    -0xfb0(%rbp),%rdi
mov    -0xfb4(%rbp),%esi
call   1080 <analize2@plt>
mov    -0xfc0(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xfd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xfb0,%rsp
lea    0xe7a(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     122d <main+0xbd>
mov    %rax,%rbx
lea    0x10(%rsp),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0xfa0,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
call   1070 <feof@plt>
mov    $0x0,%ebp
test   %eax,%eax
jne    1217 <main+0xa7>
xor    %ebp,%ebp
lea    0xe52(%rip),%r15
lea    0xc(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movl   $0xffffffff,0xc(%rsp)
ff
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <fscanf@plt>
add    $0x1,%eax
cmp    $0x1,%eax
jbe    1217 <main+0xa7>
movzbl 0xc(%rsp),%eax
mov    %al,0x10(%rsp,%rbp,1)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11e0 <main+0x70>
lea    0x10(%rsp),%rdi
mov    %ebp,%esi
call   1080 <analize2@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    124f <main+0xdf>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
lea    0xdbc(%rip),%rdx
call   1060 <fprintf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0xfb0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"cipher1.txt\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [15 x i8] c"Can't open %s\0A\00"
@.str.3 = [4 x i8] c"%d,\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4000 x i8]
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %8
%12 = load i32*, i32** %8
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %47
17: ; preds = %2
store i32 0, i32* %7
%18 = getelementptr inbounds [4000 x i8], [4000 x i8]* %6, i64 0, i64 0
%19 = call i32 @memset(i8* %18, i32 0, i32 4000)
br label %20
20: ; preds = %34, %17
%21 = load i32*, i32** %8
%22 = call i32 @feof(i32* %21)
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
br i1 %24, label %25, label %41
25: ; preds = %20
store i32 -1, i32* %9
%26 = load i32*, i32** %8
%27 = call i32 @fscanf(i32* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %9)
store i32 %27, i32* %10
%28 = load i32, i32* %10
%29 = icmp eq i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %25
%31 = load i32, i32* %10
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %34
33: ; preds = %30, %25
br label %41
34: ; preds = %30
%35 = load i32, i32* %9
%36 = trunc i32 %35 to i8
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
%39 = sext i32 %37 to i64
%40 = getelementptr inbounds [4000 x i8], [4000 x i8]* %6, i64 0, i64 %39
store i8 %36, i8* %40
br label %20
41: ; preds = %33, %20
%42 = getelementptr inbounds [4000 x i8], [4000 x i8]* %6, i64 0, i64 0
%43 = load i32, i32* %7
%44 = call i32 @analize2(i8* %42, i32 %43)
%45 = load i32*, i32** %8
%46 = call i32 @fclose(i32* %45)
store i32 0, i32* %3
br label %47
47: ; preds = %41, %14
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [12 x i8] c"cipher1.txt\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [15 x i8] c"Can't open %s\0A\00"
@.str.3 = [4 x i8] c"%d,\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4000 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [4000 x i8], [4000 x i8]* %3, i64 0, i64 0
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %37
11: ; preds = %2
%12 = call i32 @memset(i8* %5, i32 0, i32 4000)
%13 = call i32 @feof(i32* %6)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %33
15: ; preds = %11
%16 = bitcast i32* %4 to i8*
br label %17
17: ; preds = %15, %24
%18 = phi i64 [ 0, %15 ], [ %27, %24 ]
store i32 -1, i32* %4
%19 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%20 = add i32 %19, 1
%21 = icmp ult i32 %20, 2
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = trunc i64 %18 to i32
br label %33
24: ; preds = %17
%25 = load i32, i32* %4
%26 = trunc i32 %25 to i8
%27 = add nuw i64 %18, 1
%28 = getelementptr inbounds [4000 x i8], [4000 x i8]* %3, i64 0, i64 %18
store i8 %26, i8* %28
%29 = call i32 @feof(i32* %6)
%30 = icmp eq i32 %29, 0
br i1 %30, label %17, label %31
31: ; preds = %24
%32 = trunc i64 %27 to i32
br label %33
33: ; preds = %31, %11, %22
%34 = phi i32 [ %23, %22 ], [ 0, %11 ], [ %32, %31 ]
%35 = call i32 @analize2(i8* %5, i32 %34)
%36 = call i32 @fclose(i32* %6)
br label %37
37: ; preds = %33, %8
%38 = phi i32 [ -1, %8 ], [ 0, %33 ]
ret i32 %38
}