; LLVM IR from GGiecold-zz/Cluster_Ensembles :: src/Cluster_Ensembles/Hypergraph_Partitioning/metis-5.1.0/libmetis (gklib)

; 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.rkv_t = type { float, i32 }

@.str = external hidden unnamed_addr constant [18 x i8], align 1

; 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

declare void @gk_free(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @libmetis__rargmax_n(i64 noundef %0, ptr noundef %1, i64 noundef %2) #2 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %10 = load i64, ptr %4, align 8, !tbaa !5
  %11 = call ptr @libmetis__rkvmalloc(i64 noundef %10, ptr noundef @.str)
  store ptr %11, ptr %9, align 8, !tbaa !9
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %31, %3
  %13 = load i64, ptr %7, align 8, !tbaa !5
  %14 = load i64, ptr %4, align 8, !tbaa !5
  %15 = icmp ult i64 %13, %14
  br i1 %15, label %16, label %34

16:                                               ; preds = %12
  %17 = load i64, ptr %7, align 8, !tbaa !5
  %18 = trunc i64 %17 to i32
  %19 = load ptr, ptr %9, align 8, !tbaa !9
  %20 = load i64, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.rkv_t, ptr %19, i64 %20
  %22 = getelementptr inbounds %struct.rkv_t, ptr %21, i32 0, i32 1
  store i32 %18, ptr %22, align 4, !tbaa !11
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = load i64, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds float, ptr %23, i64 %24
  %26 = load float, ptr %25, align 4, !tbaa !15
  %27 = load ptr, ptr %9, align 8, !tbaa !9
  %28 = load i64, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.rkv_t, ptr %27, i64 %28
  %30 = getelementptr inbounds %struct.rkv_t, ptr %29, i32 0, i32 0
  store float %26, ptr %30, align 4, !tbaa !16
  br label %31

31:                                               ; preds = %16
  %32 = load i64, ptr %7, align 8, !tbaa !5
  %33 = add i64 %32, 1
  store i64 %33, ptr %7, align 8, !tbaa !5
  br label %12, !llvm.loop !17

34:                                               ; preds = %12
  %35 = load i64, ptr %4, align 8, !tbaa !5
  %36 = load ptr, ptr %9, align 8, !tbaa !9
  call void @libmetis__rkvsortd(i64 noundef %35, ptr noundef %36)
  %37 = load ptr, ptr %9, align 8, !tbaa !9
  %38 = load i64, ptr %6, align 8, !tbaa !5
  %39 = sub i64 %38, 1
  %40 = getelementptr inbounds %struct.rkv_t, ptr %37, i64 %39
  %41 = getelementptr inbounds %struct.rkv_t, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 4, !tbaa !11
  %43 = sext i32 %42 to i64
  store i64 %43, ptr %8, align 8, !tbaa !5
  call void (ptr, ...) @gk_free(ptr noundef %9, ptr noundef null)
  %44 = load i64, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i64 %44
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @libmetis__rkvmalloc(i64 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @libmetis__rkvsortd(i64 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = !{!"long", !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, !14, i64 4}
!12 = !{!"", !13, i64 0, !14, i64 4}
!13 = !{!"float", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !13, i64 0}
!16 = !{!12, !13, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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"

%struct.rkv_t = type { float, i32 }

@.str = external hidden unnamed_addr constant [18 x i8], align 1

; 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

declare void @gk_free(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i64 -2147483648, 2147483648) i64 @libmetis__rargmax_n(i64 noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #2 {
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %5 = tail call ptr @libmetis__rkvmalloc(i64 noundef %0, ptr noundef nonnull @.str)
  store ptr %5, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i64 %0, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %min.iters.check = icmp ult i64 %0, 12
  br i1 %min.iters.check, label %.lr.ph.preheader17, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %6 = shl i64 %0, 3
  %7 = getelementptr i8, ptr %5, i64 %6
  %scevgep = getelementptr i8, ptr %7, i64 -4
  %8 = shl i64 %0, 2
  %scevgep13 = getelementptr i8, ptr %1, i64 %8
  %bound0 = icmp ult ptr %5, %scevgep13
  %bound1 = icmp ugt ptr %scevgep, %1
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %.lr.ph.preheader17, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %0, -4
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <2 x i32> [ <i32 0, i32 1>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <2 x i32> %vec.ind, <i32 2, i32 2>
  %9 = or disjoint i64 %index, 2
  %10 = getelementptr inbounds float, ptr %1, i64 %index
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %wide.load = load <2 x float>, ptr %10, align 4, !tbaa !9, !alias.scope !11
  %wide.load15 = load <2 x float>, ptr %11, align 4, !tbaa !9, !alias.scope !11
  %12 = getelementptr inbounds %struct.rkv_t, ptr %5, i64 %index
  %13 = getelementptr inbounds %struct.rkv_t, ptr %5, i64 %9
  %14 = bitcast <2 x i32> %vec.ind to <2 x float>
  %interleaved.vec = shufflevector <2 x float> %wide.load, <2 x float> %14, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec, ptr %12, align 4, !tbaa !14
  %15 = bitcast <2 x i32> %step.add to <2 x float>
  %interleaved.vec16 = shufflevector <2 x float> %wide.load15, <2 x float> %15, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %interleaved.vec16, ptr %13, align 4, !tbaa !14
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <2 x i32> %vec.ind, <i32 4, i32 4>
  %16 = icmp eq i64 %index.next, %n.vec
  br i1 %16, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %0
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader17

.lr.ph.preheader17:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %.012.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %0, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader17, %.lr.ph.prol
  %.012.prol = phi i64 [ %22, %.lr.ph.prol ], [ %.012.ph, %.lr.ph.preheader17 ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader17 ]
  %17 = trunc i64 %.012.prol to i32
  %18 = getelementptr inbounds %struct.rkv_t, ptr %5, i64 %.012.prol, i32 1
  store i32 %17, ptr %18, align 4, !tbaa !19
  %19 = getelementptr inbounds float, ptr %1, i64 %.012.prol
  %20 = load float, ptr %19, align 4, !tbaa !9
  %21 = getelementptr inbounds %struct.rkv_t, ptr %5, i64 %.012.prol
  store float %20, ptr %21, align 4, !tbaa !22
  %22 = add nuw i64 %.012.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !23

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader17
  %.012.unr = phi i64 [ %.012.ph, %.lr.ph.preheader17 ], [ %22, %.lr.ph.prol ]
  %23 = sub i64 %.012.ph, %0
  %24 = icmp ugt i64 %23, -4
  br i1 %24, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.012 = phi i64 [ %48, %.lr.ph ], [ %.012.unr, %.lr.ph.prol.loopexit ]
  %25 = trunc i64 %.012 to i32
  %26 = getelementptr inbounds %struct.rkv_t, ptr %5, i64 %.012, i32 1
  store i32 %25, ptr %26, align 4, !tbaa !19
  %27 = getelementptr inbounds float, ptr %1, i64 %.012
  %28 = load float, ptr %27, align 4, !tbaa !9
  %29 = getelementptr inbounds %struct.rkv_t, ptr %5, i64 %.012
  store float %28, ptr %29, align 4, !tbaa !22
  %30 = add nuw i64 %.012, 1
  %31 = trunc i64 %30 to i32
  %32 = getelementptr inbounds %struct.rkv_t, ptr %5, i64 %30, i32 1
  store i32 %31, ptr %32, align 4, !tbaa !19
  %33 = getelementptr inbounds float, ptr %1, i64 %30
  %34 = load float, ptr %33, align 4, !tbaa !9
  %35 = getelementptr inbounds %struct.rkv_t, ptr %5, i64 %30
  store float %34, ptr %35, align 4, !tbaa !22
  %36 = add nuw i64 %.012, 2
  %37 = trunc i64 %36 to i32
  %38 = getelementptr inbounds %struct.rkv_t, ptr %5, i64 %36, i32 1
  store i32 %37, ptr %38, align 4, !tbaa !19
  %39 = getelementptr inbounds float, ptr %1, i64 %36
  %40 = load float, ptr %39, align 4, !tbaa !9
  %41 = getelementptr inbounds %struct.rkv_t, ptr %5, i64 %36
  store float %40, ptr %41, align 4, !tbaa !22
  %42 = add nuw i64 %.012, 3
  %43 = trunc i64 %42 to i32
  %44 = getelementptr inbounds %struct.rkv_t, ptr %5, i64 %42, i32 1
  store i32 %43, ptr %44, align 4, !tbaa !19
  %45 = getelementptr inbounds float, ptr %1, i64 %42
  %46 = load float, ptr %45, align 4, !tbaa !9
  %47 = getelementptr inbounds %struct.rkv_t, ptr %5, i64 %42
  store float %46, ptr %47, align 4, !tbaa !22
  %48 = add nuw i64 %.012, 4
  %exitcond.not.3 = icmp eq i64 %48, %0
  br i1 %exitcond.not.3, label %._crit_edge, label %.lr.ph, !llvm.loop !25

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %3
  tail call void @libmetis__rkvsortd(i64 noundef %0, ptr noundef %5)
  %49 = getelementptr %struct.rkv_t, ptr %5, i64 %2
  %50 = getelementptr i8, ptr %49, i64 -4
  %51 = load i32, ptr %50, align 4, !tbaa !19
  %52 = sext i32 %51 to i64
  call void (ptr, ...) @gk_free(ptr noundef nonnull %4, ptr noundef null) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i64 %52
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @libmetis__rkvmalloc(i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @libmetis__rkvsortd(i64 noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12}
!12 = distinct !{!12, !13}
!13 = distinct !{!13, !"LVerDomain"}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16, !17, !18}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.isvectorized", i32 1}
!18 = !{!"llvm.loop.unroll.runtime.disable"}
!19 = !{!20, !21, i64 4}
!20 = !{!"", !10, i64 0, !21, i64 4}
!21 = !{!"int", !7, i64 0}
!22 = !{!20, !10, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.unroll.disable"}
!25 = distinct !{!25, !16, !17}


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