; LLVM IR from FOSS-UCSC/FOSSALGO :: algorithms/gr-dij/cpp/dijkstra_algorithm.ll (Z11minDistancePiPb)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z11minDistancePiPb(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 2147483647, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %37, %2
  %9 = load i32, ptr %7, align 4, !tbaa !9
  %10 = icmp slt i32 %9, 9
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %40

12:                                               ; preds = %8
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds i8, ptr %13, i64 %15
  %17 = load i8, ptr %16, align 1, !tbaa !11, !range !13, !noundef !14
  %18 = trunc i8 %17 to i1
  %19 = zext i1 %18 to i32
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %36

21:                                               ; preds = %12
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i32, ptr %22, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = load i32, ptr %5, align 4, !tbaa !9
  %28 = icmp sle i32 %26, %27
  br i1 %28, label %29, label %36

29:                                               ; preds = %21
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr %30, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !9
  store i32 %34, ptr %5, align 4, !tbaa !9
  %35 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %35, ptr %6, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %29, %21, %12
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %7, align 4, !tbaa !9
  br label %8, !llvm.loop !15

40:                                               ; preds = %11
  %41 = load i32, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %41
}

; 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

attributes #0 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef i32 @_Z11minDistancePiPb(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load i8, ptr %1, align 1, !tbaa !5, !range !9, !noundef !10
  %4 = icmp eq i8 %3, 0
  br i1 %4, label %5, label %7

5:                                                ; preds = %2
  %6 = load i32, ptr %0, align 4, !tbaa !11
  br label %7

7:                                                ; preds = %5, %2
  %.112 = phi i32 [ 2147483647, %2 ], [ %6, %5 ]
  %8 = getelementptr inbounds i8, ptr %1, i64 1
  %9 = load i8, ptr %8, align 1, !tbaa !5, !range !9, !noundef !10
  %10 = icmp eq i8 %9, 0
  br i1 %10, label %11, label %14

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %.not.1 = icmp sle i32 %13, %.112
  %spec.select.1 = tail call i32 @llvm.smin.i32(i32 %13, i32 %.112)
  %spec.select14.1 = zext i1 %.not.1 to i32
  br label %14

14:                                               ; preds = %11, %7
  %.112.1 = phi i32 [ %.112, %7 ], [ %spec.select.1, %11 ]
  %.1.1 = phi i32 [ 0, %7 ], [ %spec.select14.1, %11 ]
  %15 = getelementptr inbounds i8, ptr %1, i64 2
  %16 = load i8, ptr %15, align 1, !tbaa !5, !range !9, !noundef !10
  %17 = icmp eq i8 %16, 0
  br i1 %17, label %18, label %21

18:                                               ; preds = %14
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %.not.2 = icmp sgt i32 %20, %.112.1
  %spec.select.2 = tail call i32 @llvm.smin.i32(i32 %20, i32 %.112.1)
  %spec.select14.2 = select i1 %.not.2, i32 %.1.1, i32 2
  br label %21

21:                                               ; preds = %18, %14
  %.112.2 = phi i32 [ %.112.1, %14 ], [ %spec.select.2, %18 ]
  %.1.2 = phi i32 [ %.1.1, %14 ], [ %spec.select14.2, %18 ]
  %22 = getelementptr inbounds i8, ptr %1, i64 3
  %23 = load i8, ptr %22, align 1, !tbaa !5, !range !9, !noundef !10
  %24 = icmp eq i8 %23, 0
  br i1 %24, label %25, label %28

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %0, i64 12
  %27 = load i32, ptr %26, align 4, !tbaa !11
  %.not.3 = icmp sgt i32 %27, %.112.2
  %spec.select.3 = tail call i32 @llvm.smin.i32(i32 %27, i32 %.112.2)
  %spec.select14.3 = select i1 %.not.3, i32 %.1.2, i32 3
  br label %28

28:                                               ; preds = %25, %21
  %.112.3 = phi i32 [ %.112.2, %21 ], [ %spec.select.3, %25 ]
  %.1.3 = phi i32 [ %.1.2, %21 ], [ %spec.select14.3, %25 ]
  %29 = getelementptr inbounds i8, ptr %1, i64 4
  %30 = load i8, ptr %29, align 1, !tbaa !5, !range !9, !noundef !10
  %31 = icmp eq i8 %30, 0
  br i1 %31, label %32, label %35

32:                                               ; preds = %28
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %.not.4 = icmp sgt i32 %34, %.112.3
  %spec.select.4 = tail call i32 @llvm.smin.i32(i32 %34, i32 %.112.3)
  %spec.select14.4 = select i1 %.not.4, i32 %.1.3, i32 4
  br label %35

35:                                               ; preds = %32, %28
  %.112.4 = phi i32 [ %.112.3, %28 ], [ %spec.select.4, %32 ]
  %.1.4 = phi i32 [ %.1.3, %28 ], [ %spec.select14.4, %32 ]
  %36 = getelementptr inbounds i8, ptr %1, i64 5
  %37 = load i8, ptr %36, align 1, !tbaa !5, !range !9, !noundef !10
  %38 = icmp eq i8 %37, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %35
  %40 = getelementptr inbounds i8, ptr %0, i64 20
  %41 = load i32, ptr %40, align 4, !tbaa !11
  %.not.5 = icmp sgt i32 %41, %.112.4
  %spec.select.5 = tail call i32 @llvm.smin.i32(i32 %41, i32 %.112.4)
  %spec.select14.5 = select i1 %.not.5, i32 %.1.4, i32 5
  br label %42

42:                                               ; preds = %39, %35
  %.112.5 = phi i32 [ %.112.4, %35 ], [ %spec.select.5, %39 ]
  %.1.5 = phi i32 [ %.1.4, %35 ], [ %spec.select14.5, %39 ]
  %43 = getelementptr inbounds i8, ptr %1, i64 6
  %44 = load i8, ptr %43, align 1, !tbaa !5, !range !9, !noundef !10
  %45 = icmp eq i8 %44, 0
  br i1 %45, label %46, label %49

46:                                               ; preds = %42
  %47 = getelementptr inbounds i8, ptr %0, i64 24
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %.not.6 = icmp sgt i32 %48, %.112.5
  %spec.select.6 = tail call i32 @llvm.smin.i32(i32 %48, i32 %.112.5)
  %spec.select14.6 = select i1 %.not.6, i32 %.1.5, i32 6
  br label %49

49:                                               ; preds = %46, %42
  %.112.6 = phi i32 [ %.112.5, %42 ], [ %spec.select.6, %46 ]
  %.1.6 = phi i32 [ %.1.5, %42 ], [ %spec.select14.6, %46 ]
  %50 = getelementptr inbounds i8, ptr %1, i64 7
  %51 = load i8, ptr %50, align 1, !tbaa !5, !range !9, !noundef !10
  %52 = icmp eq i8 %51, 0
  br i1 %52, label %53, label %56

53:                                               ; preds = %49
  %54 = getelementptr inbounds i8, ptr %0, i64 28
  %55 = load i32, ptr %54, align 4, !tbaa !11
  %.not.7 = icmp sgt i32 %55, %.112.6
  %spec.select.7 = tail call i32 @llvm.smin.i32(i32 %55, i32 %.112.6)
  %spec.select14.7 = select i1 %.not.7, i32 %.1.6, i32 7
  br label %56

56:                                               ; preds = %53, %49
  %.112.7 = phi i32 [ %.112.6, %49 ], [ %spec.select.7, %53 ]
  %.1.7 = phi i32 [ %.1.6, %49 ], [ %spec.select14.7, %53 ]
  %57 = getelementptr inbounds i8, ptr %1, i64 8
  %58 = load i8, ptr %57, align 1, !tbaa !5, !range !9, !noundef !10
  %59 = icmp eq i8 %58, 0
  br i1 %59, label %60, label %63

60:                                               ; preds = %56
  %61 = getelementptr inbounds i8, ptr %0, i64 32
  %62 = load i32, ptr %61, align 4, !tbaa !11
  %.not.8 = icmp sgt i32 %62, %.112.7
  %spec.select14.8 = select i1 %.not.8, i32 %.1.7, i32 8
  br label %63

63:                                               ; preds = %60, %56
  %.1.8 = phi i32 [ %.1.7, %56 ], [ %spec.select14.8, %60 ]
  ret i32 %.1.8
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 speculatable 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass