#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 MAXPATHLEN;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
char *getenv(char *);
scalar_t__ malloc(int);
char *realloc(char *, int);
scalar_t__ realpath(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, ...);
int strlen(char *);
int /*<<< orphan*/ whichPATH(char *, char *, int);
FILE *findCONFIG(char *argvzero) {
  FILE *fp;
  register char *etc = "../etc/";
  register char *home = getenv("HOME");
  register char *path, *p;
  register char *configfilename = ".ESTaterc";
  register int lenc = strlen(configfilename), lenh = strlen(home),
               lena = argvzero ? strlen(argvzero) : 0, lene = strlen(etc), lend;
  char realexecpath[MAXPATHLEN];
  if ((fp = fopen(configfilename, "r")))
    return fp;
  path = (char *)malloc(sizeof(char) * lenc +
                        (((lenh) > (lena)) ? (lenh) : (lena)) + lene);
  sprintf(path, "%s/%s", home, configfilename);
  fp = fopen(path, "r");
  if (fp) {
    free(path);
    return fp;
  }
  if (!realpath(argvzero, realexecpath)) {
    if (!(whichPATH(argvzero, realexecpath, MAXPATHLEN)) &&
        (realpath(argvzero, realexecpath))) {
      free(path);
      return (FILE *)0;
    }
  }
  lend = strlen(realexecpath);
  path = realloc(path, sizeof(char) * (lend + lenc + lenh));
  for (p = realexecpath + lend; p > realexecpath; p--)
    if (*p == '/') {
      p++;
      break;
    }
  *p = '\0';
  sprintf(path, "%s%s", realexecpath, configfilename);
  fp = fopen(path, "r");
  if (!fp) {
    sprintf(path, "%s%s%s", realexecpath, etc, configfilename + 1);
    fp = fopen(path, "r");
  }
  free(path);
  return fp;
}


