; LLVM IR from JanaSabuj/cppdump :: Old/LIS.ll (Z3LISPxx)

; 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: 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: mustprogress uwtable
define dso_local noundef i64 @_Z3LISPxx(ptr noundef %0, i64 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %11 = load i64, ptr %4, align 8, !tbaa !9
  %12 = call ptr @llvm.stacksave.p0()
  store ptr %12, ptr %5, align 8
  %13 = alloca i64, i64 %11, align 16
  store i64 %11, ptr %6, align 8
  %14 = getelementptr inbounds i64, ptr %13, i64 0
  store i64 1, ptr %14, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 1, ptr %7, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %54, %2
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = load i64, ptr %4, align 8, !tbaa !9
  %18 = icmp slt i64 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %57

20:                                               ; preds = %15
  %21 = load i64, ptr %7, align 8, !tbaa !9
  %22 = getelementptr inbounds i64, ptr %13, i64 %21
  store i64 1, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %23

23:                                               ; preds = %50, %20
  %24 = load i64, ptr %9, align 8, !tbaa !9
  %25 = load i64, ptr %7, align 8, !tbaa !9
  %26 = icmp slt i64 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %53

28:                                               ; preds = %23
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = load i64, ptr %9, align 8, !tbaa !9
  %31 = getelementptr inbounds i64, ptr %29, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = load i64, ptr %7, align 8, !tbaa !9
  %35 = getelementptr inbounds i64, ptr %33, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !9
  %37 = icmp slt i64 %32, %36
  br i1 %37, label %38, label %49

38:                                               ; preds = %28
  %39 = load i64, ptr %7, align 8, !tbaa !9
  %40 = getelementptr inbounds i64, ptr %13, i64 %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %41 = load i64, ptr %9, align 8, !tbaa !9
  %42 = getelementptr inbounds i64, ptr %13, i64 %41
  %43 = load i64, ptr %42, align 8, !tbaa !9
  %44 = add nsw i64 %43, 1
  store i64 %44, ptr %10, align 8, !tbaa !9
  %45 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %40, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %46 = load i64, ptr %45, align 8, !tbaa !9
  %47 = load i64, ptr %7, align 8, !tbaa !9
  %48 = getelementptr inbounds i64, ptr %13, i64 %47
  store i64 %46, ptr %48, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %49

49:                                               ; preds = %38, %28
  br label %50

50:                                               ; preds = %49
  %51 = load i64, ptr %9, align 8, !tbaa !9
  %52 = add nsw i64 %51, 1
  store i64 %52, ptr %9, align 8, !tbaa !9
  br label %23, !llvm.loop !11

53:                                               ; preds = %27
  br label %54

54:                                               ; preds = %53
  %55 = load i64, ptr %7, align 8, !tbaa !9
  %56 = add nsw i64 %55, 1
  store i64 %56, ptr %7, align 8, !tbaa !9
  br label %15, !llvm.loop !13

57:                                               ; preds = %19
  %58 = load i64, ptr %4, align 8, !tbaa !9
  %59 = getelementptr inbounds i64, ptr %13, i64 %58
  %60 = call noundef ptr @_ZSt11max_elementIPxET_S1_S1_(ptr noundef %13, ptr noundef %59)
  %61 = load i64, ptr %60, align 8, !tbaa !9
  store i32 1, ptr %8, align 4
  %62 = load ptr, ptr %5, align 8
  call void @llvm.stackrestore.p0(ptr %62)
  ret i64 %61
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11max_elementIPxET_S1_S1_(ptr noundef, ptr noundef) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 }
attributes #3 = { inlinehint 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 #4 = { inlinehint mustprogress 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 #5 = { 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 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z3LISPxx(ptr nocapture noundef readonly %0, i64 noundef %1) local_unnamed_addr #1 {
  %3 = alloca i64, align 8
  %4 = alloca i64, i64 %1, align 16
  store i64 1, ptr %4, align 16, !tbaa !5
  %5 = icmp sgt i64 %1, 1
  br i1 %5, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %11, %2
  %6 = getelementptr inbounds i64, ptr %4, i64 %1
  %7 = call noundef ptr @_ZSt11max_elementIPxET_S1_S1_(ptr noundef nonnull %4, ptr noundef nonnull %6)
  %8 = load i64, ptr %7, align 8, !tbaa !5
  ret i64 %8

.lr.ph:                                           ; preds = %2, %11
  %.01619 = phi i64 [ %12, %11 ], [ 1, %2 ]
  %9 = getelementptr inbounds i64, ptr %4, i64 %.01619
  store i64 1, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i64, ptr %0, i64 %.01619
  br label %13

11:                                               ; preds = %24
  %12 = add nuw nsw i64 %.01619, 1
  %exitcond20.not = icmp eq i64 %12, %1
  br i1 %exitcond20.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

13:                                               ; preds = %.lr.ph, %24
  %.018 = phi i64 [ 0, %.lr.ph ], [ %25, %24 ]
  %14 = getelementptr inbounds i64, ptr %0, i64 %.018
  %15 = load i64, ptr %14, align 8, !tbaa !5
  %16 = load i64, ptr %10, align 8, !tbaa !5
  %17 = icmp slt i64 %15, %16
  br i1 %17, label %18, label %24

18:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %19 = getelementptr inbounds i64, ptr %4, i64 %.018
  %20 = load i64, ptr %19, align 8, !tbaa !5
  %21 = add nsw i64 %20, 1
  store i64 %21, ptr %3, align 8, !tbaa !5
  %22 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %23 = load i64, ptr %22, align 8, !tbaa !5
  store i64 %23, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  br label %24

24:                                               ; preds = %13, %18
  %25 = add nuw nsw i64 %.018, 1
  %exitcond.not = icmp eq i64 %25, %.01619
  br i1 %exitcond.not, label %11, label %13, !llvm.loop !11
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11max_elementIPxET_S1_S1_(ptr noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { inlinehint 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 #3 = { inlinehint mustprogress 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 }

!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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass