; LLVM IR from overnote/over-algorithm :: code/code-c-like/01-list (01-SqList)

; 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.SqList = type { [5 x i32], i32 }

@.str.9 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z10InitSqListR6SqList(ptr noundef nonnull align 4 dereferenceable(24)) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z9ClearListR6SqList(ptr noundef nonnull align 4 dereferenceable(24)) #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7Display6SqList(ptr noundef byval(%struct.SqList) align 8) #1

declare i32 @printf(ptr 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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z10InsertElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24), i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z10DeleteElemR6SqListiRi(ptr noundef nonnull align 4 dereferenceable(24), i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z10UpdateElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24), i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z7GetElem6SqListiRi(ptr noundef byval(%struct.SqList) align 8, i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z10LocateElem6SqListiRi(ptr noundef byval(%struct.SqList) align 8, i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %1 = alloca %struct.SqList, align 4
  %2 = alloca %struct.SqList, align 8
  %3 = alloca %struct.SqList, align 8
  %4 = alloca i32, align 4
  %5 = alloca %struct.SqList, align 8
  %6 = alloca %struct.SqList, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.SqList, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.SqList, align 8
  %11 = alloca %struct.SqList, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %1) #6
  call void @_Z10InitSqListR6SqList(ptr noundef nonnull align 4 dereferenceable(24) %1)
  %12 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 4 %1, i64 24, i1 false), !tbaa.struct !5
  call void @_Z7Display6SqList(ptr noundef byval(%struct.SqList) align 8 %2)
  %13 = call noundef zeroext i1 @_Z10InsertElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 1, i32 noundef 5)
  %14 = call noundef zeroext i1 @_Z10InsertElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 2, i32 noundef 6)
  %15 = call noundef zeroext i1 @_Z10InsertElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 3, i32 noundef 1)
  %16 = call noundef zeroext i1 @_Z10InsertElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 4, i32 noundef 2)
  %17 = call noundef zeroext i1 @_Z10InsertElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 5, i32 noundef 3)
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 %1, i64 24, i1 false), !tbaa.struct !5
  call void @_Z7Display6SqList(ptr noundef byval(%struct.SqList) align 8 %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %19 = call noundef zeroext i1 @_Z10DeleteElemR6SqListiRi(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 5, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef %21)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %1, i64 24, i1 false), !tbaa.struct !5
  call void @_Z7Display6SqList(ptr noundef byval(%struct.SqList) align 8 %5)
  %23 = call noundef zeroext i1 @_Z10UpdateElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 4, i32 noundef 10)
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %1, i64 24, i1 false), !tbaa.struct !5
  call void @_Z7Display6SqList(ptr noundef byval(%struct.SqList) align 8 %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %1, i64 24, i1 false), !tbaa.struct !5
  %25 = call noundef zeroext i1 @_Z7GetElem6SqListiRi(ptr noundef byval(%struct.SqList) align 8 %8, i32 noundef 3, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, i32 noundef %27)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %1, i64 24, i1 false), !tbaa.struct !5
  %29 = call noundef zeroext i1 @_Z10LocateElem6SqListiRi(ptr noundef byval(%struct.SqList) align 8 %10, i32 noundef 1, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  %31 = load i32, ptr %9, align 4, !tbaa !9
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.16, i32 noundef %31)
  call void @_Z9ClearListR6SqList(ptr noundef nonnull align 4 dereferenceable(24) %1)
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %1, i64 24, i1 false), !tbaa.struct !5
  call void @_Z7Display6SqList(ptr noundef byval(%struct.SqList) align 8 %11)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr %1) #6
  ret i32 0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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 = { "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 = { mustprogress norecurse 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 = !{i64 0, i64 20, !6, i64 20, i64 4, !9}
!6 = !{!7, !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; 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.SqList = type { [5 x i32], i32 }

@.str.9 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [31 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z10InitSqListR6SqList(ptr noundef nonnull align 4 dereferenceable(24)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z9ClearListR6SqList(ptr noundef nonnull align 4 dereferenceable(24)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7Display6SqList(ptr noundef byval(%struct.SqList) align 8) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z10InsertElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24), i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z10DeleteElemR6SqListiRi(ptr noundef nonnull align 4 dereferenceable(24), i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z10UpdateElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24), i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z7GetElem6SqListiRi(ptr noundef byval(%struct.SqList) align 8, i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z10LocateElem6SqListiRi(ptr noundef byval(%struct.SqList) align 8, i32 noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #4 {
  %1 = alloca %struct.SqList, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %1) #5
  call void @_Z10InitSqListR6SqList(ptr noundef nonnull align 4 dereferenceable(24) %1)
  %5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  call void @_Z7Display6SqList(ptr noundef nonnull byval(%struct.SqList) align 8 %1)
  %6 = call noundef zeroext i1 @_Z10InsertElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 1, i32 noundef 5)
  %7 = call noundef zeroext i1 @_Z10InsertElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 2, i32 noundef 6)
  %8 = call noundef zeroext i1 @_Z10InsertElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 3, i32 noundef 1)
  %9 = call noundef zeroext i1 @_Z10InsertElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 4, i32 noundef 2)
  %10 = call noundef zeroext i1 @_Z10InsertElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 5, i32 noundef 3)
  %11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  call void @_Z7Display6SqList(ptr noundef nonnull byval(%struct.SqList) align 8 %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %12 = call noundef zeroext i1 @_Z10DeleteElemR6SqListiRi(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 5, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %14)
  call void @_Z7Display6SqList(ptr noundef nonnull byval(%struct.SqList) align 8 %1)
  %16 = call noundef zeroext i1 @_Z10UpdateElemR6SqListii(ptr noundef nonnull align 4 dereferenceable(24) %1, i32 noundef 4, i32 noundef 10)
  %17 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  call void @_Z7Display6SqList(ptr noundef nonnull byval(%struct.SqList) align 8 %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %18 = call noundef zeroext i1 @_Z7GetElem6SqListiRi(ptr noundef nonnull byval(%struct.SqList) align 8 %1, i32 noundef 3, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, i32 noundef %20)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %22 = call noundef zeroext i1 @_Z10LocateElem6SqListiRi(ptr noundef nonnull byval(%struct.SqList) align 8 %1, i32 noundef 1, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16, i32 noundef %24)
  call void @_Z9ClearListR6SqList(ptr noundef nonnull align 4 dereferenceable(24) %1)
  %26 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17)
  call void @_Z7Display6SqList(ptr noundef nonnull byval(%struct.SqList) align 8 %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %1) #5
  ret i32 0
}

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


; Effective O3 passes: DSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass