#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int strspn(char *, char *);
char *locatepath(char *program, int *nlocate) {
  static char pathbuff[256];
  char command[256];
  FILE *locateout = NULL;
  char pathline[256];
  int nlines = 0;
  int linelen = 0, pathlen = 9999;
  char *path = NULL;
  if (((program) == NULL ? 1 : (*(program) == '\000' ? 1 : 0)))
    goto end_of_job;
  sprintf(command, "locate -q -r \"/%s$\" | grep \"bin\"", program);
  locateout = popen(command, "r");
  if (locateout == NULL)
    goto end_of_job;
  while (fgets(pathline, 255, locateout) != NULL) {
    if ((pathline) != NULL) {
      int thislen = strlen(pathline);
      while (--thislen >= 0)
        if ((((pathline)[thislen]) != '\000' &&
             !((" \t\n\r\f\v") == NULL
                   ? 1
                   : (*(" \t\n\r\f\v") == '\000' ? 1 : 0)) &&
             strchr((" \t\n\r\f\v"), ((pathline)[thislen])) != (char *)NULL))
          (pathline)[thislen] = '\000';
        else
          break;
      if ((thislen = strspn((pathline), " \t\n\r\f\v")) > 0) {
        if ((thislen) != 0) {
          if (!((((pathline))) == NULL ? 1
                                       : (*(((pathline))) == '\000' ? 1 : 0))) {
            int thislen3 = strlen((pathline));
            if ((thislen) >= thislen3)
              *((pathline)) = '\000';
            else
              memmove(((pathline)), ((pathline)) + (thislen),
                      1 + thislen3 - (thislen));
          }
        } else
          ;
      }
    } else
      ;
    if ((linelen = strlen(pathline)) > 0) {
      if (linelen < pathlen) {
        strcpy(pathbuff, pathline);
        pathlen = linelen;
      }
      nlines++;
    }
  }
  pclose(locateout);
  if (pathlen > 0 && pathlen < 256)
    path = pathbuff;
  if (nlocate != NULL)
    *nlocate = nlines;
end_of_job:
  return (path);
}


x86 assembly (clang, -O0):
<locatepath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x118(%rbp)
movl   $0x0,-0x224(%rbp)
movl   $0x0,-0x228(%rbp)
movl   $0x270f,-0x22c(%rbp)
movq   $0x0,-0x238(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11f1 <locatepath+0x61>
mov    $0x1,%al
test   $0x1,%al
jne    121f <locatepath+0x8f>
jmp    1224 <locatepath+0x94>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1210 <locatepath+0x80>
mov    $0x1,%al
test   $0x1,%al
jne    121f <locatepath+0x8f>
jmp    1224 <locatepath+0x94>
xor    %eax,%eax
test   $0x1,%al
jne    121f <locatepath+0x8f>
jmp    1224 <locatepath+0x94>
jmp    14b4 <locatepath+0x324>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xdca(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    0xdd8(%rip),%rsi
call   10a0 <popen@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x118(%rbp)
jne    1268 <locatepath+0xd8>
jmp    14b4 <locatepath+0x324>
jmp    126d <locatepath+0xdd>
lea    -0x220(%rbp),%rdi
mov    -0x118(%rbp),%rdx
mov    $0xff,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1461 <locatepath+0x2d1>
lea    -0x220(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x23c(%rbp)
mov    -0x23c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x23c(%rbp)
cmp    $0x0,%eax
jl     1314 <locatepath+0x184>
movslq -0x23c(%rbp),%rax
movsbl -0x220(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     130a <locatepath+0x17a>
movslq -0x23c(%rbp),%rax
lea    0xd44(%rip),%rdi
movsbl -0x220(%rbp,%rax,1),%esi
ff
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     130a <locatepath+0x17a>
movslq -0x23c(%rbp),%rax
movb   $0x0,-0x220(%rbp,%rax,1)
jmp    130f <locatepath+0x17f>
jmp    1314 <locatepath+0x184>
jmp    12a1 <locatepath+0x111>
lea    -0x220(%rbp),%rdi
lea    0xd01(%rip),%rsi
call   1070 <strspn@plt>
mov    %eax,-0x23c(%rbp)
cmp    $0x0,%eax
jle    1401 <locatepath+0x271>
cmpl   $0x0,-0x23c(%rbp)
je     13f7 <locatepath+0x267>
lea    -0x220(%rbp),%rax
cmp    $0x0,%rax
jne    1363 <locatepath+0x1d3>
mov    $0x1,%al
test   $0x1,%al
jne    13f2 <locatepath+0x262>
jmp    1391 <locatepath+0x201>
movsbl -0x220(%rbp),%eax
cmp    $0x0,%eax
jne    1382 <locatepath+0x1f2>
mov    $0x1,%al
test   $0x1,%al
jne    13f2 <locatepath+0x262>
jmp    1391 <locatepath+0x201>
xor    %eax,%eax
test   $0x1,%al
jne    13f2 <locatepath+0x262>
jmp    1391 <locatepath+0x201>
lea    -0x220(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x240(%rbp)
mov    -0x23c(%rbp),%eax
cmp    -0x240(%rbp),%eax
jl     13c1 <locatepath+0x231>
movb   $0x0,-0x220(%rbp)
jmp    13ed <locatepath+0x25d>
lea    -0x220(%rbp),%rdi
lea    -0x220(%rbp),%rsi
movslq -0x23c(%rbp),%rax
add    %rax,%rsi
mov    -0x240(%rbp),%edx
add    $0x1,%edx
sub    -0x23c(%rbp),%edx
call   1090 <memmove@plt>
jmp    13f2 <locatepath+0x262>
jmp    13fc <locatepath+0x26c>
jmp    13fc <locatepath+0x26c>
jmp    1401 <locatepath+0x271>
lea    -0x220(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x228(%rbp)
cmp    $0x0,%eax
jle    145c <locatepath+0x2cc>
mov    -0x228(%rbp),%eax
cmp    -0x22c(%rbp),%eax
jge    144d <locatepath+0x2bd>
lea    -0x220(%rbp),%rsi
lea    0x2c44(%rip),%rdi
call   1030 <strcpy@plt>
mov    -0x228(%rbp),%eax
mov    %eax,-0x22c(%rbp)
mov    -0x224(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x224(%rbp)
jmp    126d <locatepath+0xdd>
mov    -0x118(%rbp),%rdi
call   1060 <pclose@plt>
cmpl   $0x0,-0x22c(%rbp)
jle    1498 <locatepath+0x308>
cmpl   $0x100,-0x22c(%rbp)
jge    1498 <locatepath+0x308>
lea    0x2bef(%rip),%rax
mov    %rax,-0x238(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     14af <locatepath+0x31f>
mov    -0x224(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    14b4 <locatepath+0x324>
mov    -0x238(%rbp),%rax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<locatepath>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
test   %rdi,%rdi
je     1309 <locatepath+0x179>
mov    %rdi,%rdx
cmpb   $0x0,(%rdi)
je     1309 <locatepath+0x179>
mov    %rsi,%rbp
lea    0xe40(%rip),%rsi
lea    0x110(%rsp),%rbx
mov    %rbx,%rdi
call   10b0 <sprintf@plt>
lea    0xe4a(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <popen@plt>
test   %rax,%rax
je     1309 <locatepath+0x179>
mov    %rax,%r12
lea    0x10(%rsp),%rdi
mov    $0xff,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1346 <locatepath+0x1b6>
mov    %rbp,0x8(%rsp)
xor    %r15d,%r15d
movl   $0x270f,0x4(%rsp)
lea    0x10(%rsp),%r13
lea    0xe01(%rip),%rbx
jmp    124d <locatepath+0xbd>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r15d
mov    %r13,%rdi
mov    $0xff,%esi
mov    %r12,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     131d <locatepath+0x18d>
mov    %r13,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    128e <locatepath+0xfe>
mov    %eax,%ebp
add    $0x1,%rbp
nop
lea    -0x2(%rbp),%r14d
movzbl 0x10(%rsp,%r14,1),%eax
test   %al,%al
je     128e <locatepath+0xfe>
movsbl %al,%esi
mov    %rbx,%rdi
call   1050 <strchr@plt>
test   %rax,%rax
je     128e <locatepath+0xfe>
movb   $0x0,0x10(%rsp,%r14,1)
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
ja     1260 <locatepath+0xd0>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <strspn@plt>
test   %eax,%eax
jle    12d5 <locatepath+0x145>
cmpb   $0x0,0x10(%rsp)
je     12d5 <locatepath+0x145>
mov    %eax,%ebp
mov    %r13,%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebp
jge    12d0 <locatepath+0x140>
mov    %ebp,%ecx
lea    (%rsp,%rcx,1),%rsi
add    $0x10,%rsi
sub    %ebp,%eax
add    $0x1,%eax
mov    %r13,%rdi
mov    %eax,%edx
call   1090 <memmove@plt>
jmp    12d5 <locatepath+0x145>
nopl   (%rax)
movb   $0x0,0x10(%rsp)
mov    %r13,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1234 <locatepath+0xa4>
mov    %eax,%ebp
cmp    0x4(%rsp),%eax
jge    1230 <locatepath+0xa0>
lea    0x2d88(%rip),%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %ebp,0x4(%rsp)
jmp    1230 <locatepath+0xa0>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r12,%rdi
call   1060 <pclose@plt>
xor    %eax,%eax
cmpl   $0x100,0x4(%rsp)
lea    0x2d4a(%rip),%rcx
cmovl  %rcx,%rax
mov    0x8(%rsp),%rbp
test   %rbp,%rbp
jne    1358 <locatepath+0x1c8>
jmp    130b <locatepath+0x17b>
mov    %r12,%rdi
call   1060 <pclose@plt>
xor    %r15d,%r15d
xor    %eax,%eax
test   %rbp,%rbp
je     130b <locatepath+0x17b>
mov    %r15d,0x0(%rbp)
jmp    130b <locatepath+0x17b>

LLVM IR (-O0):
@locatepath.pathbuff = internal global [256 x i8] zeroinitializer
@.str = [33 x i8] c"locate -q -r \22/%s$\22 | grep \22bin\22\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c" \09\0A\0D\0C\0B\00"
define i8* @locatepath(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [256 x i8]
%6 = alloca i32*
%7 = alloca [256 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32* null, i32** %6
store i32 0, i32* %8
store i32 0, i32* %9
store i32 9999, i32* %10
store i8* null, i8** %11
%14 = load i8*, i8** %3
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %2
br i1 true, label %24, label %25
17: ; preds = %2
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17
br i1 true, label %24, label %25
23: ; preds = %17
br i1 false, label %24, label %25
24: ; preds = %23, %22, %16
br label %140
25: ; preds = %23, %22, %16
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%27 = load i8*, i8** %3
%28 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%30 = call i32* @popen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %30, i32** %6
%31 = load i32*, i32** %6
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %34
33: ; preds = %25
br label %140
34: ; preds = %25
br label %35
35: ; preds = %123, %34
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%37 = load i32*, i32** %6
%38 = call i32* @fgets(i8* %36, i32 255, i32* %37)
%39 = icmp ne i32* %38, null
br i1 %39, label %40, label %124
40: ; preds = %35
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
store i32 %42, i32* %12
br label %43
43: ; preds = %66, %40
%44 = load i32, i32* %12
%45 = add nsw i32 %44, -1
store i32 %45, i32* %12
%46 = icmp sge i32 %45, 0
br i1 %46, label %47, label %67
47: ; preds = %43
%48 = load i32, i32* %12
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %65
54: ; preds = %47
%55 = load i32, i32* %12
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = call i8* @strchr(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8 signext %58)
%60 = icmp ne i8* %59, null
br i1 %60, label %61, label %65
61: ; preds = %54
%62 = load i32, i32* %12
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %63
store i8 0, i8* %64
br label %66
65: ; preds = %54, %47
br label %67
66: ; preds = %61
br label %43
67: ; preds = %65, %43
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%69 = call i32 @strspn(i8* %68, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 %69, i32* %12
%70 = icmp sgt i32 %69, 0
br i1 %70, label %71, label %108
71: ; preds = %67
%72 = load i32, i32* %12
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %106
74: ; preds = %71
%75 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%76 = icmp eq i8* %75, null
br i1 %76, label %77, label %78
77: ; preds = %74
br i1 true, label %105, label %85
78: ; preds = %74
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %84
83: ; preds = %78
br i1 true, label %105, label %85
84: ; preds = %78
br i1 false, label %105, label %85
85: ; preds = %84, %83, %77
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%87 = call i32 @strlen(i8* %86)
store i32 %87, i32* %13
%88 = load i32, i32* %12
%89 = load i32, i32* %13
%90 = icmp sge i32 %88, %89
br i1 %90, label %91, label %93
91: ; preds = %85
%92 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
store i8 0, i8* %92
br label %104
93: ; preds = %85
%94 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%95 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%96 = load i32, i32* %12
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8, i8* %95, i64 %97
%99 = load i32, i32* %13
%100 = add nsw i32 1, %99
%101 = load i32, i32* %12
%102 = sub nsw i32 %100, %101
%103 = call i32 @memmove(i8* %94, i8* %98, i32 %102)
br label %104
104: ; preds = %93, %91
br label %105
105: ; preds = %104, %84, %83, %77
br label %107
106: ; preds = %71
br label %107
107: ; preds = %106, %105
br label %108
108: ; preds = %107, %67
%109 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%110 = call i32 @strlen(i8* %109)
store i32 %110, i32* %9
%111 = icmp sgt i32 %110, 0
br i1 %111, label %112, label %123
112: ; preds = %108
%113 = load i32, i32* %9
%114 = load i32, i32* %10
%115 = icmp slt i32 %113, %114
br i1 %115, label %116, label %120
116: ; preds = %112
%117 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%118 = call i32 @strcpy(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @locatepath.pathbuff, i64 0, i64 0), i8* %117)
%119 = load i32, i32* %9
store i32 %119, i32* %10
br label %120
120: ; preds = %116, %112
%121 = load i32, i32* %8
%122 = add nsw i32 %121, 1
store i32 %122, i32* %8
br label %123
123: ; preds = %120, %108
br label %35
124: ; preds = %35
%125 = load i32*, i32** %6
%126 = call i32 @pclose(i32* %125)
%127 = load i32, i32* %10
%128 = icmp sgt i32 %127, 0
br i1 %128, label %129, label %133
129: ; preds = %124
%130 = load i32, i32* %10
%131 = icmp slt i32 %130, 256
br i1 %131, label %132, label %133
132: ; preds = %129
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @locatepath.pathbuff, i64 0, i64 0), i8** %11
br label %133
133: ; preds = %132, %129, %124
%134 = load i32*, i32** %4
%135 = icmp ne i32* %134, null
br i1 %135, label %136, label %139
136: ; preds = %133
%137 = load i32, i32* %8
%138 = load i32*, i32** %4
store i32 %137, i32* %138
br label %139
139: ; preds = %136, %133
br label %140
140: ; preds = %139, %33, %24
%141 = load i8*, i8** %11
ret i8* %141
}

LLVM IR (-O2):
@locatepath.pathbuff = internal global [256 x i8] zeroinitializer
@.str = [33 x i8] c"locate -q -r \22/%s$\22 | grep \22bin\22\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c" \09\0A\0D\0C\0B\00"
define i8* @locatepath(i8* %0, i32* writeonly %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = icmp eq i8* %0, null
br i1 %7, label %79, label %8
8: ; preds = %2
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 0
br i1 %10, label %79, label %11
11: ; preds = %8
%12 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0)
%13 = call i32* @popen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %79, label %15
15: ; preds = %11
%16 = call i32* @fgets(i8* %6, i32 255, i32* %13)
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @pclose(i32* %13)
br label %74
20: ; preds = %15, %65
%21 = phi i32 [ %67, %65 ], [ 9999, %15 ]
%22 = phi i32 [ %66, %65 ], [ 0, %15 ]
%23 = call i32 @strlen(i8* %6)
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %39
25: ; preds = %20
%26 = zext i32 %23 to i64
br label %27
27: ; preds = %25, %37
%28 = phi i64 [ %26, %25 ], [ %29, %37 ]
%29 = add nsw i64 %28, -1
%30 = and i64 %29, 4294967295
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 0
br i1 %33, label %39, label %34
34: ; preds = %27
%35 = call i8* @strchr(i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8 signext %32)
%36 = icmp eq i8* %35, null
br i1 %36, label %39, label %37
37: ; preds = %34
store i8 0, i8* %31
%38 = icmp ugt i64 %28, 1
br i1 %38, label %27, label %39
39: ; preds = %37, %34, %27, %20
%40 = call i32 @strspn(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%41 = icmp slt i32 %40, 1
%42 = load i8, i8* %6
%43 = icmp eq i8 %42, 0
%44 = select i1 %41, i1 true, i1 %43
br i1 %44, label %55, label %45
45: ; preds = %39
%46 = call i32 @strlen(i8* %6)
%47 = icmp slt i32 %40, %46
br i1 %47, label %49, label %48
48: ; preds = %45
store i8 0, i8* %6
br label %55
49: ; preds = %45
%50 = zext i32 %40 to i64
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %50
%52 = sub nsw i32 1, %40
%53 = add i32 %52, %46
%54 = call i32 @memmove(i8* %6, i8* %51, i32 %53)
br label %55
55: ; preds = %48, %49, %39
%56 = call i32 @strlen(i8* %6)
%57 = icmp sgt i32 %56, 0
br i1 %57, label %58, label %65
58: ; preds = %55
%59 = icmp slt i32 %56, %21
br i1 %59, label %60, label %62
60: ; preds = %58
%61 = call i32 @strcpy(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @locatepath.pathbuff, i64 0, i64 0), i8* %6)
br label %62
62: ; preds = %60, %58
%63 = phi i32 [ %56, %60 ], [ %21, %58 ]
%64 = add nsw i32 %22, 1
br label %65
65: ; preds = %62, %55
%66 = phi i32 [ %64, %62 ], [ %22, %55 ]
%67 = phi i32 [ %63, %62 ], [ %21, %55 ]
%68 = call i32* @fgets(i8* %6, i32 255, i32* %13)
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %20
70: ; preds = %65
%71 = call i32 @pclose(i32* %13)
%72 = icmp slt i32 %67, 256
%73 = select i1 %72, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @locatepath.pathbuff, i64 0, i64 0), i8* null
br label %74
74: ; preds = %70, %18
%75 = phi i32 [ 0, %18 ], [ %66, %70 ]
%76 = phi i8* [ null, %18 ], [ %73, %70 ]
%77 = icmp eq i32* %1, null
br i1 %77, label %79, label %78
78: ; preds = %74
store i32 %75, i32* %1
br label %79
79: ; preds = %74, %78, %11, %2, %8
%80 = phi i8* [ null, %2 ], [ null, %8 ], [ null, %11 ], [ %76, %78 ], [ %76, %74 ]
ret i8* %80
}