; LLVM IR from MostafaTwfiq/C-DataStructures-And-Algorithms :: Unit Test/Tests/DataStructuresTests/LinkedListsTest/DoublyLinkedListTest (doublyLinkedListAddFrom1To10Values)

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @doublyLinkedListAddFrom1To10Values(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %5 = call noalias ptr @malloc(i64 noundef 80) #6
  store ptr %5, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %23, %1
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 10
  br i1 %8, label %10, label %9

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

10:                                               ; preds = %6
  %11 = call noalias ptr @malloc(i64 noundef 4) #6
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds ptr, ptr %12, i64 %14
  store ptr %11, ptr %15, align 8, !tbaa !5
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = add nsw i32 %16, 1
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds ptr, ptr %18, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  store i32 %17, ptr %22, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %10
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %4, align 4, !tbaa !9
  br label %6, !llvm.loop !11

26:                                               ; preds = %9
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  call void @doublyLinkedListAddAll(ptr noundef %27, ptr noundef %28, i32 noundef 10)
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %29) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

declare void @doublyLinkedListAddAll(ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind 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 = { 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 #3 = { "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 #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!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"

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @doublyLinkedListAddFrom1To10Values(ptr noundef %0) local_unnamed_addr #1 {
  %2 = tail call noalias dereferenceable_or_null(80) ptr @malloc(i64 noundef 80) #4
  %3 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #4
  store ptr %3, ptr %2, align 8, !tbaa !5
  store i32 1, ptr %3, align 4, !tbaa !9
  %4 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #4
  %5 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %4, ptr %5, align 8, !tbaa !5
  store i32 2, ptr %4, align 4, !tbaa !9
  %6 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #4
  %7 = getelementptr inbounds i8, ptr %2, i64 16
  store ptr %6, ptr %7, align 8, !tbaa !5
  store i32 3, ptr %6, align 4, !tbaa !9
  %8 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #4
  %9 = getelementptr inbounds i8, ptr %2, i64 24
  store ptr %8, ptr %9, align 8, !tbaa !5
  store i32 4, ptr %8, align 4, !tbaa !9
  %10 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #4
  %11 = getelementptr inbounds i8, ptr %2, i64 32
  store ptr %10, ptr %11, align 8, !tbaa !5
  store i32 5, ptr %10, align 4, !tbaa !9
  %12 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #4
  %13 = getelementptr inbounds i8, ptr %2, i64 40
  store ptr %12, ptr %13, align 8, !tbaa !5
  store i32 6, ptr %12, align 4, !tbaa !9
  %14 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #4
  %15 = getelementptr inbounds i8, ptr %2, i64 48
  store ptr %14, ptr %15, align 8, !tbaa !5
  store i32 7, ptr %14, align 4, !tbaa !9
  %16 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #4
  %17 = getelementptr inbounds i8, ptr %2, i64 56
  store ptr %16, ptr %17, align 8, !tbaa !5
  store i32 8, ptr %16, align 4, !tbaa !9
  %18 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #4
  %19 = getelementptr inbounds i8, ptr %2, i64 64
  store ptr %18, ptr %19, align 8, !tbaa !5
  store i32 9, ptr %18, align 4, !tbaa !9
  %20 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #4
  %21 = getelementptr inbounds i8, ptr %2, i64 72
  store ptr %20, ptr %21, align 8, !tbaa !5
  store i32 10, ptr %20, align 4, !tbaa !9
  tail call void @doublyLinkedListAddAll(ptr noundef %0, ptr noundef nonnull %2, i32 noundef 10) #5
  tail call void @free(ptr noundef %2) #5
  ret void
}

declare void @doublyLinkedListAddAll(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #2 = { "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { nounwind allocsize(0) }
attributes #5 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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