; LLVM IR from kmxz/overlayfs-tools :: lib (scan_dir)

; 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.scan_ctx = type { ptr, ptr, %struct.scan_result, ptr, ptr, ptr, ptr }
%struct.scan_result = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.ovl_layer = type { ptr, i32, i32, i32, i32 }
%struct._ftsent = type { ptr, ptr, ptr, i64, ptr, ptr, ptr, i32, i32, i16, i16, i64, i64, i64, i16, i16, i16, i16, ptr, [1 x 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.scan_operations = type { ptr, ptr, ptr, ptr, ptr }

@.str.7 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [26 x i8], align 1

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

declare void @print_err(ptr noundef, ...) #1

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

declare ptr @smalloc(i64 noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @scan_dir(ptr noundef %0, ptr noundef %1) #4 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [2 x ptr], align 16
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #6
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.scan_ctx, ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.ovl_layer, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds ptr, ptr %6, i64 1
  store ptr null, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !15
  %17 = getelementptr inbounds [2 x ptr], ptr %6, i64 0, i64 0
  %18 = call ptr @fts_open(ptr noundef %17, i32 noundef 20, ptr noundef null)
  store ptr %18, ptr %7, align 8, !tbaa !5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %30

21:                                               ; preds = %2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.scan_ctx, ptr %22, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.ovl_layer, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = call ptr @__errno_location() #7
  %28 = load i32, ptr %27, align 4, !tbaa !15
  %29 = call ptr @strerror(i32 noundef %28) #6
  call void (ptr, ...) @print_err(ptr noundef @.str.7, ptr noundef %26, ptr noundef %29)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %218

30:                                               ; preds = %2
  br label %31

31:                                               ; preds = %212, %30
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = call ptr @fts_read(ptr noundef %32)
  store ptr %33, ptr %8, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %213

35:                                               ; preds = %31
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  call void @scan_entry_init(ptr noundef %36, ptr noundef %37)
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._ftsent, ptr %38, i32 0, i32 15
  %40 = load i16, ptr %39, align 2, !tbaa !16
  %41 = zext i16 %40 to i32
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %43, label %44

43:                                               ; preds = %35
  br label %106

44:                                               ; preds = %35
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._ftsent, ptr %45, i32 0, i32 15
  %47 = load i16, ptr %46, align 2, !tbaa !16
  %48 = zext i16 %47 to i32
  %49 = icmp eq i32 %48, 4
  br i1 %49, label %50, label %51

50:                                               ; preds = %44
  br label %104

51:                                               ; preds = %44
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._ftsent, ptr %52, i32 0, i32 15
  %54 = load i16, ptr %53, align 2, !tbaa !16
  %55 = zext i16 %54 to i32
  %56 = icmp eq i32 %55, 6
  br i1 %56, label %57, label %58

57:                                               ; preds = %51
  br label %102

58:                                               ; preds = %51
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._ftsent, ptr %59, i32 0, i32 15
  %61 = load i16, ptr %60, align 2, !tbaa !16
  %62 = zext i16 %61 to i32
  %63 = icmp eq i32 %62, 8
  br i1 %63, label %64, label %65

64:                                               ; preds = %58
  br label %100

65:                                               ; preds = %58
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._ftsent, ptr %66, i32 0, i32 15
  %68 = load i16, ptr %67, align 2, !tbaa !16
  %69 = zext i16 %68 to i32
  %70 = icmp eq i32 %69, 10
  br i1 %70, label %71, label %72

71:                                               ; preds = %65
  br label %98

72:                                               ; preds = %65
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._ftsent, ptr %73, i32 0, i32 15
  %75 = load i16, ptr %74, align 2, !tbaa !16
  %76 = zext i16 %75 to i32
  %77 = icmp eq i32 %76, 12
  br i1 %77, label %78, label %79

78:                                               ; preds = %72
  br label %96

79:                                               ; preds = %72
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._ftsent, ptr %80, i32 0, i32 15
  %82 = load i16, ptr %81, align 2, !tbaa !16
  %83 = zext i16 %82 to i32
  %84 = icmp eq i32 %83, 13
  br i1 %84, label %85, label %86

85:                                               ; preds = %79
  br label %94

86:                                               ; preds = %79
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct._ftsent, ptr %87, i32 0, i32 15
  %89 = load i16, ptr %88, align 2, !tbaa !16
  %90 = zext i16 %89 to i32
  %91 = icmp eq i32 %90, 3
  %92 = zext i1 %91 to i64
  %93 = select i1 %91, ptr @.str.16, ptr @.str.17
  br label %94

94:                                               ; preds = %86, %85
  %95 = phi ptr [ @.str.15, %85 ], [ %93, %86 ]
  br label %96

96:                                               ; preds = %94, %78
  %97 = phi ptr [ @.str.14, %78 ], [ %95, %94 ]
  br label %98

98:                                               ; preds = %96, %71
  %99 = phi ptr [ @.str.13, %71 ], [ %97, %96 ]
  br label %100

100:                                              ; preds = %98, %64
  %101 = phi ptr [ @.str.12, %64 ], [ %99, %98 ]
  br label %102

102:                                              ; preds = %100, %57
  %103 = phi ptr [ @.str.11, %57 ], [ %101, %100 ]
  br label %104

104:                                              ; preds = %102, %50
  %105 = phi ptr [ @.str.10, %50 ], [ %103, %102 ]
  br label %106

106:                                              ; preds = %104, %43
  %107 = phi ptr [ @.str.9, %43 ], [ %105, %104 ]
  %108 = load ptr, ptr %8, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct._ftsent, ptr %108, i32 0, i32 14
  %110 = load i16, ptr %109, align 8, !tbaa !20
  %111 = sext i16 %110 to i32
  %112 = load ptr, ptr %8, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct._ftsent, ptr %112, i32 0, i32 18
  %114 = load ptr, ptr %113, align 8, !tbaa !21
  %115 = getelementptr inbounds %struct.stat, ptr %114, i32 0, i32 8
  %116 = load i64, ptr %115, align 8, !tbaa !22
  %117 = load ptr, ptr %8, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct._ftsent, ptr %117, i32 0, i32 6
  %119 = load ptr, ptr %118, align 8, !tbaa !25
  %120 = load ptr, ptr %4, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.scan_ctx, ptr %120, i32 0, i32 1
  %122 = load ptr, ptr %121, align 8, !tbaa !9
  %123 = getelementptr inbounds %struct.ovl_layer, ptr %122, i32 0, i32 0
  %124 = load ptr, ptr %123, align 8, !tbaa !13
  call void (ptr, ...) @print_debug(ptr noundef @.str.8, ptr noundef %107, i32 noundef %111, i64 noundef %116, ptr noundef %119, ptr noundef %124)
  %125 = load ptr, ptr %8, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct._ftsent, ptr %125, i32 0, i32 15
  %127 = load i16, ptr %126, align 2, !tbaa !16
  %128 = zext i16 %127 to i32
  switch i32 %128, label %212 [
    i32 8, label %129
    i32 3, label %144
    i32 1, label %154
    i32 6, label %186
    i32 10, label %204
    i32 4, label %204
    i32 7, label %204
  ]

129:                                              ; preds = %106
  %130 = load ptr, ptr %4, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.scan_ctx, ptr %130, i32 0, i32 2
  %132 = getelementptr inbounds %struct.scan_result, ptr %131, i32 0, i32 0
  %133 = load i32, ptr %132, align 8, !tbaa !26
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr %132, align 8, !tbaa !26
  %135 = load ptr, ptr %5, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.scan_operations, ptr %135, i32 0, i32 3
  %137 = load ptr, ptr %136, align 8, !tbaa !27
  %138 = load ptr, ptr %4, align 8, !tbaa !5
  %139 = call i32 @scan_check_entry(ptr noundef %137, ptr noundef %138)
  store i32 %139, ptr %9, align 4, !tbaa !15
  %140 = load i32, ptr %9, align 4, !tbaa !15
  %141 = icmp ne i32 %140, 0
  br i1 %141, label %142, label %143

142:                                              ; preds = %129
  br label %214

143:                                              ; preds = %129
  br label %212

144:                                              ; preds = %106
  %145 = load ptr, ptr %5, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.scan_operations, ptr %145, i32 0, i32 0
  %147 = load ptr, ptr %146, align 8, !tbaa !29
  %148 = load ptr, ptr %4, align 8, !tbaa !5
  %149 = call i32 @scan_check_entry(ptr noundef %147, ptr noundef %148)
  store i32 %149, ptr %9, align 4, !tbaa !15
  %150 = load i32, ptr %9, align 4, !tbaa !15
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %152, label %153

152:                                              ; preds = %144
  br label %214

153:                                              ; preds = %144
  br label %212

154:                                              ; preds = %106
  %155 = load ptr, ptr %4, align 8, !tbaa !5
  %156 = getelementptr inbounds %struct.scan_ctx, ptr %155, i32 0, i32 2
  %157 = getelementptr inbounds %struct.scan_result, ptr %156, i32 0, i32 1
  %158 = load i32, ptr %157, align 4, !tbaa !30
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr %157, align 4, !tbaa !30
  %160 = load ptr, ptr %5, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.scan_operations, ptr %160, i32 0, i32 1
  %162 = load ptr, ptr %161, align 8, !tbaa !31
  %163 = load ptr, ptr %4, align 8, !tbaa !5
  %164 = call i32 @scan_check_entry(ptr noundef %162, ptr noundef %163)
  store i32 %164, ptr %9, align 4, !tbaa !15
  %165 = load i32, ptr %9, align 4, !tbaa !15
  %166 = icmp ne i32 %165, 0
  br i1 %166, label %167, label %168

167:                                              ; preds = %154
  br label %214

168:                                              ; preds = %154
  %169 = load ptr, ptr %5, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct.scan_operations, ptr %169, i32 0, i32 3
  %171 = load ptr, ptr %170, align 8, !tbaa !27
  %172 = load ptr, ptr %4, align 8, !tbaa !5
  %173 = call i32 @scan_check_entry(ptr noundef %171, ptr noundef %172)
  store i32 %173, ptr %9, align 4, !tbaa !15
  %174 = load i32, ptr %9, align 4, !tbaa !15
  %175 = icmp ne i32 %174, 0
  br i1 %175, label %176, label %177

176:                                              ; preds = %168
  br label %214

177:                                              ; preds = %168
  %178 = load ptr, ptr %4, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.scan_ctx, ptr %178, i32 0, i32 6
  %180 = load ptr, ptr %179, align 8, !tbaa !32
  %181 = load ptr, ptr %8, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct._ftsent, ptr %181, i32 0, i32 4
  store ptr %180, ptr %182, align 8, !tbaa !33
  %183 = call ptr @smalloc(i64 noundef 12)
  %184 = load ptr, ptr %4, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.scan_ctx, ptr %184, i32 0, i32 6
  store ptr %183, ptr %185, align 8, !tbaa !32
  br label %212

186:                                              ; preds = %106
  %187 = load ptr, ptr %5, align 8, !tbaa !5
  %188 = getelementptr inbounds %struct.scan_operations, ptr %187, i32 0, i32 4
  %189 = load ptr, ptr %188, align 8, !tbaa !34
  %190 = load ptr, ptr %4, align 8, !tbaa !5
  %191 = call i32 @scan_check_entry(ptr noundef %189, ptr noundef %190)
  store i32 %191, ptr %9, align 4, !tbaa !15
  %192 = load i32, ptr %9, align 4, !tbaa !15
  %193 = icmp ne i32 %192, 0
  br i1 %193, label %194, label %195

194:                                              ; preds = %186
  br label %214

195:                                              ; preds = %186
  %196 = load ptr, ptr %4, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.scan_ctx, ptr %196, i32 0, i32 6
  %198 = load ptr, ptr %197, align 8, !tbaa !32
  call void @free(ptr noundef %198) #6
  %199 = load ptr, ptr %8, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct._ftsent, ptr %199, i32 0, i32 4
  %201 = load ptr, ptr %200, align 8, !tbaa !33
  %202 = load ptr, ptr %4, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.scan_ctx, ptr %202, i32 0, i32 6
  store ptr %201, ptr %203, align 8, !tbaa !32
  br label %212

204:                                              ; preds = %106, %106, %106
  %205 = load ptr, ptr %8, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct._ftsent, ptr %205, i32 0, i32 6
  %207 = load ptr, ptr %206, align 8, !tbaa !25
  %208 = load ptr, ptr %8, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct._ftsent, ptr %208, i32 0, i32 7
  %210 = load i32, ptr %209, align 8, !tbaa !35
  %211 = call ptr @strerror(i32 noundef %210) #6
  call void (ptr, ...) @print_err(ptr noundef @.str.18, ptr noundef %207, ptr noundef %211)
  store i32 -1, ptr %9, align 4, !tbaa !15
  br label %214

212:                                              ; preds = %195, %177, %153, %143, %106
  br label %31, !llvm.loop !36

213:                                              ; preds = %31
  br label %214

214:                                              ; preds = %213, %204, %194, %176, %167, %152, %142
  %215 = load ptr, ptr %7, align 8, !tbaa !5
  %216 = call i32 @fts_close(ptr noundef %215)
  %217 = load i32, ptr %9, align 4, !tbaa !15
  store i32 %217, ptr %3, align 4
  store i32 1, ptr %10, align 4
  br label %218

218:                                              ; preds = %214, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #6
  %219 = load i32, ptr %3, align 4
  ret i32 %219
}

declare ptr @fts_open(ptr noundef, i32 noundef, ptr noundef) #1

declare ptr @fts_read(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @scan_entry_init(ptr noundef, ptr noundef) #4

declare void @print_debug(ptr noundef, ...) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @scan_check_entry(ptr noundef, ptr noundef) #5

declare i32 @fts_close(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 #2 = { nounwind "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(none) "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 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 #5 = { inlinehint 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

!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 8}
!10 = !{!"scan_ctx", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72}
!11 = !{!"scan_result", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"ovl_layer", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!15 = !{!12, !12, i64 0}
!16 = !{!17, !19, i64 98}
!17 = !{!"_ftsent", !6, i64 0, !6, i64 8, !6, i64 16, !18, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 60, !19, i64 64, !19, i64 66, !18, i64 72, !18, i64 80, !18, i64 88, !19, i64 96, !19, i64 98, !19, i64 100, !19, i64 102, !6, i64 104, !7, i64 112}
!18 = !{!"long", !7, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = !{!17, !19, i64 96}
!21 = !{!17, !6, i64 104}
!22 = !{!23, !18, i64 48}
!23 = !{!"stat", !18, i64 0, !18, i64 8, !18, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !18, i64 40, !18, i64 48, !18, i64 56, !18, i64 64, !24, i64 72, !24, i64 88, !24, i64 104, !7, i64 120}
!24 = !{!"timespec", !18, i64 0, !18, i64 8}
!25 = !{!17, !6, i64 48}
!26 = !{!10, !12, i64 16}
!27 = !{!28, !6, i64 24}
!28 = !{!"scan_operations", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!29 = !{!28, !6, i64 0}
!30 = !{!10, !12, i64 20}
!31 = !{!28, !6, i64 8}
!32 = !{!10, !6, i64 72}
!33 = !{!17, !6, i64 32}
!34 = !{!28, !6, i64 32}
!35 = !{!17, !12, i64 56}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}


; 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"

@.str.7 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [26 x i8], align 1
@switch.table.scan_dir = private unnamed_addr constant [13 x ptr] [ptr @.str.9, ptr @.str.9, ptr @.str.9, ptr @.str.10, ptr @.str.9, ptr @.str.11, ptr @.str.9, ptr @.str.12, ptr @.str.9, ptr @.str.13, ptr @.str.9, ptr @.str.14, ptr @.str.15], align 8

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

declare void @print_err(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #3

declare ptr @smalloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
define dso_local i32 @scan_dir(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #5 {
  %3 = alloca [2 x ptr], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #7
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  store ptr %6, ptr %3, align 16, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr null, ptr %7, align 8, !tbaa !14
  %8 = call ptr @fts_open(ptr noundef nonnull %3, i32 noundef 20, ptr noundef null) #7
  %9 = icmp eq ptr %8, null
  br i1 %9, label %17, label %.preheader

.preheader:                                       ; preds = %2
  %10 = call ptr @fts_read(ptr noundef nonnull %8) #7
  %.not71 = icmp eq ptr %10, null
  br i1 %.not71, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %11 = getelementptr inbounds i8, ptr %1, i64 32
  %12 = getelementptr inbounds i8, ptr %0, i64 72
  %13 = getelementptr inbounds i8, ptr %0, i64 20
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  %15 = getelementptr inbounds i8, ptr %1, i64 24
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  br label %23

17:                                               ; preds = %2
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load ptr, ptr %18, align 8, !tbaa !12
  %20 = tail call ptr @__errno_location() #8
  %21 = load i32, ptr %20, align 4, !tbaa !15
  %22 = call ptr @strerror(i32 noundef %21) #7
  call void (ptr, ...) @print_err(ptr noundef nonnull @.str.7, ptr noundef %19, ptr noundef %22) #7
  br label %82

23:                                               ; preds = %.lr.ph, %79
  %24 = phi ptr [ %10, %.lr.ph ], [ %80, %79 ]
  call void @scan_entry_init(ptr noundef nonnull %0, ptr noundef nonnull %24)
  %25 = getelementptr inbounds i8, ptr %24, i64 98
  %26 = load i16, ptr %25, align 2, !tbaa !16
  %switch.tableidx = add i16 %26, -1
  %27 = icmp ult i16 %switch.tableidx, 13
  br i1 %27, label %switch.hole_check, label %28

28:                                               ; preds = %switch.hole_check, %23
  %29 = icmp eq i16 %26, 3
  %30 = select i1 %29, ptr @.str.16, ptr @.str.17
  br label %32

switch.hole_check:                                ; preds = %23
  %switch.shifted = lshr i16 6825, %switch.tableidx
  %switch.lobit = trunc i16 %switch.shifted to i1
  br i1 %switch.lobit, label %switch.lookup, label %28

switch.lookup:                                    ; preds = %switch.hole_check
  %31 = zext nneg i16 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [13 x ptr], ptr @switch.table.scan_dir, i64 0, i64 %31
  %switch.load = load ptr, ptr %switch.gep, align 8
  br label %32

32:                                               ; preds = %switch.lookup, %28
  %33 = phi ptr [ %30, %28 ], [ %switch.load, %switch.lookup ]
  %34 = getelementptr inbounds i8, ptr %24, i64 96
  %35 = load i16, ptr %34, align 8, !tbaa !20
  %36 = sext i16 %35 to i32
  %37 = getelementptr inbounds i8, ptr %24, i64 104
  %38 = load ptr, ptr %37, align 8, !tbaa !21
  %39 = getelementptr inbounds i8, ptr %38, i64 48
  %40 = load i64, ptr %39, align 8, !tbaa !22
  %41 = getelementptr inbounds i8, ptr %24, i64 48
  %42 = load ptr, ptr %41, align 8, !tbaa !25
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load ptr, ptr %43, align 8, !tbaa !12
  call void (ptr, ...) @print_debug(ptr noundef nonnull @.str.8, ptr noundef nonnull %33, i32 noundef %36, i64 noundef %40, ptr noundef %42, ptr noundef %44) #7
  %45 = load i16, ptr %25, align 2, !tbaa !16
  switch i16 %45, label %79 [
    i16 8, label %46
    i16 3, label %51
    i16 1, label %54
    i16 6, label %66
    i16 10, label %73
    i16 4, label %73
    i16 7, label %73
  ]

46:                                               ; preds = %32
  %47 = load i32, ptr %16, align 8, !tbaa !26
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %16, align 8, !tbaa !26
  %49 = load ptr, ptr %15, align 8, !tbaa !27
  %50 = call i32 @scan_check_entry(ptr noundef %49, ptr noundef nonnull %0)
  %.not62 = icmp eq i32 %50, 0
  br i1 %.not62, label %79, label %.loopexit

51:                                               ; preds = %32
  %52 = load ptr, ptr %1, align 8, !tbaa !29
  %53 = call i32 @scan_check_entry(ptr noundef %52, ptr noundef nonnull %0)
  %.not61 = icmp eq i32 %53, 0
  br i1 %.not61, label %79, label %.loopexit

54:                                               ; preds = %32
  %55 = load i32, ptr %13, align 4, !tbaa !30
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %13, align 4, !tbaa !30
  %57 = load ptr, ptr %14, align 8, !tbaa !31
  %58 = call i32 @scan_check_entry(ptr noundef %57, ptr noundef nonnull %0)
  %.not59 = icmp eq i32 %58, 0
  br i1 %.not59, label %59, label %.loopexit

59:                                               ; preds = %54
  %60 = load ptr, ptr %15, align 8, !tbaa !27
  %61 = call i32 @scan_check_entry(ptr noundef %60, ptr noundef nonnull %0)
  %.not60 = icmp eq i32 %61, 0
  br i1 %.not60, label %62, label %.loopexit

62:                                               ; preds = %59
  %63 = load ptr, ptr %12, align 8, !tbaa !32
  %64 = getelementptr inbounds i8, ptr %24, i64 32
  store ptr %63, ptr %64, align 8, !tbaa !33
  %65 = call ptr @smalloc(i64 noundef 12) #7
  br label %.sink.split

66:                                               ; preds = %32
  %67 = load ptr, ptr %11, align 8, !tbaa !34
  %68 = call i32 @scan_check_entry(ptr noundef %67, ptr noundef nonnull %0)
  %.not58 = icmp eq i32 %68, 0
  br i1 %.not58, label %69, label %.loopexit

69:                                               ; preds = %66
  %70 = load ptr, ptr %12, align 8, !tbaa !32
  call void @free(ptr noundef %70) #7
  %71 = getelementptr inbounds i8, ptr %24, i64 32
  %72 = load ptr, ptr %71, align 8, !tbaa !33
  br label %.sink.split

73:                                               ; preds = %32, %32, %32
  %74 = getelementptr inbounds i8, ptr %24, i64 48
  %75 = load ptr, ptr %74, align 8, !tbaa !25
  %76 = getelementptr inbounds i8, ptr %24, i64 56
  %77 = load i32, ptr %76, align 8, !tbaa !35
  %78 = call ptr @strerror(i32 noundef %77) #7
  call void (ptr, ...) @print_err(ptr noundef nonnull @.str.18, ptr noundef %75, ptr noundef %78) #7
  br label %.loopexit

.sink.split:                                      ; preds = %62, %69
  %.sink = phi ptr [ %72, %69 ], [ %65, %62 ]
  store ptr %.sink, ptr %12, align 8, !tbaa !32
  br label %79

79:                                               ; preds = %.sink.split, %51, %46, %32
  %80 = call ptr @fts_read(ptr noundef nonnull %8) #7
  %.not = icmp eq ptr %80, null
  br i1 %.not, label %.loopexit, label %23, !llvm.loop !36

.loopexit:                                        ; preds = %46, %51, %54, %59, %66, %79, %.preheader, %73
  %.2 = phi i32 [ -1, %73 ], [ 0, %.preheader ], [ %50, %46 ], [ %53, %51 ], [ %58, %54 ], [ %61, %59 ], [ %68, %66 ], [ 0, %79 ]
  %81 = call i32 @fts_close(ptr noundef nonnull %8) #7
  br label %82

82:                                               ; preds = %.loopexit, %17
  %.046 = phi i32 [ -1, %17 ], [ %.2, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  ret i32 %.046
}

declare ptr @fts_open(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare ptr @fts_read(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @scan_entry_init(ptr noundef, ptr noundef) local_unnamed_addr #5

declare void @print_debug(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @scan_check_entry(ptr noundef, ptr noundef) local_unnamed_addr #6

declare i32 @fts_close(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 #2 = { nounwind "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 nosync nounwind willreturn memory(none) "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { 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 #6 = { inlinehint 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(none) }

!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, !7, i64 8}
!6 = !{!"scan_ctx", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"scan_result", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"ovl_layer", !7, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!14 = !{!7, !7, i64 0}
!15 = !{!11, !11, i64 0}
!16 = !{!17, !19, i64 98}
!17 = !{!"_ftsent", !7, i64 0, !7, i64 8, !7, i64 16, !18, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !11, i64 56, !11, i64 60, !19, i64 64, !19, i64 66, !18, i64 72, !18, i64 80, !18, i64 88, !19, i64 96, !19, i64 98, !19, i64 100, !19, i64 102, !7, i64 104, !8, i64 112}
!18 = !{!"long", !8, i64 0}
!19 = !{!"short", !8, i64 0}
!20 = !{!17, !19, i64 96}
!21 = !{!17, !7, i64 104}
!22 = !{!23, !18, i64 48}
!23 = !{!"stat", !18, i64 0, !18, i64 8, !18, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !18, i64 40, !18, i64 48, !18, i64 56, !18, i64 64, !24, i64 72, !24, i64 88, !24, i64 104, !8, i64 120}
!24 = !{!"timespec", !18, i64 0, !18, i64 8}
!25 = !{!17, !7, i64 48}
!26 = !{!6, !11, i64 16}
!27 = !{!28, !7, i64 24}
!28 = !{!"scan_operations", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!29 = !{!28, !7, i64 0}
!30 = !{!6, !11, i64 20}
!31 = !{!28, !7, i64 8}
!32 = !{!6, !7, i64 72}
!33 = !{!17, !7, i64 32}
!34 = !{!28, !7, i64 32}
!35 = !{!17, !11, i64 56}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}


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