#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 */
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
size_t ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
char *scat(char *, char *, int);
int /*<<< orphan*/ strcmp(char *, char *);
int countLines(char *dirpath) {
  int lines = 0;
  DIR *dir;
  if (!(dir = opendir(dirpath))) {
    return 0;
  }
  struct dirent *dirent;
  while ((dirent = readdir(dir))) {
    char *path = scat(dirpath, "/", 0);
    path = scat(path, dirent->d_name, 1);
    if (opendir(path)) {
      if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, "..")) {
        free(path);
        continue;
      }
      printf("Dir: \"%s\"\n", path);
      lines += countLines(path);
    } else {
      printf("File: \"%s\"\n", path);
      char *buffer;
      size_t size;
      FILE *file;
      if (!(file = fopen(path, "r"))) {
        printf("File opening error, file: \"%s\"\n", dirent->d_name);
        continue;
      }
      fseek(file, 0, SEEK_END);
      size = ftell(file);
      rewind(file);
      if (!(buffer = (char *)malloc(sizeof(char) * size))) {
        printf("Memory allocating error, file: \"%s\"\n", dirent->d_name);
        fclose(file);
        continue;
      }
      if (!fread(buffer, sizeof(char), size, file)) {
        printf("File reading error, file: \"%s\"\n", dirent->d_name);
        free(buffer);
        fclose(file);
        continue;
      }
      for (int i = 0; i < size; i++) {
        if (buffer[i] == '\n') {
          lines++;
        }
      }
      free(buffer);
      fclose(file);
    }
    free(path);
  }
  closedir(dir);
  return lines;
}


x86 assembly (clang, -O0):
<countLines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1226 <countLines+0x36>
movl   $0x0,-0x4(%rbp)
jmp    145a <countLines+0x26a>
jmp    122b <countLines+0x3b>
mov    -0x20(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     144b <countLines+0x25b>
mov    -0x10(%rbp),%rdi
lea    0xdb3(%rip),%rsi
xor    %edx,%edx
call   1110 <scat@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
mov    $0x1,%edx
call   1110 <scat@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <opendir@plt>
cmp    $0x0,%rax
je     12ee <countLines+0xfe>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xd71(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
je     12bc <countLines+0xcc>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xd54(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    12ca <countLines+0xda>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    122b <countLines+0x3b>
mov    -0x30(%rbp),%rsi
lea    0xd30(%rip),%rdi
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   10c0 <countLines@plt>
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    143d <countLines+0x24d>
mov    -0x30(%rbp),%rsi
lea    0xd17(%rip),%rdi
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    0xd13(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1334 <countLines+0x144>
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
lea    0xcf4(%rip),%rdi
call   1070 <printf@plt>
jmp    122b <countLines+0x3b>
mov    -0x48(%rbp),%rdi
mov    0x2ca9(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10f0 <fseek@plt>
mov    -0x48(%rbp),%rdi
call   10b0 <ftell@plt>
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rdi
call   1080 <rewind@plt>
mov    -0x40(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    139c <countLines+0x1ac>
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
lea    0xcb5(%rip),%rdi
call   1070 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
jmp    122b <countLines+0x3b>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
cmp    $0x0,%eax
jne    13e5 <countLines+0x1f5>
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
lea    0xc9a(%rip),%rdi
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
jmp    122b <countLines+0x3b>
movl   $0x0,-0x4c(%rbp)
movslq -0x4c(%rbp),%rax
cmp    -0x40(%rbp),%rax
jae    142b <countLines+0x23b>
mov    -0x38(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1418 <countLines+0x228>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    141d <countLines+0x22d>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    13ec <countLines+0x1fc>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    122b <countLines+0x3b>
mov    -0x20(%rbp),%rdi
call   1090 <closedir@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<countLines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
call   1060 <opendir@plt>
test   %rax,%rax
je     152b <countLines+0x33b>
mov    %rax,%r15
mov    %rax,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
je     1530 <countLines+0x340>
mov    %rax,%rbx
xor    %r12d,%r12d
lea    0xdf0(%rip),%rbp
mov    %r14,0x10(%rsp)
mov    %r15,0x8(%rsp)
jmp    127c <countLines+0x8c>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    0x8(%rsp),%r15
mov    0x10(%rsp),%r14
lea    0xdc3(%rip),%rbp
nopl   (%rax)
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   10d0 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1533 <countLines+0x343>
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %edx,%edx
call   1110 <scat@plt>
mov    (%rbx),%rsi
mov    %rax,%rdi
mov    $0x1,%edx
call   1110 <scat@plt>
mov    %rax,%r13
mov    %rax,%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     1300 <countLines+0x110>
mov    (%rbx),%rbx
mov    %rbx,%rdi
lea    0xd6d(%rip),%rsi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     1260 <countLines+0x70>
mov    %rbx,%rdi
lea    0xd59(%rip),%rsi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     1260 <countLines+0x70>
lea    0xd4c(%rip),%rdi
mov    %r13,%rsi
call   1070 <printf@plt>
mov    %r13,%rdi
call   10c0 <countLines@plt>
add    %eax,%r12d
jmp    1260 <countLines+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xd29(%rip),%rdi
mov    %r13,%rsi
call   1070 <printf@plt>
mov    %r13,%rdi
lea    0xd23(%rip),%rsi
call   1100 <fopen@plt>
test   %rax,%rax
je     138c <countLines+0x19c>
mov    %rax,%rcx
mov    0x2cbb(%rip),%rax
mov    (%rax),%edx
mov    %rcx,%rbp
mov    %rcx,%rdi
xor    %esi,%esi
call   10f0 <fseek@plt>
mov    %rbp,%rdi
call   10b0 <ftell@plt>
mov    %rax,%r14
mov    %rbp,%rdi
call   1080 <rewind@plt>
mov    %r14d,%edi
call   10e0 <malloc@plt>
test   %rax,%rax
je     13a0 <countLines+0x1b0>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rbp,%rcx
call   1040 <fread@plt>
test   %eax,%eax
je     13b1 <countLines+0x1c1>
test   %r14,%r14
je     123c <countLines+0x4c>
cmp    $0x8,%r14
jae    13e6 <countLines+0x1f6>
xor    %eax,%eax
jmp    1510 <countLines+0x320>
mov    (%rbx),%rsi
lea    0xca8(%rip),%rdi
call   1070 <printf@plt>
jmp    1268 <countLines+0x78>
mov    (%rbx),%rsi
lea    0xcb4(%rip),%rdi
call   1070 <printf@plt>
jmp    13c8 <countLines+0x1d8>
mov    (%rbx),%rsi
lea    0xcc8(%rip),%rdi
call   1070 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
mov    0x8(%rsp),%r15
mov    0x10(%rsp),%r14
lea    0xc3f(%rip),%rbp
jmp    1268 <countLines+0x78>
mov    %r14,%rax
and    $0xfffffffffffffff8,%rax
movd   %r12d,%xmm0
lea    -0x8(%rax),%rdx
mov    %rdx,%rcx
shr    $0x3,%rcx
add    $0x1,%rcx
test   %rdx,%rdx
movdqa 0xbf4(%rip),%xmm4
movdqa 0xbfc(%rip),%xmm5
je     14fc <countLines+0x30c>
mov    %rcx,%rsi
and    $0xfffffffffffffffe,%rsi
pxor   %xmm1,%xmm1
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
movd   (%r15,%rdx,1),%xmm3
movd   0x4(%r15,%rdx,1),%xmm2
pcmpeqb %xmm4,%xmm3
punpcklbw %xmm3,%xmm3
punpcklwd %xmm3,%xmm3
pand   %xmm5,%xmm3
paddd  %xmm0,%xmm3
pcmpeqb %xmm4,%xmm2
punpcklbw %xmm2,%xmm2
punpcklwd %xmm2,%xmm2
pand   %xmm5,%xmm2
paddd  %xmm1,%xmm2
movd   0x8(%r15,%rdx,1),%xmm0
movd   0xc(%r15,%rdx,1),%xmm1
pcmpeqb %xmm4,%xmm0
punpcklbw %xmm0,%xmm0
punpcklwd %xmm0,%xmm0
pand   %xmm5,%xmm0
paddd  %xmm3,%xmm0
pcmpeqb %xmm4,%xmm1
punpcklbw %xmm1,%xmm1
punpcklwd %xmm1,%xmm1
pand   %xmm5,%xmm1
paddd  %xmm2,%xmm1
add    $0x10,%rdx
add    $0xfffffffffffffffe,%rsi
jne    1430 <countLines+0x240>
test   $0x1,%cl
je     14df <countLines+0x2ef>
movd   (%r15,%rdx,1),%xmm2
movd   0x4(%r15,%rdx,1),%xmm3
pcmpeqb %xmm4,%xmm2
punpcklbw %xmm2,%xmm2
punpcklwd %xmm2,%xmm2
pand   %xmm5,%xmm2
paddd  %xmm2,%xmm0
pcmpeqb %xmm4,%xmm3
punpcklbw %xmm3,%xmm3
punpcklwd %xmm3,%xmm3
pand   %xmm5,%xmm3
paddd  %xmm3,%xmm1
paddd  %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%r12d
jmp    1521 <countLines+0x331>
pxor   %xmm1,%xmm1
xor    %edx,%edx
test   $0x1,%cl
jne    14aa <countLines+0x2ba>
jmp    14df <countLines+0x2ef>
nopl   0x0(%rax)
xor    %ecx,%ecx
cmpb   $0xa,(%r15,%rax,1)
sete   %cl
add    %ecx,%r12d
add    $0x1,%rax
cmp    %rax,%r14
jne    1510 <countLines+0x320>
jmp    123c <countLines+0x4c>
xor    %r12d,%r12d
jmp    153b <countLines+0x34b>
xor    %r12d,%r12d
mov    %r15,%rdi
call   1090 <closedir@plt>
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [2 x i8] c"/\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [11 x i8] c"Dir: \22%s\22\0A\00"
@.str.4 = [12 x i8] c"File: \22%s\22\0A\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [32 x i8] c"File opening error, file: \22%s\22\0A\00"
@SEEK_END = global i32 0
@.str.7 = [37 x i8] c"Memory allocating error, file: \22%s\22\0A\00"
@.str.8 = [32 x i8] c"File reading error, file: \22%s\22\0A\00"
define i32 @countLines(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca %struct.dirent*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32*
%11 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
%12 = load i8*, i8** %3
%13 = call i32* @opendir(i8* %12)
store i32* %13, i32** %5
%14 = icmp ne i32* %13, null
br i1 %14, label %16, label %15
15: ; preds = %1
store i32 0, i32* %2
br label %134
16: ; preds = %1
br label %17
17: ; preds = %127, %92, %79, %60, %44, %16
%18 = load i32*, i32** %5
%19 = call %struct.dirent* @readdir(i32* %18)
store %struct.dirent* %19, %struct.dirent** %6
%20 = icmp ne %struct.dirent* %19, null
br i1 %20, label %21, label %130
21: ; preds = %17
%22 = load i8*, i8** %3
%23 = call i8* @scat(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0)
store i8* %23, i8** %7
%24 = load i8*, i8** %7
%25 = load %struct.dirent*, %struct.dirent** %6
%26 = getelementptr inbounds %struct.dirent, %struct.dirent* %25, i32 0, i32 0
%27 = load i8*, i8** %26
%28 = call i8* @scat(i8* %24, i8* %27, i32 1)
store i8* %28, i8** %7
%29 = load i8*, i8** %7
%30 = call i32* @opendir(i8* %29)
%31 = icmp ne i32* %30, null
br i1 %31, label %32, label %54
32: ; preds = %21
%33 = load %struct.dirent*, %struct.dirent** %6
%34 = getelementptr inbounds %struct.dirent, %struct.dirent* %33, i32 0, i32 0
%35 = load i8*, i8** %34
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %32
%39 = load %struct.dirent*, %struct.dirent** %6
%40 = getelementptr inbounds %struct.dirent, %struct.dirent* %39, i32 0, i32 0
%41 = load i8*, i8** %40
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %38, %32
%45 = load i8*, i8** %7
%46 = call i32 @free(i8* %45)
br label %17
47: ; preds = %38
%48 = load i8*, i8** %7
%49 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %48)
%50 = load i8*, i8** %7
%51 = call i32 @countLines(i8* %50)
%52 = load i32, i32* %4
%53 = add nsw i32 %52, %51
store i32 %53, i32* %4
br label %127
54: ; preds = %21
%55 = load i8*, i8** %7
%56 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%57 = load i8*, i8** %7
%58 = call i32* @fopen(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %58, i32** %10
%59 = icmp ne i32* %58, null
br i1 %59, label %65, label %60
60: ; preds = %54
%61 = load %struct.dirent*, %struct.dirent** %6
%62 = getelementptr inbounds %struct.dirent, %struct.dirent* %61, i32 0, i32 0
%63 = load i8*, i8** %62
%64 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %63)
br label %17
65: ; preds = %54
%66 = load i32*, i32** %10
%67 = load i32, i32* @SEEK_END
%68 = call i32 @fseek(i32* %66, i32 0, i32 %67)
%69 = load i32*, i32** %10
%70 = call i64 @ftell(i32* %69)
store i64 %70, i64* %9
%71 = load i32*, i32** %10
%72 = call i32 @rewind(i32* %71)
%73 = load i64, i64* %9
%74 = mul i64 1, %73
%75 = trunc i64 %74 to i32
%76 = call i64 @malloc(i32 %75)
%77 = inttoptr i64 %76 to i8*
store i8* %77, i8** %8
%78 = icmp ne i8* %77, null
br i1 %78, label %86, label %79
79: ; preds = %65
%80 = load %struct.dirent*, %struct.dirent** %6
%81 = getelementptr inbounds %struct.dirent, %struct.dirent* %80, i32 0, i32 0
%82 = load i8*, i8** %81
%83 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %82)
%84 = load i32*, i32** %10
%85 = call i32 @fclose(i32* %84)
br label %17
86: ; preds = %65
%87 = load i8*, i8** %8
%88 = load i64, i64* %9
%89 = load i32*, i32** %10
%90 = call i32 @fread(i8* %87, i32 1, i64 %88, i32* %89)
%91 = icmp ne i32 %90, 0
br i1 %91, label %101, label %92
92: ; preds = %86
%93 = load %struct.dirent*, %struct.dirent** %6
%94 = getelementptr inbounds %struct.dirent, %struct.dirent* %93, i32 0, i32 0
%95 = load i8*, i8** %94
%96 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* %95)
%97 = load i8*, i8** %8
%98 = call i32 @free(i8* %97)
%99 = load i32*, i32** %10
%100 = call i32 @fclose(i32* %99)
br label %17
101: ; preds = %86
store i32 0, i32* %11
br label %102
102: ; preds = %119, %101
%103 = load i32, i32* %11
%104 = sext i32 %103 to i64
%105 = load i64, i64* %9
%106 = icmp ult i64 %104, %105
br i1 %106, label %107, label %122
107: ; preds = %102
%108 = load i8*, i8** %8
%109 = load i32, i32* %11
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %108, i64 %110
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %113, 10
br i1 %114, label %115, label %118
115: ; preds = %107
%116 = load i32, i32* %4
%117 = add nsw i32 %116, 1
store i32 %117, i32* %4
br label %118
118: ; preds = %115, %107
br label %119
119: ; preds = %118
%120 = load i32, i32* %11
%121 = add nsw i32 %120, 1
store i32 %121, i32* %11
br label %102
122: ; preds = %102
%123 = load i8*, i8** %8
%124 = call i32 @free(i8* %123)
%125 = load i32*, i32** %10
%126 = call i32 @fclose(i32* %125)
br label %127
127: ; preds = %122, %47
%128 = load i8*, i8** %7
%129 = call i32 @free(i8* %128)
br label %17
130: ; preds = %17
%131 = load i32*, i32** %5
%132 = call i32 @closedir(i32* %131)
%133 = load i32, i32* %4
store i32 %133, i32* %2
br label %134
134: ; preds = %130, %15
%135 = load i32, i32* %2
ret i32 %135
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [2 x i8] c"/\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [11 x i8] c"Dir: \22%s\22\0A\00"
@.str.4 = [12 x i8] c"File: \22%s\22\0A\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [32 x i8] c"File opening error, file: \22%s\22\0A\00"
@SEEK_END = global i32 0
@.str.7 = [37 x i8] c"Memory allocating error, file: \22%s\22\0A\00"
@.str.8 = [32 x i8] c"File reading error, file: \22%s\22\0A\00"
define i32 @countLines(i8* %0) {
%2 = tail call i32* @opendir(i8* %0)
%3 = icmp eq i32* %2, null
br i1 %3, label %157, label %4
4: ; preds = %1
%5 = tail call %struct.dirent* @readdir(i32* %2)
%6 = icmp eq %struct.dirent* %5, null
br i1 %6, label %154, label %7
7: ; preds = %4, %150
%8 = phi %struct.dirent* [ %152, %150 ], [ %5, %4 ]
%9 = phi i32 [ %151, %150 ], [ 0, %4 ]
%10 = tail call i8* @scat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0)
%11 = getelementptr inbounds %struct.dirent, %struct.dirent* %8, i64 0, i32 0
%12 = load i8*, i8** %11
%13 = tail call i8* @scat(i8* %10, i8* %12, i32 1)
%14 = tail call i32* @opendir(i8* %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %29, label %16
16: ; preds = %7
%17 = load i8*, i8** %11
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20, %16
%24 = tail call i32 @free(i8* %13)
br label %150
25: ; preds = %20
%26 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%27 = tail call i32 @countLines(i8* %13)
%28 = add nsw i32 %27, %9
br label %147
29: ; preds = %7
%30 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%31 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i8*, i8** %11
%35 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %34)
br label %150
36: ; preds = %29
%37 = load i32, i32* @SEEK_END
%38 = tail call i32 @fseek(i32* %31, i32 0, i32 %37)
%39 = tail call i64 @ftell(i32* %31)
%40 = tail call i32 @rewind(i32* %31)
%41 = trunc i64 %39 to i32
%42 = tail call i64 @malloc(i32 %41)
%43 = inttoptr i64 %42 to i8*
%44 = icmp eq i64 %42, 0
br i1 %44, label %45, label %49
45: ; preds = %36
%46 = load i8*, i8** %11
%47 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %46)
%48 = tail call i32 @fclose(i32* %31)
br label %150
49: ; preds = %36
%50 = tail call i32 @fread(i8* %43, i32 1, i64 %39, i32* %31)
%51 = icmp eq i32 %50, 0
br i1 %51, label %128, label %52
52: ; preds = %49
%53 = icmp eq i64 %39, 0
br i1 %53, label %143, label %54
54: ; preds = %52
%55 = icmp ult i64 %39, 8
br i1 %55, label %125, label %56
56: ; preds = %54
%57 = and i64 %39, -8
%58 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %9, i64 0
%59 = add i64 %57, -8
%60 = lshr exact i64 %59, 3
%61 = add nuw nsw i64 %60, 1
%62 = and i64 %61, 1
%63 = icmp eq i64 %59, 0
br i1 %63, label %99, label %64
64: ; preds = %56
%65 = and i64 %61, 4611686018427387902
br label %66
66: ; preds = %66, %64
%67 = phi i64 [ 0, %64 ], [ %96, %66 ]
%68 = phi <4 x i32> [ %58, %64 ], [ %94, %66 ]
%69 = phi <4 x i32> [ zeroinitializer, %64 ], [ %95, %66 ]
%70 = phi i64 [ 0, %64 ], [ %97, %66 ]
%71 = getelementptr inbounds i8, i8* %43, i64 %67
%72 = bitcast i8* %71 to <4 x i8>*
%73 = load <4 x i8>, <4 x i8>* %72
%74 = getelementptr inbounds i8, i8* %71, i64 4
%75 = bitcast i8* %74 to <4 x i8>*
%76 = load <4 x i8>, <4 x i8>* %75
%77 = icmp eq <4 x i8> %73, <i8 10, i8 10, i8 10, i8 10>
%78 = icmp eq <4 x i8> %76, <i8 10, i8 10, i8 10, i8 10>
%79 = zext <4 x i1> %77 to <4 x i32>
%80 = zext <4 x i1> %78 to <4 x i32>
%81 = add <4 x i32> %68, %79
%82 = add <4 x i32> %69, %80
%83 = or i64 %67, 8
%84 = getelementptr inbounds i8, i8* %43, i64 %83
%85 = bitcast i8* %84 to <4 x i8>*
%86 = load <4 x i8>, <4 x i8>* %85
%87 = getelementptr inbounds i8, i8* %84, i64 4
%88 = bitcast i8* %87 to <4 x i8>*
%89 = load <4 x i8>, <4 x i8>* %88
%90 = icmp eq <4 x i8> %86, <i8 10, i8 10, i8 10, i8 10>
%91 = icmp eq <4 x i8> %89, <i8 10, i8 10, i8 10, i8 10>
%92 = zext <4 x i1> %90 to <4 x i32>
%93 = zext <4 x i1> %91 to <4 x i32>
%94 = add <4 x i32> %81, %92
%95 = add <4 x i32> %82, %93
%96 = add nuw i64 %67, 16
%97 = add i64 %70, 2
%98 = icmp eq i64 %97, %65
br i1 %98, label %99, label %66
99: ; preds = %66, %56
%100 = phi <4 x i32> [ undef, %56 ], [ %94, %66 ]
%101 = phi <4 x i32> [ undef, %56 ], [ %95, %66 ]
%102 = phi i64 [ 0, %56 ], [ %96, %66 ]
%103 = phi <4 x i32> [ %58, %56 ], [ %94, %66 ]
%104 = phi <4 x i32> [ zeroinitializer, %56 ], [ %95, %66 ]
%105 = icmp eq i64 %62, 0
br i1 %105, label %119, label %106
106: ; preds = %99
%107 = getelementptr inbounds i8, i8* %43, i64 %102
%108 = bitcast i8* %107 to <4 x i8>*
%109 = load <4 x i8>, <4 x i8>* %108
%110 = getelementptr inbounds i8, i8* %107, i64 4
%111 = bitcast i8* %110 to <4 x i8>*
%112 = load <4 x i8>, <4 x i8>* %111
%113 = icmp eq <4 x i8> %109, <i8 10, i8 10, i8 10, i8 10>
%114 = icmp eq <4 x i8> %112, <i8 10, i8 10, i8 10, i8 10>
%115 = zext <4 x i1> %113 to <4 x i32>
%116 = zext <4 x i1> %114 to <4 x i32>
%117 = add <4 x i32> %103, %115
%118 = add <4 x i32> %104, %116
br label %119
119: ; preds = %99, %106
%120 = phi <4 x i32> [ %100, %99 ], [ %117, %106 ]
%121 = phi <4 x i32> [ %101, %99 ], [ %118, %106 ]
%122 = add <4 x i32> %121, %120
%123 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %122)
%124 = icmp eq i64 %39, %57
br i1 %124, label %143, label %125
125: ; preds = %54, %119
%126 = phi i64 [ 0, %54 ], [ %57, %119 ]
%127 = phi i32 [ %9, %54 ], [ %123, %119 ]
br label %133
128: ; preds = %49
%129 = load i8*, i8** %11
%130 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* %129)
%131 = tail call i32 @free(i8* %43)
%132 = tail call i32 @fclose(i32* %31)
br label %150
133: ; preds = %125, %133
%134 = phi i64 [ %141, %133 ], [ %126, %125 ]
%135 = phi i32 [ %140, %133 ], [ %127, %125 ]
%136 = getelementptr inbounds i8, i8* %43, i64 %134
%137 = load i8, i8* %136
%138 = icmp eq i8 %137, 10
%139 = zext i1 %138 to i32
%140 = add nsw i32 %135, %139
%141 = add nuw nsw i64 %134, 1
%142 = icmp eq i64 %141, %39
br i1 %142, label %143, label %133
143: ; preds = %133, %119, %52
%144 = phi i32 [ %9, %52 ], [ %123, %119 ], [ %140, %133 ]
%145 = tail call i32 @free(i8* %43)
%146 = tail call i32 @fclose(i32* %31)
br label %147
147: ; preds = %143, %25
%148 = phi i32 [ %28, %25 ], [ %144, %143 ]
%149 = tail call i32 @free(i8* %13)
br label %150
150: ; preds = %33, %45, %128, %147, %23
%151 = phi i32 [ %148, %147 ], [ %9, %23 ], [ %9, %128 ], [ %9, %45 ], [ %9, %33 ]
%152 = tail call %struct.dirent* @readdir(i32* %2)
%153 = icmp eq %struct.dirent* %152, null
br i1 %153, label %154, label %7
154: ; preds = %150, %4
%155 = phi i32 [ 0, %4 ], [ %151, %150 ]
%156 = tail call i32 @closedir(i32* %2)
br label %157
157: ; preds = %1, %154
%158 = phi i32 [ %155, %154 ], [ 0, %1 ]
ret i32 %158
}