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

; 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 [83 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [39 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

declare i32 @printf(ptr noundef, ...) #2

; 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_() #3

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

declare ptr @queue_create(ptr noundef) #2

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

declare i64 @queue_size(ptr noundef) #2

declare void @queue_destroy(ptr noundef) #2

; 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

; Function Attrs: nounwind
declare i64 @clock() #4

declare void @queue_enqueue(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @test_dequeue() #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
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #6
  %9 = call ptr @queue_create(ptr noundef @free)
  store ptr %9, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  %10 = call i64 @time(ptr noundef %2) #6
  %11 = trunc i64 %10 to i32
  call void @srand(i32 noundef %11) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %12 = call ptr @create_random_array(i32 noundef 1000000)
  store ptr %12, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %13 = call i64 @clock() #6
  store i64 %13, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %14

14:                                               ; preds = %26, %0
  %15 = load i32, ptr %5, align 4, !tbaa !11
  %16 = icmp ult i32 %15, 1000000
  br i1 %16, label %18, label %17

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

18:                                               ; preds = %14
  %19 = load ptr, ptr %1, align 8, !tbaa !5
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load i32, ptr %5, align 4, !tbaa !11
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds i32, ptr %20, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = call ptr @createData(i32 noundef %24)
  call void @queue_enqueue(ptr noundef %19, ptr noundef %25)
  br label %26

26:                                               ; preds = %18
  %27 = load i32, ptr %5, align 4, !tbaa !11
  %28 = add i32 %27, 1
  store i32 %28, ptr %5, align 4, !tbaa !11
  br label %14, !llvm.loop !13

29:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %30

30:                                               ; preds = %69, %29
  %31 = load i32, ptr %7, align 4, !tbaa !11
  %32 = icmp ult i32 %31, 1000000
  br i1 %32, label %34, label %33

33:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %72

34:                                               ; preds = %30
  %35 = load ptr, ptr %1, align 8, !tbaa !5
  %36 = call ptr @queue_dequeue(ptr noundef %35)
  store ptr %36, ptr %6, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %34
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load i32, ptr %38, align 4, !tbaa !11
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = load i32, ptr %7, align 4, !tbaa !11
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds i32, ptr %40, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = icmp eq i32 %39, %44
  %46 = zext i1 %45 to i32
  %47 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %46, ptr noundef @.str.38, i32 noundef 66, ptr noundef @.str.5, ptr noundef @.str.43)
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %50, label %49

49:                                               ; preds = %37
  call void @acutest_abort_() #7
  unreachable

50:                                               ; preds = %37
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %53) #6
  br label %54

54:                                               ; preds = %52
  %55 = load ptr, ptr %1, align 8, !tbaa !5
  %56 = call i64 @queue_size(ptr noundef %55)
  %57 = load i32, ptr %7, align 4, !tbaa !11
  %58 = sub i32 1000000, %57
  %59 = sub i32 %58, 1
  %60 = zext i32 %59 to i64
  %61 = icmp eq i64 %56, %60
  %62 = zext i1 %61 to i32
  %63 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %62, ptr noundef @.str.38, i32 noundef 70, ptr noundef @.str.5, ptr noundef @.str.44)
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %66, label %65

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

66:                                               ; preds = %54
  br label %67

67:                                               ; preds = %66
  br label %68

68:                                               ; preds = %67
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %7, align 4, !tbaa !11
  %71 = add i32 %70, 1
  store i32 %71, ptr %7, align 4, !tbaa !11
  br label %30, !llvm.loop !15

72:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %73 = call i64 @clock() #6
  %74 = load i64, ptr %4, align 8, !tbaa !9
  %75 = sub nsw i64 %73, %74
  %76 = sitofp i64 %75 to double
  %77 = fdiv double %76, 1.000000e+06
  store double %77, ptr %8, align 8, !tbaa !16
  %78 = load ptr, ptr %1, align 8, !tbaa !5
  call void @queue_destroy(ptr noundef %78)
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %79) #6
  %80 = load double, ptr %8, align 8, !tbaa !16
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.45, double noundef %80)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #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 ptr @queue_dequeue(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 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 #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}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !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"

@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [39 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: 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.end.p0(i64 immarg, ptr nocapture) #1

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

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

declare ptr @queue_create(ptr noundef) local_unnamed_addr #4

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

declare i64 @queue_size(ptr noundef) local_unnamed_addr #4

declare void @queue_destroy(ptr noundef) local_unnamed_addr #4

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

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

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

; Function Attrs: nounwind
declare i64 @clock() local_unnamed_addr #6

declare void @queue_enqueue(ptr noundef, ptr noundef) local_unnamed_addr #4

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

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

11:                                               ; preds = %26
  %indvars.iv.next23 = add nuw nsw i64 %indvars.iv22, 1
  %exitcond25.not = icmp eq i64 %indvars.iv.next23, 1000000
  br i1 %exitcond25.not, label %12, label %.preheader, !llvm.loop !11

12:                                               ; preds = %11
  %13 = call i64 @clock() #8
  %14 = sub nsw i64 %13, %6
  %15 = sitofp i64 %14 to double
  %16 = fdiv double %15, 1.000000e+06
  call void @queue_destroy(ptr noundef %2) #8
  call void @free(ptr noundef nonnull %5) #8
  %17 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.45, double noundef %16)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #8
  ret void

.preheader:                                       ; preds = %7, %11
  %indvars.iv22 = phi i64 [ %indvars.iv.next23, %11 ], [ 0, %7 ]
  %18 = call ptr @queue_dequeue(ptr noundef %2) #8
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = getelementptr inbounds i32, ptr %5, i64 %indvars.iv22
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = icmp eq i32 %19, %21
  %23 = zext i1 %22 to i32
  %24 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %23, ptr noundef nonnull @.str.38, i32 noundef 66, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.43)
  %.not = icmp eq i32 %24, 0
  br i1 %.not, label %25, label %26

25:                                               ; preds = %.preheader
  call void @acutest_abort_() #9
  unreachable

26:                                               ; preds = %.preheader
  call void @free(ptr noundef nonnull %18) #8
  %27 = call i64 @queue_size(ptr noundef %2) #8
  %28 = sub nuw nsw i64 999999, %indvars.iv22
  %29 = icmp eq i64 %27, %28
  %30 = zext i1 %29 to i32
  %31 = call i32 (i32, ptr, i32, ptr, ...) @acutest_check_(i32 noundef %30, ptr noundef nonnull @.str.38, i32 noundef 70, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.44)
  %.not18 = icmp eq i32 %31, 0
  br i1 %.not18, label %32, label %11

32:                                               ; preds = %26
  call void @acutest_abort_() #9
  unreachable
}

declare ptr @queue_dequeue(ptr noundef) local_unnamed_addr #4

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 = { 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 = { 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 #4 = { "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 = { 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 #6 = { 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { 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: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass