#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 scalar_t__ time_t;
struct stat {
  scalar_t__ st_mtime;
};
struct direct {
  char *d_name;
};
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ InstallNewEngine(char *, char *, char *, char *);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ *opendir(char *);
struct direct *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, ...);
int sscanf(char *, char *, char *, char *);
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strstr(char *, char *);
void InstallFromDir(char *dirName, char *protocol, char *settingsFile) {
  DIR *dir;
  struct direct *dp;
  struct stat statBuf;
  time_t lastSaved = 0;
  char buf[1024];
  if (!stat(settingsFile, &statBuf))
    lastSaved = statBuf.st_mtime;
  snprintf(buf, 1024, "%s/%s", dirName, protocol);
  if (!(dir = opendir(buf)))
    return;
  while ((dp = readdir(dir))) {
    time_t installed = 0;
    if (!strstr(dp->d_name, ".eng"))
      continue;
    snprintf(buf, 1024, "%s/%s/%s", dirName, protocol, dp->d_name);
    if (!stat(buf, &statBuf))
      installed = statBuf.st_mtime;
    if (lastSaved == 0 || (int)(installed - lastSaved) > 0) {
      FILE *f = fopen(buf, "r");
      if (f) {
        char engineCommand[1024], engineDir[1024], variants[1024];
        char bad = 0, dummy, *engineCom = engineCommand;
        int major, minor;
        if (fscanf(f, "plugin spec %d.%d%c", &major, &minor, &dummy) != 3 ||
            fscanf(f, "%[^\n]%c", engineCommand, &dummy) != 2 ||
            fscanf(f, "%[^\n]%c", variants, &dummy) != 2)
          bad = 1;
        fclose(f);
        if (bad)
          continue;
        strcpy(engineDir, "");
        if (sscanf(engineCommand, "cd %[^;];%c", engineDir, &dummy) == 2)
          engineCom = engineCommand + strlen(engineDir) + 4;
        InstallNewEngine(engineCom, engineDir, variants, protocol);
      }
    }
  }
  closedir(dir);
}


x86 assembly (clang, -O0):
<InstallFromDir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1070,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0x0,%eax
jne    120d <InstallFromDir+0x3d>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x440(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    $0x400,%esi
lea    0xde0(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
lea    -0x440(%rbp),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    124e <InstallFromDir+0x7e>
jmp    1491 <InstallFromDir+0x2c1>
jmp    1253 <InstallFromDir+0x83>
mov    -0x20(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     1488 <InstallFromDir+0x2b8>
movq   $0x0,-0x448(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    0xd7d(%rip),%rsi
call   10f0 <strstr@plt>
cmp    $0x0,%eax
jne    1296 <InstallFromDir+0xc6>
jmp    1253 <InstallFromDir+0x83>
lea    -0x440(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x28(%rbp),%rax
mov    (%rax),%r9
mov    $0x400,%esi
lea    0xd4d(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
lea    -0x440(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10b0 <stat@plt>
cmp    $0x0,%eax
jne    12e3 <InstallFromDir+0x113>
mov    -0x30(%rbp),%rax
mov    %rax,-0x448(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1302 <InstallFromDir+0x132>
mov    -0x448(%rbp),%rax
sub    -0x38(%rbp),%rax
cmp    $0x0,%eax
jle    1483 <InstallFromDir+0x2b3>
lea    -0x440(%rbp),%rdi
lea    0xcfe(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x450(%rbp)
je     147e <InstallFromDir+0x2ae>
movb   $0x0,-0x1051(%rbp)
lea    -0x850(%rbp),%rax
mov    %rax,-0x1060(%rbp)
mov    -0x450(%rbp),%rdi
lea    0xcc3(%rip),%rsi
lea    -0x1064(%rbp),%rdx
lea    -0x1068(%rbp),%rcx
lea    -0x1052(%rbp),%r8
mov    $0x0,%al
call   1090 <fscanf@plt>
cmp    $0x3,%eax
jne    13ca <InstallFromDir+0x1fa>
mov    -0x450(%rbp),%rdi
lea    -0x850(%rbp),%rdx
lea    0xc9d(%rip),%rsi
lea    -0x1052(%rbp),%rcx
mov    $0x0,%al
call   1090 <fscanf@plt>
cmp    $0x2,%eax
jne    13ca <InstallFromDir+0x1fa>
mov    -0x450(%rbp),%rdi
lea    -0x1050(%rbp),%rdx
lea    0xc71(%rip),%rsi
lea    -0x1052(%rbp),%rcx
mov    $0x0,%al
call   1090 <fscanf@plt>
cmp    $0x2,%eax
je     13d1 <InstallFromDir+0x201>
movb   $0x1,-0x1051(%rbp)
mov    -0x450(%rbp),%rdi
call   1050 <fclose@plt>
cmpb   $0x0,-0x1051(%rbp)
je     13ef <InstallFromDir+0x21f>
jmp    1253 <InstallFromDir+0x83>
lea    -0xc50(%rbp),%rdi
lea    0xc3a(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x850(%rbp),%rdi
lea    -0xc50(%rbp),%rdx
lea    0xc15(%rip),%rsi
lea    -0x1052(%rbp),%rcx
call   10d0 <sscanf@plt>
cmp    $0x2,%eax
jne    1460 <InstallFromDir+0x290>
lea    -0x850(%rbp),%rax
mov    %rax,-0x1070(%rbp)
lea    -0xc50(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x1070(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x4,%rax
mov    %rax,-0x1060(%rbp)
mov    -0x1060(%rbp),%rdi
lea    -0xc50(%rbp),%rsi
lea    -0x1050(%rbp),%rdx
mov    -0x10(%rbp),%rcx
call   1040 <InstallNewEngine@plt>
jmp    1483 <InstallFromDir+0x2b3>
jmp    1253 <InstallFromDir+0x83>
mov    -0x20(%rbp),%rdi
call   10a0 <closedir@plt>
add    $0x1070,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InstallFromDir>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1028,%rsp
mov    %rsi,%r15
mov    %rdi,0x10(%rsp)
lea    0x8(%rsp),%rsi
mov    %rdx,%rdi
call   10b0 <stat@plt>
test   %eax,%eax
jne    1201 <InstallFromDir+0x31>
mov    0x8(%rsp),%r14
jmp    1204 <InstallFromDir+0x34>
xor    %r14d,%r14d
lea    0xdfd(%rip),%rdx
lea    0xc20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    0x10(%rsp),%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    %rbx,%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     13e2 <InstallFromDir+0x212>
mov    %rax,%rbx
mov    %rax,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     13da <InstallFromDir+0x20a>
mov    %rax,%rbp
lea    0xc20(%rsp),%r12
jmp    1284 <InstallFromDir+0xb4>
mov    %r13,%rdi
call   1050 <fclose@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   10c0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     13da <InstallFromDir+0x20a>
mov    0x0(%rbp),%rdi
lea    0xd71(%rip),%rsi
call   10f0 <strstr@plt>
test   %eax,%eax
je     1270 <InstallFromDir+0xa0>
mov    0x0(%rbp),%r9
xor    %ebp,%ebp
mov    %r12,%rdi
mov    $0x400,%esi
lea    0xd58(%rip),%rdx
mov    0x10(%rsp),%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    %r12,%rdi
lea    0x8(%rsp),%rsi
call   10b0 <stat@plt>
test   %eax,%eax
jne    12d1 <InstallFromDir+0x101>
mov    0x8(%rsp),%ebp
test   %r14,%r14
je     12dd <InstallFromDir+0x10d>
sub    %r14d,%ebp
test   %ebp,%ebp
jle    1270 <InstallFromDir+0xa0>
mov    %r12,%rdi
lea    0xd27(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1270 <InstallFromDir+0xa0>
mov    %rax,%r13
mov    %rax,%rdi
lea    0xd0e(%rip),%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x7(%rsp),%rbp
mov    %rbp,%r8
xor    %eax,%eax
call   1090 <fscanf@plt>
cmp    $0x3,%eax
jne    125c <InstallFromDir+0x8c>
mov    %r13,%rdi
lea    0xcf6(%rip),%rsi
lea    0x20(%rsp),%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1090 <fscanf@plt>
cmp    $0x2,%eax
jne    125c <InstallFromDir+0x8c>
mov    %r13,%rdi
lea    0xcd4(%rip),%rsi
lea    0x420(%rsp),%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1090 <fscanf@plt>
cmp    $0x2,%eax
jne    125c <InstallFromDir+0x8c>
mov    %r13,%rdi
call   1050 <fclose@plt>
lea    0x820(%rsp),%rdi
lea    0xcb5(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x20(%rsp),%rdi
lea    0xc99(%rip),%rsi
lea    0x820(%rsp),%r13
mov    %r13,%rdx
mov    %rbp,%rcx
call   10d0 <sscanf@plt>
lea    0x20(%rsp),%rdi
cmp    $0x2,%eax
jne    13c2 <InstallFromDir+0x1f2>
mov    %r13,%rdi
call   1070 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rdi
add    $0x24,%rdi
mov    %r13,%rsi
lea    0x420(%rsp),%rdx
mov    %r15,%rcx
call   1040 <InstallNewEngine@plt>
jmp    1270 <InstallFromDir+0xa0>
mov    %rbx,%rdi
call   10a0 <closedir@plt>
add    $0x1028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.direct = type { i8* }
%struct.stat = type { i64 }
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [5 x i8] c".eng\00"
@.str.2 = [9 x i8] c"%s/%s/%s\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [20 x i8] c"plugin spec %d.%d%c\00"
@.str.5 = [8 x i8] c"%[^\0A]%c\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [12 x i8] c"cd %[^;];%c\00"
define void @InstallFromDir(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca %struct.direct*
%9 = alloca %struct.stat
%10 = alloca i64
%11 = alloca [1024 x i8]
%12 = alloca i64
%13 = alloca i32*
%14 = alloca [1024 x i8]
%15 = alloca [1024 x i8]
%16 = alloca [1024 x i8]
%17 = alloca i8
%18 = alloca i8
%19 = alloca i8*
%20 = alloca i32
%21 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i64 0, i64* %10
%22 = load i8*, i8** %6
%23 = call i32 @stat(i8* %22, %struct.stat* %9)
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %3
%26 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%27 = load i64, i64* %26
store i64 %27, i64* %10
br label %28
28: ; preds = %25, %3
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %29, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %30, i8* %31)
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%34 = call i32* @opendir(i8* %33)
store i32* %34, i32** %7
%35 = icmp ne i32* %34, null
br i1 %35, label %37, label %36
36: ; preds = %28
br label %124
37: ; preds = %28
br label %38
38: ; preds = %120, %98, %48, %37
%39 = load i32*, i32** %7
%40 = call %struct.direct* @readdir(i32* %39)
store %struct.direct* %40, %struct.direct** %8
%41 = icmp ne %struct.direct* %40, null
br i1 %41, label %42, label %121
42: ; preds = %38
store i64 0, i64* %12
%43 = load %struct.direct*, %struct.direct** %8
%44 = getelementptr inbounds %struct.direct, %struct.direct* %43, i32 0, i32 0
%45 = load i8*, i8** %44
%46 = call i32 @strstr(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%47 = icmp ne i32 %46, 0
br i1 %47, label %49, label %48
48: ; preds = %42
br label %38
49: ; preds = %42
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%51 = load i8*, i8** %4
%52 = load i8*, i8** %5
%53 = load %struct.direct*, %struct.direct** %8
%54 = getelementptr inbounds %struct.direct, %struct.direct* %53, i32 0, i32 0
%55 = load i8*, i8** %54
%56 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %50, i32 1024, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %51, i8* %52, i8* %55)
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%58 = call i32 @stat(i8* %57, %struct.stat* %9)
%59 = icmp ne i32 %58, 0
br i1 %59, label %63, label %60
60: ; preds = %49
%61 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%62 = load i64, i64* %61
store i64 %62, i64* %12
br label %63
63: ; preds = %60, %49
%64 = load i64, i64* %10
%65 = icmp eq i64 %64, 0
br i1 %65, label %72, label %66
66: ; preds = %63
%67 = load i64, i64* %12
%68 = load i64, i64* %10
%69 = sub nsw i64 %67, %68
%70 = trunc i64 %69 to i32
%71 = icmp sgt i32 %70, 0
br i1 %71, label %72, label %120
72: ; preds = %66, %63
%73 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%74 = call i32* @fopen(i8* %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %74, i32** %13
%75 = load i32*, i32** %13
%76 = icmp ne i32* %75, null
br i1 %76, label %77, label %119
77: ; preds = %72
store i8 0, i8* %17
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
store i8* %78, i8** %19
%79 = load i32*, i32** %13
%80 = call i32 (i32*, i8*, ...) @fscanf(i32* %79, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32* %20, i32* %21, i8* %18)
%81 = icmp ne i32 %80, 3
br i1 %81, label %92, label %82
82: ; preds = %77
%83 = load i32*, i32** %13
%84 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%85 = call i32 (i32*, i8*, ...) @fscanf(i32* %83, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %84, i8* %18)
%86 = icmp ne i32 %85, 2
br i1 %86, label %92, label %87
87: ; preds = %82
%88 = load i32*, i32** %13
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%90 = call i32 (i32*, i8*, ...) @fscanf(i32* %88, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %89, i8* %18)
%91 = icmp ne i32 %90, 2
br i1 %91, label %92, label %93
92: ; preds = %87, %82, %77
store i8 1, i8* %17
br label %93
93: ; preds = %92, %87
%94 = load i32*, i32** %13
%95 = call i32 @fclose(i32* %94)
%96 = load i8, i8* %17
%97 = icmp ne i8 %96, 0
br i1 %97, label %98, label %99
98: ; preds = %93
br label %38
99: ; preds = %93
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%101 = call i32 @strcpy(i8* %100, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%102 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%104 = call i32 @sscanf(i8* %102, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %103, i8* %18)
%105 = icmp eq i32 %104, 2
br i1 %105, label %106, label %113
106: ; preds = %99
%107 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%108 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%109 = call i32 @strlen(i8* %108)
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %107, i64 %110
%112 = getelementptr inbounds i8, i8* %111, i64 4
store i8* %112, i8** %19
br label %113
113: ; preds = %106, %99
%114 = load i8*, i8** %19
%115 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%116 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%117 = load i8*, i8** %5
%118 = call i32 @InstallNewEngine(i8* %114, i8* %115, i8* %116, i8* %117)
br label %119
119: ; preds = %113, %72
br label %120
120: ; preds = %119, %66
br label %38
121: ; preds = %38
%122 = load i32*, i32** %7
%123 = call i32 @closedir(i32* %122)
br label %124
124: ; preds = %121, %36
ret void
}

LLVM IR (-O2):
%struct.stat = type { i64 }
%struct.direct = type { i8* }
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [5 x i8] c".eng\00"
@.str.2 = [9 x i8] c"%s/%s/%s\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [20 x i8] c"plugin spec %d.%d%c\00"
@.str.5 = [8 x i8] c"%[^\0A]%c\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [12 x i8] c"cd %[^;];%c\00"
define void @InstallFromDir(i8* %0, i8* %1, i8* nocapture %2) {
%4 = alloca %struct.stat
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = bitcast %struct.stat* %4 to i8*
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%14 = call i32 @stat(i8* %2, %struct.stat* %4)
%15 = icmp eq i32 %14, 0
%16 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%17 = load i64, i64* %16
%18 = select i1 %15, i64 %17, i64 0
%19 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %13, i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%20 = call i32* @opendir(i8* %13)
%21 = icmp eq i32* %20, null
br i1 %21, label %81, label %22
22: ; preds = %3
%23 = call %struct.direct* @readdir(i32* %20)
%24 = icmp eq %struct.direct* %23, null
br i1 %24, label %79, label %25
25: ; preds = %22
%26 = icmp eq i64 %18, 0
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%30 = bitcast i32* %10 to i8*
%31 = bitcast i32* %11 to i8*
br label %32
32: ; preds = %25, %76
%33 = phi %struct.direct* [ %23, %25 ], [ %77, %76 ]
%34 = getelementptr inbounds %struct.direct, %struct.direct* %33, i64 0, i32 0
%35 = load i8*, i8** %34
%36 = call i32 @strstr(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i32 %36, 0
br i1 %37, label %76, label %38
38: ; preds = %32
%39 = load i8*, i8** %34
%40 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %13, i32 1024, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1, i8* %39)
%41 = call i32 @stat(i8* %13, %struct.stat* %4)
%42 = icmp eq i32 %41, 0
%43 = load i64, i64* %16
%44 = select i1 %42, i64 %43, i64 0
%45 = sub nsw i64 %44, %18
%46 = trunc i64 %45 to i32
%47 = icmp sgt i32 %46, 0
%48 = select i1 %26, i1 true, i1 %47
br i1 %48, label %49, label %76
49: ; preds = %38
%50 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%51 = icmp eq i32* %50, null
br i1 %51, label %76, label %52
52: ; preds = %49
%53 = call i32 (i32*, i8*, ...) @fscanf(i32* %50, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32* %10, i32* %11, i8* %9)
%54 = icmp eq i32 %53, 3
br i1 %54, label %55, label %61
55: ; preds = %52
%56 = call i32 (i32*, i8*, ...) @fscanf(i32* %50, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %27, i8* %9)
%57 = icmp eq i32 %56, 2
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = call i32 (i32*, i8*, ...) @fscanf(i32* %50, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %29, i8* %9)
%60 = icmp eq i32 %59, 2
br i1 %60, label %63, label %61
61: ; preds = %58, %55, %52
%62 = call i32 @fclose(i32* %50)
br label %76
63: ; preds = %58
%64 = call i32 @fclose(i32* %50)
%65 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
%66 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %28, i8* %9)
%67 = icmp eq i32 %66, 2
br i1 %67, label %68, label %73
68: ; preds = %63
%69 = call i32 @strlen(i8* %28)
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %70
%72 = getelementptr inbounds i8, i8* %71, i64 4
br label %73
73: ; preds = %68, %63
%74 = phi i8* [ %72, %68 ], [ %27, %63 ]
%75 = call i32 @InstallNewEngine(i8* %74, i8* %28, i8* %29, i8* %1)
br label %76
76: ; preds = %73, %49, %61, %38, %32
%77 = call %struct.direct* @readdir(i32* %20)
%78 = icmp eq %struct.direct* %77, null
br i1 %78, label %79, label %32
79: ; preds = %76, %22
%80 = call i32 @closedir(i32* %20)
br label %81
81: ; preds = %3, %79
ret void
}