; LLVM IR from vmartinv/eldiego :: grafos/centroid.ll (Z3lcaii)

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

@f = external dso_local global [100100 x [20 x i32]], align 16
@L = external dso_local global [100100 x i32], align 16

; 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: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5climbii(i32 noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.ctlz.i32(i32, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z3lcaii(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [100100 x i32], ptr @L, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [100100 x i32], ptr @L, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = icmp slt i32 %10, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %2
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5) #4
  br label %17

17:                                               ; preds = %16, %2
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [100100 x i32], ptr @L, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [100100 x i32], ptr @L, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = sub nsw i32 %22, %26
  %28 = call noundef i32 @_Z5climbii(i32 noundef %18, i32 noundef %27)
  store i32 %28, ptr %4, align 4, !tbaa !5
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = icmp eq i32 %29, %30
  br i1 %31, label %32, label %34

32:                                               ; preds = %17
  %33 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %33, ptr %3, align 4
  br label %88

34:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100100 x i32], ptr @L, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = call i32 @llvm.ctlz.i32(i32 %38, i1 true)
  %40 = sub nsw i32 31, %39
  %41 = add nsw i32 %40, 1
  %42 = sub nsw i32 %41, 1
  store i32 %42, ptr %6, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %79, %34
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = icmp sge i32 %44, 0
  br i1 %45, label %47, label %46

46:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %82

47:                                               ; preds = %43
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [100100 x [20 x i32]], ptr @f, i64 0, i64 %49
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [20 x i32], ptr %50, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [100100 x [20 x i32]], ptr @f, i64 0, i64 %56
  %58 = load i32, ptr %6, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [20 x i32], ptr %57, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = icmp ne i32 %54, %61
  br i1 %62, label %63, label %78

63:                                               ; preds = %47
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100100 x [20 x i32]], ptr @f, i64 0, i64 %65
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [20 x i32], ptr %66, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  store i32 %70, ptr %4, align 4, !tbaa !5
  %71 = load i32, ptr %5, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [100100 x [20 x i32]], ptr @f, i64 0, i64 %72
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [20 x i32], ptr %73, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  store i32 %77, ptr %5, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %63, %47
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = add nsw i32 %80, -1
  store i32 %81, ptr %6, align 4, !tbaa !5
  br label %43, !llvm.loop !9

82:                                               ; preds = %46
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100100 x [20 x i32]], ptr @f, i64 0, i64 %84
  %86 = getelementptr inbounds [20 x i32], ptr %85, i64 0, i64 0
  %87 = load i32, ptr %86, align 16, !tbaa !5
  store i32 %87, ptr %3, align 4
  br label %88

88:                                               ; preds = %82, %32
  %89 = load i32, ptr %3, align 4
  ret i32 %89
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

!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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"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"

@f = external dso_local local_unnamed_addr global [100100 x [20 x i32]], align 16
@L = external dso_local local_unnamed_addr global [100100 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5climbii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.ctlz.i32(i32, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z3lcaii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %5 = sext i32 %0 to i64
  %6 = getelementptr inbounds [100100 x i32], ptr @L, i64 0, i64 %5
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = sext i32 %1 to i64
  %9 = getelementptr inbounds [100100 x i32], ptr @L, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = icmp slt i32 %7, %10
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4) #3
  %.pre = load i32, ptr %3, align 4, !tbaa !5
  %.phi.trans.insert = sext i32 %.pre to i64
  %.phi.trans.insert13 = getelementptr inbounds [100100 x i32], ptr @L, i64 0, i64 %.phi.trans.insert
  %.pre14 = load i32, ptr %.phi.trans.insert13, align 4, !tbaa !5
  %.pre15 = load i32, ptr %4, align 4, !tbaa !5
  %.phi.trans.insert16 = sext i32 %.pre15 to i64
  %.phi.trans.insert17 = getelementptr inbounds [100100 x i32], ptr @L, i64 0, i64 %.phi.trans.insert16
  %.pre18 = load i32, ptr %.phi.trans.insert17, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %12, %2
  %14 = phi i32 [ %.pre18, %12 ], [ %10, %2 ]
  %15 = phi i32 [ %.pre14, %12 ], [ %7, %2 ]
  %16 = phi i32 [ %.pre, %12 ], [ %0, %2 ]
  %17 = sub nsw i32 %15, %14
  %18 = call noundef i32 @_Z5climbii(i32 noundef %16, i32 noundef %17)
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = icmp eq i32 %18, %19
  br i1 %20, label %50, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %13
  %21 = sext i32 %18 to i64
  %22 = getelementptr inbounds [100100 x i32], ptr @L, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = call range(i32 0, 33) i32 @llvm.ctlz.i32(i32 %23, i1 true)
  %25 = xor i32 %24, 31
  %26 = zext nneg i32 %25 to i64
  %27 = and i64 %26, 1
  %lcmp.mod.not.not = icmp eq i64 %27, 0
  br i1 %lcmp.mod.not.not, label %.lr.ph.prol, label %.lr.ph.prol.loopexit

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader
  %28 = sext i32 %18 to i64
  %29 = getelementptr inbounds [100100 x [20 x i32]], ptr @f, i64 0, i64 %28, i64 %26
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = sext i32 %19 to i64
  %32 = getelementptr inbounds [100100 x [20 x i32]], ptr @f, i64 0, i64 %31, i64 %26
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %.not.prol = icmp eq i32 %30, %33
  %spec.select.prol = select i1 %.not.prol, i32 %19, i32 %33
  %spec.select24.prol = select i1 %.not.prol, i32 %18, i32 %30
  %indvars.iv.next.prol = add nsw i64 %26, -1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ %26, %.lr.ph.preheader ], [ %indvars.iv.next.prol, %.lr.ph.prol ]
  %.unr = phi i32 [ %18, %.lr.ph.preheader ], [ %spec.select24.prol, %.lr.ph.prol ]
  %.unr25 = phi i32 [ %19, %.lr.ph.preheader ], [ %spec.select.prol, %.lr.ph.prol ]
  %spec.select24.lcssa.unr = phi i32 [ poison, %.lr.ph.preheader ], [ %spec.select24.prol, %.lr.ph.prol ]
  %34 = icmp eq i32 %24, 31
  br i1 %34, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph.prol.loopexit
  %spec.select24.lcssa = phi i32 [ %spec.select24.lcssa.unr, %.lr.ph.prol.loopexit ], [ %spec.select24.1, %.lr.ph ]
  %.pre19 = sext i32 %spec.select24.lcssa to i64
  %.phi.trans.insert20 = getelementptr inbounds [100100 x [20 x i32]], ptr @f, i64 0, i64 %.pre19
  %.pre21 = load i32, ptr %.phi.trans.insert20, align 16, !tbaa !5
  br label %50

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph ], [ %indvars.iv.unr, %.lr.ph.prol.loopexit ]
  %35 = phi i32 [ %spec.select24.1, %.lr.ph ], [ %.unr, %.lr.ph.prol.loopexit ]
  %36 = phi i32 [ %spec.select.1, %.lr.ph ], [ %.unr25, %.lr.ph.prol.loopexit ]
  %37 = sext i32 %35 to i64
  %38 = getelementptr inbounds [100100 x [20 x i32]], ptr @f, i64 0, i64 %37, i64 %indvars.iv
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = sext i32 %36 to i64
  %41 = getelementptr inbounds [100100 x [20 x i32]], ptr @f, i64 0, i64 %40, i64 %indvars.iv
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %.not = icmp eq i32 %39, %42
  %spec.select = select i1 %.not, i32 %36, i32 %42
  %spec.select24 = select i1 %.not, i32 %35, i32 %39
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %43 = sext i32 %spec.select24 to i64
  %44 = getelementptr inbounds [100100 x [20 x i32]], ptr @f, i64 0, i64 %43, i64 %indvars.iv.next
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = sext i32 %spec.select to i64
  %47 = getelementptr inbounds [100100 x [20 x i32]], ptr @f, i64 0, i64 %46, i64 %indvars.iv.next
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %.not.1 = icmp eq i32 %45, %48
  %spec.select.1 = select i1 %.not.1, i32 %spec.select, i32 %48
  %spec.select24.1 = select i1 %.not.1, i32 %spec.select24, i32 %45
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, -2
  %49 = icmp sgt i64 %indvars.iv, 1
  br i1 %49, label %.lr.ph, label %._crit_edge, !llvm.loop !9

50:                                               ; preds = %13, %._crit_edge
  %.07 = phi i32 [ %.pre21, %._crit_edge ], [ %18, %13 ]
  ret i32 %.07
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

attributes #0 = { mustprogress 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 speculatable willreturn memory(none) }
attributes #2 = { inlinehint mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass