#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 /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int findStrings(char *path, int minlen) {
  FILE *inputfile;
  int char_counter;
  char current_char;
  char prev_char;
  int seek_value;
  seek_value = 0 - minlen - 1;
  printf("\nFilename: %s\n\n", path);
  inputfile = fopen(path, "rb");
  if (inputfile == NULL) {
    return (1);
  }
  while (!feof(inputfile)) {
    current_char = fgetc(inputfile);
    if (char_counter > minlen) {
      if ((current_char >= 32) && (current_char <= 126)) {
        char_counter++;
        printf("%c", current_char);
      } else {
        char_counter = 0;
        printf("\n");
      }
    } else if (char_counter == minlen) {
      fseek(inputfile, seek_value, SEEK_CUR);
      for (char_counter = 0; char_counter < minlen; char_counter++) {
        prev_char = fgetc(inputfile);
        printf("%c", prev_char);
      }
      if ((current_char >= 32) && (current_char <= 126)) {
        char_counter++;
      } else {
        char_counter = 0;
        printf("\n");
      }
    } else {
      if ((current_char >= 32) && (current_char <= 126)) {
        char_counter++;
      } else {
        char_counter = 0;
      }
    }
  }
  fclose(inputfile);
  return 0;
}


x86 assembly (clang, -O0):
<findStrings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xor    %eax,%eax
sub    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b7 <findStrings+0x57>
movl   $0x1,-0x4(%rbp)
jmp    1336 <findStrings+0x1d6>
jmp    11bc <findStrings+0x5c>
mov    -0x20(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11da <findStrings+0x7a>
jmp    1326 <findStrings+0x1c6>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x25(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1246 <findStrings+0xe6>
movsbl -0x25(%rbp),%eax
cmp    $0x20,%eax
jl     122c <findStrings+0xcc>
movsbl -0x25(%rbp),%eax
cmp    $0x7e,%eax
jg     122c <findStrings+0xcc>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsbl -0x25(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1241 <findStrings+0xe1>
movl   $0x0,-0x24(%rbp)
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1321 <findStrings+0x1c1>
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    12e8 <findStrings+0x188>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    0x2d88(%rip),%rax
mov    (%rax),%edx
call   1070 <fseek@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12a6 <findStrings+0x146>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x26(%rbp)
movsbl -0x26(%rbp),%esi
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    126e <findStrings+0x10e>
movsbl -0x25(%rbp),%eax
cmp    $0x20,%eax
jl     12ce <findStrings+0x16e>
movsbl -0x25(%rbp),%eax
cmp    $0x7e,%eax
jg     12ce <findStrings+0x16e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12e3 <findStrings+0x183>
movl   $0x0,-0x24(%rbp)
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    131c <findStrings+0x1bc>
movsbl -0x25(%rbp),%eax
cmp    $0x20,%eax
jl     1310 <findStrings+0x1b0>
movsbl -0x25(%rbp),%eax
cmp    $0x7e,%eax
jg     1310 <findStrings+0x1b0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1317 <findStrings+0x1b7>
movl   $0x0,-0x24(%rbp)
jmp    131c <findStrings+0x1bc>
jmp    1321 <findStrings+0x1c1>
jmp    11bc <findStrings+0x5c>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findStrings>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xe78(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     11c1 <findStrings+0x51>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11d5 <findStrings+0x65>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11c6 <findStrings+0x56>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14d,%r12d
not    %r12d
jmp    11f9 <findStrings+0x89>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %r15d,%r15d
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11b5 <findStrings+0x45>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    %eax,%r13d
cmp    %r14d,%r15d
jle    1220 <findStrings+0xb0>
lea    -0x20(%r13),%eax
cmp    $0x5e,%al
ja     11e0 <findStrings+0x70>
movzbl %r13b,%edi
add    $0x1,%r15d
call   1030 <putchar@plt>
jmp    11ed <findStrings+0x7d>
jne    1260 <findStrings+0xf0>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r12d,%esi
call   1080 <fseek@plt>
test   %r14d,%r14d
jle    127a <findStrings+0x10a>
mov    %r14d,%ebp
xchg   %ax,%ax
mov    %rbx,%rdi
call   1060 <fgetc@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1240 <findStrings+0xd0>
mov    %r14d,%r15d
jmp    127d <findStrings+0x10d>
nopw   0x0(%rax,%rax,1)
add    $0xe0,%r13b
add    $0x1,%r15d
cmp    $0x5f,%r13b
mov    $0x0,%eax
cmovae %eax,%r15d
jmp    11ed <findStrings+0x7d>
xor    %r15d,%r15d
add    $0xe0,%r13b
cmp    $0x5e,%r13b
ja     11e0 <findStrings+0x70>
add    $0x1,%r15d
jmp    11ed <findStrings+0x7d>

LLVM IR (-O0):
@.str = [16 x i8] c"\0AFilename: %s\0A\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
@SEEK_CUR = global i32 0
define i32 @findStrings(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%11 = load i32, i32* %5
%12 = sub nsw i32 0, %11
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %10
%14 = load i8*, i8** %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %4
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %6
%18 = load i32*, i32** %6
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %21
20: ; preds = %2
store i32 1, i32* %3
br label %104
21: ; preds = %2
br label %22
22: ; preds = %100, %21
%23 = load i32*, i32** %6
%24 = call i32 @feof(i32* %23)
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
br i1 %26, label %27, label %101
27: ; preds = %22
%28 = load i32*, i32** %6
%29 = call signext i8 @fgetc(i32* %28)
store i8 %29, i8* %8
%30 = load i32, i32* %7
%31 = load i32, i32* %5
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %50
33: ; preds = %27
%34 = load i8, i8* %8
%35 = sext i8 %34 to i32
%36 = icmp sge i32 %35, 32
br i1 %36, label %37, label %47
37: ; preds = %33
%38 = load i8, i8* %8
%39 = sext i8 %38 to i32
%40 = icmp sle i32 %39, 126
br i1 %40, label %41, label %47
41: ; preds = %37
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
%44 = load i8, i8* %8
%45 = sext i8 %44 to i32
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %45)
br label %49
47: ; preds = %37, %33
store i32 0, i32* %7
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %47, %41
br label %100
50: ; preds = %27
%51 = load i32, i32* %7
%52 = load i32, i32* %5
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %86
54: ; preds = %50
%55 = load i32*, i32** %6
%56 = load i32, i32* %10
%57 = load i32, i32* @SEEK_CUR
%58 = call i32 @fseek(i32* %55, i32 %56, i32 %57)
store i32 0, i32* %7
br label %59
59: ; preds = %69, %54
%60 = load i32, i32* %7
%61 = load i32, i32* %5
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %72
63: ; preds = %59
%64 = load i32*, i32** %6
%65 = call signext i8 @fgetc(i32* %64)
store i8 %65, i8* %9
%66 = load i8, i8* %9
%67 = sext i8 %66 to i32
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %63
%70 = load i32, i32* %7
%71 = add nsw i32 %70, 1
store i32 %71, i32* %7
br label %59
72: ; preds = %59
%73 = load i8, i8* %8
%74 = sext i8 %73 to i32
%75 = icmp sge i32 %74, 32
br i1 %75, label %76, label %83
76: ; preds = %72
%77 = load i8, i8* %8
%78 = sext i8 %77 to i32
%79 = icmp sle i32 %78, 126
br i1 %79, label %80, label %83
80: ; preds = %76
%81 = load i32, i32* %7
%82 = add nsw i32 %81, 1
store i32 %82, i32* %7
br label %85
83: ; preds = %76, %72
store i32 0, i32* %7
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %85
85: ; preds = %83, %80
br label %99
86: ; preds = %50
%87 = load i8, i8* %8
%88 = sext i8 %87 to i32
%89 = icmp sge i32 %88, 32
br i1 %89, label %90, label %97
90: ; preds = %86
%91 = load i8, i8* %8
%92 = sext i8 %91 to i32
%93 = icmp sle i32 %92, 126
br i1 %93, label %94, label %97
94: ; preds = %90
%95 = load i32, i32* %7
%96 = add nsw i32 %95, 1
store i32 %96, i32* %7
br label %98
97: ; preds = %90, %86
store i32 0, i32* %7
br label %98
98: ; preds = %97, %94
br label %99
99: ; preds = %98, %85
br label %100
100: ; preds = %99, %49
br label %22
101: ; preds = %22
%102 = load i32*, i32** %6
%103 = call i32 @fclose(i32* %102)
store i32 0, i32* %3
br label %104
104: ; preds = %101, %20
%105 = load i32, i32* %3
ret i32 %105
}

LLVM IR (-O2):
@.str = [16 x i8] c"\0AFilename: %s\0A\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@SEEK_CUR = global i32 0
define i32 @findStrings(i8* %0, i32 %1) {
%3 = xor i32 %1, -1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %56, label %7
7: ; preds = %2
%8 = tail call i32 @feof(i32* %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %54
10: ; preds = %7
%11 = icmp sgt i32 %1, 0
br label %12
12: ; preds = %10, %50
%13 = phi i32 [ undef, %10 ], [ %51, %50 ]
%14 = tail call signext i8 @fgetc(i32* %5)
%15 = icmp sgt i32 %13, %1
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = add i8 %14, -32
%18 = icmp ult i8 %17, 95
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = zext i8 %14 to i32
%21 = add nsw i32 %13, 1
%22 = tail call i32 @putchar(i32 %20)
br label %50
23: ; preds = %16
%24 = tail call i32 @putchar(i32 10)
br label %50
25: ; preds = %12
%26 = icmp eq i32 %13, %1
br i1 %26, label %27, label %45
27: ; preds = %25
%28 = load i32, i32* @SEEK_CUR
%29 = tail call i32 @fseek(i32* %5, i32 %3, i32 %28)
br i1 %11, label %30, label %37
30: ; preds = %27, %30
%31 = phi i32 [ %35, %30 ], [ 0, %27 ]
%32 = tail call signext i8 @fgetc(i32* %5)
%33 = sext i8 %32 to i32
%34 = tail call i32 @putchar(i32 %33)
%35 = add nuw nsw i32 %31, 1
%36 = icmp eq i32 %35, %1
br i1 %36, label %37, label %30
37: ; preds = %30, %27
%38 = phi i32 [ 0, %27 ], [ %1, %30 ]
%39 = add i8 %14, -32
%40 = icmp ult i8 %39, 95
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = add nuw nsw i32 %38, 1
br label %50
43: ; preds = %37
%44 = tail call i32 @putchar(i32 10)
br label %50
45: ; preds = %25
%46 = add i8 %14, -32
%47 = icmp ult i8 %46, 95
%48 = add nsw i32 %13, 1
%49 = select i1 %47, i32 %48, i32 0
br label %50
50: ; preds = %45, %43, %41, %19, %23
%51 = phi i32 [ %21, %19 ], [ 0, %23 ], [ %42, %41 ], [ 0, %43 ], [ %49, %45 ]
%52 = tail call i32 @feof(i32* %5)
%53 = icmp eq i32 %52, 0
br i1 %53, label %12, label %54
54: ; preds = %50, %7
%55 = tail call i32 @fclose(i32* %5)
br label %56
56: ; preds = %2, %54
%57 = phi i32 [ 0, %54 ], [ 1, %2 ]
ret i32 %57
}