; LLVM IR from wumo/vkg :: src/par/test (test_sprune)

; 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.par_sprune__context = type { ptr, i32, ptr, i32, ptr, i32, [2 x ptr], [2 x ptr] }

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @pa___growf(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare ptr @bsearch(ptr noundef nonnull, ptr noundef nonnull, i64 noundef, i64 noundef, ptr noundef nonnull) #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @par_sprune__is_culled(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @par_sprune_cull(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %10, ptr %3, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.par_sprune__context, ptr %11, i32 0, i32 2
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = icmp ne ptr %13, null
  br i1 %14, label %15, label %21

15:                                               ; preds = %1
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.par_sprune__context, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = getelementptr inbounds i32, ptr %18, i64 -2
  %20 = getelementptr inbounds i32, ptr %19, i64 1
  store i32 0, ptr %20, align 4, !tbaa !12
  br label %21

21:                                               ; preds = %15, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.par_sprune__context, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  store ptr %24, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.par_sprune__context, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !14
  store i32 %27, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 8, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !12
  br label %28

28:                                               ; preds = %106, %21
  %29 = load i32, ptr %7, align 4, !tbaa !12
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.par_sprune__context, ptr %30, i32 0, i32 5
  %32 = load i32, ptr %31, align 8, !tbaa !15
  %33 = icmp slt i32 %29, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %28
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %109

35:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load i32, ptr %5, align 4, !tbaa !12
  %38 = sext i32 %37 to i64
  %39 = load i32, ptr %6, align 4, !tbaa !12
  %40 = sext i32 %39 to i64
  %41 = call ptr @bsearch(ptr noundef %7, ptr noundef %36, i64 noundef %38, i64 noundef %40, ptr noundef @par__cmpfindsingle)
  store ptr %41, ptr %9, align 8, !tbaa !5
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %45, label %44

44:                                               ; preds = %35
  store i32 4, ptr %8, align 4
  br label %103

45:                                               ; preds = %35
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = load ptr, ptr %9, align 8, !tbaa !5
  %48 = getelementptr inbounds i32, ptr %47, i64 0
  %49 = load i32, ptr %48, align 4, !tbaa !12
  %50 = call zeroext i1 @par_sprune__is_culled(ptr noundef %46, i32 noundef %49)
  br i1 %50, label %102, label %51

51:                                               ; preds = %45
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds i32, ptr %53, i64 1
  %55 = load i32, ptr %54, align 4, !tbaa !12
  %56 = call zeroext i1 @par_sprune__is_culled(ptr noundef %52, i32 noundef %55)
  br i1 %56, label %102, label %57

57:                                               ; preds = %51
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.par_sprune__context, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !9
  %61 = icmp eq ptr %60, null
  br i1 %61, label %77, label %62

62:                                               ; preds = %57
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.par_sprune__context, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  %66 = getelementptr inbounds i32, ptr %65, i64 -2
  %67 = getelementptr inbounds i32, ptr %66, i64 1
  %68 = load i32, ptr %67, align 4, !tbaa !12
  %69 = add nsw i32 %68, 1
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.par_sprune__context, ptr %70, i32 0, i32 2
  %72 = load ptr, ptr %71, align 8, !tbaa !9
  %73 = getelementptr inbounds i32, ptr %72, i64 -2
  %74 = getelementptr inbounds i32, ptr %73, i64 0
  %75 = load i32, ptr %74, align 4, !tbaa !12
  %76 = icmp sge i32 %69, %75
  br i1 %76, label %77, label %84

77:                                               ; preds = %62, %57
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.par_sprune__context, ptr %78, i32 0, i32 2
  %80 = load ptr, ptr %79, align 8, !tbaa !9
  %81 = call ptr @pa___growf(ptr noundef %80, i32 noundef 1, i32 noundef 4)
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.par_sprune__context, ptr %82, i32 0, i32 2
  store ptr %81, ptr %83, align 8, !tbaa !5
  br label %85

84:                                               ; preds = %62
  br label %85

85:                                               ; preds = %84, %77
  %86 = phi ptr [ %81, %77 ], [ null, %84 ]
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = getelementptr inbounds i32, ptr %87, i64 0
  %89 = load i32, ptr %88, align 4, !tbaa !12
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.par_sprune__context, ptr %90, i32 0, i32 2
  %92 = load ptr, ptr %91, align 8, !tbaa !9
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.par_sprune__context, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !9
  %96 = getelementptr inbounds i32, ptr %95, i64 -2
  %97 = getelementptr inbounds i32, ptr %96, i64 1
  %98 = load i32, ptr %97, align 4, !tbaa !12
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %97, align 4, !tbaa !12
  %100 = sext i32 %98 to i64
  %101 = getelementptr inbounds i32, ptr %92, i64 %100
  store i32 %89, ptr %101, align 4, !tbaa !12
  br label %102

102:                                              ; preds = %85, %51, %45
  store i32 0, ptr %8, align 4
  br label %103

103:                                              ; preds = %102, %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %104 = load i32, ptr %8, align 4
  switch i32 %104, label %126 [
    i32 0, label %105
    i32 4, label %106
  ]

105:                                              ; preds = %103
  br label %106

106:                                              ; preds = %105, %103
  %107 = load i32, ptr %7, align 4, !tbaa !12
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %7, align 4, !tbaa !12
  br label %28, !llvm.loop !16

109:                                              ; preds = %34
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.par_sprune__context, ptr %110, i32 0, i32 2
  %112 = load ptr, ptr %111, align 8, !tbaa !9
  %113 = icmp ne ptr %112, null
  br i1 %113, label %114, label %121

114:                                              ; preds = %109
  %115 = load ptr, ptr %3, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.par_sprune__context, ptr %115, i32 0, i32 2
  %117 = load ptr, ptr %116, align 8, !tbaa !9
  %118 = getelementptr inbounds i32, ptr %117, i64 -2
  %119 = getelementptr inbounds i32, ptr %118, i64 1
  %120 = load i32, ptr %119, align 4, !tbaa !12
  br label %122

121:                                              ; preds = %109
  br label %122

122:                                              ; preds = %121, %114
  %123 = phi i32 [ %120, %114 ], [ 0, %121 ]
  %124 = load ptr, ptr %3, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.par_sprune__context, ptr %124, i32 0, i32 3
  store i32 %123, ptr %125, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void

126:                                              ; preds = %103
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden i32 @par__cmpfindsingle(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"", !6, i64 0, !11, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !11, i64 40, !7, i64 48, !7, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !6, i64 0}
!14 = !{!10, !11, i64 8}
!15 = !{!10, !11, i64 40}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!10, !11, i64 24}


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

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @pa___growf(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare ptr @bsearch(ptr noundef nonnull, ptr noundef nonnull, i64 noundef, i64 noundef, ptr noundef nonnull) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @par_sprune__is_culled(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @par_sprune_cull(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %7, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %4, i64 -4
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %7

7:                                                ; preds = %5, %1
  %8 = load ptr, ptr %0, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load i32, ptr %9, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 0, ptr %2, align 4, !tbaa !11
  %12 = load i32, ptr %11, align 8, !tbaa !14
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %7
  %14 = sext i32 %10 to i64
  br label %16

._crit_edge.loopexit:                             ; preds = %43
  %.pre30 = load ptr, ptr %3, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %7
  %15 = phi ptr [ %.pre30, %._crit_edge.loopexit ], [ %4, %7 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  %.not27 = icmp eq ptr %15, null
  br i1 %.not27, label %51, label %48

16:                                               ; preds = %.lr.ph, %43
  %17 = call ptr @bsearch(ptr noundef %2, ptr noundef %8, i64 noundef %14, i64 noundef 8, ptr noundef @par__cmpfindsingle)
  %.not28 = icmp eq ptr %17, null
  br i1 %.not28, label %43, label %18

18:                                               ; preds = %16
  %19 = load i32, ptr %17, align 4, !tbaa !11
  %20 = call zeroext i1 @par_sprune__is_culled(ptr noundef nonnull %0, i32 noundef %19)
  br i1 %20, label %43, label %21

21:                                               ; preds = %18
  %22 = getelementptr inbounds i8, ptr %17, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !11
  %24 = call zeroext i1 @par_sprune__is_culled(ptr noundef nonnull %0, i32 noundef %23)
  br i1 %24, label %43, label %25

25:                                               ; preds = %21
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %34, label %28

28:                                               ; preds = %25
  %29 = getelementptr inbounds i8, ptr %26, i64 -8
  %30 = getelementptr inbounds i8, ptr %26, i64 -4
  %31 = load i32, ptr %30, align 4, !tbaa !11
  %32 = add nsw i32 %31, 1
  %33 = load i32, ptr %29, align 4, !tbaa !11
  %.not29 = icmp slt i32 %32, %33
  br i1 %.not29, label %36, label %34

34:                                               ; preds = %28, %25
  %35 = call ptr @pa___growf(ptr noundef %26, i32 noundef 1, i32 noundef 4)
  store ptr %35, ptr %3, align 8, !tbaa !15
  %.phi.trans.insert = getelementptr inbounds i8, ptr %35, i64 -4
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !11
  %.pre31 = add nsw i32 %.pre, 1
  br label %36

36:                                               ; preds = %28, %34
  %.pre-phi = phi i32 [ %32, %28 ], [ %.pre31, %34 ]
  %37 = phi i32 [ %31, %28 ], [ %.pre, %34 ]
  %38 = phi ptr [ %26, %28 ], [ %35, %34 ]
  %39 = load i32, ptr %17, align 4, !tbaa !11
  %40 = getelementptr inbounds i8, ptr %38, i64 -4
  store i32 %.pre-phi, ptr %40, align 4, !tbaa !11
  %41 = sext i32 %37 to i64
  %42 = getelementptr inbounds i32, ptr %38, i64 %41
  store i32 %39, ptr %42, align 4, !tbaa !11
  br label %43

43:                                               ; preds = %18, %21, %36, %16
  %44 = load i32, ptr %2, align 4, !tbaa !11
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %2, align 4, !tbaa !11
  %46 = load i32, ptr %11, align 8, !tbaa !14
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %16, label %._crit_edge.loopexit, !llvm.loop !16

48:                                               ; preds = %._crit_edge
  %49 = getelementptr inbounds i8, ptr %15, i64 -4
  %50 = load i32, ptr %49, align 4, !tbaa !11
  br label %51

51:                                               ; preds = %._crit_edge, %48
  %52 = phi i32 [ %50, %48 ], [ 0, %._crit_edge ]
  %53 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %52, ptr %53, align 8, !tbaa !18
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i32 @par__cmpfindsingle(ptr noundef, ptr noundef) #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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 16}
!6 = !{!"", !7, i64 0, !10, i64 8, !7, i64 16, !10, i64 24, !7, i64 32, !10, i64 40, !8, i64 48, !8, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !10, i64 40}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !10, i64 24}


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