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

; 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 nounwind uwtable
define dso_local noundef ptr @_Z6rotateP4Nodei(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %15

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %14, ptr %3, align 8
  br label %73

15:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %16, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store ptr null, ptr %7, align 8, !tbaa !5
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call noundef i32 @_Z6lengthP4Node(ptr noundef %18)
  %20 = icmp eq i32 %17, %19
  br i1 %20, label %21, label %40

21:                                               ; preds = %15
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %22, ptr %7, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %28, %21
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %class.Node, ptr %24, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %33

28:                                               ; preds = %23
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %29, ptr %7, align 8, !tbaa !5
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %class.Node, ptr %30, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  store ptr %32, ptr %6, align 8, !tbaa !5
  br label %23, !llvm.loop !13

33:                                               ; preds = %23
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.Node, ptr %35, i32 0, i32 1
  store ptr %34, ptr %36, align 8, !tbaa !11
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %class.Node, ptr %37, i32 0, i32 1
  store ptr null, ptr %38, align 8, !tbaa !11
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %39, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %72

40:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %51, %40
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  store i32 4, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  br label %54

46:                                               ; preds = %41
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %47, ptr %7, align 8, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %class.Node, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !11
  store ptr %50, ptr %6, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %46
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %9, align 4, !tbaa !9
  br label %41, !llvm.loop !15

54:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %55, ptr %10, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %61, %54
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %class.Node, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !11
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %65

61:                                               ; preds = %56
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %class.Node, ptr %62, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !11
  store ptr %64, ptr %6, align 8, !tbaa !5
  br label %56, !llvm.loop !16

65:                                               ; preds = %56
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %class.Node, ptr %67, i32 0, i32 1
  store ptr %66, ptr %68, align 8, !tbaa !11
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = getelementptr inbounds %class.Node, ptr %69, i32 0, i32 1
  store ptr null, ptr %70, align 8, !tbaa !11
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %71, ptr %3, align 8
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  br label %72

72:                                               ; preds = %65, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %73

73:                                               ; preds = %72, %13
  %74 = load ptr, ptr %3, align 8
  ret ptr %74
}

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, !6, i64 8}
!12 = !{!"_ZTS4Node", !10, i64 0, !6, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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
define dso_local noundef ptr @_Z6rotateP4Nodei(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %34, label %4

4:                                                ; preds = %2
  %5 = tail call noundef i32 @_Z6lengthP4Node(ptr noundef nonnull %0)
  %6 = icmp eq i32 %5, %1
  br i1 %6, label %.preheader, label %.preheader37

.preheader37:                                     ; preds = %4
  %7 = icmp sgt i32 %1, 0
  br i1 %7, label %.lr.ph.preheader, label %.preheader36

.lr.ph.preheader:                                 ; preds = %.preheader37
  %xtraiter = and i32 %1, 7
  %8 = icmp ult i32 %1, 8
  br i1 %8, label %.preheader36.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %1, 2147483640
  br label %.lr.ph

.preheader:                                       ; preds = %4, %.preheader
  %.028 = phi ptr [ %10, %.preheader ], [ %0, %4 ]
  %.026 = phi ptr [ %.028, %.preheader ], [ %0, %4 ]
  %9 = getelementptr inbounds i8, ptr %.028, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %.not35 = icmp eq ptr %10, null
  br i1 %.not35, label %.sink.split, label %.preheader, !llvm.loop !11

.preheader36.loopexit.unr-lcssa:                  ; preds = %.lr.ph, %.lr.ph.preheader
  %.12939.lcssa.ph = phi ptr [ poison, %.lr.ph.preheader ], [ %26, %.lr.ph ]
  %.lcssa.ph = phi ptr [ poison, %.lr.ph.preheader ], [ %28, %.lr.ph ]
  %.12939.unr = phi ptr [ %0, %.lr.ph.preheader ], [ %28, %.lr.ph ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader36, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.preheader36.loopexit.unr-lcssa, %.lr.ph.epil
  %.12939.epil = phi ptr [ %12, %.lr.ph.epil ], [ %.12939.unr, %.preheader36.loopexit.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.preheader36.loopexit.unr-lcssa ]
  %11 = getelementptr inbounds i8, ptr %.12939.epil, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader36, label %.lr.ph.epil, !llvm.loop !13

.preheader36:                                     ; preds = %.preheader36.loopexit.unr-lcssa, %.lr.ph.epil, %.preheader37
  %.129.lcssa = phi ptr [ %0, %.preheader37 ], [ %.lcssa.ph, %.preheader36.loopexit.unr-lcssa ], [ %12, %.lr.ph.epil ]
  %.127.lcssa = phi ptr [ null, %.preheader37 ], [ %.12939.lcssa.ph, %.preheader36.loopexit.unr-lcssa ], [ %.12939.epil, %.lr.ph.epil ]
  br label %29

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.12939 = phi ptr [ %0, %.lr.ph.preheader.new ], [ %28, %.lr.ph ]
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.7, %.lr.ph ]
  %13 = getelementptr inbounds i8, ptr %.12939, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 8
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %niter.next.7 = add i32 %niter, 8
  %niter.ncmp.7 = icmp eq i32 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %.preheader36.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !15

29:                                               ; preds = %.preheader36, %29
  %.2 = phi ptr [ %31, %29 ], [ %.129.lcssa, %.preheader36 ]
  %30 = getelementptr inbounds i8, ptr %.2, i64 8
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %.not = icmp eq ptr %31, null
  br i1 %.not, label %.sink.split, label %29, !llvm.loop !16

.sink.split:                                      ; preds = %29, %.preheader
  %.028.lcssa45.sink = phi ptr [ %.028, %.preheader ], [ %.2, %29 ]
  %.026.lcssa.sink = phi ptr [ %.026, %.preheader ], [ %.127.lcssa, %29 ]
  %.1.ph = phi ptr [ %.028, %.preheader ], [ %.129.lcssa, %29 ]
  %32 = getelementptr inbounds i8, ptr %.028.lcssa45.sink, i64 8
  store ptr %0, ptr %32, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %.026.lcssa.sink, i64 8
  store ptr null, ptr %33, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %.sink.split, %2
  %.1 = phi ptr [ null, %2 ], [ %.1.ph, %.sink.split ]
  ret ptr %.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" }

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


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