; LLVM IR from TheAlgorithms/C-Plus-Plus :: data_structures/linkedlist_implentation_usingarray.ll (Z15initialise_listv)

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

@AvailArray = external dso_local global [100 x %struct.Node], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z15initialise_listv() #0 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %2

2:                                                ; preds = %13, %0
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = icmp sle i32 %3, 98
  br i1 %4, label %6, label %5

5:                                                ; preds = %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  br label %16

6:                                                ; preds = %2
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = add nsw i32 %7, 1
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [100 x %struct.Node], ptr @AvailArray, i64 0, i64 %10
  %12 = getelementptr inbounds %struct.Node, ptr %11, i32 0, i32 1
  store i32 %8, ptr %12, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %6
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %1, align 4, !tbaa !5
  br label %2, !llvm.loop !11

16:                                               ; preds = %5
  store i32 -1, ptr getelementptr inbounds (%struct.Node, ptr getelementptr inbounds ([100 x %struct.Node], ptr @AvailArray, i64 0, i64 99), i32 0, i32 1), align 4, !tbaa !9
  ret void
}

; 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

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 4}
!10 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4}
!11 = distinct !{!11, !12}
!12 = !{!"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"

%struct.Node = type { i32, i32 }

@AvailArray = external dso_local local_unnamed_addr global [100 x %struct.Node], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z15initialise_listv() local_unnamed_addr #0 {
  store i32 1, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 4), align 4, !tbaa !5
  store i32 2, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 12), align 4, !tbaa !5
  store i32 3, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 20), align 4, !tbaa !5
  store i32 4, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 28), align 4, !tbaa !5
  store i32 5, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 36), align 4, !tbaa !5
  store i32 6, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 44), align 4, !tbaa !5
  store i32 7, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 52), align 4, !tbaa !5
  store i32 8, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 60), align 4, !tbaa !5
  store i32 9, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 68), align 4, !tbaa !5
  store i32 10, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 76), align 4, !tbaa !5
  store i32 11, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 84), align 4, !tbaa !5
  store i32 12, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 92), align 4, !tbaa !5
  store i32 13, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 100), align 4, !tbaa !5
  store i32 14, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 108), align 4, !tbaa !5
  store i32 15, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 116), align 4, !tbaa !5
  store i32 16, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 124), align 4, !tbaa !5
  store i32 17, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 132), align 4, !tbaa !5
  store i32 18, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 140), align 4, !tbaa !5
  store i32 19, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 148), align 4, !tbaa !5
  store i32 20, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 156), align 4, !tbaa !5
  store i32 21, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 164), align 4, !tbaa !5
  store i32 22, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 172), align 4, !tbaa !5
  store i32 23, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 180), align 4, !tbaa !5
  store i32 24, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 188), align 4, !tbaa !5
  store i32 25, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 196), align 4, !tbaa !5
  store i32 26, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 204), align 4, !tbaa !5
  store i32 27, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 212), align 4, !tbaa !5
  store i32 28, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 220), align 4, !tbaa !5
  store i32 29, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 228), align 4, !tbaa !5
  store i32 30, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 236), align 4, !tbaa !5
  store i32 31, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 244), align 4, !tbaa !5
  store i32 32, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 252), align 4, !tbaa !5
  store i32 33, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 260), align 4, !tbaa !5
  store i32 34, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 268), align 4, !tbaa !5
  store i32 35, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 276), align 4, !tbaa !5
  store i32 36, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 284), align 4, !tbaa !5
  store i32 37, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 292), align 4, !tbaa !5
  store i32 38, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 300), align 4, !tbaa !5
  store i32 39, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 308), align 4, !tbaa !5
  store i32 40, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 316), align 4, !tbaa !5
  store i32 41, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 324), align 4, !tbaa !5
  store i32 42, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 332), align 4, !tbaa !5
  store i32 43, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 340), align 4, !tbaa !5
  store i32 44, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 348), align 4, !tbaa !5
  store i32 45, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 356), align 4, !tbaa !5
  store i32 46, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 364), align 4, !tbaa !5
  store i32 47, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 372), align 4, !tbaa !5
  store i32 48, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 380), align 4, !tbaa !5
  store i32 49, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 388), align 4, !tbaa !5
  store i32 50, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 396), align 4, !tbaa !5
  store i32 51, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 404), align 4, !tbaa !5
  store i32 52, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 412), align 4, !tbaa !5
  store i32 53, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 420), align 4, !tbaa !5
  store i32 54, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 428), align 4, !tbaa !5
  store i32 55, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 436), align 4, !tbaa !5
  store i32 56, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 444), align 4, !tbaa !5
  store i32 57, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 452), align 4, !tbaa !5
  store i32 58, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 460), align 4, !tbaa !5
  store i32 59, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 468), align 4, !tbaa !5
  store i32 60, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 476), align 4, !tbaa !5
  store i32 61, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 484), align 4, !tbaa !5
  store i32 62, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 492), align 4, !tbaa !5
  store i32 63, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 500), align 4, !tbaa !5
  store i32 64, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 508), align 4, !tbaa !5
  store i32 65, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 516), align 4, !tbaa !5
  store i32 66, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 524), align 4, !tbaa !5
  store i32 67, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 532), align 4, !tbaa !5
  store i32 68, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 540), align 4, !tbaa !5
  store i32 69, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 548), align 4, !tbaa !5
  store i32 70, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 556), align 4, !tbaa !5
  store i32 71, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 564), align 4, !tbaa !5
  store i32 72, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 572), align 4, !tbaa !5
  store i32 73, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 580), align 4, !tbaa !5
  store i32 74, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 588), align 4, !tbaa !5
  store i32 75, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 596), align 4, !tbaa !5
  store i32 76, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 604), align 4, !tbaa !5
  store i32 77, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 612), align 4, !tbaa !5
  store i32 78, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 620), align 4, !tbaa !5
  store i32 79, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 628), align 4, !tbaa !5
  store i32 80, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 636), align 4, !tbaa !5
  store i32 81, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 644), align 4, !tbaa !5
  store i32 82, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 652), align 4, !tbaa !5
  store i32 83, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 660), align 4, !tbaa !5
  store i32 84, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 668), align 4, !tbaa !5
  store i32 85, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 676), align 4, !tbaa !5
  store i32 86, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 684), align 4, !tbaa !5
  store i32 87, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 692), align 4, !tbaa !5
  store i32 88, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 700), align 4, !tbaa !5
  store i32 89, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 708), align 4, !tbaa !5
  store i32 90, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 716), align 4, !tbaa !5
  store i32 91, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 724), align 4, !tbaa !5
  store i32 92, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 732), align 4, !tbaa !5
  store i32 93, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 740), align 4, !tbaa !5
  store i32 94, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 748), align 4, !tbaa !5
  store i32 95, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 756), align 4, !tbaa !5
  store i32 96, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 764), align 4, !tbaa !5
  store i32 97, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 772), align 4, !tbaa !5
  store i32 98, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 780), align 4, !tbaa !5
  store i32 99, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 788), align 4, !tbaa !5
  store i32 -1, ptr getelementptr inbounds (i8, ptr @AvailArray, i64 796), align 4, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none, inaccessiblemem: none) 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, !7, i64 4}
!6 = !{!"_ZTS4Node", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass