; LLVM IR from pavlosdais/Abstract-Data-Types :: tests (test_Vector)

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

@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @acutest_check_(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #0

; 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

; Function Attrs: noreturn nounwind uwtable
declare dso_local void @acutest_abort_() #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @createData(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @compareFunction(ptr noundef, ptr noundef) #0

declare ptr @vector_create(ptr noundef) #3

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

declare void @vector_destroy(ptr noundef) #3

; Function Attrs: nounwind
declare void @srand(i32 noundef) #4

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #4

declare void @vector_push_back(ptr noundef, ptr noundef) #3

declare ptr @vector_at(ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @test_sort() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #6
  %6 = call ptr @vector_create(ptr noundef @free)
  store ptr %6, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  %7 = call i64 @time(ptr noundef %2) #6
  %8 = trunc i64 %7 to i32
  call void @srand(i32 noundef %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %9 = call ptr @create_shuffled_array(i32 noundef 20000)
  store ptr %9, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 0, ptr %4, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %21, %0
  %11 = load i64, ptr %4, align 8, !tbaa !9
  %12 = icmp ult i64 %11, 20000
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  br label %24

14:                                               ; preds = %10
  %15 = load ptr, ptr %1, align 8, !tbaa !5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = load i64, ptr %4, align 8, !tbaa !9
  %18 = getelementptr inbounds i32, ptr %16, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !11
  %20 = call ptr @createData(i32 noundef %19)
  call void @vector_push_back(ptr noundef %15, ptr noundef %20)
  br label %21

21:                                               ; preds = %14
  %22 = load i64, ptr %4, align 8, !tbaa !9
  %23 = add i64 %22, 1
  store i64 %23, ptr %4, align 8, !tbaa !9
  br label %10, !llvm.loop !13

24:                                               ; preds = %13
  %25 = load ptr, ptr %1, align 8, !tbaa !5
  call void @vector_sort(ptr noundef %25, ptr noundef @compareFunction)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %26

26:                                               ; preds = %46, %24
  %27 = load i32, ptr %5, align 4, !tbaa !11
  %28 = icmp slt i32 %27, 20000
  br i1 %28, label %30, label %29

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

30:                                               ; preds = %26
  br label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr %1, align 8, !tbaa !5
  %33 = load i32, ptr %5, align 4, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = call ptr @vector_at(ptr noundef %32, i64 noundef %34)
  %36 = load i32, ptr %35, align 4, !tbaa !11
  %37 = load i32, ptr %5, align 4, !tbaa !11
  %38 = icmp eq i32 %36, %37
  %39 = zext i1 %38 to i32
  %40 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %39, ptr noundef @.str.38, i32 noundef 114, ptr noundef @.str.5, ptr noundef @.str.47)
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %43, label %42

42:                                               ; preds = %31
  call void @acutest_abort_() #7
  unreachable

43:                                               ; preds = %31
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %5, align 4, !tbaa !11
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %5, align 4, !tbaa !11
  br label %26, !llvm.loop !15

49:                                               ; preds = %29
  %50 = load ptr, ptr %1, align 8, !tbaa !5
  call void @vector_destroy(ptr noundef %50)
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %51) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #6
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @create_shuffled_array(i32 noundef) #5

declare void @vector_sort(ptr noundef, ptr noundef) #3

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 = { noreturn 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 = { inlinehint 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 #6 = { nounwind }
attributes #7 = { noreturn }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [32 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @acutest_check_(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

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

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

; Function Attrs: noreturn nounwind uwtable
declare dso_local void @acutest_abort_() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @createData(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @compareFunction(ptr noundef, ptr noundef) #0

declare ptr @vector_create(ptr noundef) local_unnamed_addr #3

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

declare void @vector_destroy(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #5

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #5

declare void @vector_push_back(ptr noundef, ptr noundef) local_unnamed_addr #3

declare ptr @vector_at(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @test_sort() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = tail call ptr @vector_create(ptr noundef nonnull @free) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  %3 = call i64 @time(ptr noundef nonnull %1) #7
  %4 = trunc i64 %3 to i32
  call void @srand(i32 noundef %4) #7
  %5 = call ptr @create_shuffled_array(i32 noundef 20000)
  br label %7

6:                                                ; preds = %7
  call void @vector_sort(ptr noundef %2, ptr noundef nonnull @compareFunction) #7
  br label %14

7:                                                ; preds = %0, %7
  %.01213 = phi i64 [ 0, %0 ], [ %11, %7 ]
  %8 = getelementptr inbounds i32, ptr %5, i64 %.01213
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = call ptr @createData(i32 noundef %9)
  call void @vector_push_back(ptr noundef %2, ptr noundef %10) #7
  %11 = add nuw nsw i64 %.01213, 1
  %exitcond.not = icmp eq i64 %11, 20000
  br i1 %exitcond.not, label %6, label %7, !llvm.loop !9

12:                                               ; preds = %14
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond16.not = icmp eq i64 %indvars.iv.next, 20000
  br i1 %exitcond16.not, label %13, label %14, !llvm.loop !11

13:                                               ; preds = %12
  call void @vector_destroy(ptr noundef %2) #7
  call void @free(ptr noundef %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  ret void

14:                                               ; preds = %6, %12
  %indvars.iv = phi i64 [ 0, %6 ], [ %indvars.iv.next, %12 ]
  %15 = call ptr @vector_at(ptr noundef %2, i64 noundef %indvars.iv) #7
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = zext i32 %16 to i64
  %18 = icmp eq i64 %indvars.iv, %17
  %19 = zext i1 %18 to i32
  %20 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %19, ptr noundef nonnull @.str.38, i32 noundef 114, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.47)
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %21, label %12

21:                                               ; preds = %14
  call void @acutest_abort_() #8
  unreachable
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @create_shuffled_array(i32 noundef) local_unnamed_addr #6

declare void @vector_sort(ptr noundef, ptr noundef) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { noreturn 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 = { 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 #5 = { 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 #6 = { inlinehint 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 #7 = { nounwind }
attributes #8 = { noreturn }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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