; 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.43 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [40 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

declare ptr @vector_create(ptr noundef) #3

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

declare i64 @vector_size(ptr noundef) #3

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

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

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_clear_at() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  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_random_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
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %58, %24
  %26 = load i64, ptr %5, align 8, !tbaa !9
  %27 = icmp ult i64 %26, 20000
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %61

29:                                               ; preds = %25
  %30 = load ptr, ptr %1, align 8, !tbaa !5
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = call zeroext i1 @vector_clear_at(ptr noundef %30, i64 noundef %31)
  br label %33

33:                                               ; preds = %29
  %34 = load ptr, ptr %1, align 8, !tbaa !5
  %35 = load i64, ptr %5, align 8, !tbaa !9
  %36 = call ptr @vector_at(ptr noundef %34, i64 noundef %35)
  %37 = icmp eq ptr %36, null
  %38 = zext i1 %37 to i32
  %39 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %38, ptr noundef @.str.38, i32 noundef 59, ptr noundef @.str.5, ptr noundef @.str.43)
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %42, label %41

41:                                               ; preds = %33
  call void @acutest_abort_() #7
  unreachable

42:                                               ; preds = %33
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  %46 = load ptr, ptr %1, align 8, !tbaa !5
  %47 = call i64 @vector_size(ptr noundef %46)
  %48 = load i64, ptr %5, align 8, !tbaa !9
  %49 = sub i64 19999, %48
  %50 = icmp eq i64 %47, %49
  %51 = zext i1 %50 to i32
  %52 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %51, ptr noundef @.str.38, i32 noundef 62, ptr noundef @.str.5, ptr noundef @.str.44)
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %55, label %54

54:                                               ; preds = %45
  call void @acutest_abort_() #7
  unreachable

55:                                               ; preds = %45
  br label %56

56:                                               ; preds = %55
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  %59 = load i64, ptr %5, align 8, !tbaa !9
  %60 = add i64 %59, 1
  store i64 %60, ptr %5, align 8, !tbaa !9
  br label %25, !llvm.loop !15

61:                                               ; preds = %28
  %62 = load ptr, ptr %1, align 8, !tbaa !5
  call void @vector_destroy(ptr noundef %62)
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %63) #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
}

declare zeroext i1 @vector_clear_at(ptr noundef, i64 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.43 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [40 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

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 i64 @vector_size(ptr noundef) local_unnamed_addr #3

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

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

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_clear_at() 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_random_array(i32 noundef 20000)
  br label %6

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

11:                                               ; preds = %20
  %12 = add nuw nsw i64 %.017, 1
  %exitcond18.not = icmp eq i64 %12, 20000
  br i1 %exitcond18.not, label %13, label %.preheader, !llvm.loop !11

13:                                               ; preds = %11
  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

.preheader:                                       ; preds = %6, %11
  %.017 = phi i64 [ %12, %11 ], [ 0, %6 ]
  %14 = call zeroext i1 @vector_clear_at(ptr noundef %2, i64 noundef %.017) #7
  %15 = call ptr @vector_at(ptr noundef %2, i64 noundef %.017) #7
  %16 = icmp eq ptr %15, null
  %17 = zext i1 %16 to i32
  %18 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %17, ptr noundef nonnull @.str.38, i32 noundef 59, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.43)
  %.not = icmp eq i32 %18, 0
  br i1 %.not, label %19, label %20

19:                                               ; preds = %.preheader
  call void @acutest_abort_() #8
  unreachable

20:                                               ; preds = %.preheader
  %21 = call i64 @vector_size(ptr noundef %2) #7
  %22 = sub nuw nsw i64 19999, %.017
  %23 = icmp eq i64 %21, %22
  %24 = zext i1 %23 to i32
  %25 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %24, ptr noundef nonnull @.str.38, i32 noundef 62, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.44)
  %.not15 = icmp eq i32 %25, 0
  br i1 %.not15, label %26, label %11

26:                                               ; preds = %20
  call void @acutest_abort_() #8
  unreachable
}

declare zeroext i1 @vector_clear_at(ptr noundef, i64 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,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass