; LLVM IR from davidesantangelo/krep :: krep (search_directory_recursive)

; 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.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.dirent = type { i64, i64, i16, i8, [256 x i8] }

@stderr = external global ptr, align 8
@.str.105 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.124 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.125 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.126 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.127 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.128 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.129 = external hidden unnamed_addr constant [53 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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @search_file(ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @search_directory_recursive(ptr noundef %0, ptr noundef %1, i32 noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca [4096 x i8], align 16
  %13 = alloca i32, align 4
  %14 = alloca %struct.stat, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call ptr @opendir(ptr noundef %16)
  store ptr %17, ptr %8, align 8, !tbaa !5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %52, label %20

20:                                               ; preds = %3
  %21 = call ptr @__errno_location() #7
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = icmp eq i32 %22, 13
  br i1 %23, label %24, label %28

24:                                               ; preds = %20
  %25 = load ptr, ptr @stderr, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef @.str.124, ptr noundef %26) #6
  br label %40

28:                                               ; preds = %20
  %29 = call ptr @__errno_location() #7
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = icmp ne i32 %30, 2
  br i1 %31, label %32, label %39

32:                                               ; preds = %28
  %33 = load ptr, ptr @stderr, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = call ptr @__errno_location() #7
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %37 = call ptr @strerror(i32 noundef %36) #6
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str.105, ptr noundef %34, ptr noundef %37) #6
  br label %39

39:                                               ; preds = %32, %28
  br label %40

40:                                               ; preds = %39, %24
  %41 = call ptr @__errno_location() #7
  %42 = load i32, ptr %41, align 4, !tbaa !9
  %43 = icmp eq i32 %42, 13
  br i1 %43, label %48, label %44

44:                                               ; preds = %40
  %45 = call ptr @__errno_location() #7
  %46 = load i32, ptr %45, align 4, !tbaa !9
  %47 = icmp eq i32 %46, 2
  br label %48

48:                                               ; preds = %44, %40
  %49 = phi i1 [ true, %40 ], [ %47, %44 ]
  %50 = zext i1 %49 to i64
  %51 = select i1 %49, i32 0, i32 1
  store i32 %51, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %185

52:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4096, ptr %12) #6
  br label %53

53:                                               ; preds = %180, %178, %69, %52
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = call ptr @readdir(ptr noundef %54)
  store ptr %55, ptr %10, align 8, !tbaa !5
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %181

57:                                               ; preds = %53
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.dirent, ptr %58, i32 0, i32 4
  %60 = getelementptr inbounds [256 x i8], ptr %59, i64 0, i64 0
  %61 = call i32 @strcmp(ptr noundef %60, ptr noundef @.str.125) #8
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %69, label %63

63:                                               ; preds = %57
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.dirent, ptr %64, i32 0, i32 4
  %66 = getelementptr inbounds [256 x i8], ptr %65, i64 0, i64 0
  %67 = call i32 @strcmp(ptr noundef %66, ptr noundef @.str.126) #8
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %63, %57
  br label %53, !llvm.loop !11

70:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = call i64 @strlen(ptr noundef %72) #8
  %74 = sub i64 %73, 1
  %75 = getelementptr inbounds i8, ptr %71, i64 %74
  %76 = load i8, ptr %75, align 1, !tbaa !13
  %77 = sext i8 %76 to i32
  %78 = icmp eq i32 %77, 47
  br i1 %78, label %79, label %86

79:                                               ; preds = %70
  %80 = getelementptr inbounds [4096 x i8], ptr %12, i64 0, i64 0
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.dirent, ptr %82, i32 0, i32 4
  %84 = getelementptr inbounds [256 x i8], ptr %83, i64 0, i64 0
  %85 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %80, i64 noundef 4096, ptr noundef @.str.127, ptr noundef %81, ptr noundef %84) #6
  store i32 %85, ptr %13, align 4, !tbaa !9
  br label %93

86:                                               ; preds = %70
  %87 = getelementptr inbounds [4096 x i8], ptr %12, i64 0, i64 0
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = load ptr, ptr %10, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.dirent, ptr %89, i32 0, i32 4
  %91 = getelementptr inbounds [256 x i8], ptr %90, i64 0, i64 0
  %92 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %87, i64 noundef 4096, ptr noundef @.str.128, ptr noundef %88, ptr noundef %91) #6
  store i32 %92, ptr %13, align 4, !tbaa !9
  br label %93

93:                                               ; preds = %86, %79
  %94 = load i32, ptr %13, align 4, !tbaa !9
  %95 = icmp slt i32 %94, 0
  br i1 %95, label %100, label %96

96:                                               ; preds = %93
  %97 = load i32, ptr %13, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = icmp uge i64 %98, 4096
  br i1 %99, label %100, label %109

100:                                              ; preds = %96, %93
  %101 = load ptr, ptr @stderr, align 8, !tbaa !5
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  %103 = load ptr, ptr %10, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.dirent, ptr %103, i32 0, i32 4
  %105 = getelementptr inbounds [256 x i8], ptr %104, i64 0, i64 0
  %106 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef @.str.129, ptr noundef %102, ptr noundef %105) #6
  %107 = load i32, ptr %11, align 4, !tbaa !9
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %11, align 4, !tbaa !9
  store i32 2, ptr %9, align 4
  br label %178, !llvm.loop !11

109:                                              ; preds = %96
  call void @llvm.lifetime.start.p0(i64 144, ptr %14) #6
  %110 = getelementptr inbounds [4096 x i8], ptr %12, i64 0, i64 0
  %111 = call i32 @lstat(ptr noundef %110, ptr noundef %14) #6
  %112 = icmp eq i32 %111, -1
  br i1 %112, label %113, label %127

113:                                              ; preds = %109
  %114 = call ptr @__errno_location() #7
  %115 = load i32, ptr %114, align 4, !tbaa !9
  %116 = icmp ne i32 %115, 2
  br i1 %116, label %117, label %126

117:                                              ; preds = %113
  %118 = load ptr, ptr @stderr, align 8, !tbaa !5
  %119 = getelementptr inbounds [4096 x i8], ptr %12, i64 0, i64 0
  %120 = call ptr @__errno_location() #7
  %121 = load i32, ptr %120, align 4, !tbaa !9
  %122 = call ptr @strerror(i32 noundef %121) #6
  %123 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %118, ptr noundef @.str.105, ptr noundef %119, ptr noundef %122) #6
  %124 = load i32, ptr %11, align 4, !tbaa !9
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %11, align 4, !tbaa !9
  br label %126

126:                                              ; preds = %117, %113
  store i32 2, ptr %9, align 4
  br label %177, !llvm.loop !11

127:                                              ; preds = %109
  %128 = getelementptr inbounds %struct.stat, ptr %14, i32 0, i32 3
  %129 = load i32, ptr %128, align 8, !tbaa !14
  %130 = and i32 %129, 61440
  %131 = icmp eq i32 %130, 16384
  br i1 %131, label %132, label %145

132:                                              ; preds = %127
  %133 = load ptr, ptr %10, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.dirent, ptr %133, i32 0, i32 4
  %135 = getelementptr inbounds [256 x i8], ptr %134, i64 0, i64 0
  %136 = call zeroext i1 @should_skip_directory(ptr noundef %135)
  br i1 %136, label %137, label %138

137:                                              ; preds = %132
  store i32 2, ptr %9, align 4
  br label %177, !llvm.loop !11

138:                                              ; preds = %132
  %139 = getelementptr inbounds [4096 x i8], ptr %12, i64 0, i64 0
  %140 = load ptr, ptr %6, align 8, !tbaa !5
  %141 = load i32, ptr %7, align 4, !tbaa !9
  %142 = call i32 @search_directory_recursive(ptr noundef %139, ptr noundef %140, i32 noundef %141)
  %143 = load i32, ptr %11, align 4, !tbaa !9
  %144 = add nsw i32 %143, %142
  store i32 %144, ptr %11, align 4, !tbaa !9
  br label %176

145:                                              ; preds = %127
  %146 = getelementptr inbounds %struct.stat, ptr %14, i32 0, i32 3
  %147 = load i32, ptr %146, align 8, !tbaa !14
  %148 = and i32 %147, 61440
  %149 = icmp eq i32 %148, 32768
  br i1 %149, label %150, label %175

