; LLVM IR from MaxGoryunov/LinearSystemsToolkit :: LinearSystemsToolkit (VectorTest)

; 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.Vector = type { ptr, i32 }

@.str = external hidden unnamed_addr constant [46 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [100 x i8], align 1
@__PRETTY_FUNCTION__.sumsTwoVectors = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @sumsTwoVectors() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 3, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = call ptr @vectorCreate(i32 noundef %6)
  store ptr %7, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = call ptr @vectorCreate(i32 noundef %8)
  store ptr %9, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = call ptr @vectorCreate(i32 noundef %10)
  store ptr %11, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %44, %0
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %12
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = sitofp i32 %18 to double
  %20 = load ptr, ptr %2, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct.Vector, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds double, ptr %22, i64 %24
  store double %19, ptr %25, align 8, !tbaa !13
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = mul nsw i32 %26, 2
  %28 = sitofp i32 %27 to double
  %29 = load ptr, ptr %3, align 8, !tbaa !9
  %30 = getelementptr inbounds %struct.Vector, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds double, ptr %31, i64 %33
  store double %28, ptr %34, align 8, !tbaa !13
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = mul nsw i32 %35, 3
  %37 = sitofp i32 %36 to double
  %38 = load ptr, ptr %4, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.Vector, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds double, ptr %40, i64 %42
  store double %37, ptr %43, align 8, !tbaa !13
  br label %44

44:                                               ; preds = %17
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %5, align 4, !tbaa !5
  br label %12, !llvm.loop !15

47:                                               ; preds = %16
  %48 = load ptr, ptr %2, align 8, !tbaa !9
  %49 = load ptr, ptr %3, align 8, !tbaa !9
  %50 = call ptr @vectorSum(ptr noundef %48, ptr noundef %49)
  %51 = load ptr, ptr %4, align 8, !tbaa !9
  %52 = call signext i8 @vectorEqual(ptr noundef %50, ptr noundef %51)
  %53 = sext i8 %52 to i32
  %54 = icmp eq i32 1, %53
  br i1 %54, label %55, label %56

55:                                               ; preds = %47
  br label %57

56:                                               ; preds = %47
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 18, ptr noundef @__PRETTY_FUNCTION__.sumsTwoVectors) #5
  unreachable

57:                                               ; preds = %55
  %58 = load ptr, ptr %2, align 8, !tbaa !9
  call void @vectorDestroy(ptr noundef %58)
  %59 = load ptr, ptr %3, align 8, !tbaa !9
  call void @vectorDestroy(ptr noundef %59)
  %60 = load ptr, ptr %4, align 8, !tbaa !9
  call void @vectorDestroy(ptr noundef %60)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

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

declare ptr @vectorCreate(i32 noundef) #2

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

declare signext i8 @vectorEqual(ptr noundef, ptr noundef) #2

declare ptr @vectorSum(ptr noundef, ptr noundef) #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

declare void @vectorDestroy(ptr noundef) #2

attributes #0 = { 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 = { "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 = { noreturn 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 #4 = { nounwind }
attributes #5 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"Vector", !10, i64 0, !6, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

@.str = external hidden unnamed_addr constant [46 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [100 x i8], align 1
@__PRETTY_FUNCTION__.sumsTwoVectors = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @sumsTwoVectors() local_unnamed_addr #0 {
  %1 = tail call ptr @vectorCreate(i32 noundef 3) #3
  %2 = tail call ptr @vectorCreate(i32 noundef 3) #3
  %3 = tail call ptr @vectorCreate(i32 noundef 3) #3
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  store double 0.000000e+00, ptr %4, align 8, !tbaa !11
  store double 0.000000e+00, ptr %5, align 8, !tbaa !11
  store double 0.000000e+00, ptr %6, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  store double 1.000000e+00, ptr %7, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %5, i64 8
  store double 2.000000e+00, ptr %8, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %6, i64 8
  store double 3.000000e+00, ptr %9, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %4, i64 16
  store double 2.000000e+00, ptr %10, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %5, i64 16
  store double 4.000000e+00, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %6, i64 16
  store double 6.000000e+00, ptr %12, align 8, !tbaa !11
  %13 = tail call ptr @vectorSum(ptr noundef nonnull %1, ptr noundef nonnull %2) #3
  %14 = tail call signext i8 @vectorEqual(ptr noundef %13, ptr noundef nonnull %3) #3
  %15 = icmp eq i8 %14, 1
  br i1 %15, label %17, label %16

16:                                               ; preds = %0
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 18, ptr noundef nonnull @__PRETTY_FUNCTION__.sumsTwoVectors) #4
  unreachable

17:                                               ; preds = %0
  tail call void @vectorDestroy(ptr noundef nonnull %1) #3
  tail call void @vectorDestroy(ptr noundef nonnull %2) #3
  tail call void @vectorDestroy(ptr noundef nonnull %3) #3
  ret void
}

declare ptr @vectorCreate(i32 noundef) local_unnamed_addr #1

declare signext i8 @vectorEqual(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @vectorSum(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @vectorDestroy(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 = { "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 = { noreturn 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 = { nounwind }
attributes #4 = { noreturn 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, !7, i64 0}
!6 = !{!"Vector", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !8, i64 0}


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