#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 */
scalar_t__ EOF;
int /*<<< orphan*/ decrypt(int *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, int);
int main(int agc, char *argv[]) {
  int encrypted[1201] = {'\0'};
  int *eptr = encrypted;
  char plaintext[1202] = {'\0'};
  FILE *hFile = fopen("cipher1.txt", "r");
  while (fscanf(hFile, "%i,", eptr) != EOF) {
    eptr++;
  }
  decrypt(encrypted, plaintext);
  int sum = 0;
  for (int i = 0; i < 1201; i++) {
    sum += plaintext[i];
  }
  printf("%i", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x17b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x12e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x12c4,%edx
call   1050 <memset@plt>
lea    -0x12e0(%rbp),%rax
mov    %rax,-0x12e8(%rbp)
lea    -0x17a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x4b2,%edx
call   1050 <memset@plt>
lea    0xe5c(%rip),%rdi
lea    0xe61(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x17a8(%rbp)
mov    -0x17a8(%rbp),%rdi
mov    -0x12e8(%rbp),%rdx
lea    0xe42(%rip),%rsi
call   1060 <fscanf@plt>
mov    0x2e10(%rip),%rcx
cmp    (%rcx),%rax
je     11f8 <main+0xa8>
mov    -0x12e8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x12e8(%rbp)
jmp    11b7 <main+0x67>
lea    -0x12e0(%rbp),%rdi
lea    -0x17a0(%rbp),%rsi
call   1030 <decrypt@plt>
movl   $0x0,-0x17ac(%rbp)
movl   $0x0,-0x17b0(%rbp)
cmpl   $0x4b1,-0x17b0(%rbp)
jge    125e <main+0x10e>
movslq -0x17b0(%rbp),%rax
movsbl -0x17a0(%rbp,%rax,1),%eax
ff
add    -0x17ac(%rbp),%eax
mov    %eax,-0x17ac(%rbp)
mov    -0x17b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x17b0(%rbp)
jmp    121f <main+0xcf>
mov    -0x17ac(%rbp),%esi
lea    0xda7(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x17b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1788,%rsp
lea    0x4c0(%rsp),%rbx
mov    $0x12c4,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    %rsp,%rdi
mov    $0x4b2,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xe75(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
lea    0xe6d(%rip),%r15
mov    0x2e40(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
add    $0x4,%rbx
cmp    (%r12),%rax
jne    11b0 <main+0x60>
lea    0x4c0(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <decrypt@plt>
pxor   %xmm0,%xmm0
mov    $0x14,%eax
pxor   %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
nop
movq   -0x14(%rsp,%rax,1),%xmm2
punpcklbw %xmm2,%xmm2
punpcklwd %xmm2,%xmm3
movd   -0x10(%rsp,%rax,1),%xmm2
punpcklbw %xmm2,%xmm2
punpcklwd %xmm2,%xmm2
psrad  $0x18,%xmm3
paddd  %xmm0,%xmm3
psrad  $0x18,%xmm2
paddd  %xmm1,%xmm2
movq   -0xc(%rsp,%rax,1),%xmm0
punpcklbw %xmm0,%xmm0
punpcklwd %xmm0,%xmm4
movd   -0x8(%rsp,%rax,1),%xmm0
punpcklbw %xmm0,%xmm0
punpcklwd %xmm0,%xmm5
psrad  $0x18,%xmm4
psrad  $0x18,%xmm5
movq   -0x4(%rsp,%rax,1),%xmm0
punpcklbw %xmm0,%xmm0
punpcklwd %xmm0,%xmm0
movd   (%rsp,%rax,1),%xmm1
punpcklbw %xmm1,%xmm1
punpcklwd %xmm1,%xmm1
psrad  $0x18,%xmm0
paddd  %xmm4,%xmm0
paddd  %xmm3,%xmm0
psrad  $0x18,%xmm1
paddd  %xmm5,%xmm1
paddd  %xmm2,%xmm1
add    $0x18,%rax
cmp    $0x4c4,%rax
jne    11f0 <main+0xa0>
paddd  %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%eax
movsbl 0x4b0(%rsp),%esi
add    %eax,%esi
lea    0xd5e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1788,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"cipher1.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%i,\00"
@EOF = global i64 0
@.str.3 = [3 x i8] c"%i\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1201 x i32]
%7 = alloca i32*
%8 = alloca [1202 x i8]
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = bitcast [1201 x i32]* %6 to i8*
%13 = getelementptr inbounds [1201 x i32], [1201 x i32]* %6, i64 0, i64 0
store i32* %13, i32** %7
%14 = bitcast [1202 x i8]* %8 to i8*
%15 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %9
br label %16
16: ; preds = %22, %2
%17 = load i32*, i32** %9
%18 = load i32*, i32** %7
%19 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %18)
%20 = load i64, i64* @EOF
%21 = icmp ne i64 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i32*, i32** %7
%24 = getelementptr inbounds i32, i32* %23, i32 1
store i32* %24, i32** %7
br label %16
25: ; preds = %16
%26 = getelementptr inbounds [1201 x i32], [1201 x i32]* %6, i64 0, i64 0
%27 = getelementptr inbounds [1202 x i8], [1202 x i8]* %8, i64 0, i64 0
%28 = call i32 @decrypt(i32* %26, i8* %27)
store i32 0, i32* %10
store i32 0, i32* %11
br label %29
29: ; preds = %40, %25
%30 = load i32, i32* %11
%31 = icmp slt i32 %30, 1201
br i1 %31, label %32, label %43
32: ; preds = %29
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [1202 x i8], [1202 x i8]* %8, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = load i32, i32* %10
%39 = add nsw i32 %38, %37
store i32 %39, i32* %10
br label %40
40: ; preds = %32
%41 = load i32, i32* %11
%42 = add nsw i32 %41, 1
store i32 %42, i32* %11
br label %29
43: ; preds = %29
%44 = load i32, i32* %10
%45 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"cipher1.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%i,\00"
@EOF = global i64 0
@.str.3 = [3 x i8] c"%i\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1201 x i32]
%4 = alloca [1202 x i8]
%5 = bitcast [1201 x i32]* %3 to i8*
%6 = getelementptr inbounds [1201 x i32], [1201 x i32]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1202 x i8], [1202 x i8]* %4, i64 0, i64 0
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %9, %2
%10 = phi i32* [ %6, %2 ], [ %14, %9 ]
%11 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
%14 = getelementptr inbounds i32, i32* %10, i64 1
br i1 %13, label %15, label %9
15: ; preds = %9
%16 = call i32 @decrypt(i32* %6, i8* %7)
br label %17
17: ; preds = %17, %15
%18 = phi i64 [ 0, %15 ], [ %53, %17 ]
%19 = phi <4 x i32> [ zeroinitializer, %15 ], [ %51, %17 ]
%20 = phi <4 x i32> [ zeroinitializer, %15 ], [ %52, %17 ]
%21 = getelementptr inbounds [1202 x i8], [1202 x i8]* %4, i64 0, i64 %18
%22 = bitcast i8* %21 to <4 x i8>*
%23 = load <4 x i8>, <4 x i8>* %22
%24 = getelementptr inbounds i8, i8* %21, i64 4
%25 = bitcast i8* %24 to <4 x i8>*
%26 = load <4 x i8>, <4 x i8>* %25
%27 = sext <4 x i8> %23 to <4 x i32>
%28 = sext <4 x i8> %26 to <4 x i32>
%29 = add <4 x i32> %19, %27
%30 = add <4 x i32> %20, %28
%31 = add nuw nsw i64 %18, 8
%32 = getelementptr inbounds [1202 x i8], [1202 x i8]* %4, i64 0, i64 %31
%33 = bitcast i8* %32 to <4 x i8>*
%34 = load <4 x i8>, <4 x i8>* %33
%35 = getelementptr inbounds i8, i8* %32, i64 4
%36 = bitcast i8* %35 to <4 x i8>*
%37 = load <4 x i8>, <4 x i8>* %36
%38 = sext <4 x i8> %34 to <4 x i32>
%39 = sext <4 x i8> %37 to <4 x i32>
%40 = add <4 x i32> %29, %38
%41 = add <4 x i32> %30, %39
%42 = add nuw nsw i64 %18, 16
%43 = getelementptr inbounds [1202 x i8], [1202 x i8]* %4, i64 0, i64 %42
%44 = bitcast i8* %43 to <4 x i8>*
%45 = load <4 x i8>, <4 x i8>* %44
%46 = getelementptr inbounds i8, i8* %43, i64 4
%47 = bitcast i8* %46 to <4 x i8>*
%48 = load <4 x i8>, <4 x i8>* %47
%49 = sext <4 x i8> %45 to <4 x i32>
%50 = sext <4 x i8> %48 to <4 x i32>
%51 = add <4 x i32> %40, %49
%52 = add <4 x i32> %41, %50
%53 = add nuw nsw i64 %18, 24
%54 = icmp eq i64 %53, 1200
br i1 %54, label %55, label %17
55: ; preds = %17
%56 = add <4 x i32> %52, %51
%57 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %56)
%58 = getelementptr inbounds [1202 x i8], [1202 x i8]* %4, i64 0, i64 1200
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = add nsw i32 %57, %60
%62 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %61)
ret i32 0
}