; LLVM IR from Discngine/fpocket :: src (clusterlib)

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

; 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
define dso_local void @getclustermedoids(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca double, align 8
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %26, %6
  %18 = load i32, ptr %14, align 4, !tbaa !5
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %21, label %29

21:                                               ; preds = %17
  %22 = load ptr, ptr %12, align 8, !tbaa !9
  %23 = load i32, ptr %14, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds double, ptr %22, i64 %24
  store double 0x7FEFFFFFFFFFFFFF, ptr %25, align 8, !tbaa !11
  br label %26

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

29:                                               ; preds = %17
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %117, %29
  %31 = load i32, ptr %13, align 4, !tbaa !5
  %32 = load i32, ptr %8, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %34, label %120

34:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  store double 0.000000e+00, ptr %16, align 8, !tbaa !11
  %35 = load ptr, ptr %10, align 8, !tbaa !9
  %36 = load i32, ptr %13, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i32, ptr %35, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  store i32 %39, ptr %14, align 4, !tbaa !5
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %94, %34
  %41 = load i32, ptr %15, align 4, !tbaa !5
  %42 = load i32, ptr %8, align 4, !tbaa !5
  %43 = icmp slt i32 %41, %42
  br i1 %43, label %44, label %97

44:                                               ; preds = %40
  %45 = load i32, ptr %13, align 4, !tbaa !5
  %46 = load i32, ptr %15, align 4, !tbaa !5
  %47 = icmp eq i32 %45, %46
  br i1 %47, label %56, label %48

48:                                               ; preds = %44
  %49 = load ptr, ptr %10, align 8, !tbaa !9
  %50 = load i32, ptr %15, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i32, ptr %49, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = load i32, ptr %14, align 4, !tbaa !5
  %55 = icmp ne i32 %53, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %48, %44
  br label %94

57:                                               ; preds = %48
  %58 = load i32, ptr %13, align 4, !tbaa !5
  %59 = load i32, ptr %15, align 4, !tbaa !5
  %60 = icmp slt i32 %58, %59
  br i1 %60, label %61, label %71

61:                                               ; preds = %57
  %62 = load ptr, ptr %9, align 8, !tbaa !9
  %63 = load i32, ptr %15, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds ptr, ptr %62, i64 %64
  %66 = load ptr, ptr %65, align 8, !tbaa !9
  %67 = load i32, ptr %13, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds double, ptr %66, i64 %68
  %70 = load double, ptr %69, align 8, !tbaa !11
  br label %81

71:                                               ; preds = %57
  %72 = load ptr, ptr %9, align 8, !tbaa !9
  %73 = load i32, ptr %13, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds ptr, ptr %72, i64 %74
  %76 = load ptr, ptr %75, align 8, !tbaa !9
  %77 = load i32, ptr %15, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds double, ptr %76, i64 %78
  %80 = load double, ptr %79, align 8, !tbaa !11
  br label %81

81:                                               ; preds = %71, %61
  %82 = phi double [ %70, %61 ], [ %80, %71 ]
  %83 = load double, ptr %16, align 8, !tbaa !11
  %84 = fadd double %83, %82
  store double %84, ptr %16, align 8, !tbaa !11
  %85 = load double, ptr %16, align 8, !tbaa !11
  %86 = load ptr, ptr %12, align 8, !tbaa !9
  %87 = load i32, ptr %14, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds double, ptr %86, i64 %88
  %90 = load double, ptr %89, align 8, !tbaa !11
  %91 = fcmp ogt double %85, %90
  br i1 %91, label %92, label %93

92:                                               ; preds = %81
  br label %97

93:                                               ; preds = %81
  br label %94

94:                                               ; preds = %93, %56
  %95 = load i32, ptr %15, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %15, align 4, !tbaa !5
  br label %40, !llvm.loop !15

97:                                               ; preds = %92, %40
  %98 = load double, ptr %16, align 8, !tbaa !11
  %99 = load ptr, ptr %12, align 8, !tbaa !9
  %100 = load i32, ptr %14, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds double, ptr %99, i64 %101
  %103 = load double, ptr %102, align 8, !tbaa !11
  %104 = fcmp olt double %98, %103
  br i1 %104, label %105, label %116

105:                                              ; preds = %97
  %106 = load double, ptr %16, align 8, !tbaa !11
  %107 = load ptr, ptr %12, align 8, !tbaa !9
  %108 = load i32, ptr %14, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds double, ptr %107, i64 %109
  store double %106, ptr %110, align 8, !tbaa !11
  %111 = load i32, ptr %13, align 4, !tbaa !5
  %112 = load ptr, ptr %11, align 8, !tbaa !9
  %113 = load i32, ptr %14, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds i32, ptr %112, i64 %114
  store i32 %111, ptr %115, align 4, !tbaa !5
  br label %116

116:                                              ; preds = %105, %97
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  br label %117

117:                                              ; preds = %116
  %118 = load i32, ptr %13, align 4, !tbaa !5
  %119 = add nsw i32 %118, 1
  store i32 %119, ptr %13, align 4, !tbaa !5
  br label %30, !llvm.loop !16

120:                                              ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  ret void
}

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

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @getclustermedoids(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef %5) local_unnamed_addr #0 {
  %7 = icmp sgt i32 %0, 0
  br i1 %7, label %.lr.ph.preheader, label %.preheader

.lr.ph.preheader:                                 ; preds = %6
  %wide.trip.count = zext nneg i32 %0 to i64
  %min.iters.check = icmp ult i32 %0, 4
  br i1 %min.iters.check, label %.lr.ph.preheader69, label %vector.ph

.lr.ph.preheader69:                               ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %wide.trip.count, 2147483644
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %8 = getelementptr inbounds double, ptr %5, i64 %index
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  store <2 x double> <double 0x7FEFFFFFFFFFFFFF, double 0x7FEFFFFFFFFFFFFF>, ptr %8, align 8, !tbaa !5
  store <2 x double> <double 0x7FEFFFFFFFFFFFFF, double 0x7FEFFFFFFFFFFFFF>, ptr %9, align 8, !tbaa !5
  %index.next = add nuw i64 %index, 4
  %10 = icmp eq i64 %index.next, %n.vec
  br i1 %10, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.preheader, label %.lr.ph.preheader69

.preheader:                                       ; preds = %.lr.ph, %middle.block, %6
  %11 = icmp sgt i32 %1, 0
  br i1 %11, label %.lr.ph48.us.preheader, label %._crit_edge53

.lr.ph48.us.preheader:                            ; preds = %.preheader
  %wide.trip.count63 = zext nneg i32 %1 to i64
  br label %.lr.ph48.us

.lr.ph48.us:                                      ; preds = %.lr.ph48.us.preheader, %33
  %indvars.iv60 = phi i64 [ 0, %.lr.ph48.us.preheader ], [ %indvars.iv.next61, %33 ]
  %12 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv60
  %13 = load i32, ptr %12, align 4, !tbaa !13
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds double, ptr %5, i64 %14
  br label %16

16:                                               ; preds = %.lr.ph48.us, %34
  %indvars.iv55 = phi i64 [ 0, %.lr.ph48.us ], [ %indvars.iv.next56, %34 ]
  %.047.us = phi double [ 0.000000e+00, %.lr.ph48.us ], [ %.1.us, %34 ]
  %17 = icmp eq i64 %indvars.iv60, %indvars.iv55
  br i1 %17, label %34, label %18

18:                                               ; preds = %16
  %19 = getelementptr inbounds i32, ptr %3, i64 %indvars.iv55
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %.not.us = icmp eq i32 %20, %13
  br i1 %.not.us, label %21, label %34

21:                                               ; preds = %18
  %.sink66.v = tail call i64 @llvm.umax.i64(i64 %indvars.iv60, i64 %indvars.iv55)
  %.sink66 = getelementptr inbounds ptr, ptr %2, i64 %.sink66.v
  %indvars.iv60.sink = tail call i64 @llvm.umin.i64(i64 %indvars.iv60, i64 %indvars.iv55)
  %22 = load ptr, ptr %.sink66, align 8, !tbaa !15
  %23 = getelementptr inbounds double, ptr %22, i64 %indvars.iv60.sink
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = fadd double %.047.us, %24
  %26 = load double, ptr %15, align 8, !tbaa !5
  %27 = fcmp ogt double %25, %26
  br i1 %27, label %._crit_edge.us, label %34

._crit_edge.us:                                   ; preds = %21, %.._crit_edge.us_crit_edge
  %28 = phi double [ %.pre, %.._crit_edge.us_crit_edge ], [ %26, %21 ]
  %.2.us = phi double [ %.1.us, %.._crit_edge.us_crit_edge ], [ %25, %21 ]
  %29 = fcmp olt double %.2.us, %28
  br i1 %29, label %30, label %33

30:                                               ; preds = %._crit_edge.us
  store double %.2.us, ptr %15, align 8, !tbaa !5
  %31 = getelementptr inbounds i32, ptr %4, i64 %14
  %32 = trunc nuw nsw i64 %indvars.iv60 to i32
  store i32 %32, ptr %31, align 4, !tbaa !13
  br label %33

33:                                               ; preds = %30, %._crit_edge.us
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %exitcond64.not = icmp eq i64 %indvars.iv.next61, %wide.trip.count63
  br i1 %exitcond64.not, label %._crit_edge53, label %.lr.ph48.us, !llvm.loop !17

34:                                               ; preds = %21, %18, %16
  %.1.us = phi double [ %.047.us, %16 ], [ %.047.us, %18 ], [ %25, %21 ]
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %exitcond59.not = icmp eq i64 %indvars.iv.next56, %wide.trip.count63
  br i1 %exitcond59.not, label %.._crit_edge.us_crit_edge, label %16, !llvm.loop !18

.._crit_edge.us_crit_edge:                        ; preds = %34
  %.pre = load double, ptr %15, align 8, !tbaa !5
  br label %._crit_edge.us

.lr.ph:                                           ; preds = %.lr.ph.preheader69, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader69 ]
  %35 = getelementptr inbounds double, ptr %5, i64 %indvars.iv
  store double 0x7FEFFFFFFFFFFFFF, ptr %35, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %.lr.ph, !llvm.loop !19

._crit_edge53:                                    ; preds = %33, %.preheader
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #1

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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 speculatable willreturn memory(none) }

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"any pointer", !7, i64 0}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10, !12, !11}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass