; LLVM IR from yellow-footed-honeyguide/facad :: src (dev_dir_utils)

; 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] }
%struct.FileCardInfo = type { ptr, ptr, i32, i32, [2 x i8], i32 }

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@stderr = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [41 x i8], align 1

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

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

19:                                               ; preds = %3
  call void @perror(ptr noundef @.str.1)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %192

20:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  call void @llvm.lifetime.start.p0(i64 4096, ptr %11) #8
  call void @llvm.lifetime.start.p0(i64 144, ptr %12) #8
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %35

24:                                               ; preds = %20
  %25 = call noalias ptr @malloc(i64 noundef 2048) #9
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %25, ptr %26, align 8, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %33

30:                                               ; preds = %24
  call void @perror(ptr noundef @.str.2)
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = call i32 @closedir(ptr noundef %31)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %191

33:                                               ; preds = %24
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 64, ptr %34, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %33, %20
  br label %36

36:                                               ; preds = %187, %52, %35
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = call ptr @readdir(ptr noundef %37)
  store ptr %38, ptr %10, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %188

40:                                               ; preds = %36
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.dirent, ptr %41, i32 0, i32 4
  %43 = getelementptr inbounds [256 x i8], ptr %42, i64 0, i64 0
  %44 = call i32 @strcmp(ptr noundef %43, ptr noundef @.str.3) #10
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %52, label %46

46:                                               ; preds = %40
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.dirent, ptr %47, i32 0, i32 4
  %49 = getelementptr inbounds [256 x i8], ptr %48, i64 0, i64 0
  %50 = call i32 @strcmp(ptr noundef %49, ptr noundef @.str.4) #10
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %52, label %53

52:                                               ; preds = %46, %40
  br label %36, !llvm.loop !11

53:                                               ; preds = %46
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = icmp sge i32 %55, %57
  br i1 %58, label %59, label %87

59:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load i32, ptr %60, align 4, !tbaa !9
  %62 = mul nsw i32 %61, 2
  store i32 %62, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load ptr, ptr %63, align 8, !tbaa !5
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = mul i64 %66, 32
  %68 = call ptr @realloc(ptr noundef %64, i64 noundef %67) #11
  store ptr %68, ptr %14, align 8, !tbaa !5
  %69 = load ptr, ptr %14, align 8, !tbaa !5
  %70 = icmp ne ptr %69, null
  br i1 %70, label %79, label %71

71:                                               ; preds = %59
  %72 = load ptr, ptr @stderr, align 8, !tbaa !5
  %73 = call ptr @__errno_location() #12
  %74 = load i32, ptr %73, align 4, !tbaa !9
  %75 = call ptr @strerror(i32 noundef %74) #8
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %72, ptr noundef @.str.5, ptr noundef %75) #8
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = call i32 @closedir(ptr noundef %77)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %84

79:                                               ; preds = %59
  %80 = load ptr, ptr %14, align 8, !tbaa !5
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %80, ptr %81, align 8, !tbaa !5
  %82 = load i32, ptr %13, align 4, !tbaa !9
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  store i32 %82, ptr %83, align 4, !tbaa !9
  store i32 0, ptr %9, align 4
  br label %84

84:                                               ; preds = %79, %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  %85 = load i32, ptr %9, align 4
  switch i32 %85, label %191 [
    i32 0, label %86
  ]

86:                                               ; preds = %84
  br label %87

87:                                               ; preds = %86, %53
  %88 = getelementptr inbounds [4096 x i8], ptr %11, i64 0, i64 0
  %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 %88, i64 noundef 4096, ptr noundef @.str.6, ptr noundef %91) #8
  %93 = getelementptr inbounds [4096 x i8], ptr %11, i64 0, i64 0
  %94 = call i32 @lstat(ptr noundef %93, ptr noundef %12) #8
  %95 = icmp eq i32 %94, 0
  br i1 %95, label %96, label %187

96:                                               ; preds = %87
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = load ptr, ptr %97, align 8, !tbaa !5
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = load i32, ptr %99, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds %struct.FileCardInfo, ptr %98, i64 %101
  store ptr %102, ptr %15, 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 noalias ptr @strdup(ptr noundef %105) #8
  %107 = load ptr, ptr %15, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.FileCardInfo, ptr %107, i32 0, i32 0
  store ptr %106, ptr %108, align 8, !tbaa !13
  %109 = load ptr, ptr %15, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.FileCardInfo, ptr %109, i32 0, i32 0
  %111 = load ptr, ptr %110, align 8, !tbaa !13
  %112 = icmp eq ptr %111, null
  br i1 %112, label %113, label %116

113:                                              ; preds = %96
  call void @perror(ptr noundef @.str.7)
  %114 = load ptr, ptr %8, align 8, !tbaa !5
  %115 = call i32 @closedir(ptr noundef %114)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %184

116:                                              ; preds = %96
  %117 = getelementptr inbounds %struct.stat, ptr %12, i32 0, i32 3
  %118 = load i32, ptr %117, align 8, !tbaa !15
  %119 = and i32 %118, 61440
  %120 = icmp eq i32 %119, 16384
  %121 = zext i1 %120 to i32
  %122 = load ptr, ptr %15, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.FileCardInfo, ptr %122, i32 0, i32 2
  store i32 %121, ptr %123, align 8, !tbaa !19
  %124 = load ptr, ptr %10, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.dirent, ptr %124, i32 0, i32 4
  %126 = getelementptr inbounds [256 x i8], ptr %125, i64 0, i64 0
  %127 = load i8, ptr %126, align 1, !tbaa !20
  %128 = sext i8 %127 to i32
  %129 = icmp eq i32 %128, 46
  %130 = zext i1 %129 to i32
  %131 = load ptr, ptr %15, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.FileCardInfo, ptr %131, i32 0, i32 3
  store i32 %130, ptr %132, align 4, !tbaa !21
  %133 = getelementptr inbounds %struct.stat, ptr %12, i32 0, i32 3
  %134 = load i32, ptr %133, align 8, !tbaa !15
  %135 = and i32 %134, 61440
  %136 = icmp eq i32 %135, 40960
  br i1 %136, label %137, label %147

137:                                              ; preds = %116
  %138 = load ptr, ptr %15, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.FileCardInfo, ptr %138, i32 0, i32 2
  %140 = load i32, ptr %139, align 8, !tbaa !19
  %141 = icmp ne i32 %140, 0
  %142 = zext i1 %141 to i64
  %143 = select i1 %141, ptr @.str.8, ptr @.str.9
  %144 = call noalias ptr @strdup(ptr noundef %143) #8
  %145 = load ptr, ptr %15, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.FileCardInfo, ptr %145, i32 0, i32 1
  store ptr %144, ptr %146, align 8, !tbaa !22
  br label %164

147:                                              ; preds = %116
  %148 = load ptr, ptr %15, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.FileCardInfo, ptr %148, i32 0, i32 2
  %150 = load i32, ptr %149, align 8, !tbaa !19
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %152, label %156

152:                                              ; preds = %147
  %153 = call noalias ptr @strdup(ptr noundef @.str.10) #8
  %154 = load ptr, ptr %15, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct.FileCardInfo, ptr %154, i32 0, i32 1
  store ptr %153, ptr %155, align 8, !tbaa !22
  br label %163

156:                                              ; preds = %147
  %157 = load ptr, ptr %10, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.dirent, ptr %157, i32 0, i32 4
  %159 = getelementptr inbounds [256 x i8], ptr %158, i64 0, i64 0
  %160 = call ptr @get_dev_emoji(ptr noundef %159)
  %161 = load ptr, ptr %15, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.FileCardInfo, ptr %161, i32 0, i32 1
  store ptr %160, ptr %162, align 8, !tbaa !22
  br label %163

163:                                              ; preds = %156, %152
  br label %164

164:                                              ; preds = %163, %137
  %165 = load ptr, ptr %15, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.FileCardInfo, ptr %165, i32 0, i32 1
  %167 = load ptr, ptr %166, align 8, !tbaa !22
  %168 = icmp eq ptr %167, null
  br i1 %168, label %169, label %180

169:                                              ; preds = %164
  %170 = load ptr, ptr @stderr, align 8, !tbaa !5
  %171 = call ptr @__errno_location() #12
  %172 = load i32, ptr %171, align 4, !tbaa !9
  %173 = call ptr @strerror(i32 noundef %172) #8
  %174 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %170, ptr noundef @.str.11, ptr noundef %173) #8
  %175 = load ptr, ptr %15, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct.FileCardInfo, ptr %175, i32 0, i32 0
  %177 = load ptr, ptr %176, align 8, !tbaa !13
  call void @free(ptr noundef %177) #8
  %178 = load ptr, ptr %8, align 8, !tbaa !5
  %179 = call i32 @closedir(ptr noundef %178)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %184

180:                                              ; preds = %164
  %181 = load ptr, ptr %6, align 8, !tbaa !5
  %182 = load i32, ptr %181, align 4, !tbaa !9
  %183 = add nsw i32 %182, 1
  store i32 %183, ptr %181, align 4, !tbaa !9
  store i32 0, ptr %9, align 4
  br label %184

184:                                              ; preds = %180, %169, %113
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  %185 = load i32, ptr %9, align 4
  switch i32 %185, label %191 [
    i32 0, label %186
  ]

186:                                              ; preds = %184
  br label %187

187:                                              ; preds = %186, %87
  br label %36, !llvm.loop !11

188:                                              ; preds = %36
  %189 = load ptr, ptr %8, align 8, !tbaa !5
  %190 = call i32 @closedir(ptr noundef %189)
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %191

191:                                              ; preds = %188, %184, %84, %30
  call void @llvm.lifetime.end.p0(i64 144, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 4096, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  br label %192

192:                                              ; preds = %191, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  %193 = load i32, ptr %4, align 4
  ret i32 %193
}

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

declare ptr @opendir(ptr noundef) #3

declare void @perror(ptr noundef) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

declare i32 @closedir(ptr noundef) #3

declare ptr @readdir(ptr noundef) #3

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #5

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

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

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

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

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

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

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #6

declare ptr @get_dev_emoji(ptr noundef) #3

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

attributes #0 = { 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 #1 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 allocsize(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 = { nounwind allocsize(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 #6 = { 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { nounwind willreturn memory(read) }
attributes #11 = { nounwind allocsize(1) }
attributes #12 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 0}
!14 = !{!"", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !7, i64 24, !10, i64 28}
!15 = !{!16, !10, i64 24}
!16 = !{!"stat", !17, i64 0, !17, i64 8, !17, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !17, i64 40, !17, i64 48, !17, i64 56, !17, i64 64, !18, i64 72, !18, i64 88, !18, i64 104, !7, i64 120}
!17 = !{!"long", !7, i64 0}
!18 = !{!"timespec", !17, i64 0, !17, i64 8}
!19 = !{!14, !10, i64 16}
!20 = !{!7, !7, i64 0}
!21 = !{!14, !10, i64 20}
!22 = !{!14, !6, 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.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.FileCardInfo = type { ptr, ptr, i32, i32, [2 x i8], i32 }

@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [41 x i8], align 1

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

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

7:                                                ; preds = %3
  tail call void @perror(ptr noundef nonnull @.str.1) #11
  br label %89

8:                                                ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %4) #12
  call void @llvm.lifetime.start.p0(i64 144, ptr nonnull %5) #12
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %16

11:                                               ; preds = %8
  %12 = tail call noalias dereferenceable_or_null(2048) ptr @malloc(i64 noundef 2048) #13
  store ptr %12, ptr %0, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  tail call void @perror(ptr noundef nonnull @.str.2) #11
  br label %.critedge

15:                                               ; preds = %11
  store i32 64, ptr %2, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %15, %8
  %17 = tail call ptr @readdir(ptr noundef nonnull %6) #12
  %.not5056 = icmp eq ptr %17, null
  br i1 %.not5056, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %16
  %18 = getelementptr inbounds i8, ptr %5, i64 24
  br label %19

19:                                               ; preds = %.lr.ph, %.backedge
  %20 = phi ptr [ %17, %.lr.ph ], [ %27, %.backedge ]
  %21 = getelementptr inbounds i8, ptr %20, i64 19
  %22 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %21, ptr noundef nonnull dereferenceable(1) @.str.3) #14
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %.backedge, label %24

24:                                               ; preds = %19
  %25 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %21, ptr noundef nonnull dereferenceable(1) @.str.4) #14
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %.backedge, label %28

.backedge:                                        ; preds = %43, %85, %19, %24
  %27 = tail call ptr @readdir(ptr noundef nonnull %6) #12
  %.not50 = icmp eq ptr %27, null
  br i1 %.not50, label %.critedge, label %19, !llvm.loop !11

28:                                               ; preds = %24
  %29 = load i32, ptr %1, align 4, !tbaa !9
  %30 = load i32, ptr %2, align 4, !tbaa !9
  %.not51 = icmp slt i32 %29, %30
  br i1 %.not51, label %43, label %31

31:                                               ; preds = %28
  %32 = shl nsw i32 %30, 1
  %33 = load ptr, ptr %0, align 8, !tbaa !5
  %34 = sext i32 %32 to i64
  %35 = shl nsw i64 %34, 5
  %36 = tail call ptr @realloc(ptr noundef %33, i64 noundef %35) #15
  %.not52.not = icmp eq ptr %36, null
  br i1 %.not52.not, label %.thread, label %42

.thread:                                          ; preds = %31
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = tail call ptr @__errno_location() #16
  %39 = load i32, ptr %38, align 4, !tbaa !9
  %40 = tail call ptr @strerror(i32 noundef %39) #12
  %41 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef nonnull @.str.5, ptr noundef %40) #17
  br label %.critedge

42:                                               ; preds = %31
  store ptr %36, ptr %0, align 8, !tbaa !5
  store i32 %32, ptr %2, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %42, %28
  %44 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %4, i64 noundef 4096, ptr noundef nonnull @.str.6, ptr noundef nonnull %21) #12
  %45 = call i32 @lstat(ptr noundef nonnull %4, ptr noundef nonnull %5) #12
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %.backedge

47:                                               ; preds = %43
  %48 = load ptr, ptr %0, align 8, !tbaa !5
  %49 = load i32, ptr %1, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds %struct.FileCardInfo, ptr %48, i64 %50
  %52 = tail call noalias ptr @strdup(ptr noundef nonnull %21) #12
  store ptr %52, ptr %51, align 8, !tbaa !13
  %53 = icmp eq ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %47
  tail call void @perror(ptr noundef nonnull @.str.7) #11
  br label %.critedge

55:                                               ; preds = %47
  %56 = load i32, ptr %18, align 8, !tbaa !15
  %57 = and i32 %56, 61440
  %58 = icmp eq i32 %57, 16384
  %59 = zext i1 %58 to i32
  %60 = getelementptr inbounds i8, ptr %51, i64 16
  store i32 %59, ptr %60, align 8, !tbaa !19
  %61 = load i8, ptr %21, align 1, !tbaa !20
  %62 = icmp eq i8 %61, 46
  %63 = zext i1 %62 to i32
  %64 = getelementptr inbounds i8, ptr %51, i64 20
  store i32 %63, ptr %64, align 4, !tbaa !21
  %65 = icmp eq i32 %57, 40960
  br i1 %65, label %66, label %69

66:                                               ; preds = %55
  %67 = tail call noalias ptr @strdup(ptr noundef nonnull @.str.9) #12
  %68 = getelementptr inbounds i8, ptr %51, i64 8
  store ptr %67, ptr %68, align 8, !tbaa !22
  br label %75

69:                                               ; preds = %55
  %70 = getelementptr inbounds i8, ptr %51, i64 8
  br i1 %58, label %71, label %73

71:                                               ; preds = %69
  %72 = tail call noalias ptr @strdup(ptr noundef nonnull @.str.10) #12
  store ptr %72, ptr %70, align 8, !tbaa !22
  br label %75

73:                                               ; preds = %69
  %74 = tail call ptr @get_dev_emoji(ptr noundef nonnull %21) #12
  store ptr %74, ptr %70, align 8, !tbaa !22
  br label %75

75:                                               ; preds = %71, %73, %66
  %76 = phi ptr [ %72, %71 ], [ %74, %73 ], [ %67, %66 ]
  %77 = icmp eq ptr %76, null
  br i1 %77, label %78, label %85

78:                                               ; preds = %75
  %79 = load ptr, ptr @stderr, align 8, !tbaa !5
  %80 = tail call ptr @__errno_location() #16
  %81 = load i32, ptr %80, align 4, !tbaa !9
  %82 = tail call ptr @strerror(i32 noundef %81) #12
  %83 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %79, ptr noundef nonnull @.str.11, ptr noundef %82) #17
  %84 = load ptr, ptr %51, align 8, !tbaa !13
  tail call void @free(ptr noundef %84) #12
  br label %.critedge

85:                                               ; preds = %75
  %86 = load i32, ptr %1, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %1, align 4, !tbaa !9
  br label %.backedge

.critedge:                                        ; preds = %.backedge, %16, %.thread, %54, %78, %14
  %.5 = phi i32 [ -1, %14 ], [ -1, %78 ], [ -1, %54 ], [ -1, %.thread ], [ 0, %16 ], [ 0, %.backedge ]
  %88 = tail call i32 @closedir(ptr noundef nonnull %6)
  call void @llvm.lifetime.end.p0(i64 144, ptr nonnull %5) #12
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %4) #12
  br label %89

89:                                               ; preds = %.critedge, %7
  %.6 = phi i32 [ %.5, %.critedge ], [ -1, %7 ]
  ret i32 %.6
}

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

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

; Function Attrs: nofree nounwind
declare void @perror(ptr nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

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

declare ptr @readdir(ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #6

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

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

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

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

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #9

declare ptr @get_dev_emoji(ptr noundef) local_unnamed_addr #5

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

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(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 = { "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 = { mustprogress nounwind willreturn allockind("realloc") allocsize(1) 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 #7 = { 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 #8 = { 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 #9 = { mustprogress nofree nounwind willreturn 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 #10 = { 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 #11 = { cold }
attributes #12 = { nounwind }
attributes #13 = { nounwind allocsize(0) }
attributes #14 = { nounwind willreturn memory(read) }
attributes #15 = { nounwind allocsize(1) }
attributes #16 = { nounwind willreturn memory(none) }
attributes #17 = { cold nounwind }

!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 = !{!14, !6, i64 0}
!14 = !{!"", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !7, i64 24, !10, i64 28}
!15 = !{!16, !10, i64 24}
!16 = !{!"stat", !17, i64 0, !17, i64 8, !17, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !17, i64 40, !17, i64 48, !17, i64 56, !17, i64 64, !18, i64 72, !18, i64 88, !18, i64 104, !7, i64 120}
!17 = !{!"long", !7, i64 0}
!18 = !{!"timespec", !17, i64 0, !17, i64 8}
!19 = !{!14, !10, i64 16}
!20 = !{!7, !7, i64 0}
!21 = !{!14, !10, i64 20}
!22 = !{!14, !6, i64 8}


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