150:                                              ; preds = %145
  %151 = load ptr, ptr %10, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.dirent, ptr %151, i32 0, i32 4
  %153 = getelementptr inbounds [256 x i8], ptr %152, i64 0, i64 0
  %154 = call zeroext i1 @should_skip_extension(ptr noundef %153)
  br i1 %154, label %155, label %156

155:                                              ; preds = %150
  store i32 2, ptr %9, align 4
  br label %177, !llvm.loop !11

156:                                              ; preds = %150
  %157 = getelementptr inbounds %struct.stat, ptr %14, i32 0, i32 8
  %158 = load i64, ptr %157, align 8, !tbaa !18
  %159 = icmp sgt i64 %158, 1048576
  br i1 %159, label %160, label %164

160:                                              ; preds = %156
  %161 = getelementptr inbounds [4096 x i8], ptr %12, i64 0, i64 0
  %162 = call zeroext i1 @is_binary_file(ptr noundef %161)
  br i1 %162, label %163, label %164

163:                                              ; preds = %160
  store i32 2, ptr %9, align 4
  br label %177, !llvm.loop !11

164:                                              ; preds = %160, %156
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  %165 = load ptr, ptr %6, align 8, !tbaa !5
  %166 = getelementptr inbounds [4096 x i8], ptr %12, i64 0, i64 0
  %167 = load i32, ptr %7, align 4, !tbaa !9
  %168 = call i32 @search_file(ptr noundef %165, ptr noundef %166, i32 noundef %167)
  store i32 %168, ptr %15, align 4, !tbaa !9
  %169 = load i32, ptr %15, align 4, !tbaa !9
  %170 = icmp eq i32 %169, 2
  br i1 %170, label %171, label %174

171:                                              ; preds = %164
  %172 = load i32, ptr %11, align 4, !tbaa !9
  %173 = add nsw i32 %172, 1
  store i32 %173, ptr %11, align 4, !tbaa !9
  br label %174

174:                                              ; preds = %171, %164
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %175

175:                                              ; preds = %174, %145
  br label %176

176:                                              ; preds = %175, %138
  store i32 0, ptr %9, align 4
  br label %177

177:                                              ; preds = %176, %163, %155, %137, %126
  call void @llvm.lifetime.end.p0(i64 144, ptr %14) #6
  br label %178

178:                                              ; preds = %177, %100
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  %179 = load i32, ptr %9, align 4
  switch i32 %179, label %187 [
    i32 0, label %180
    i32 2, label %53
  ]

180:                                              ; preds = %178
  br label %53, !llvm.loop !11

181:                                              ; preds = %53
  %182 = load ptr, ptr %8, align 8, !tbaa !5
  %183 = call i32 @closedir(ptr noundef %182)
  %184 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %184, ptr %4, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4096, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %185

185:                                              ; preds = %181, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %186 = load i32, ptr %4, align 4
  ret i32 %186

187:                                              ; preds = %178
  unreachable
}

declare ptr @opendir(ptr noundef) #5

declare ptr @readdir(ptr noundef) #5

; Function Attrs: nounwind
declare i32 @lstat(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @should_skip_directory(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @should_skip_extension(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @is_binary_file(ptr noundef) #3

declare i32 @closedir(ptr noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 #4 = { 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 #5 = { "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) }
attributes #8 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !10, i64 24}
!15 = !{!"stat", !16, i64 0, !16, i64 8, !16, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !16, i64 40, !16, i64 48, !16, i64 56, !16, i64 64, !17, i64 72, !17, i64 88, !17, i64 104, !7, i64 120}
!16 = !{!"long", !7, i64 0}
!17 = !{!"timespec", !16, i64 0, !16, i64 8}
!18 = !{!15, !16, i64 48}


; 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.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 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.105 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.124 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.125 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.126 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.127 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.128 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.129 = external hidden unnamed_addr constant [53 x i8], align 1

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

; Function Attrs: nofree nounwind
declare noundef i32 @snprintf(ptr noalias nocapture noundef writeonly, i64 noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @search_file(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @search_directory_recursive(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #3 {
  %4 = alloca [4096 x i8], align 16
  %5 = alloca %struct.stat, align 8
  %6 = tail call ptr @opendir(ptr noundef %0)
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %7, label %21

7:                                                ; preds = %3
  %8 = tail call ptr @__errno_location() #7
  %9 = load i32, ptr %8, align 4, !tbaa !5
  switch i32 %9, label %13 [
    i32 13, label %10
    i32 2, label %17
  ]

10:                                               ; preds = %7
  %11 = load ptr, ptr @stderr, align 8, !tbaa !9
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.124, ptr noundef %0) #8
  br label %17

13:                                               ; preds = %7
  %14 = load ptr, ptr @stderr, align 8, !tbaa !9
  %15 = tail call ptr @strerror(i32 noundef %9) #9
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.105, ptr noundef %0, ptr noundef %15) #8
  br label %17

17:                                               ; preds = %7, %13, %10
  %18 = load i32, ptr %8, align 4, !tbaa !5
  %19 = icmp ne i32 %18, 13
  %20 = icmp ne i32 %18, 2
  %narrow = and i1 %19, %20
  %not. = zext i1 %narrow to i32
  br label %79

21:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %4) #9
  %invariant.gep = getelementptr i8, ptr %0, i64 -1
  %22 = tail call ptr @readdir(ptr noundef nonnull %6) #9
  %.not414446 = icmp eq ptr %22, null
  br i1 %.not414446, label %.outer._crit_edge, label %.lr.ph.lr.ph

.lr.ph.lr.ph:                                     ; preds = %21
  %23 = getelementptr inbounds i8, ptr %5, i64 24
  %24 = getelementptr inbounds i8, ptr %5, i64 48
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.lr.ph, %.outer
  %25 = phi ptr [ %22, %.lr.ph.lr.ph ], [ %77, %.outer ]
  %.033.ph47 = phi i32 [ 0, %.lr.ph.lr.ph ], [ %.5, %.outer ]
  br label %26

26:                                               ; preds = %.lr.ph, %34
  %27 = phi ptr [ %25, %.lr.ph ], [ %35, %34 ]
  %28 = getelementptr inbounds i8, ptr %27, i64 19
  %29 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %28, ptr noundef nonnull dereferenceable(1) @.str.125) #10
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %34, label %31

31:                                               ; preds = %26
  %32 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %28, ptr noundef nonnull dereferenceable(1) @.str.126) #10
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %36

34:                                               ; preds = %31, %26
  %35 = call ptr @readdir(ptr noundef nonnull %6) #9
  %.not41 = icmp eq ptr %35, null
  br i1 %.not41, label %.outer._crit_edge, label %26, !llvm.loop !11

36:                                               ; preds = %31
  %37 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #10
  %gep = getelementptr i8, ptr %invariant.gep, i64 %37
  %38 = load i8, ptr %gep, align 1, !tbaa !13
  %39 = icmp eq i8 %38, 47
  %.str.127..str.128 = select i1 %39, ptr @.str.127, ptr @.str.128
  %40 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %4, i64 noundef 4096, ptr noundef nonnull %.str.127..str.128, ptr noundef nonnull %0, ptr noundef nonnull %28) #9
  %41 = icmp ugt i32 %40, 4095
  br i1 %41, label %42, label %46

42:                                               ; preds = %36
  %43 = load ptr, ptr @stderr, align 8, !tbaa !9
  %44 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef nonnull @.str.129, ptr noundef nonnull %0, ptr noundef nonnull %28) #8
  %45 = add nsw i32 %.033.ph47, 1
  br label %.outer, !llvm.loop !11

46:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %5) #9
  %47 = call i32 @lstat(ptr noundef nonnull %4, ptr noundef nonnull %5) #9
  %48 = icmp eq i32 %47, -1
  br i1 %48, label %49, label %57

49:                                               ; preds = %46
  %50 = tail call ptr @__errno_location() #7
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %.not42 = icmp eq i32 %51, 2
  br i1 %.not42, label %76, label %52, !llvm.loop !11

52:                                               ; preds = %49
  %53 = load ptr, ptr @stderr, align 8, !tbaa !9
  %54 = call ptr @strerror(i32 noundef %51) #9
  %55 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %53, ptr noundef nonnull @.str.105, ptr noundef nonnull %4, ptr noundef %54) #8
  %56 = add nsw i32 %.033.ph47, 1
  br label %76, !llvm.loop !11

57:                                               ; preds = %46
  %58 = load i32, ptr %23, align 8, !tbaa !14
  %59 = trunc i32 %58 to i16
  %trunc = and i16 %59, -4096
  switch i16 %trunc, label %76 [
    i16 16384, label %60
    i16 -32768, label %65
  ]

60:                                               ; preds = %57
  %61 = call zeroext i1 @should_skip_directory(ptr noundef nonnull %28)
  br i1 %61, label %76, label %62, !llvm.loop !11

62:                                               ; preds = %60
  %63 = call i32 @search_directory_recursive(ptr noundef nonnull %4, ptr noundef %1, i32 noundef %2)
  %64 = add nsw i32 %63, %.033.ph47
  br label %76

65:                                               ; preds = %57
  %66 = call zeroext i1 @should_skip_extension(ptr noundef nonnull %28)
  br i1 %66, label %76, label %67, !llvm.loop !11

67:                                               ; preds = %65
  %68 = load i64, ptr %24, align 8, !tbaa !18
  %69 = icmp sgt i64 %68, 1048576
  br i1 %69, label %70, label %72

70:                                               ; preds = %67
  %71 = call zeroext i1 @is_binary_file(ptr noundef nonnull %4)
  br i1 %71, label %76, label %72, !llvm.loop !11

72:                                               ; preds = %70, %67
  %73 = call i32 @search_file(ptr noundef %1, ptr noundef nonnull %4, i32 noundef %2)
  %74 = icmp eq i32 %73, 2
  %75 = zext i1 %74 to i32
  %spec.select = add nsw i32 %.033.ph47, %75
  br label %76

76:                                               ; preds = %62, %72, %57, %70, %65, %60, %49, %52
  %.4 = phi i32 [ %56, %52 ], [ %.033.ph47, %49 ], [ %.033.ph47, %60 ], [ %.033.ph47, %65 ], [ %.033.ph47, %70 ], [ %64, %62 ], [ %spec.select, %72 ], [ %.033.ph47, %57 ]
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %5) #9
  br label %.outer

.outer:                                           ; preds = %76, %42
  %.5 = phi i32 [ %45, %42 ], [ %.4, %76 ]
  %77 = call ptr @readdir(ptr noundef nonnull %6) #9
  %.not4144 = icmp eq ptr %77, null
  br i1 %.not4144, label %.outer._crit_edge, label %.lr.ph

.outer._crit_edge:                                ; preds = %.outer, %34, %21
  %.033.ph.lcssa = phi i32 [ 0, %21 ], [ %.033.ph47, %34 ], [ %.5, %.outer ]
  %78 = call i32 @closedir(ptr noundef nonnull %6)
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %4) #9
  br label %79

79:                                               ; preds = %.outer._crit_edge, %17
  %.0 = phi i32 [ %.033.ph.lcssa, %.outer._crit_edge ], [ %not., %17 ]
  ret i32 %.0
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @opendir(ptr nocapture noundef readonly) local_unnamed_addr #1

declare ptr @readdir(ptr noundef) local_unnamed_addr #6

; Function Attrs: nofree nounwind
declare noundef i32 @lstat(ptr nocapture noundef readonly, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @should_skip_directory(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @should_skip_extension(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @is_binary_file(ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @closedir(ptr nocapture noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree 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 #2 = { 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 #3 = { 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 #4 = { 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 #5 = { 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 #6 = { "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 willreturn memory(none) }
attributes #8 = { cold nounwind }
attributes #9 = { nounwind }
attributes #10 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !6, i64 24}
!15 = !{!"stat", !16, i64 0, !16, i64 8, !16, i64 16, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36, !16, i64 40, !16, i64 48, !16, i64 56, !16, i64 64, !17, i64 72, !17, i64 88, !17, i64 104, !7, i64 120}
!16 = !{!"long", !7, i64 0}
!17 = !{!"timespec", !16, i64 0, !16, i64 8}
!18 = !{!15, !16, i64 48}


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