; LLVM IR from Dev-XYS/Algorithms :: Skip-List.ll (Z4initv)

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

%struct.node = type { i32, i32, ptr, ptr }

@head = external dso_local global [20 x ptr], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4initv() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #4
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %4)
          to label %5 unwind label %10

5:                                                ; preds = %0
  store ptr %4, ptr @head, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %30, %5
  %7 = load i32, ptr %3, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 20
  br i1 %8, label %14, label %9

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

10:                                               ; preds = %0
  %11 = landingpad { ptr, i32 }
          cleanup
  %12 = extractvalue { ptr, i32 } %11, 0
  store ptr %12, ptr %1, align 8
  %13 = extractvalue { ptr, i32 } %11, 1
  store i32 %13, ptr %2, align 4
  call void @_ZdlPvm(ptr noundef %4, i64 noundef 24) #6
  br label %38

14:                                               ; preds = %6
  %15 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 24) #4
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %15)
          to label %16 unwind label %33

16:                                               ; preds = %14
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [20 x ptr], ptr @head, i64 0, i64 %18
  store ptr %15, ptr %19, align 8, !tbaa !5
  %20 = load i32, ptr %3, align 4, !tbaa !9
  %21 = sub nsw i32 %20, 1
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [20 x ptr], ptr @head, i64 0, i64 %22
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = load i32, ptr %3, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [20 x ptr], ptr @head, i64 0, i64 %26
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.node, ptr %28, i32 0, i32 3
  store ptr %24, ptr %29, align 8, !tbaa !11
  br label %30

30:                                               ; preds = %16
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %3, align 4, !tbaa !9
  br label %6, !llvm.loop !13

33:                                               ; preds = %14
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %1, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %2, align 4
  call void @_ZdlPvm(ptr noundef %15, i64 noundef 24) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %38

37:                                               ; preds = %9
  ret void

38:                                               ; preds = %33, %10
  %39 = load ptr, ptr %1, align 8
  %40 = load i32, ptr %2, align 4
  %41 = insertvalue { ptr, i32 } poison, ptr %39, 0
  %42 = insertvalue { ptr, i32 } %41, i32 %40, 1
  resume { ptr, i32 } %42
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

declare void @_ZN4nodeC1Ev(ptr)

attributes #0 = { 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 #1 = { nobuiltin allocsize(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 = { nobuiltin nounwind "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 willreturn memory(argmem: readwrite) }
attributes #4 = { builtin allocsize(0) }
attributes #5 = { nounwind }
attributes #6 = { builtin 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 16}
!12 = !{!"_ZTS4node", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16}
!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"

@head = external dso_local local_unnamed_addr global [20 x ptr], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4initv() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %1)
          to label %2 unwind label %4

2:                                                ; preds = %0
  store ptr %1, ptr @head, align 16, !tbaa !5
  %3 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %3)
          to label %6 unwind label %81

4:                                                ; preds = %0
  %5 = landingpad { ptr, i32 }
          cleanup
  br label %83

6:                                                ; preds = %2
  store ptr %3, ptr getelementptr inbounds (i8, ptr @head, i64 8), align 8, !tbaa !5
  %7 = load ptr, ptr @head, align 16, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr %7, ptr %8, align 8, !tbaa !9
  %9 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %9)
          to label %10 unwind label %81

10:                                               ; preds = %6
  store ptr %9, ptr getelementptr inbounds (i8, ptr @head, i64 16), align 16, !tbaa !5
  %11 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 8), align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %9, i64 16
  store ptr %11, ptr %12, align 8, !tbaa !9
  %13 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %13)
          to label %14 unwind label %81

14:                                               ; preds = %10
  store ptr %13, ptr getelementptr inbounds (i8, ptr @head, i64 24), align 8, !tbaa !5
  %15 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 16), align 16, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %13, i64 16
  store ptr %15, ptr %16, align 8, !tbaa !9
  %17 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %17)
          to label %18 unwind label %81

18:                                               ; preds = %14
  store ptr %17, ptr getelementptr inbounds (i8, ptr @head, i64 32), align 16, !tbaa !5
  %19 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 24), align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %17, i64 16
  store ptr %19, ptr %20, align 8, !tbaa !9
  %21 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %21)
          to label %22 unwind label %81

22:                                               ; preds = %18
  store ptr %21, ptr getelementptr inbounds (i8, ptr @head, i64 40), align 8, !tbaa !5
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 32), align 16, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %21, i64 16
  store ptr %23, ptr %24, align 8, !tbaa !9
  %25 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %25)
          to label %26 unwind label %81

26:                                               ; preds = %22
  store ptr %25, ptr getelementptr inbounds (i8, ptr @head, i64 48), align 16, !tbaa !5
  %27 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 40), align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %25, i64 16
  store ptr %27, ptr %28, align 8, !tbaa !9
  %29 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %29)
          to label %30 unwind label %81

30:                                               ; preds = %26
  store ptr %29, ptr getelementptr inbounds (i8, ptr @head, i64 56), align 8, !tbaa !5
  %31 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 48), align 16, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %29, i64 16
  store ptr %31, ptr %32, align 8, !tbaa !9
  %33 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %33)
          to label %34 unwind label %81

34:                                               ; preds = %30
  store ptr %33, ptr getelementptr inbounds (i8, ptr @head, i64 64), align 16, !tbaa !5
  %35 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 56), align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %33, i64 16
  store ptr %35, ptr %36, align 8, !tbaa !9
  %37 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %37)
          to label %38 unwind label %81

38:                                               ; preds = %34
  store ptr %37, ptr getelementptr inbounds (i8, ptr @head, i64 72), align 8, !tbaa !5
  %39 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 64), align 16, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %37, i64 16
  store ptr %39, ptr %40, align 8, !tbaa !9
  %41 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %41)
          to label %42 unwind label %81

42:                                               ; preds = %38
  store ptr %41, ptr getelementptr inbounds (i8, ptr @head, i64 80), align 16, !tbaa !5
  %43 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 72), align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %41, i64 16
  store ptr %43, ptr %44, align 8, !tbaa !9
  %45 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %45)
          to label %46 unwind label %81

46:                                               ; preds = %42
  store ptr %45, ptr getelementptr inbounds (i8, ptr @head, i64 88), align 8, !tbaa !5
  %47 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 80), align 16, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %45, i64 16
  store ptr %47, ptr %48, align 8, !tbaa !9
  %49 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %49)
          to label %50 unwind label %81

50:                                               ; preds = %46
  store ptr %49, ptr getelementptr inbounds (i8, ptr @head, i64 96), align 16, !tbaa !5
  %51 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 88), align 8, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %49, i64 16
  store ptr %51, ptr %52, align 8, !tbaa !9
  %53 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %53)
          to label %54 unwind label %81

54:                                               ; preds = %50
  store ptr %53, ptr getelementptr inbounds (i8, ptr @head, i64 104), align 8, !tbaa !5
  %55 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 96), align 16, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %53, i64 16
  store ptr %55, ptr %56, align 8, !tbaa !9
  %57 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %57)
          to label %58 unwind label %81

58:                                               ; preds = %54
  store ptr %57, ptr getelementptr inbounds (i8, ptr @head, i64 112), align 16, !tbaa !5
  %59 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 104), align 8, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %57, i64 16
  store ptr %59, ptr %60, align 8, !tbaa !9
  %61 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %61)
          to label %62 unwind label %81

62:                                               ; preds = %58
  store ptr %61, ptr getelementptr inbounds (i8, ptr @head, i64 120), align 8, !tbaa !5
  %63 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 112), align 16, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %61, i64 16
  store ptr %63, ptr %64, align 8, !tbaa !9
  %65 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %65)
          to label %66 unwind label %81

66:                                               ; preds = %62
  store ptr %65, ptr getelementptr inbounds (i8, ptr @head, i64 128), align 16, !tbaa !5
  %67 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 120), align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %65, i64 16
  store ptr %67, ptr %68, align 8, !tbaa !9
  %69 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %69)
          to label %70 unwind label %81

70:                                               ; preds = %66
  store ptr %69, ptr getelementptr inbounds (i8, ptr @head, i64 136), align 8, !tbaa !5
  %71 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 128), align 16, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %69, i64 16
  store ptr %71, ptr %72, align 8, !tbaa !9
  %73 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %73)
          to label %74 unwind label %81

74:                                               ; preds = %70
  store ptr %73, ptr getelementptr inbounds (i8, ptr @head, i64 144), align 16, !tbaa !5
  %75 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 136), align 8, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %73, i64 16
  store ptr %75, ptr %76, align 8, !tbaa !9
  %77 = tail call noalias noundef nonnull dereferenceable(24) ptr @_Znwm(i64 noundef 24) #3
  invoke void @_ZN4nodeC1Ev(ptr noundef nonnull align 8 dereferenceable(24) %77)
          to label %78 unwind label %81

78:                                               ; preds = %74
  store ptr %77, ptr getelementptr inbounds (i8, ptr @head, i64 152), align 8, !tbaa !5
  %79 = load ptr, ptr getelementptr inbounds (i8, ptr @head, i64 144), align 16, !tbaa !5
  %80 = getelementptr inbounds i8, ptr %77, i64 16
  store ptr %79, ptr %80, align 8, !tbaa !9
  ret void

81:                                               ; preds = %74, %70, %66, %62, %58, %54, %50, %46, %42, %38, %34, %30, %26, %22, %18, %14, %10, %6, %2
  %.lcssa = phi ptr [ %3, %2 ], [ %9, %6 ], [ %13, %10 ], [ %17, %14 ], [ %21, %18 ], [ %25, %22 ], [ %29, %26 ], [ %33, %30 ], [ %37, %34 ], [ %41, %38 ], [ %45, %42 ], [ %49, %46 ], [ %53, %50 ], [ %57, %54 ], [ %61, %58 ], [ %65, %62 ], [ %69, %66 ], [ %73, %70 ], [ %77, %74 ]
  %82 = landingpad { ptr, i32 }
          cleanup
  br label %83

83:                                               ; preds = %81, %4
  %.lcssa.sink = phi ptr [ %.lcssa, %81 ], [ %1, %4 ]
  %.pn = phi { ptr, i32 } [ %82, %81 ], [ %5, %4 ]
  tail call void @_ZdlPvm(ptr noundef nonnull %.lcssa.sink, i64 noundef 24) #4
  resume { ptr, i32 } %.pn
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

declare void @_ZN4nodeC1Ev(ptr) local_unnamed_addr

attributes #0 = { 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 #1 = { nobuiltin allocsize(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 = { nobuiltin nounwind "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 = { builtin allocsize(0) }
attributes #4 = { builtin 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, !6, i64 16}
!10 = !{!"_ZTS4node", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}


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