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

/* Variables and functions */
int /*<<< orphan*/ decrypt(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, char *);
void decryptfile() {
  FILE *infile;
  FILE *outfile;
  infile = fopen("encrypted-test.ini", "r");
  outfile = fopen("decrypted-test.ini", "w+");
  char file_read_buff[1024] = {'\0'};
  char write_buff[1024] = {'\0'};
  printf("\n\ndecryptfile():\n\n");
  while (fgets(file_read_buff, sizeof(file_read_buff), infile) != NULL) {
    char line_buff[sizeof(file_read_buff)] = {'\0'};
    sscanf(file_read_buff, " %[^\n]", line_buff);
    printf("\n  Plain Text Line:\t%s\n", line_buff);
    decrypt(write_buff, line_buff);
    printf("  Decrypted Line:\t%s\n", write_buff);
    fputs(write_buff, outfile);
    fputs("\n", outfile);
  }
  fclose(infile);
  fclose(outfile);
}


x86 assembly (clang, -O0):
<decryptfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc10,%rsp
lea    0xe6e(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x8(%rbp)
lea    0xe6c(%rip),%rdi
lea    0xe78(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x400,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     129b <decryptfile+0x11b>
lea    -0xc10(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
lea    -0x410(%rbp),%rdi
lea    -0xc10(%rbp),%rdx
lea    0xe0a(%rip),%rsi
call   1090 <sscanf@plt>
lea    -0xc10(%rbp),%rsi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x810(%rbp),%rdi
lea    -0xc10(%rbp),%rsi
call   1030 <decrypt@plt>
lea    -0x810(%rbp),%rsi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <fputs@plt>
mov    -0x10(%rbp),%rsi
lea    0xdab(%rip),%rdi
call   1060 <fputs@plt>
jmp    11ed <decryptfile+0x6d>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0xc10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decryptfile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc08,%rsp
lea    0xe48(%rip),%rdi
lea    0xe54(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r14
lea    0xe47(%rip),%rdi
lea    0xe53(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r15
lea    0x400(%rsp),%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
mov    %rsp,%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1080 <memset@plt>
lea    0xe56(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     12c7 <decryptfile+0x127>
lea    0x800(%rsp),%rbx
lea    0x400(%rsp),%r13
mov    %rsp,%r12
lea    0xe08(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
mov    %r13,%rdi
lea    0xdc2(%rip),%rsi
mov    %rbx,%rdx
call   10b0 <sscanf@plt>
lea    0xdba(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <decrypt@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <fputs@plt>
mov    $0xa,%edi
mov    %r15,%rsi
call   1090 <fputc@plt>
mov    %r13,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
jne    1250 <decryptfile+0xb0>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
add    $0xc08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"encrypted-test.ini\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"decrypted-test.ini\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [19 x i8] c"\0A\0Adecryptfile():\0A\0A\00"
@.str.5 = [7 x i8] c" %[^\0A]\00"
@.str.6 = [24 x i8] c"\0A Plain Text Line:\09%s\0A\00"
@.str.7 = [22 x i8] c" Decrypted Line:\09%s\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
define void @decryptfile() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %7, i32** %2
%8 = bitcast [1024 x i8]* %3 to i8*
%9 = bitcast [1024 x i8]* %4 to i8*
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %11
11: ; preds = %16, %0
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = load i32*, i32** %1
%14 = call i32* @fgets(i8* %12, i32 1024, i32* %13)
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %33
16: ; preds = %11
%17 = bitcast [1024 x i8]* %5 to i8*
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%20 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%25 = call i32 @decrypt(i8* %23, i8* %24)
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%29 = load i32*, i32** %2
%30 = call i32 @fputs(i8* %28, i32* %29)
%31 = load i32*, i32** %2
%32 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32* %31)
br label %11
33: ; preds = %11
%34 = load i32*, i32** %1
%35 = call i32 @fclose(i32* %34)
%36 = load i32*, i32** %2
%37 = call i32 @fclose(i32* %36)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"encrypted-test.ini\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"decrypted-test.ini\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.5 = [7 x i8] c" %[^\0A]\00"
@.str.6 = [24 x i8] c"\0A Plain Text Line:\09%s\0A\00"
@.str.7 = [22 x i8] c" Decrypted Line:\09%s\0A\00"
@str = [18 x i8] c"\0A\0Adecryptfile():\0A\00"
define void @decryptfile() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%9 = call i32* @fgets(i8* %6, i32 1024, i32* %4)
%10 = icmp eq i32* %9, null
br i1 %10, label %22, label %11
11: ; preds = %0
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
br label %13
13: ; preds = %11, %13
%14 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %12)
%16 = call i32 @decrypt(i8* %7, i8* %12)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %7)
%18 = call i32 @fputs(i8* %7, i32* %5)
%19 = call i32 @fputc(i32 10, i32* %5)
%20 = call i32* @fgets(i8* %6, i32 1024, i32* %4)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %13
22: ; preds = %13, %0
%23 = call i32 @fclose(i32* %4)
%24 = call i32 @fclose(i32* %5)
ret void
}