; LLVM IR from Dev-XYS/Algorithms :: High-Precision(Integer).ll (ZN4lintmlES_)

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

%class.lint = type { i32, i32, ptr, ptr }

; 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
declare dso_local void @_ZN4lint4mul1Eii(ptr dead_on_unwind noalias writable sret(%class.lint) align 8, ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4lintplES_(ptr dead_on_unwind noalias writable sret(%class.lint) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef byval(%class.lint) align 8) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4lintmlES_(ptr dead_on_unwind noalias writable sret(%class.lint) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef byval(%class.lint) align 8 %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca %class.lint, align 8
  %6 = alloca i32, align 4
  %7 = alloca %class.lint, align 8
  %8 = alloca %class.lint, align 8
  %9 = alloca %class.lint, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  %11 = getelementptr inbounds %class.lint, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !9
  call void @_ZN4lintC1Ei(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %12)
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #3
  %13 = getelementptr inbounds %class.lint, ptr %10, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !9
  call void @_ZN4lintC1Ei(ptr noundef nonnull align 8 dereferenceable(24) %5, i32 noundef %14)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !12
  br label %15

15:                                               ; preds = %29, %3
  %16 = load i32, ptr %6, align 4, !tbaa !12
  %17 = getelementptr inbounds %class.lint, ptr %10, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !9
  %19 = icmp slt i32 %16, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %32

21:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #3
  %22 = getelementptr inbounds %class.lint, ptr %2, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = load i32, ptr %6, align 4, !tbaa !12
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i32, ptr %23, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = load i32, ptr %6, align 4, !tbaa !12
  call void @_ZN4lint4mul1Eii(ptr dead_on_unwind writable sret(%class.lint) align 8 %7, ptr noundef nonnull align 8 dereferenceable(24) %10, i32 noundef %27, i32 noundef %28)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %7, i64 24, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %5, i64 24, i1 false), !tbaa.struct !14
  call void @_ZN4lintplES_(ptr dead_on_unwind writable sret(%class.lint) align 8 %8, ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef byval(%class.lint) align 8 %9)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %8, i64 24, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #3
  br label %29

29:                                               ; preds = %21
  %30 = load i32, ptr %6, align 4, !tbaa !12
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %6, align 4, !tbaa !12
  br label %15, !llvm.loop !15

32:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #3
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare void @_ZN4lintC1Ei(ptr, i32)

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 nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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, !11, i64 0}
!10 = !{!"_ZTS4lint", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{i64 0, i64 4, !12, i64 4, i64 4, !12, i64 8, i64 8, !5, i64 16, i64 8, !5}
!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"

%class.lint = type { i32, i32, ptr, ptr }

; 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
declare dso_local void @_ZN4lint4mul1Eii(ptr dead_on_unwind noalias writable sret(%class.lint) align 8, ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4lintplES_(ptr dead_on_unwind noalias writable sret(%class.lint) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef byval(%class.lint) align 8) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4lintmlES_(ptr dead_on_unwind noalias writable sret(%class.lint) align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr nocapture noundef readonly byval(%class.lint) align 8 %2) local_unnamed_addr #1 align 2 {
  %4 = alloca %class.lint, align 8
  %5 = alloca %class.lint, align 8
  %6 = alloca %class.lint, align 8
  %7 = load i32, ptr %1, align 8, !tbaa !5
  tail call void @_ZN4lintC1Ei(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %7)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #3
  %8 = load i32, ptr %1, align 8, !tbaa !5
  call void @_ZN4lintC1Ei(ptr noundef nonnull align 8 dereferenceable(24) %4, i32 noundef %8)
  %9 = load i32, ptr %1, align 8, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %11 = getelementptr inbounds i8, ptr %2, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  br label %13

._crit_edge:                                      ; preds = %13, %3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  ret void

13:                                               ; preds = %.lr.ph, %13
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %13 ]
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #3
  %14 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv
  %15 = load i32, ptr %14, align 4, !tbaa !12
  %16 = trunc nuw nsw i64 %indvars.iv to i32
  call void @_ZN4lint4mul1Eii(ptr dead_on_unwind nonnull writable sret(%class.lint) align 8 %5, ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %15, i32 noundef %16)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) %5, i64 24, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #3
  call void @_ZN4lintplES_(ptr dead_on_unwind nonnull writable sret(%class.lint) align 8 %6, ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull byval(%class.lint) align 8 %4)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %6, i64 24, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = load i32, ptr %1, align 8, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = icmp slt i64 %indvars.iv.next, %18
  br i1 %19, label %13, label %._crit_edge, !llvm.loop !15
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare void @_ZN4lintC1Ei(ptr, i32) local_unnamed_addr

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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, !7, i64 0}
!6 = !{!"_ZTS4lint", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!7, !7, i64 0}
!13 = !{i64 0, i64 4, !12, i64 4, i64 4, !12, i64 8, i64 8, !14, i64 16, i64 8, !14}
!14 = !{!10, !10, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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