; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/Middlewares/Third_Party/FatFs/src (ff)

; 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.DIR = type { %struct._FDID, i64, i64, i64, ptr, [12 x i8], i64 }
%struct._FDID = type { ptr, i16, i8, i8, i64, i64 }
%struct.FATFS = type { i8, i8, i8, i8, i8, i16, i16, i16, ptr, i64, i64, i64, i64, i64, i64, i64, i64, i64, [512 x i8] }

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

; Function Attrs: nounwind uwtable
declare hidden i32 @find_volume(ptr noundef, ptr noundef, i8 noundef zeroext) #1

; 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
declare hidden i32 @follow_path(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i64 @ld_clust(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @f_opendir(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = 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 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %2
  store i32 9, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %78

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.DIR, ptr %14, i32 0, i32 0
  store ptr %15, ptr %8, align 8, !tbaa !5
  %16 = call i32 @find_volume(ptr noundef %5, ptr noundef %7, i8 noundef zeroext 0)
  store i32 %16, ptr %6, align 4, !tbaa !9
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %70

19:                                               ; preds = %13
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._FDID, ptr %21, i32 0, i32 0
  store ptr %20, ptr %22, align 8, !tbaa !11
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call i32 @follow_path(ptr noundef %23, ptr noundef %24)
  store i32 %25, ptr %6, align 4, !tbaa !9
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %65

28:                                               ; preds = %19
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.DIR, ptr %29, i32 0, i32 5
  %31 = getelementptr inbounds [12 x i8], ptr %30, i64 0, i64 11
  %32 = load i8, ptr %31, align 1, !tbaa !15
  %33 = zext i8 %32 to i32
  %34 = and i32 %33, 128
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %53, label %36

36:                                               ; preds = %28
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._FDID, ptr %37, i32 0, i32 2
  %39 = load i8, ptr %38, align 2, !tbaa !16
  %40 = zext i8 %39 to i32
  %41 = and i32 %40, 16
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %51

43:                                               ; preds = %36
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.DIR, ptr %45, i32 0, i32 4
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = call i64 @ld_clust(ptr noundef %44, ptr noundef %47)
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._FDID, ptr %49, i32 0, i32 4
  store i64 %48, ptr %50, align 8, !tbaa !19
  br label %52

51:                                               ; preds = %36
  store i32 5, ptr %6, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %51, %43
  br label %53

53:                                               ; preds = %52, %28
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = icmp eq i32 %54, 0
  br i1 %55, label %56, label %64

56:                                               ; preds = %53
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.FATFS, ptr %57, i32 0, i32 5
  %59 = load i16, ptr %58, align 2, !tbaa !20
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._FDID, ptr %60, i32 0, i32 1
  store i16 %59, ptr %61, align 8, !tbaa !22
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = call i32 @dir_sdi(ptr noundef %62, i64 noundef 0)
  store i32 %63, ptr %6, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %56, %53
  br label %65

65:                                               ; preds = %64, %19
  %66 = load i32, ptr %6, align 4, !tbaa !9
  %67 = icmp eq i32 %66, 4
  br i1 %67, label %68, label %69

68:                                               ; preds = %65
  store i32 5, ptr %6, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %68, %65
  br label %70

70:                                               ; preds = %69, %13
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %76

73:                                               ; preds = %70
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._FDID, ptr %74, i32 0, i32 0
  store ptr null, ptr %75, align 8, !tbaa !11
  br label %76

76:                                               ; preds = %73, %70
  %77 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %77, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %78

78:                                               ; preds = %76, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %79 = load i32, ptr %3, align 4
  ret i32 %79
}

; Function Attrs: nounwind uwtable
declare hidden i32 @dir_sdi(ptr noundef, i64 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !13, i64 8, !7, i64 10, !7, i64 11, !14, i64 16, !14, i64 24}
!13 = !{!"short", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = !{!12, !7, i64 10}
!17 = !{!18, !6, i64 56}
!18 = !{!"", !12, i64 0, !14, i64 32, !14, i64 40, !14, i64 48, !6, i64 56, !7, i64 64, !14, i64 80}
!19 = !{!12, !14, i64 16}
!20 = !{!21, !13, i64 6}
!21 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !13, i64 6, !13, i64 8, !13, i64 10, !6, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !7, i64 96}
!22 = !{!12, !13, i64 8}


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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @find_volume(ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

; 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
declare hidden i32 @follow_path(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i64 @ld_clust(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @f_opendir(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %1, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #2
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %33, label %5

5:                                                ; preds = %2
  %6 = call i32 @find_volume(ptr noundef nonnull %3, ptr noundef nonnull %4, i8 noundef zeroext 0)
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %.thread30

8:                                                ; preds = %5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %9, ptr %0, align 8, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call i32 @follow_path(ptr noundef nonnull %0, ptr noundef %10)
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %32

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %0, i64 75
  %15 = load i8, ptr %14, align 1, !tbaa !13
  %.not22 = icmp sgt i8 %15, -1
  br i1 %.not22, label %16, label %26

16:                                               ; preds = %13
  %17 = getelementptr inbounds i8, ptr %0, i64 10
  %18 = load i8, ptr %17, align 2, !tbaa !14
  %19 = and i8 %18, 16
  %.not23 = icmp eq i8 %19, 0
  br i1 %.not23, label %.thread30, label %20

20:                                               ; preds = %16
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %0, i64 56
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = call i64 @ld_clust(ptr noundef %21, ptr noundef %23)
  %25 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %24, ptr %25, align 8, !tbaa !17
  br label %26

26:                                               ; preds = %13, %20
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 6
  %29 = load i16, ptr %28, align 2, !tbaa !18
  %30 = getelementptr inbounds i8, ptr %0, i64 8
  store i16 %29, ptr %30, align 8, !tbaa !20
  %31 = call i32 @dir_sdi(ptr noundef nonnull %0, i64 noundef 0)
  br label %32

32:                                               ; preds = %26, %8
  %.1 = phi i32 [ %31, %26 ], [ %11, %8 ]
  %.1.fr = freeze i32 %.1
  switch i32 %.1.fr, label %.thread30.fold.split [
    i32 4, label %.thread30
    i32 0, label %33
  ]

.thread30.fold.split:                             ; preds = %32
  br label %.thread30

.thread30:                                        ; preds = %32, %.thread30.fold.split, %16, %5
  %.233 = phi i32 [ %6, %5 ], [ 5, %16 ], [ 5, %32 ], [ %.1.fr, %.thread30.fold.split ]
  store ptr null, ptr %0, align 8, !tbaa !9
  br label %33

33:                                               ; preds = %32, %.thread30, %2
  %.0 = phi i32 [ 9, %2 ], [ %.233, %.thread30 ], [ %.1.fr, %32 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #2
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @dir_sdi(ptr noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !7, i64 10, !7, i64 11, !12, i64 16, !12, i64 24}
!11 = !{!"short", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!10, !7, i64 10}
!15 = !{!16, !6, i64 56}
!16 = !{!"", !10, i64 0, !12, i64 32, !12, i64 40, !12, i64 48, !6, i64 56, !7, i64 64, !12, i64 80}
!17 = !{!10, !12, i64 16}
!18 = !{!19, !11, i64 6}
!19 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !11, i64 6, !11, i64 8, !11, i64 10, !6, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !7, i64 96}
!20 = !{!10, !11, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass