#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ slowprint(char *, int);
char *deciphering(char *finput, char *pass, int key) {
  int i, ch;
  char chaos;
  double x = key / 1000.0;
  FILE *fin;
  if ((fin = fopen(finput, "r")) == 0) {
    slowprint("Cannot open input file.\n", 15);
    return NULL;
  }
  for (i = 0; i < 100; i++) {
    x = x * 4 * (1 - x);
  }
  i = 0;
  while ((ch = getc(fin)) != EOF && i < 19) {
    x = x * 4 * (1 - x);
    chaos = (char)(x * 95);
    ch = ch ^ chaos;
    *(pass + i) = (char)ch;
    i++;
  }
  fclose(fin);
  pass[i] = '\0';
  return pass;
}


x86 assembly (clang, -O0):
<deciphering>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  0xea0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    11a5 <deciphering+0x65>
lea    0xe94(%rip),%rdi
mov    $0xf,%esi
call   1040 <slowprint@plt>
movq   $0x0,-0x8(%rbp)
jmp    12b2 <deciphering+0x172>
movl   $0x0,-0x20(%rbp)
cmpl   $0x64,-0x20(%rbp)
jge    11e7 <deciphering+0xa7>
movsd  0xe4a(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  0xe45(%rip),%xmm1
subsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ac <deciphering+0x6c>
movl   $0x0,-0x20(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,%ecx
mov    %ecx,-0x24(%rbp)
xor    %eax,%eax
mov    0x2de3(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x39(%rbp)
je     121a <deciphering+0xda>
cmpl   $0x13,-0x20(%rbp)
setl   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    122a <deciphering+0xea>
jmp    1295 <deciphering+0x155>
movsd  -0x30(%rbp),%xmm2
movsd  0xdd1(%rip),%xmm1
movaps %xmm2,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdca(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdb8(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,-0x25(%rbp)
mov    -0x24(%rbp),%eax
movsbl -0x25(%rbp),%ecx
xor    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ee <deciphering+0xae>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deciphering>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
lea    0xec8(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1203 <deciphering+0xc3>
mov    %rax,%r12
cvtsi2sd %ebp,%xmm1
divsd  0xe8b(%rip),%xmm1
mov    $0x64,%eax
movsd  0xe86(%rip),%xmm2
movsd  0xe86(%rip),%xmm3
nopw   0x0(%rax,%rax,1)
movapd %xmm3,%xmm0
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm3,%xmm0
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm3,%xmm0
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm3,%xmm0
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm3,%xmm0
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
add    $0xfffffffb,%eax
jne    1190 <deciphering+0x50>
movsd  %xmm1,0x8(%rsp)
mov    %r12,%rdi
call   1060 <getc@plt>
mov    0x2dee(%rip),%r15
cmp    (%r15),%eax
jne    1219 <deciphering+0xd9>
xor    %ebx,%ebx
jmp    1274 <deciphering+0x134>
lea    0xe18(%rip),%rdi
mov    $0xf,%esi
call   1040 <slowprint@plt>
xor    %r14d,%r14d
jmp    1281 <deciphering+0x141>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsd  0xde8(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm1,%xmm0
mulsd  0xdce(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
mulsd  0xdc8(%rip),%xmm0
cvttsd2si %xmm0,%ecx
xor    %eax,%ecx
mov    %cl,(%r14,%rbp,1)
lea    0x1(%rbp),%rbx
mov    %r12,%rdi
call   1060 <getc@plt>
cmp    (%r15),%eax
je     1274 <deciphering+0x134>
cmp    $0x12,%rbp
mov    %rbx,%rbp
jb     1220 <deciphering+0xe0>
mov    %r12,%rdi
call   1030 <fclose@plt>
movb   $0x0,(%r14,%rbx,1)
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [25 x i8] c"Cannot open input file.\0A\00"
@EOF = global i32 0
define i8* @deciphering(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca double
%12 = alloca i32*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%13 = load i32, i32* %7
%14 = sitofp i32 %13 to double
%15 = fdiv double %14, 1.000000e+03
store double %15, double* %11
%16 = load i8*, i8** %5
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %12
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %3
%20 = call i32 @slowprint(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 15)
store i8* null, i8** %4
br label %74
21: ; preds = %3
store i32 0, i32* %8
br label %22
22: ; preds = %31, %21
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 100
br i1 %24, label %25, label %34
25: ; preds = %22
%26 = load double, double* %11
%27 = fmul double %26, 4.000000e+00
%28 = load double, double* %11
%29 = fsub double 1.000000e+00, %28
%30 = fmul double %27, %29
store double %30, double* %11
br label %31
31: ; preds = %25
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %22
34: ; preds = %22
store i32 0, i32* %8
br label %35
35: ; preds = %45, %34
%36 = load i32*, i32** %12
%37 = call i32 @getc(i32* %36)
store i32 %37, i32* %9
%38 = load i32, i32* @EOF
%39 = icmp ne i32 %37, %38
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load i32, i32* %8
%42 = icmp slt i32 %41, 19
br label %43
43: ; preds = %40, %35
%44 = phi i1 [ false, %35 ], [ %42, %40 ]
br i1 %44, label %45, label %66
45: ; preds = %43
%46 = load double, double* %11
%47 = fmul double %46, 4.000000e+00
%48 = load double, double* %11
%49 = fsub double 1.000000e+00, %48
%50 = fmul double %47, %49
store double %50, double* %11
%51 = load double, double* %11
%52 = fmul double %51, 9.500000e+01
%53 = fptosi double %52 to i8
store i8 %53, i8* %10
%54 = load i32, i32* %9
%55 = load i8, i8* %10
%56 = sext i8 %55 to i32
%57 = xor i32 %54, %56
store i32 %57, i32* %9
%58 = load i32, i32* %9
%59 = trunc i32 %58 to i8
%60 = load i8*, i8** %6
%61 = load i32, i32* %8
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
store i8 %59, i8* %63
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
store i32 %65, i32* %8
br label %35
66: ; preds = %43
%67 = load i32*, i32** %12
%68 = call i32 @fclose(i32* %67)
%69 = load i8*, i8** %6
%70 = load i32, i32* %8
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
store i8 0, i8* %72
%73 = load i8*, i8** %6
store i8* %73, i8** %4
br label %74
74: ; preds = %66, %19
%75 = load i8*, i8** %4
ret i8* %75
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [25 x i8] c"Cannot open input file.\0A\00"
@EOF = global i32 0
define i8* @deciphering(i8* nocapture %0, i8* writeonly %1, i32 %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @slowprint(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 15)
br label %57
8: ; preds = %3
%9 = sitofp i32 %2 to double
%10 = fdiv double %9, 1.000000e+03
br label %15
11: ; preds = %15
%12 = tail call i32 @getc(i32* %4)
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %53, label %35
15: ; preds = %15, %8
%16 = phi double [ %10, %8 ], [ %32, %15 ]
%17 = phi i32 [ 0, %8 ], [ %33, %15 ]
%18 = fmul double %16, 4.000000e+00
%19 = fsub double 1.000000e+00, %16
%20 = fmul double %18, %19
%21 = fmul double %20, 4.000000e+00
%22 = fsub double 1.000000e+00, %20
%23 = fmul double %21, %22
%24 = fmul double %23, 4.000000e+00
%25 = fsub double 1.000000e+00, %23
%26 = fmul double %24, %25
%27 = fmul double %26, 4.000000e+00
%28 = fsub double 1.000000e+00, %26
%29 = fmul double %27, %28
%30 = fmul double %29, 4.000000e+00
%31 = fsub double 1.000000e+00, %29
%32 = fmul double %30, %31
%33 = add nuw nsw i32 %17, 5
%34 = icmp eq i32 %33, 100
br i1 %34, label %11, label %15
35: ; preds = %11, %35
%36 = phi i64 [ %47, %35 ], [ 0, %11 ]
%37 = phi i32 [ %48, %35 ], [ %12, %11 ]
%38 = phi double [ %41, %35 ], [ %32, %11 ]
%39 = fmul double %38, 4.000000e+00
%40 = fsub double 1.000000e+00, %38
%41 = fmul double %39, %40
%42 = fmul double %41, 9.500000e+01
%43 = fptosi double %42 to i8
%44 = trunc i32 %37 to i8
%45 = xor i8 %43, %44
%46 = getelementptr inbounds i8, i8* %1, i64 %36
store i8 %45, i8* %46
%47 = add nuw nsw i64 %36, 1
%48 = tail call i32 @getc(i32* %4)
%49 = load i32, i32* @EOF
%50 = icmp ne i32 %48, %49
%51 = icmp ult i64 %36, 18
%52 = select i1 %50, i1 %51, i1 false
br i1 %52, label %35, label %53
53: ; preds = %35, %11
%54 = phi i64 [ 0, %11 ], [ %47, %35 ]
%55 = tail call i32 @fclose(i32* %4)
%56 = getelementptr inbounds i8, i8* %1, i64 %54
store i8 0, i8* %56
br label %57
57: ; preds = %53, %6
%58 = phi i8* [ null, %6 ], [ %1, %53 ]
ret i8* %58
}