; LLVM IR from mickypaganini/SSI2016-jet-clustering :: spartyjet-4.0.2_mac/ExternalTools/AngularCorrelation.ll (ZN3ASF12KeyColToLeftEi)

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

%class.ASF = type { %struct.functiondata, %struct.functiondata, %struct.functiondata, %"class.std::vector", %"class.std::vector.14", %"class.std::vector.19", i32, i32, i32, double, double }
%struct.functiondata = type { [500 x double], [500 x double] }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<fastjet::PseudoJet, std::allocator<fastjet::PseudoJet>>::_Vector_impl" }
%"struct.std::_Vector_base<fastjet::PseudoJet, std::allocator<fastjet::PseudoJet>>::_Vector_impl" = type { %"struct.std::_Vector_base<fastjet::PseudoJet, std::allocator<fastjet::PseudoJet>>::_Vector_impl_data" }
%"struct.std::_Vector_base<fastjet::PseudoJet, std::allocator<fastjet::PseudoJet>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.14" = type { %"struct.std::_Vector_base.15" }
%"struct.std::_Vector_base.15" = type { %"struct.std::_Vector_base<particlepair, std::allocator<particlepair>>::_Vector_impl" }
%"struct.std::_Vector_base<particlepair, std::allocator<particlepair>>::_Vector_impl" = type { %"struct.std::_Vector_base<particlepair, std::allocator<particlepair>>::_Vector_impl_data" }
%"struct.std::_Vector_base<particlepair, std::allocator<particlepair>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.19" = type { %"struct.std::_Vector_base.20" }
%"struct.std::_Vector_base.20" = type { %"struct.std::_Vector_base<peak, std::allocator<peak>>::_Vector_impl" }
%"struct.std::_Vector_base<peak, std::allocator<peak>>::_Vector_impl" = type { %"struct.std::_Vector_base<peak, std::allocator<peak>>::_Vector_impl_data" }
%"struct.std::_Vector_base<peak, std::allocator<peak>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.peak = type { double, double, double, double, i32 }

; 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 nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN3ASF12KeyColToLeftEi(ptr noundef nonnull align 8 dereferenceable(24104) %0, i32 noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %13 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 -1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %14 = getelementptr inbounds %class.ASF, ptr %13, i32 0, i32 5
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %16) #2
  %18 = getelementptr inbounds %struct.peak, ptr %17, i32 0, i32 1
  %19 = load double, ptr %18, align 8, !tbaa !11
  store double %19, ptr %6, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %20 = load double, ptr %6, align 8, !tbaa !14
  store double %20, ptr %7, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = sub nsw i32 %21, 1
  store i32 %22, ptr %8, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %39, %2
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = icmp sge i32 %24, 0
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  store i32 2, ptr %9, align 4
  br label %42

27:                                               ; preds = %23
  %28 = getelementptr inbounds %class.ASF, ptr %13, i32 0, i32 5
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %30) #2
  %32 = getelementptr inbounds %struct.peak, ptr %31, i32 0, i32 1
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = load double, ptr %6, align 8, !tbaa !14
  %35 = fcmp ogt double %33, %34
  br i1 %35, label %36, label %38

36:                                               ; preds = %27
  %37 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %37, ptr %5, align 4, !tbaa !9
  store i32 2, ptr %9, align 4
  br label %42

38:                                               ; preds = %27
  br label %39

39:                                               ; preds = %38
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = add nsw i32 %40, -1
  store i32 %41, ptr %8, align 4, !tbaa !9
  br label %23, !llvm.loop !15

42:                                               ; preds = %36, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = icmp ne i32 %44, -1
  br i1 %45, label %46, label %87

46:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %47 = getelementptr inbounds %class.ASF, ptr %13, i32 0, i32 5
  %48 = load i32, ptr %4, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %47, i64 noundef %49) #2
  %51 = getelementptr inbounds %struct.peak, ptr %50, i32 0, i32 4
  %52 = load i32, ptr %51, align 8, !tbaa !17
  store i32 %52, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %53 = getelementptr inbounds %class.ASF, ptr %13, i32 0, i32 5
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %53, i64 noundef %55) #2
  %57 = getelementptr inbounds %struct.peak, ptr %56, i32 0, i32 4
  %58 = load i32, ptr %57, align 8, !tbaa !17
  store i32 %58, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %12, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %83, %46
  %62 = load i32, ptr %12, align 4, !tbaa !9
  %63 = load i32, ptr %10, align 4, !tbaa !9
  %64 = icmp slt i32 %62, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %61
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  br label %86

66:                                               ; preds = %61
  %67 = getelementptr inbounds %class.ASF, ptr %13, i32 0, i32 0
  %68 = getelementptr inbounds %struct.functiondata, ptr %67, i32 0, i32 1
  %69 = load i32, ptr %12, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [500 x double], ptr %68, i64 0, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !14
  %73 = load double, ptr %7, align 8, !tbaa !14
  %74 = fcmp olt double %72, %73
  br i1 %74, label %75, label %82

75:                                               ; preds = %66
  %76 = getelementptr inbounds %class.ASF, ptr %13, i32 0, i32 0
  %77 = getelementptr inbounds %struct.functiondata, ptr %76, i32 0, i32 1
  %78 = load i32, ptr %12, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [500 x double], ptr %77, i64 0, i64 %79
  %81 = load double, ptr %80, align 8, !tbaa !14
  store double %81, ptr %7, align 8, !tbaa !14
  br label %82

82:                                               ; preds = %75, %66
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %12, align 4, !tbaa !9
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %12, align 4, !tbaa !9
  br label %61, !llvm.loop !18

86:                                               ; preds = %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %88

87:                                               ; preds = %43
  store double 0.000000e+00, ptr %7, align 8, !tbaa !14
  br label %88

88:                                               ; preds = %87, %86
  %89 = load double, ptr %7, align 8, !tbaa !14
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret double %89
}

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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"_ZTS4peak", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !10, i64 32}
!13 = !{!"double", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !10, i64 32}
!18 = distinct !{!18, !16}


; 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 nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN3ASF12KeyColToLeftEi(ptr noundef nonnull align 8 dereferenceable(24104) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24048
  %4 = sext i32 %1 to i64
  %5 = tail call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %4) #1
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = zext i32 %1 to i64
  br label %9

9:                                                ; preds = %12, %2
  %indvars.iv = phi i64 [ %13, %12 ], [ %8, %2 ]
  %10 = trunc nuw i64 %indvars.iv to i32
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %12, label %.thread

12:                                               ; preds = %9
  %13 = add nsw i64 %indvars.iv, -1
  %14 = tail call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %13) #1
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fcmp ogt double %16, %7
  br i1 %17, label %18, label %9, !llvm.loop !11

18:                                               ; preds = %12
  %19 = tail call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %4) #1
  %20 = getelementptr inbounds i8, ptr %19, i64 32
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %22 = and i64 %13, 4294967295
  %23 = tail call noundef nonnull align 8 dereferenceable(40) ptr @_ZNSt6vectorI4peakSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %22) #1
  %24 = getelementptr inbounds i8, ptr %23, i64 32
  %25 = load i32, ptr %24, align 8, !tbaa !13
  %.027 = add nsw i32 %25, 1
  %26 = icmp slt i32 %.027, %21
  br i1 %26, label %.lr.ph, label %.thread

.lr.ph:                                           ; preds = %18
  %27 = getelementptr inbounds i8, ptr %0, i64 4000
  %28 = sext i32 %25 to i64
  %29 = add nsw i64 %28, 1
  %30 = xor i32 %25, -1
  %31 = add i32 %21, %30
  %32 = add i32 %21, -2
  %33 = sub i32 %32, %25
  %xtraiter = and i32 %31, 3
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.preheader

.prol.preheader:                                  ; preds = %.lr.ph, %.prol.preheader
  %indvars.iv33.prol = phi i64 [ %indvars.iv.next34.prol, %.prol.preheader ], [ %29, %.lr.ph ]
  %.02028.prol = phi double [ %.1.prol, %.prol.preheader ], [ %7, %.lr.ph ]
  %prol.iter = phi i32 [ %prol.iter.next, %.prol.preheader ], [ 0, %.lr.ph ]
  %34 = getelementptr inbounds [500 x double], ptr %27, i64 0, i64 %indvars.iv33.prol
  %35 = load double, ptr %34, align 8, !tbaa !14
  %36 = fcmp olt double %35, %.02028.prol
  %.1.prol = select i1 %36, double %35, double %.02028.prol
  %indvars.iv.next34.prol = add nsw i64 %indvars.iv33.prol, 1
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.prol.loopexit, label %.prol.preheader, !llvm.loop !15

.prol.loopexit:                                   ; preds = %.prol.preheader, %.lr.ph
  %.1.lcssa.unr = phi double [ poison, %.lr.ph ], [ %.1.prol, %.prol.preheader ]
  %indvars.iv33.unr = phi i64 [ %29, %.lr.ph ], [ %indvars.iv.next34.prol, %.prol.preheader ]
  %.02028.unr = phi double [ %7, %.lr.ph ], [ %.1.prol, %.prol.preheader ]
  %37 = icmp ult i32 %33, 3
  br i1 %37, label %.thread, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.prol.loopexit, %.lr.ph.new
  %indvars.iv33 = phi i64 [ %indvars.iv.next34.3, %.lr.ph.new ], [ %indvars.iv33.unr, %.prol.loopexit ]
  %.02028 = phi double [ %.1.3, %.lr.ph.new ], [ %.02028.unr, %.prol.loopexit ]
  %38 = getelementptr inbounds [500 x double], ptr %27, i64 0, i64 %indvars.iv33
  %39 = load double, ptr %38, align 8, !tbaa !14
  %40 = fcmp olt double %39, %.02028
  %.1 = select i1 %40, double %39, double %.02028
  %indvars.iv.next34 = add nsw i64 %indvars.iv33, 1
  %41 = getelementptr inbounds [500 x double], ptr %27, i64 0, i64 %indvars.iv.next34
  %42 = load double, ptr %41, align 8, !tbaa !14
  %43 = fcmp olt double %42, %.1
  %.1.1 = select i1 %43, double %42, double %.1
  %indvars.iv.next34.1 = add nsw i64 %indvars.iv33, 2
  %44 = getelementptr inbounds [500 x double], ptr %27, i64 0, i64 %indvars.iv.next34.1
  %45 = load double, ptr %44, align 8, !tbaa !14
  %46 = fcmp olt double %45, %.1.1
  %.1.2 = select i1 %46, double %45, double %.1.1
  %indvars.iv.next34.2 = add nsw i64 %indvars.iv33, 3
  %47 = getelementptr inbounds [500 x double], ptr %27, i64 0, i64 %indvars.iv.next34.2
  %48 = load double, ptr %47, align 8, !tbaa !14
  %49 = fcmp olt double %48, %.1.2
  %.1.3 = select i1 %49, double %48, double %.1.2
  %indvars.iv.next34.3 = add nsw i64 %indvars.iv33, 4
  %lftr.wideiv.3 = trunc i64 %indvars.iv.next34.3 to i32
  %exitcond.not.3 = icmp eq i32 %21, %lftr.wideiv.3
  br i1 %exitcond.not.3, label %.thread, label %.lr.ph.new, !llvm.loop !17

.thread:                                          ; preds = %9, %.prol.loopexit, %.lr.ph.new, %18
  %.2 = phi double [ %7, %18 ], [ %.1.lcssa.unr, %.prol.loopexit ], [ %.1.3, %.lr.ph.new ], [ 0.000000e+00, %9 ]
  ret double %.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 = { 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 8}
!6 = !{!"_ZTS4peak", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!6, !10, i64 32}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}
!17 = distinct !{!17, !12}


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