x86 assembly (clang, -O0):
<findCONFIG>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe5a(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe57(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x28(%rbp)
lea    0xe4c(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x48(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11f9 <findCONFIG+0x69>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x70(%rbp)
jmp    1203 <findCONFIG+0x73>
xor    %eax,%eax
mov    %eax,-0x70(%rbp)
jmp    1203 <findCONFIG+0x73>
mov    -0x70(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x50(%rbp)
mov    0x2dcc(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x78(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x68(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xdcb(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1273 <findCONFIG+0xe3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x6c(%rbp)
jmp    1498 <findCONFIG+0x308>
movslq -0x44(%rbp),%rax
shl    $0x0,%rax
mov    %rax,-0x80(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jle    1299 <findCONFIG+0x109>
mov    -0x48(%rbp),%eax
mov    %eax,-0x84(%rbp)
jmp    12a2 <findCONFIG+0x112>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x80(%rbp),%rax
mov    -0x84(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
movslq -0x50(%rbp),%rcx
add    %rcx,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x40(%rbp),%rcx
lea    0xd42(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xd2e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     131a <findCONFIG+0x18a>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x6c(%rbp)
jmp    1498 <findCONFIG+0x308>
mov    -0x78(%rbp),%rsi
mov    -0x10(%rbp),%rdi
call   1060 <realpath@plt>
cmp    $0x0,%rax
jne    1389 <findCONFIG+0x1f9>
mov    -0x78(%rbp),%rsi
mov    -0x10(%rbp),%rdi
mov    0x2ca8(%rip),%rax
mov    (%rax),%edx
call   10a0 <whichPATH@plt>
cmp    $0x0,%eax
jne    1384 <findCONFIG+0x1f4>
mov    -0x78(%rbp),%rsi
mov    -0x10(%rbp),%rdi
call   1060 <realpath@plt>
cmp    $0x0,%rax
je     1384 <findCONFIG+0x1f4>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x6c(%rbp)
jmp    1498 <findCONFIG+0x308>
jmp    1389 <findCONFIG+0x1f9>
mov    -0x78(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x54(%rbp),%eax
add    -0x44(%rbp),%eax
add    -0x48(%rbp),%eax
cltq
shl    $0x0,%rax
mov    %eax,%esi
call   1080 <realloc@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
mov    %rcx,-0x30(%rbp)
movslq -0x54(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x78(%rbp),%rax
cmp    %rax,-0x38(%rbp)
jbe    140a <findCONFIG+0x27a>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    13f4 <findCONFIG+0x264>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    140a <findCONFIG+0x27a>
jmp    13f9 <findCONFIG+0x269>
mov    -0x38(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
jmp    13c5 <findCONFIG+0x235>
mov    -0x78(%rbp),%rdx
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rcx
lea    0xbfd(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xbe1(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1480 <findCONFIG+0x2f0>
mov    -0x78(%rbp),%rdx
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    -0x40(%rbp),%r8
add    $0x1,%r8
lea    0xbba(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xba0(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x6c(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findCONFIG>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0xe5d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r13
lea    0xe53(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%r14d
mov    %r13,%rdi
call   1050 <strlen@plt>
test   %rbx,%rbx
mov    %r14d,-0x30(%rbp)
mov    %eax,-0x2c(%rbp)
mov    %rbx,-0x38(%rbp)
je     11e6 <findCONFIG+0x56>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
jmp    11e8 <findCONFIG+0x58>
xor    %ebx,%ebx
lea    0xe11(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%r12d
mov    0x2dea(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    0xdf5(%rip),%rdi
lea    0xdf8(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1341 <findCONFIG+0x1b1>
mov    -0x2c(%rbp),%eax
cmp    %ebx,%eax
cmovg  %eax,%ebx
add    -0x30(%rbp),%r12d
add    %ebx,%r12d
mov    %r12d,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xdc8(%rip),%rsi
lea    0xdb5(%rip),%rcx
mov    %rax,%rdi
mov    %r13,%rdx
xor    %eax,%eax
call   10b0 <sprintf@plt>
lea    0xdab(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1281 <findCONFIG+0xf1>
mov    %rax,%r15
jmp    1339 <findCONFIG+0x1a9>
mov    -0x2c(%rbp),%r13d
mov    -0x30(%rbp),%r12d
mov    -0x38(%rbp),%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <realpath@plt>
test   %rax,%rax
jne    12b9 <findCONFIG+0x129>
mov    0x2d44(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   10a0 <whichPATH@plt>
test   %eax,%eax
je     1389 <findCONFIG+0x1f9>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%r15d
mov    %r13d,%esi
add    %r12d,%esi
add    %eax,%esi
mov    %rbx,%rdi
call   1080 <realloc@plt>
mov    %rax,%rbx
movslq %r15d,%rcx
lea    (%r14,%rcx,1),%rax
test   %ecx,%ecx
jle    1304 <findCONFIG+0x174>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x2f,(%rax)
je     1300 <findCONFIG+0x170>
add    $0xffffffffffffffff,%rax
cmp    %r14,%rax
ja     12f0 <findCONFIG+0x160>
jmp    1304 <findCONFIG+0x174>
add    $0x1,%rax
movb   $0x0,(%rax)
lea    0xd13(%rip),%rsi
lea    0xcf8(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   10b0 <sprintf@plt>
lea    0xcee(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
je     1353 <findCONFIG+0x1c3>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %r15,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcc5(%rip),%rsi
lea    0xc9f(%rip),%rcx
lea    0xca6(%rip),%r8
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   10b0 <sprintf@plt>
lea    0xc9b(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
jmp    1279 <findCONFIG+0xe9>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <realpath@plt>
test   %rax,%rax
je     12b9 <findCONFIG+0x129>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %r15d,%r15d
jmp    1341 <findCONFIG+0x1b1>

LLVM IR (-O0):
@.str = [8 x i8] c"../etc/\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [10 x i8] c".ESTaterc\00"
@MAXPATHLEN = global i32 0
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [6 x i8] c"%s/%s\00"
@.str.5 = [5 x i8] c"%s%s\00"
@.str.6 = [7 x i8] c"%s%s%s\00"
define i32* @findCONFIG(i8* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i32
store i8* %0, i8** %3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %5
%18 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %18, i8** %6
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %9
%19 = load i8*, i8** %9
%20 = call i32 @strlen(i8* %19)
store i32 %20, i32* %10
%21 = load i8*, i8** %6
%22 = call i32 @strlen(i8* %21)
store i32 %22, i32* %11
%23 = load i8*, i8** %3
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %1
%26 = load i8*, i8** %3
%27 = call i32 @strlen(i8* %26)
br label %29
28: ; preds = %1
br label %29
29: ; preds = %28, %25
%30 = phi i32 [ %27, %25 ], [ 0, %28 ]
store i32 %30, i32* %12
%31 = load i8*, i8** %5
%32 = call i32 @strlen(i8* %31)
store i32 %32, i32* %13
%33 = load i32, i32* @MAXPATHLEN
%34 = zext i32 %33 to i64
%35 = call i8* @llvm.stacksave()
store i8* %35, i8** %15
%36 = alloca i8, i64 %34
store i64 %34, i64* %16
%37 = load i8*, i8** %9
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %38, i32** %4
%39 = icmp ne i32* %38, null
br i1 %39, label %40, label %42
40: ; preds = %29
%41 = load i32*, i32** %4
store i32* %41, i32** %2
store i32 1, i32* %17
br label %143
42: ; preds = %29
%43 = load i32, i32* %10
%44 = sext i32 %43 to i64
%45 = mul i64 1, %44
%46 = load i32, i32* %11
%47 = load i32, i32* %12
%48 = icmp sgt i32 %46, %47
br i1 %48, label %49, label %51
49: ; preds = %42
%50 = load i32, i32* %11
br label %53
51: ; preds = %42
%52 = load i32, i32* %12
br label %53
53: ; preds = %51, %49
%54 = phi i32 [ %50, %49 ], [ %52, %51 ]
%55 = sext i32 %54 to i64
%56 = add i64 %45, %55
%57 = load i32, i32* %13
%58 = sext i32 %57 to i64
%59 = add i64 %56, %58
%60 = trunc i64 %59 to i32
%61 = call i64 @malloc(i32 %60)
%62 = inttoptr i64 %61 to i8*
store i8* %62, i8** %7
%63 = load i8*, i8** %7
%64 = load i8*, i8** %6
%65 = load i8*, i8** %9
%66 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %63, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %64, i8* %65)
%67 = load i8*, i8** %7
%68 = call i32* @fopen(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %68, i32** %4
%69 = load i32*, i32** %4
%70 = icmp ne i32* %69, null
br i1 %70, label %71, label %75
71: ; preds = %53
%72 = load i8*, i8** %7
%73 = call i32 @free(i8* %72)
%74 = load i32*, i32** %4
store i32* %74, i32** %2
store i32 1, i32* %17
br label %143
75: ; preds = %53
%76 = load i8*, i8** %3
%77 = call i64 @realpath(i8* %76, i8* %36)
%78 = icmp ne i64 %77, 0
br i1 %78, label %92, label %79
79: ; preds = %75
%80 = load i8*, i8** %3
%81 = load i32, i32* @MAXPATHLEN
%82 = call i32 @whichPATH(i8* %80, i8* %36, i32 %81)
%83 = icmp ne i32 %82, 0
br i1 %83, label %91, label %84
84: ; preds = %79
%85 = load i8*, i8** %3
%86 = call i64 @realpath(i8* %85, i8* %36)
%87 = icmp ne i64 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %84
%89 = load i8*, i8** %7
%90 = call i32 @free(i8* %89)
store i32* null, i32** %2
store i32 1, i32* %17
br label %143
91: ; preds = %84, %79
br label %92
92: ; preds = %91, %75
%93 = call i32 @strlen(i8* %36)
store i32 %93, i32* %14
%94 = load i8*, i8** %7
%95 = load i32, i32* %14
%96 = load i32, i32* %10
%97 = add nsw i32 %95, %96
%98 = load i32, i32* %11
%99 = add nsw i32 %97, %98
%100 = sext i32 %99 to i64
%101 = mul i64 1, %100
%102 = trunc i64 %101 to i32
%103 = call i8* @realloc(i8* %94, i32 %102)
store i8* %103, i8** %7
%104 = load i32, i32* %14
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %36, i64 %105
store i8* %106, i8** %8
br label %107
107: ; preds = %119, %92
%108 = load i8*, i8** %8
%109 = icmp ugt i8* %108, %36
br i1 %109, label %110, label %122
110: ; preds = %107
%111 = load i8*, i8** %8
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %113, 47
br i1 %114, label %115, label %118
115: ; preds = %110
%116 = load i8*, i8** %8
%117 = getelementptr inbounds i8, i8* %116, i32 1
store i8* %117, i8** %8
br label %122
118: ; preds = %110
br label %119
119: ; preds = %118
%120 = load i8*, i8** %8
%121 = getelementptr inbounds i8, i8* %120, i32 -1
store i8* %121, i8** %8
br label %107
122: ; preds = %115, %107
%123 = load i8*, i8** %8
store i8 0, i8* %123
%124 = load i8*, i8** %7
%125 = load i8*, i8** %9
%126 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %124, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %36, i8* %125)
%127 = load i8*, i8** %7
%128 = call i32* @fopen(i8* %127, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %128, i32** %4
%129 = load i32*, i32** %4
%130 = icmp ne i32* %129, null
br i1 %130, label %139, label %131
131: ; preds = %122
%132 = load i8*, i8** %7
%133 = load i8*, i8** %5
%134 = load i8*, i8** %9
%135 = getelementptr inbounds i8, i8* %134, i64 1
%136 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %132, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %36, i8* %133, i8* %135)
%137 = load i8*, i8** %7
%138 = call i32* @fopen(i8* %137, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %138, i32** %4
br label %139
139: ; preds = %131, %122
%140 = load i8*, i8** %7
%141 = call i32 @free(i8* %140)
%142 = load i32*, i32** %4
store i32* %142, i32** %2
store i32 1, i32* %17
br label %143
143: ; preds = %139, %88, %71, %40
%144 = load i8*, i8** %15
%145 = load i32*, i32** %2
ret i32* %145
}

LLVM IR (-O2):
@.str = [8 x i8] c"../etc/\00"
@.str.1 = [5 x i8] c"HOME\00"
@.str.2 = [10 x i8] c".ESTaterc\00"
@MAXPATHLEN = global i32 0
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [6 x i8] c"%s/%s\00"
@.str.5 = [5 x i8] c"%s%s\00"
@.str.6 = [7 x i8] c"%s%s%s\00"
define noalias i32* @findCONFIG(i8* %0) {
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @strlen(i8* %2)
%5 = icmp eq i8* %0, null
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = tail call i32 @strlen(i8* %0)
br label %8
8: ; preds = %1, %6
%9 = phi i32 [ %7, %6 ], [ 0, %1 ]
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @MAXPATHLEN
%12 = zext i32 %11 to i64
%13 = alloca i8, i64 %12
%14 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %68
16: ; preds = %8
%17 = icmp sgt i32 %4, %9
%18 = select i1 %17, i32 %4, i32 %9
%19 = add i32 %10, %3
%20 = add i32 %19, %18
%21 = tail call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i8*
%23 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %22, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%24 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %28, label %26
26: ; preds = %16
%27 = tail call i32 @free(i8* %22)
br label %68
28: ; preds = %16
%29 = call i64 @realpath(i8* %0, i8* %13)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load i32, i32* @MAXPATHLEN
%33 = call i32 @whichPATH(i8* %0, i8* %13, i32 %32)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = call i64 @realpath(i8* %0, i8* %13)
%37 = icmp eq i64 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = call i32 @free(i8* %22)
br label %68
40: ; preds = %31, %35, %28
%41 = call i32 @strlen(i8* %13)
%42 = add i32 %4, %3
%43 = add i32 %42, %41
%44 = call i8* @realloc(i8* %22, i32 %43)
%45 = sext i32 %41 to i64
%46 = getelementptr inbounds i8, i8* %13, i64 %45
%47 = icmp sgt i32 %41, 0
br i1 %47, label %48, label %57
48: ; preds = %40, %54
%49 = phi i8* [ %55, %54 ], [ %46, %40 ]
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 47
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = getelementptr inbounds i8, i8* %49, i64 1
br label %57
54: ; preds = %48
%55 = getelementptr inbounds i8, i8* %49, i64 -1
%56 = icmp ugt i8* %55, %13
br i1 %56, label %48, label %57
57: ; preds = %54, %40, %52
%58 = phi i8* [ %53, %52 ], [ %46, %40 ], [ %55, %54 ]
store i8 0, i8* %58
%59 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %44, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%60 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%61 = icmp eq i32* %60, null
br i1 %61, label %62, label %65
62: ; preds = %57
%63 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %44, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 1))
%64 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %65
65: ; preds = %62, %57
%66 = phi i32* [ %60, %57 ], [ %64, %62 ]
%67 = call i32 @free(i8* %44)
br label %68
68: ; preds = %8, %65, %38, %26
%69 = phi i32* [ %24, %26 ], [ %66, %65 ], [ null, %38 ], [ %14, %8 ]
ret i32* %69
}