; LLVM IR from mncoppola/rpef :: utilities_src/squashfs4.1/squashfs-tools (sort)

; 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_info = type { ptr, i32, i32, i32, i32, i8, ptr, ptr, ptr }
%struct.dir_ent = type { ptr, ptr, ptr, ptr, ptr }
%struct.inode_info = type { %struct.stat, ptr, i64, i32, i32, i32, i8, i8, i8, i8 }
%struct.stat = type { i64, i64, i64, i32, i32, i32, i32, i64, i64, i64, i64, %struct.timespec, %struct.timespec, %struct.timespec, [3 x i64] }
%struct.timespec = type { i64, i64 }

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @generate_file_priorities(ptr noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.dir_info, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = call i32 @get_priority(ptr noundef %14, ptr noundef %15, i32 noundef %16)
  store i32 %17, ptr %6, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %80, %78, %3
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.dir_info, ptr %19, i32 0, i32 3
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.dir_info, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 8, !tbaa !14
  %25 = icmp ult i32 %21, %24
  br i1 %25, label %26, label %81

26:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.dir_info, ptr %27, i32 0, i32 7
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.dir_info, ptr %30, i32 0, i32 3
  %32 = load i32, ptr %31, align 8, !tbaa !13
  %33 = add i32 %32, 1
  store i32 %33, ptr %31, align 8, !tbaa !13
  %34 = zext i32 %32 to i64
  %35 = getelementptr inbounds ptr, ptr %29, i64 %34
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  store ptr %36, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.dir_ent, ptr %37, i32 0, i32 2
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  %40 = getelementptr inbounds %struct.inode_info, ptr %39, i32 0, i32 0
  store ptr %40, ptr %10, align 8, !tbaa !5
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.dir_ent, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !16
  %44 = getelementptr inbounds %struct.inode_info, ptr %43, i32 0, i32 8
  %45 = load i8, ptr %44, align 2, !tbaa !18
  %46 = icmp ne i8 %45, 0
  br i1 %46, label %47, label %48

47:                                               ; preds = %26
  store i32 2, ptr %11, align 4
  br label %78, !llvm.loop !24

48:                                               ; preds = %26
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.stat, ptr %49, i32 0, i32 3
  %51 = load i32, ptr %50, align 8, !tbaa !26
  %52 = and i32 %51, 61440
  switch i32 %52, label %77 [
    i32 32768, label %53
    i32 16384, label %66
  ]

53:                                               ; preds = %48
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.dir_ent, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !27
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = load i32, ptr %6, align 4, !tbaa !9
  %60 = call i32 @get_priority(ptr noundef %57, ptr noundef %58, i32 noundef %59)
  %61 = call i32 @add_priority_list(ptr noundef %54, i32 noundef %60)
  store i32 %61, ptr %8, align 4, !tbaa !9
  %62 = load i32, ptr %8, align 4, !tbaa !9
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %53
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %78

65:                                               ; preds = %53
  br label %77

66:                                               ; preds = %48
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.dir_ent, ptr %67, i32 0, i32 3
  %69 = load ptr, ptr %68, align 8, !tbaa !28
  %70 = load i32, ptr %6, align 4, !tbaa !9
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = call i32 @generate_file_priorities(ptr noundef %69, i32 noundef %70, ptr noundef %71)
  store i32 %72, ptr %8, align 4, !tbaa !9
  %73 = load i32, ptr %8, align 4, !tbaa !9
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %76

75:                                               ; preds = %66
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %78

76:                                               ; preds = %66
  br label %77

77:                                               ; preds = %76, %65, %48
  store i32 0, ptr %11, align 4
  br label %78

78:                                               ; preds = %77, %75, %64, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  %79 = load i32, ptr %11, align 4
  switch i32 %79, label %84 [
    i32 0, label %80
    i32 2, label %18
  ]

80:                                               ; preds = %78
  br label %18, !llvm.loop !24

81:                                               ; preds = %18
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.dir_info, ptr %82, i32 0, i32 3
  store i32 0, ptr %83, align 8, !tbaa !13
  store i32 1, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %84

84:                                               ; preds = %81, %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %85 = load i32, ptr %4, align 4
  ret i32 %85
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"dir_info", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !7, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!13 = !{!12, !10, i64 16}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !6, i64 40}
!16 = !{!17, !6, i64 16}
!17 = !{!"dir_ent", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!18 = !{!19, !7, i64 174}
!19 = !{!"inode_info", !20, i64 0, !6, i64 144, !23, i64 152, !10, i64 160, !10, i64 164, !10, i64 168, !7, i64 172, !7, i64 173, !7, i64 174, !7, i64 175}
!20 = !{!"stat", !21, i64 0, !21, i64 8, !21, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !21, i64 40, !21, i64 48, !21, i64 56, !21, i64 64, !22, i64 72, !22, i64 88, !22, i64 104, !7, i64 120}
!21 = !{!"long", !7, i64 0}
!22 = !{!"timespec", !21, i64 0, !21, i64 8}
!23 = !{!"long long", !7, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!20, !10, i64 24}
!27 = !{!17, !6, i64 8}
!28 = !{!17, !6, i64 24}


; 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: nounwind uwtable
declare dso_local i32 @add_priority_list(ptr noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @generate_file_priorities(ptr nocapture noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = tail call i32 @get_priority(ptr noundef %4, ptr noundef %2, i32 noundef %1)
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load i32, ptr %6, align 8, !tbaa !11
  %9 = load i32, ptr %7, align 8, !tbaa !12
  %10 = icmp ult i32 %8, %9
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  br label %12

12:                                               ; preds = %.lr.ph, %38
  %13 = phi i32 [ %8, %.lr.ph ], [ %39, %38 ]
  %14 = load ptr, ptr %11, align 8, !tbaa !13
  %15 = add nuw i32 %13, 1
  store i32 %15, ptr %6, align 8, !tbaa !11
  %16 = zext i32 %13 to i64
  %17 = getelementptr inbounds ptr, ptr %14, i64 %16
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = getelementptr inbounds i8, ptr %20, i64 174
  %22 = load i8, ptr %21, align 2, !tbaa !17
  %.not = icmp eq i8 %22, 0
  br i1 %.not, label %23, label %38, !llvm.loop !23

23:                                               ; preds = %12
  %24 = getelementptr inbounds i8, ptr %20, i64 24
  %25 = load i32, ptr %24, align 8, !tbaa !25
  %26 = trunc i32 %25 to i16
  %trunc = and i16 %26, -4096
  switch i16 %trunc, label %38 [
    i16 -32768, label %27
    i16 16384, label %33
  ]

27:                                               ; preds = %23
  %28 = getelementptr inbounds i8, ptr %18, i64 8
  %29 = load ptr, ptr %28, align 8, !tbaa !26
  %30 = tail call i32 @get_priority(ptr noundef %29, ptr noundef nonnull %20, i32 noundef %5)
  %31 = tail call i32 @add_priority_list(ptr noundef nonnull %18, i32 noundef %30)
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %.thread, label %38

33:                                               ; preds = %23
  %34 = getelementptr inbounds i8, ptr %18, i64 24
  %35 = load ptr, ptr %34, align 8, !tbaa !27
  %36 = tail call i32 @generate_file_priorities(ptr noundef %35, i32 noundef %5, ptr noundef nonnull %20)
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %.thread, label %38

38:                                               ; preds = %23, %27, %33, %12
  %39 = load i32, ptr %6, align 8, !tbaa !11
  %40 = load i32, ptr %7, align 8, !tbaa !12
  %41 = icmp ult i32 %39, %40
  br i1 %41, label %12, label %._crit_edge

._crit_edge:                                      ; preds = %38, %3
  store i32 0, ptr %6, align 8, !tbaa !11
  br label %.thread

.thread:                                          ; preds = %33, %27, %._crit_edge
  %.2 = phi i32 [ 1, %._crit_edge ], [ 0, %27 ], [ 0, %33 ]
  ret i32 %.2
}

attributes #0 = { 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" }

!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 0}
!6 = !{!"dir_info", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !8, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !7, i64 40}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !7, i64 16}
!16 = !{!"dir_ent", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!17 = !{!18, !8, i64 174}
!18 = !{!"inode_info", !19, i64 0, !7, i64 144, !22, i64 152, !10, i64 160, !10, i64 164, !10, i64 168, !8, i64 172, !8, i64 173, !8, i64 174, !8, i64 175}
!19 = !{!"stat", !20, i64 0, !20, i64 8, !20, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !20, i64 40, !20, i64 48, !20, i64 56, !20, i64 64, !21, i64 72, !21, i64 88, !21, i64 104, !8, i64 120}
!20 = !{!"long", !8, i64 0}
!21 = !{!"timespec", !20, i64 0, !20, i64 8}
!22 = !{!"long long", !8, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!19, !10, i64 24}
!26 = !{!16, !7, i64 8}
!27 = !{!16, !7, i64 24}


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