; LLVM IR from kala13x/libxutils :: src/sys (srch)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.XDir = type { ptr, ptr, ptr, ptr, i8, i8 }
%struct.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }
%struct.XSearchCtx = type { %struct.XArray_, %struct.XArray_, i8, i8, i8, i8, i8, ptr, ptr, [2048 x i8], [4096 x i8], i32, i32, i32, i32, i64, i64, i64, i8, ptr, i32 }
%struct.XArray_ = type { ptr, ptr, i32, ptr, i8, i8, i8, i64, i64 }
%struct.XSearchEntry = type { [2048 x i8], [2048 x i8], [256 x i8], [16 x i8], [2048 x i8], i32, i32, i64, i32, i32, i64, i64, i64, ptr }

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [26 x i8], align 1

declare i64 @xstrncpy(ptr noundef, i64 noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare i64 @xstrncpyf(ptr noundef, i64 noundef, ptr noundef, ...) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @XSearch_NewEntry(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @XSearch(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca %struct.XDir, align 8
  %10 = alloca [2048 x i8], align 16
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca [2048 x i8], align 16
  %14 = alloca %struct.stat, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.XSearchCtx, ptr %18, i32 0, i32 19
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = atomicrmw add ptr %20, i32 0 seq_cst, align 4
  %22 = add i32 %21, 0
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %32, label %24

24:                                               ; preds = %2
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %33

27:                                               ; preds = %24
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.XSearchCtx, ptr %28, i32 0, i32 6
  %30 = load i8, ptr %29, align 4, !tbaa !14
  %31 = icmp ne i8 %30, 0
  br i1 %31, label %33, label %32

32:                                               ; preds = %27, %2
  store i32 -1, ptr %3, align 4
  br label %225

33:                                               ; preds = %27, %24
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.XSearchCtx, ptr %34, i32 0, i32 3
  %36 = load i8, ptr %35, align 1, !tbaa !15
  %37 = icmp ne i8 %36, 0
  br i1 %37, label %38, label %47

38:                                               ; preds = %33
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.XSearchCtx, ptr %39, i32 0, i32 9
  %41 = getelementptr inbounds [2048 x i8], ptr %40, i64 0, i64 0
  %42 = call i64 @xstrcase(ptr noundef %41, i32 noundef 0)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.XSearchCtx, ptr %43, i32 0, i32 10
  %45 = getelementptr inbounds [4096 x i8], ptr %44, i64 0, i64 0
  %46 = call i64 @xstrcase(ptr noundef %45, i32 noundef 0)
  br label %47

47:                                               ; preds = %38, %33
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.XSearchCtx, ptr %48, i32 0, i32 6
  %50 = load i8, ptr %49, align 4, !tbaa !14
  %51 = icmp ne i8 %50, 0
  br i1 %51, label %52, label %88

52:                                               ; preds = %47
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.XSearchCtx, ptr %53, i32 0, i32 10
  %55 = getelementptr inbounds [4096 x i8], ptr %54, i64 0, i64 0
  %56 = call zeroext i8 @xstrused(ptr noundef %55)
  %57 = icmp ne i8 %56, 0
  br i1 %57, label %61, label %58

58:                                               ; preds = %52
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = call i32 (ptr, ptr, ...) @XSearch_ErrorCallback(ptr noundef %59, ptr noundef @.str.2)
  store i32 -1, ptr %3, align 4
  br label %225

61:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = call i32 @XSearch_Text(ptr noundef %62, ptr noundef @.str.3, ptr noundef null, ptr noundef null)
  store i32 %63, ptr %6, align 4, !tbaa !16
  %64 = load i32, ptr %6, align 4, !tbaa !16
  %65 = icmp sle i32 %64, 0
  br i1 %65, label %66, label %68

66:                                               ; preds = %61
  %67 = load i32, ptr %6, align 4, !tbaa !16
  store i32 %67, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %87

68:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %69 = call ptr @XSearch_NewEntry(ptr noundef @.str.3, ptr noundef null, ptr noundef null)
  store ptr %69, ptr %8, align 8, !tbaa !5
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = icmp eq ptr %70, null
  br i1 %71, label %72, label %75

72:                                               ; preds = %68
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = call i32 (ptr, ptr, ...) @XSearch_ErrorCallback(ptr noundef %73, ptr noundef @.str.4)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %86

75:                                               ; preds = %68
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.XSearchEntry, ptr %76, i32 0, i32 4
  %78 = getelementptr inbounds [2048 x i8], ptr %77, i64 0, i64 0
  %79 = call i64 @xstrncpy(ptr noundef %78, i64 noundef 2048, ptr noundef @.str.5)
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = call i32 @XSearch_Callback(ptr noundef %80, ptr noundef %81)
  %83 = icmp slt i32 %82, 0
  br i1 %83, label %84, label %85

84:                                               ; preds = %75
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %86

85:                                               ; preds = %75
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %86

86:                                               ; preds = %85, %84, %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %87

87:                                               ; preds = %86, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %225

88:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 40, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 2048, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = call i64 @strlen(ptr noundef %89) #5
  store i64 %90, ptr %11, align 8, !tbaa !17
  br label %91

91:                                               ; preds = %104, %88
  %92 = load i64, ptr %11, align 8, !tbaa !17
  %93 = icmp ne i64 %92, 0
  br i1 %93, label %94, label %102

94:                                               ; preds = %91
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = load i64, ptr %11, align 8, !tbaa !17
  %97 = add i64 %96, -1
  store i64 %97, ptr %11, align 8, !tbaa !17
  %98 = getelementptr inbounds i8, ptr %95, i64 %96
  %99 = load i8, ptr %98, align 1, !tbaa !18
  %100 = sext i8 %99 to i32
  %101 = icmp eq i32 %100, 32
  br label %102

102:                                              ; preds = %94, %91
  %103 = phi i1 [ false, %91 ], [ %101, %94 ]
  br i1 %103, label %104, label %105

104:                                              ; preds = %102
  br label %91, !llvm.loop !19

105:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = load i64, ptr %11, align 8, !tbaa !17
  %108 = getelementptr inbounds i8, ptr %106, i64 %107
  %109 = load i8, ptr %108, align 1, !tbaa !18
  %110 = sext i8 %109 to i32
  %111 = icmp eq i32 %110, 47
  %112 = zext i1 %111 to i64
  %113 = select i1 %111, ptr @.str.6, ptr @.str.7
  store ptr %113, ptr %12, align 8, !tbaa !5
  %114 = getelementptr inbounds [2048 x i8], ptr %10, i64 0, i64 0
  %115 = load ptr, ptr %5, align 8, !tbaa !5
  %116 = load ptr, ptr %12, align 8, !tbaa !5
  %117 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef %114, i64 noundef 2048, ptr noundef @.str, ptr noundef %115, ptr noundef %116)
  %118 = getelementptr inbounds [2048 x i8], ptr %10, i64 0, i64 0
  %119 = call i32 @XDir_Open(ptr noundef %9, ptr noundef %118)
  %120 = icmp slt i32 %119, 0
  br i1 %120, label %121, label %133

121:                                              ; preds = %105
  %122 = load ptr, ptr %4, align 8, !tbaa !5
  %123 = getelementptr inbounds [2048 x i8], ptr %10, i64 0, i64 0
  %124 = call i32 (ptr, ptr, ...) @XSearch_ErrorCallback(ptr noundef %122, ptr noundef @.str.8, ptr noundef %123)
  %125 = load ptr, ptr %4, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.XSearchCtx, ptr %125, i32 0, i32 19
  %127 = load ptr, ptr %126, align 8, !tbaa !9
  %128 = atomicrmw add ptr %127, i32 0 seq_cst, align 4
  %129 = add i32 %128, 0
  %130 = icmp ne i32 %129, 0
  %131 = zext i1 %130 to i64
  %132 = select i1 %130, i32 -1, i32 1
  store i32 %132, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %224

133:                                              ; preds = %105
  br label %134

134:                                              ; preds = %222, %220, %133
  %135 = call i32 @XDir_Read(ptr noundef %9, ptr noundef null, i64 noundef 0)
  %136 = icmp sgt i32 %135, 0
  br i1 %136, label %137, label %145

137:                                              ; preds = %134
  %138 = load ptr, ptr %4, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.XSearchCtx, ptr %138, i32 0, i32 19
  %140 = load ptr, ptr %139, align 8, !tbaa !9
  %141 = atomicrmw add ptr %140, i32 0 seq_cst, align 4
  %142 = add i32 %141, 0
  %143 = icmp ne i32 %142, 0
  %144 = xor i1 %143, true
  br label %145

145:                                              ; preds = %137, %134
  %146 = phi i1 [ false, %134 ], [ %144, %137 ]
  br i1 %146, label %147, label %223

147:                                              ; preds = %145
  call void @llvm.lifetime.start.p0(i64 2048, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 144, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %148 = getelementptr inbounds %struct.XDir, ptr %9, i32 0, i32 1
  %149 = load ptr, ptr %148, align 8, !tbaa !21
  store ptr %149, ptr %15, align 8, !tbaa !5
  %150 = getelementptr inbounds [2048 x i8], ptr %13, i64 0, i64 0
  %151 = getelementptr inbounds [2048 x i8], ptr %10, i64 0, i64 0
  %152 = load ptr, ptr %15, align 8, !tbaa !5
  %153 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef %150, i64 noundef 2048, ptr noundef @.str, ptr noundef %151, ptr noundef %152)
  %154 = getelementptr inbounds [2048 x i8], ptr %13, i64 0, i64 0
  %155 = call i32 @xstat(ptr noundef %154, ptr noundef %14)
  %156 = icmp slt i32 %155, 0
  br i1 %156, label %157, label %169

157:                                              ; preds = %147
  %158 = load ptr, ptr %4, align 8, !tbaa !5
  %159 = getelementptr inbounds [2048 x i8], ptr %13, i64 0, i64 0
  %160 = call i32 (ptr, ptr, ...) @XSearch_ErrorCallback(ptr noundef %158, ptr noundef @.str.9, ptr noundef %159)
  %161 = load ptr, ptr %4, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.XSearchCtx, ptr %161, i32 0, i32 19
  %163 = load ptr, ptr %162, align 8, !tbaa !9
  %164 = atomicrmw add ptr %163, i32 0 seq_cst, align 4
  %165 = add i32 %164, 0
  %166 = icmp ne i32 %165, 0
  br i1 %166, label %167, label %168

167:                                              ; preds = %157
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %220

168:                                              ; preds = %157
  store i32 4, ptr %7, align 4
  br label %220, !llvm.loop !23

169:                                              ; preds = %147
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %170 = load ptr, ptr %4, align 8, !tbaa !5
  %171 = getelementptr inbounds [2048 x i8], ptr %10, i64 0, i64 0
  %172 = load ptr, ptr %15, align 8, !tbaa !5
  %173 = call i32 @XSearch_CheckCriteria(ptr noundef %170, ptr noundef %171, ptr noundef %172, ptr noundef %14)
  store i32 %173, ptr %16, align 4, !tbaa !16
  %174 = load i32, ptr %16, align 4, !tbaa !16
  %175 = icmp sgt i32 %174, 0
  br i1 %175, label %176, label %196

176:                                              ; preds = %169
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %177 = load ptr, ptr %15, align 8, !tbaa !5
  %178 = getelementptr inbounds [2048 x i8], ptr %10, i64 0, i64 0
  %179 = call ptr @XSearch_NewEntry(ptr noundef %177, ptr noundef %178, ptr noundef %14)
  store ptr %179, ptr %17, align 8, !tbaa !5
  %180 = load ptr, ptr %17, align 8, !tbaa !5
  %181 = icmp eq ptr %180, null
  br i1 %181, label %182, label %186

182:                                              ; preds = %176
  %183 = load ptr, ptr %4, align 8, !tbaa !5
  %184 = getelementptr inbounds [2048 x i8], ptr %13, i64 0, i64 0
  %185 = call i32 (ptr, ptr, ...) @XSearch_ErrorCallback(ptr noundef %183, ptr noundef @.str.10, ptr noundef %184)
  call void @XDir_Close(ptr noundef %9)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %193

186:                                              ; preds = %176
  %187 = load ptr, ptr %4, align 8, !tbaa !5
  %188 = load ptr, ptr %17, align 8, !tbaa !5
  %189 = call i32 @XSearch_Callback(ptr noundef %187, ptr noundef %188)
  %190 = icmp slt i32 %189, 0
  br i1 %190, label %191, label %192

191:                                              ; preds = %186
  call void @XDir_Close(ptr noundef %9)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %193

192:                                              ; preds = %186
  store i32 0, ptr %7, align 4
  br label %193

193:                                              ; preds = %192, %191, %182
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  %194 = load i32, ptr %7, align 4
  switch i32 %194, label %219 [
    i32 0, label %195
  ]

195:                                              ; preds = %193
  br label %201

196:                                              ; preds = %169
  %197 = load i32, ptr %16, align 4, !tbaa !16
  %198 = icmp slt i32 %197, 0
  br i1 %198, label %199, label %200

199:                                              ; preds = %196
  call void @XDir_Close(ptr noundef %9)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %219

200:                                              ; preds = %196
  br label %201

201:                                              ; preds = %200, %195
  %202 = load ptr, ptr %4, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.XSearchCtx, ptr %202, i32 0, i32 4
  %204 = load i8, ptr %203, align 2, !tbaa !24
  %205 = zext i8 %204 to i32
  %206 = icmp ne i32 %205, 0
  br i1 %206, label %207, label %218

207:                                              ; preds = %201
  %208 = getelementptr inbounds %struct.stat, ptr %14, i32 0, i32 3
  %209 = load i32, ptr %208, align 8, !tbaa !25
  %210 = and i32 %209, 61440
  %211 = icmp eq i32 %210, 16384
  br i1 %211, label %212, label %218

212:                                              ; preds = %207
  %213 = load ptr, ptr %4, align 8, !tbaa !5
  %214 = getelementptr inbounds [2048 x i8], ptr %13, i64 0, i64 0
  %215 = call i32 @XSearch(ptr noundef %213, ptr noundef %214)
  %216 = icmp slt i32 %215, 0
  br i1 %216, label %217, label %218

217:                                              ; preds = %212
  call void @XDir_Close(ptr noundef %9)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %219

218:                                              ; preds = %212, %207, %201
  store i32 0, ptr %7, align 4
  br label %219

219:                                              ; preds = %218, %217, %199, %193
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %220

220:                                              ; preds = %219, %168, %167
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 144, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr %13) #4
  %221 = load i32, ptr %7, align 4
  switch i32 %221, label %224 [
    i32 0, label %222
    i32 4, label %134
  ]

222:                                              ; preds = %220
  br label %134, !llvm.loop !23

223:                                              ; preds = %145
  call void @XDir_Close(ptr noundef %9)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %224

224:                                              ; preds = %223, %220, %121
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #4
  br label %225

225:                                              ; preds = %224, %87, %58, %32
  %226 = load i32, ptr %3, align 4
  ret i32 %226
}

declare i64 @xstrcase(ptr noundef, i32 noundef) #0

declare zeroext i8 @xstrused(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @XSearch_ErrorCallback(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @XSearch_Text(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @XSearch_Callback(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

declare i32 @XDir_Open(ptr noundef, ptr noundef) #0

declare i32 @XDir_Read(ptr noundef, ptr noundef, i64 noundef) #0

declare i32 @xstat(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @XSearch_CheckCriteria(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare void @XDir_Close(ptr noundef) #0

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 6328}
!10 = !{!"XSearchCtx", !11, i64 0, !11, i64 56, !7, i64 112, !7, i64 113, !7, i64 114, !7, i64 115, !7, i64 116, !6, i64 120, !6, i64 128, !7, i64 136, !7, i64 2184, !12, i64 6280, !12, i64 6284, !12, i64 6288, !12, i64 6292, !13, i64 6296, !13, i64 6304, !13, i64 6312, !7, i64 6320, !6, i64 6328, !12, i64 6336}
!11 = !{!"XArray_", !6, i64 0, !6, i64 8, !12, i64 16, !6, i64 24, !7, i64 32, !7, i64 33, !7, i64 34, !13, i64 40, !13, i64 48}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !7, i64 116}
!15 = !{!10, !7, i64 113}
!16 = !{!12, !12, i64 0}
!17 = !{!13, !13, i64 0}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!22, !6, i64 8}
!22 = !{!"XDir", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32, !7, i64 33}
!23 = distinct !{!23, !20}
!24 = !{!10, !7, i64 114}
!25 = !{!26, !12, i64 24}
!26 = !{!"stat", !13, i64 0, !13, i64 8, !13, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !27, i64 72, !27, i64 88, !27, i64 104, !7, i64 120}
!27 = !{!"timespec", !13, i64 0, !13, i64 8}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.XDir = type { ptr, ptr, ptr, ptr, i8, i8 }
%struct.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [26 x i8], align 1

declare i64 @xstrncpy(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare i64 @xstrncpyf(ptr noundef, i64 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @XSearch_NewEntry(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @XSearch(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca %struct.XDir, align 8
  %4 = alloca [2048 x i8], align 16
  %5 = alloca [2048 x i8], align 16
  %6 = alloca %struct.stat, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 6328
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = atomicrmw or ptr %8, i32 0 seq_cst, align 4
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %10, label %104

10:                                               ; preds = %2
  %11 = icmp eq ptr %1, null
  br i1 %11, label %12, label %15

12:                                               ; preds = %10
  %13 = getelementptr inbounds i8, ptr %0, i64 116
  %14 = load i8, ptr %13, align 4, !tbaa !13
  %.not59 = icmp eq i8 %14, 0
  br i1 %.not59, label %104, label %15

15:                                               ; preds = %12, %10
  %16 = getelementptr inbounds i8, ptr %0, i64 113
  %17 = load i8, ptr %16, align 1, !tbaa !14
  %.not60 = icmp eq i8 %17, 0
  br i1 %.not60, label %23, label %18

18:                                               ; preds = %15
  %19 = getelementptr inbounds i8, ptr %0, i64 136
  %20 = tail call i64 @xstrcase(ptr noundef nonnull %19, i32 noundef 0) #4
  %21 = getelementptr inbounds i8, ptr %0, i64 2184
  %22 = tail call i64 @xstrcase(ptr noundef nonnull %21, i32 noundef 0) #4
  br label %23

23:                                               ; preds = %18, %15
  %24 = getelementptr inbounds i8, ptr %0, i64 116
  %25 = load i8, ptr %24, align 4, !tbaa !13
  %.not61 = icmp eq i8 %25, 0
  br i1 %.not61, label %43, label %26

26:                                               ; preds = %23
  %27 = getelementptr inbounds i8, ptr %0, i64 2184
  %28 = tail call zeroext i8 @xstrused(ptr noundef nonnull %27) #4
  %.not66 = icmp eq i8 %28, 0
  br i1 %.not66, label %29, label %31

29:                                               ; preds = %26
  %30 = tail call i32 (ptr, ptr, ...) @XSearch_ErrorCallback(ptr noundef nonnull %0, ptr noundef nonnull @.str.2)
  br label %104

31:                                               ; preds = %26
  %32 = tail call i32 @XSearch_Text(ptr noundef nonnull %0, ptr noundef nonnull @.str.3, ptr noundef null, ptr noundef null)
  %33 = icmp slt i32 %32, 1
  br i1 %33, label %104, label %34

34:                                               ; preds = %31
  %35 = tail call ptr @XSearch_NewEntry(ptr noundef nonnull @.str.3, ptr noundef null, ptr noundef null)
  %36 = icmp eq ptr %35, null
  br i1 %36, label %37, label %39

37:                                               ; preds = %34
  %38 = tail call i32 (ptr, ptr, ...) @XSearch_ErrorCallback(ptr noundef nonnull %0, ptr noundef nonnull @.str.4)
  br label %104

39:                                               ; preds = %34
  %40 = getelementptr inbounds i8, ptr %35, i64 4368
  %41 = tail call i64 @xstrncpy(ptr noundef nonnull %40, i64 noundef 2048, ptr noundef nonnull @.str.5) #4
  %42 = tail call i32 @XSearch_Callback(ptr noundef nonnull %0, ptr noundef nonnull %35)
  %.inv = icmp sgt i32 %42, -1
  %. = select i1 %.inv, i32 1, i32 -1
  br label %104

43:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %4) #4
  %44 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #5
  %.old3.not = icmp eq i64 %44, 0
  br i1 %.old3.not, label %.critedge, label %.preheader71

.preheader71:                                     ; preds = %43, %.preheader71
  %.051 = phi i64 [ %45, %.preheader71 ], [ %44, %43 ]
  %45 = add i64 %.051, -1
  %46 = getelementptr inbounds i8, ptr %1, i64 %.051
  %47 = load i8, ptr %46, align 1, !tbaa !15
  %48 = icmp eq i8 %47, 32
  %49 = icmp ne i64 %45, 0
  %or.cond = and i1 %48, %49
  br i1 %or.cond, label %.preheader71, label %.critedge, !llvm.loop !16

.critedge:                                        ; preds = %.preheader71, %43
  %.152 = phi i64 [ 0, %43 ], [ %45, %.preheader71 ]
  %50 = getelementptr inbounds i8, ptr %1, i64 %.152
  %51 = load i8, ptr %50, align 1, !tbaa !15
  %52 = icmp eq i8 %51, 47
  %53 = select i1 %52, ptr @.str.6, ptr @.str.7
  %54 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %4, i64 noundef 2048, ptr noundef nonnull @.str, ptr noundef %1, ptr noundef nonnull %53) #4
  %55 = call i32 @XDir_Open(ptr noundef nonnull %3, ptr noundef nonnull %4) #4
  %56 = icmp slt i32 %55, 0
  br i1 %56, label %62, label %.preheader

.preheader:                                       ; preds = %.critedge
  %57 = call i32 @XDir_Read(ptr noundef nonnull %3, ptr noundef null, i64 noundef 0) #4
  %58 = icmp sgt i32 %57, 0
  br i1 %58, label %.lr.ph, label %.critedge2

.lr.ph:                                           ; preds = %.preheader
  %59 = getelementptr inbounds i8, ptr %3, i64 8
  %60 = getelementptr inbounds i8, ptr %0, i64 114
  %61 = getelementptr inbounds i8, ptr %6, i64 24
  br label %67

62:                                               ; preds = %.critedge
  %63 = call i32 (ptr, ptr, ...) @XSearch_ErrorCallback(ptr noundef %0, ptr noundef nonnull @.str.8, ptr noundef nonnull %4)
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = atomicrmw or ptr %64, i32 0 seq_cst, align 4
  %.not65 = icmp eq i32 %65, 0
  %66 = select i1 %.not65, i32 1, i32 -1
  br label %103

67:                                               ; preds = %.lr.ph, %.critedge69
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = atomicrmw or ptr %68, i32 0 seq_cst, align 4
  %.not62 = icmp eq i32 %69, 0
  br i1 %.not62, label %70, label %.critedge2

70:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %6) #4
  %71 = load ptr, ptr %59, align 8, !tbaa !18
  %72 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef nonnull %5, i64 noundef 2048, ptr noundef nonnull @.str, ptr noundef nonnull %4, ptr noundef %71) #4
  %73 = call i32 @xstat(ptr noundef nonnull %5, ptr noundef nonnull %6) #4
  %74 = icmp slt i32 %73, 0
  br i1 %74, label %75, label %79

75:                                               ; preds = %70
  %76 = call i32 (ptr, ptr, ...) @XSearch_ErrorCallback(ptr noundef nonnull %0, ptr noundef nonnull @.str.9, ptr noundef nonnull %5)
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = atomicrmw or ptr %77, i32 0 seq_cst, align 4
  %.not64 = icmp eq i32 %78, 0
  br i1 %.not64, label %.critedge69, label %.critedge69.thread, !llvm.loop !20

79:                                               ; preds = %70
  %80 = call i32 @XSearch_CheckCriteria(ptr noundef nonnull %0, ptr noundef nonnull %4, ptr noundef %71, ptr noundef nonnull %6)
  %81 = icmp sgt i32 %80, 0
  br i1 %81, label %82, label %90

82:                                               ; preds = %79
  %83 = call ptr @XSearch_NewEntry(ptr noundef %71, ptr noundef nonnull %4, ptr noundef nonnull %6)
  %84 = icmp eq ptr %83, null
  br i1 %84, label %85, label %87

85:                                               ; preds = %82
  %86 = call i32 (ptr, ptr, ...) @XSearch_ErrorCallback(ptr noundef nonnull %0, ptr noundef nonnull @.str.10, ptr noundef nonnull %5)
  br label %.critedge69.thread.sink.split

87:                                               ; preds = %82
  %88 = call i32 @XSearch_Callback(ptr noundef nonnull %0, ptr noundef nonnull %83)
  %89 = icmp slt i32 %88, 0
  br i1 %89, label %.critedge69.thread.sink.split, label %92

90:                                               ; preds = %79
  %91 = icmp slt i32 %80, 0
  br i1 %91, label %.critedge69.thread.sink.split, label %92

92:                                               ; preds = %87, %90
  %93 = load i8, ptr %60, align 2, !tbaa !21
  %.not63 = icmp eq i8 %93, 0
  br i1 %.not63, label %.critedge69, label %94

94:                                               ; preds = %92
  %95 = load i32, ptr %61, align 8, !tbaa !22
  %96 = and i32 %95, 61440
  %97 = icmp eq i32 %96, 16384
  br i1 %97, label %98, label %.critedge69

98:                                               ; preds = %94
  %99 = call i32 @XSearch(ptr noundef nonnull %0, ptr noundef nonnull %5)
  %100 = icmp slt i32 %99, 0
  br i1 %100, label %.critedge69.thread.sink.split, label %.critedge69

.critedge69.thread.sink.split:                    ; preds = %98, %90, %87, %85
  call void @XDir_Close(ptr noundef nonnull %3) #4
  br label %.critedge69.thread

.critedge69.thread:                               ; preds = %75, %.critedge69.thread.sink.split
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %5) #4
  br label %103

.critedge69:                                      ; preds = %75, %98, %94, %92
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %5) #4
  %101 = call i32 @XDir_Read(ptr noundef nonnull %3, ptr noundef null, i64 noundef 0) #4
  %102 = icmp sgt i32 %101, 0
  br i1 %102, label %67, label %.critedge2

.critedge2:                                       ; preds = %67, %.critedge69, %.preheader
  call void @XDir_Close(ptr noundef nonnull %3) #4
  br label %103

103:                                              ; preds = %.critedge69.thread, %.critedge2, %62
  %.7 = phi i32 [ %66, %62 ], [ 1, %.critedge2 ], [ -1, %.critedge69.thread ]
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #4
  br label %104

104:                                              ; preds = %31, %39, %37, %2, %12, %103, %29
  %.8 = phi i32 [ -1, %29 ], [ %.7, %103 ], [ -1, %12 ], [ -1, %2 ], [ %32, %31 ], [ -1, %37 ], [ %., %39 ]
  ret i32 %.8
}

declare i64 @xstrcase(ptr noundef, i32 noundef) local_unnamed_addr #0

declare zeroext i8 @xstrused(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @XSearch_ErrorCallback(ptr noundef, ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @XSearch_Text(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @XSearch_Callback(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

declare i32 @XDir_Open(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @XDir_Read(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

declare i32 @xstat(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @XSearch_CheckCriteria(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @XDir_Close(ptr noundef) local_unnamed_addr #0

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !8, i64 6328}
!6 = !{!"XSearchCtx", !7, i64 0, !7, i64 56, !9, i64 112, !9, i64 113, !9, i64 114, !9, i64 115, !9, i64 116, !8, i64 120, !8, i64 128, !9, i64 136, !9, i64 2184, !11, i64 6280, !11, i64 6284, !11, i64 6288, !11, i64 6292, !12, i64 6296, !12, i64 6304, !12, i64 6312, !9, i64 6320, !8, i64 6328, !11, i64 6336}
!7 = !{!"XArray_", !8, i64 0, !8, i64 8, !11, i64 16, !8, i64 24, !9, i64 32, !9, i64 33, !9, i64 34, !12, i64 40, !12, i64 48}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"long", !9, i64 0}
!13 = !{!6, !9, i64 116}
!14 = !{!6, !9, i64 113}
!15 = !{!9, !9, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !8, i64 8}
!19 = !{!"XDir", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !9, i64 32, !9, i64 33}
!20 = distinct !{!20, !17}
!21 = !{!6, !9, i64 114}
!22 = !{!23, !11, i64 24}
!23 = !{!"stat", !12, i64 0, !12, i64 8, !12, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !24, i64 72, !24, i64 88, !24, i64 104, !9, i64 120}
!24 = !{!"timespec", !12, i64 0, !12, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass