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

@stdout = external global ptr, align 8

; 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
declare void @free(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @distancematrix(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef signext, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @treecluster(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i8 noundef signext %6, i8 noundef signext %7, ptr noundef %8) #2 {
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i8, align 1
  %18 = alloca i8, align 1
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  store i32 %0, ptr %11, align 4, !tbaa !5
  store i32 %1, ptr %12, align 4, !tbaa !5
  store ptr %2, ptr %13, align 8, !tbaa !9
  store ptr %3, ptr %14, align 8, !tbaa !9
  store ptr %4, ptr %15, align 8, !tbaa !9
  store i32 %5, ptr %16, align 4, !tbaa !5
  store i8 %6, ptr %17, align 1, !tbaa !11
  store i8 %7, ptr %18, align 1, !tbaa !11
  store ptr %8, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  store ptr null, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %25 = load i32, ptr %16, align 4, !tbaa !5
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %9
  %28 = load i32, ptr %11, align 4, !tbaa !5
  br label %31

29:                                               ; preds = %9
  %30 = load i32, ptr %12, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %29, %27
  %32 = phi i32 [ %28, %27 ], [ %30, %29 ]
  store i32 %32, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  %33 = load ptr, ptr %19, align 8, !tbaa !9
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %39

35:                                               ; preds = %31
  %36 = load i8, ptr %18, align 1, !tbaa !11
  %37 = sext i8 %36 to i32
  %38 = icmp ne i32 %37, 115
  br label %39

39:                                               ; preds = %35, %31
  %40 = phi i1 [ false, %31 ], [ %38, %35 ]
  %41 = zext i1 %40 to i64
  %42 = select i1 %40, i32 1, i32 0
  store i32 %42, ptr %22, align 4, !tbaa !5
  %43 = load i32, ptr %21, align 4, !tbaa !5
  %44 = icmp slt i32 %43, 2
  br i1 %44, label %45, label %46

45:                                               ; preds = %39
  store ptr null, ptr %10, align 8
  store i32 1, ptr %23, align 4
  br label %116

46:                                               ; preds = %39
  %47 = load i32, ptr %22, align 4, !tbaa !5
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %62

49:                                               ; preds = %46
  %50 = load i32, ptr %11, align 4, !tbaa !5
  %51 = load i32, ptr %12, align 4, !tbaa !5
  %52 = load ptr, ptr %13, align 8, !tbaa !9
  %53 = load ptr, ptr %14, align 8, !tbaa !9
  %54 = load ptr, ptr %15, align 8, !tbaa !9
  %55 = load i8, ptr %17, align 1, !tbaa !11
  %56 = load i32, ptr %16, align 4, !tbaa !5
  %57 = call ptr @distancematrix(i32 noundef %50, i32 noundef %51, ptr noundef %52, ptr noundef %53, ptr noundef %54, i8 noundef signext %55, i32 noundef %56)
  store ptr %57, ptr %19, align 8, !tbaa !9
  %58 = load ptr, ptr %19, align 8, !tbaa !9
  %59 = icmp ne ptr %58, null
  br i1 %59, label %61, label %60

60:                                               ; preds = %49
  store ptr null, ptr %10, align 8
  store i32 1, ptr %23, align 4
  br label %116

61:                                               ; preds = %49
  br label %62

62:                                               ; preds = %61, %46
  %63 = load i8, ptr %18, align 1, !tbaa !11
  %64 = sext i8 %63 to i32
  switch i32 %64, label %93 [
    i32 115, label %65
    i32 109, label %75
    i32 97, label %79
    i32 99, label %83
  ]

65:                                               ; preds = %62
  %66 = load i32, ptr %11, align 4, !tbaa !5
  %67 = load i32, ptr %12, align 4, !tbaa !5
  %68 = load ptr, ptr %13, align 8, !tbaa !9
  %69 = load ptr, ptr %14, align 8, !tbaa !9
  %70 = load ptr, ptr %15, align 8, !tbaa !9
  %71 = load ptr, ptr %19, align 8, !tbaa !9
  %72 = load i8, ptr %17, align 1, !tbaa !11
  %73 = load i32, ptr %16, align 4, !tbaa !5
  %74 = call ptr @pslcluster(i32 noundef %66, i32 noundef %67, ptr noundef %68, ptr noundef %69, ptr noundef %70, ptr noundef %71, i8 noundef signext %72, i32 noundef %73)
  store ptr %74, ptr %20, align 8, !tbaa !9
  br label %93

75:                                               ; preds = %62
  %76 = load i32, ptr %21, align 4, !tbaa !5
  %77 = load ptr, ptr %19, align 8, !tbaa !9
  %78 = call ptr @pmlcluster(i32 noundef %76, ptr noundef %77)
  store ptr %78, ptr %20, align 8, !tbaa !9
  br label %93

79:                                               ; preds = %62
  %80 = load i32, ptr %21, align 4, !tbaa !5
  %81 = load ptr, ptr %19, align 8, !tbaa !9
  %82 = call ptr @palcluster(i32 noundef %80, ptr noundef %81)
  store ptr %82, ptr %20, align 8, !tbaa !9
  br label %93

83:                                               ; preds = %62
  %84 = load i32, ptr %11, align 4, !tbaa !5
  %85 = load i32, ptr %12, align 4, !tbaa !5
  %86 = load ptr, ptr %13, align 8, !tbaa !9
  %87 = load ptr, ptr %14, align 8, !tbaa !9
  %88 = load ptr, ptr %15, align 8, !tbaa !9
  %89 = load ptr, ptr %19, align 8, !tbaa !9
  %90 = load i8, ptr %17, align 1, !tbaa !11
  %91 = load i32, ptr %16, align 4, !tbaa !5
  %92 = call ptr @pclcluster(i32 noundef %84, i32 noundef %85, ptr noundef %86, ptr noundef %87, ptr noundef %88, ptr noundef %89, i8 noundef signext %90, i32 noundef %91)
  store ptr %92, ptr %20, align 8, !tbaa !9
  br label %93

93:                                               ; preds = %83, %79, %75, %65, %62
  %94 = load ptr, ptr @stdout, align 8, !tbaa !9
  %95 = call i32 @fflush(ptr noundef %94)
  %96 = load i32, ptr %22, align 4, !tbaa !5
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %98, label %114

98:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  store i32 1, ptr %24, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %109, %98
  %100 = load i32, ptr %24, align 4, !tbaa !5
  %101 = load i32, ptr %21, align 4, !tbaa !5
  %102 = icmp slt i32 %100, %101
  br i1 %102, label %103, label %112

103:                                              ; preds = %99
  %104 = load ptr, ptr %19, align 8, !tbaa !9
  %105 = load i32, ptr %24, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds ptr, ptr %104, i64 %106
  %108 = load ptr, ptr %107, align 8, !tbaa !9
  call void @free(ptr noundef %108) #4
  br label %109

109:                                              ; preds = %103
  %110 = load i32, ptr %24, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %24, align 4, !tbaa !5
  br label %99, !llvm.loop !12

112:                                              ; preds = %99
  %113 = load ptr, ptr %19, align 8, !tbaa !9
  call void @free(ptr noundef %113) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  br label %114

114:                                              ; preds = %112, %93
  %115 = load ptr, ptr %20, align 8, !tbaa !9
  store ptr %115, ptr %10, align 8
  store i32 1, ptr %23, align 4
  br label %116

116:                                              ; preds = %114, %60, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  %117 = load ptr, ptr %10, align 8
  ret ptr %117
}

; Function Attrs: nounwind uwtable
declare hidden ptr @pslcluster(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef signext, i32 noundef) #2

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @pclcluster(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef signext, i32 noundef) #2

declare i32 @fflush(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 }

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


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

@stdout = external local_unnamed_addr global ptr, align 8

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @distancematrix(i32 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef signext, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @treecluster(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i8 noundef signext %6, i8 noundef signext %7, ptr noundef %8) local_unnamed_addr #1 {
  %10 = icmp eq i32 %5, 0
  %11 = select i1 %10, i32 %0, i32 %1
  %12 = icmp eq ptr %8, null
  %13 = sext i8 %7 to i32
  %14 = icmp ne i8 %7, 115
  %15 = and i1 %14, %12
  %16 = icmp slt i32 %11, 2
  br i1 %16, label %36, label %17

17:                                               ; preds = %9
  br i1 %15, label %18, label %20

18:                                               ; preds = %17
  %19 = tail call ptr @distancematrix(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i8 noundef signext %6, i32 noundef %5)
  %.not = icmp eq ptr %19, null
  br i1 %.not, label %36, label %20

20:                                               ; preds = %18, %17
  %.045 = phi ptr [ %19, %18 ], [ %8, %17 ]
  %21 = add nsw i32 %13, -97
  %22 = tail call i32 @llvm.fshl.i32(i32 %21, i32 %21, i32 31)
  switch i32 %22, label %31 [
    i32 9, label %23
    i32 6, label %25
    i32 0, label %27
    i32 1, label %29
  ]

23:                                               ; preds = %20
  %24 = tail call ptr @pslcluster(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %.045, i8 noundef signext %6, i32 noundef %5)
  br label %31

25:                                               ; preds = %20
  %26 = tail call ptr @pmlcluster(i32 noundef %11, ptr noundef %.045)
  br label %31

27:                                               ; preds = %20
  %28 = tail call ptr @palcluster(i32 noundef %11, ptr noundef %.045)
  br label %31

29:                                               ; preds = %20
  %30 = tail call ptr @pclcluster(i32 noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %.045, i8 noundef signext %6, i32 noundef %5)
  br label %31

31:                                               ; preds = %29, %27, %25, %23, %20
  %.046 = phi ptr [ null, %20 ], [ %30, %29 ], [ %28, %27 ], [ %26, %25 ], [ %24, %23 ]
  %32 = load ptr, ptr @stdout, align 8, !tbaa !5
  %33 = tail call i32 @fflush(ptr noundef %32)
  br i1 %15, label %.lr.ph.preheader, label %36

.lr.ph.preheader:                                 ; preds = %31
  %wide.trip.count = zext nneg i32 %11 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %34 = getelementptr inbounds ptr, ptr %.045, i64 %indvars.iv
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  tail call void @free(ptr noundef %35) #4
  %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 %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph
  tail call void @free(ptr noundef nonnull %.045) #4
  br label %36

36:                                               ; preds = %31, %._crit_edge, %18, %9
  %.044 = phi ptr [ null, %9 ], [ null, %18 ], [ %.046, %._crit_edge ], [ %.046, %31 ]
  ret ptr %.044
}

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

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.fshl.i32(i32, i32, i32) #3

attributes #0 = { 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 #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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass