; LLVM IR from edualgo/dsa-code-store :: Linked-List/Linked-List-master/Source.ll (Z7addListP4NodeS0_PS0_)

; 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.Node = type { i32, ptr }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z6lengthP4Node(ptr 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: mustprogress uwtable
declare dso_local void @_Z4pushPP4Nodei(ptr noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z11swapPointerPP4NodeS1_(ptr noundef, ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z11addSameSizeP4NodeS0_i(ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z19addCarryToRemainingP4NodeS0_iPS0_(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7addListP4NodeS0_PS0_(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %18

15:                                               ; preds = %3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %16, ptr %17, align 8, !tbaa !5
  store i32 1, ptr %8, align 4
  br label %76

18:                                               ; preds = %3
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %24

21:                                               ; preds = %18
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %22, ptr %23, align 8, !tbaa !5
  store i32 1, ptr %8, align 4
  br label %76

24:                                               ; preds = %18
  br label %25

25:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = call noundef i32 @_Z6lengthP4Node(ptr noundef %26)
  store i32 %27, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call noundef i32 @_Z6lengthP4Node(ptr noundef %28)
  store i32 %29, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = icmp eq i32 %30, %31
  br i1 %32, label %33, label %39

33:                                               ; preds = %25
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = call noundef ptr @_Z11addSameSizeP4NodeS0_i(ptr noundef %34, ptr noundef %35, i32 noundef %36)
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %37, ptr %38, align 8, !tbaa !5
  br label %69

39:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %40 = load i32, ptr %9, align 4, !tbaa !9
  %41 = load i32, ptr %10, align 4, !tbaa !9
  %42 = sub nsw i32 %40, %41
  %43 = call i32 @llvm.abs.i32(i32 %42, i1 true)
  store i32 %43, ptr %12, align 4, !tbaa !9
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %47, label %48

47:                                               ; preds = %39
  call void @_Z11swapPointerPP4NodeS1_(ptr noundef %4, ptr noundef %5)
  br label %48

48:                                               ; preds = %47, %39
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %49, ptr %7, align 8, !tbaa !5
  br label %50

50:                                               ; preds = %55, %48
  %51 = load i32, ptr %12, align 4, !tbaa !9
  %52 = add nsw i32 %51, -1
  store i32 %52, ptr %12, align 4, !tbaa !9
  %53 = icmp ne i32 %51, 0
  br i1 %53, label %54, label %59

54:                                               ; preds = %50
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %class.Node, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !11
  store ptr %58, ptr %7, align 8, !tbaa !5
  br label %50, !llvm.loop !13

59:                                               ; preds = %50
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = call noundef ptr @_Z11addSameSizeP4NodeS0_i(ptr noundef %60, ptr noundef %61, i32 noundef %62)
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %63, ptr %64, align 8, !tbaa !5
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_Z19addCarryToRemainingP4NodeS0_iPS0_(ptr noundef %65, ptr noundef %66, i32 noundef %67, ptr noundef %68)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %69

69:                                               ; preds = %59, %33
  %70 = load i32, ptr %11, align 4, !tbaa !9
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %72, label %75

72:                                               ; preds = %69
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = load i32, ptr %11, align 4, !tbaa !9
  call void @_Z4pushPP4Nodei(ptr noundef %73, i32 noundef %74)
  br label %75

75:                                               ; preds = %72, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  store i32 0, ptr %8, align 4
  br label %76

76:                                               ; preds = %75, %21, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %77 = load i32, ptr %8, align 4
  switch i32 %77, label %79 [
    i32 0, label %78
    i32 1, label %78
  ]

78:                                               ; preds = %76, %76
  ret void

79:                                               ; preds = %76
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #3

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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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, !6, i64 8}
!12 = !{!"_ZTS4Node", !10, i64 0, !6, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"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 nounwind uwtable
declare dso_local noundef i32 @_Z6lengthP4Node(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z11swapPointerPP4NodeS1_(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_Z11addSameSizeP4NodeS0_i(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z19addCarryToRemainingP4NodeS0_iPS0_(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7addListP4NodeS0_PS0_(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = icmp eq ptr %0, null
  br i1 %6, label %7, label %8

7:                                                ; preds = %3
  store ptr %1, ptr %2, align 8, !tbaa !5
  br label %38

8:                                                ; preds = %3
  %9 = icmp eq ptr %1, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %8
  store ptr %0, ptr %2, align 8, !tbaa !5
  br label %38

11:                                               ; preds = %8
  %12 = tail call noundef i32 @_Z6lengthP4Node(ptr noundef nonnull %0)
  %13 = tail call noundef i32 @_Z6lengthP4Node(ptr noundef nonnull %1)
  %14 = icmp eq i32 %12, %13
  br i1 %14, label %15, label %17

15:                                               ; preds = %11
  %16 = tail call noundef ptr @_Z11addSameSizeP4NodeS0_i(ptr noundef nonnull %0, ptr noundef nonnull %1, i32 noundef 0)
  store ptr %16, ptr %2, align 8, !tbaa !5
  br label %38

17:                                               ; preds = %11
  %18 = sub i32 %12, %13
  %19 = tail call i32 @llvm.abs.i32(i32 %18, i1 true)
  %20 = icmp slt i32 %12, %13
  br i1 %20, label %21, label %.lr.ph.preheader

21:                                               ; preds = %17
  call void @_Z11swapPointerPP4NodeS1_(ptr noundef nonnull %4, ptr noundef nonnull %5)
  %.02024.pre = load ptr, ptr %4, align 8, !tbaa !5
  br label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %17, %21
  %.02027.ph = phi ptr [ %0, %17 ], [ %.02024.pre, %21 ]
  %smax = call i32 @llvm.abs.i32(i32 %18, i1 false)
  %22 = add i32 %smax, -1
  %xtraiter = and i32 %smax, 7
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader, %.lr.ph.prol
  %.02027.prol = phi ptr [ %.020.prol, %.lr.ph.prol ], [ %.02027.ph, %.lr.ph.preheader ]
  %.026.prol = phi i32 [ %23, %.lr.ph.prol ], [ %19, %.lr.ph.preheader ]
  %prol.iter = phi i32 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader ]
  %23 = add nsw i32 %.026.prol, -1
  %24 = getelementptr inbounds i8, ptr %.02027.prol, i64 8
  %.020.prol = load ptr, ptr %24, align 8, !tbaa !5
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !9

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.020.lcssa.unr = phi ptr [ poison, %.lr.ph.preheader ], [ %.020.prol, %.lr.ph.prol ]
  %.02027.unr = phi ptr [ %.02027.ph, %.lr.ph.preheader ], [ %.020.prol, %.lr.ph.prol ]
  %.026.unr = phi i32 [ %19, %.lr.ph.preheader ], [ %23, %.lr.ph.prol ]
  %25 = icmp ult i32 %22, 7
  br i1 %25, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.02027 = phi ptr [ %.020.7, %.lr.ph ], [ %.02027.unr, %.lr.ph.prol.loopexit ]
  %.026 = phi i32 [ %33, %.lr.ph ], [ %.026.unr, %.lr.ph.prol.loopexit ]
  %26 = getelementptr inbounds i8, ptr %.02027, i64 8
  %.020 = load ptr, ptr %26, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %.020, i64 8
  %.020.1 = load ptr, ptr %27, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %.020.1, i64 8
  %.020.2 = load ptr, ptr %28, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %.020.2, i64 8
  %.020.3 = load ptr, ptr %29, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %.020.3, i64 8
  %.020.4 = load ptr, ptr %30, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %.020.4, i64 8
  %.020.5 = load ptr, ptr %31, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %.020.5, i64 8
  %.020.6 = load ptr, ptr %32, align 8, !tbaa !5
  %33 = add nsw i32 %.026, -8
  %34 = getelementptr inbounds i8, ptr %.020.6, i64 8
  %.020.7 = load ptr, ptr %34, align 8, !tbaa !5
  %.not.7 = icmp eq i32 %33, 0
  br i1 %.not.7, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph.prol.loopexit
  %.020.lcssa = phi ptr [ %.020.lcssa.unr, %.lr.ph.prol.loopexit ], [ %.020.7, %.lr.ph ]
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call noundef ptr @_Z11addSameSizeP4NodeS0_i(ptr noundef %.020.lcssa, ptr noundef %35, i32 noundef 0)
  store ptr %36, ptr %2, align 8, !tbaa !5
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_Z19addCarryToRemainingP4NodeS0_iPS0_(ptr noundef %37, ptr noundef %.020.lcssa, i32 noundef 0, ptr noundef nonnull %2)
  br label %38

38:                                               ; preds = %._crit_edge, %15, %10, %7
  ret void
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #2

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass