; LLVM IR from mickypaganini/SSI2016-jet-clustering :: spartyjet-4.0.2_mac/External/fastjet-3.0.0/plugins/SISCone/siscone/siscone/sph_96e5c6a3 (conesC2Eid)

; 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.siscone_spherical::sph_hash_cones" = type { ptr, i32, i32, double, double }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN17siscone_spherical14sph_hash_conesC2Eid(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1, double noundef %2) unnamed_addr #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !11
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %10 = getelementptr inbounds %"class.siscone_spherical::sph_hash_cones", ptr %9, i32 0, i32 1
  store i32 0, ptr %10, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = sitofp i32 %11 to double
  %13 = load double, ptr %6, align 8, !tbaa !11
  %14 = fmul double %12, %13
  %15 = load double, ptr %6, align 8, !tbaa !11
  %16 = fmul double %14, %15
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = sitofp i32 %17 to double
  %19 = fmul double %16, %18
  %20 = fdiv double %19, 4.000000e+00
  %21 = call double @log(double noundef %20) #5
  %22 = call double @log(double noundef 2.000000e+00) #5
  %23 = fdiv double %21, %22
  %24 = fptosi double %23 to i32
  store i32 %24, ptr %8, align 4, !tbaa !9
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = icmp slt i32 %25, 1
  br i1 %26, label %27, label %28

27:                                               ; preds = %3
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %27, %3
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = shl i32 1, %29
  %31 = getelementptr inbounds %"class.siscone_spherical::sph_hash_cones", ptr %9, i32 0, i32 2
  store i32 %30, ptr %31, align 4, !tbaa !15
  %32 = getelementptr inbounds %"class.siscone_spherical::sph_hash_cones", ptr %9, i32 0, i32 2
  %33 = load i32, ptr %32, align 4, !tbaa !15
  %34 = sext i32 %33 to i64
  %35 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %34, i64 8)
  %36 = extractvalue { i64, i1 } %35, 1
  %37 = extractvalue { i64, i1 } %35, 0
  %38 = select i1 %36, i64 -1, i64 %37
  %39 = call noalias noundef nonnull ptr @_Znam(i64 noundef %38) #6
  %40 = getelementptr inbounds %"class.siscone_spherical::sph_hash_cones", ptr %9, i32 0, i32 0
  store ptr %39, ptr %40, align 8, !tbaa !16
  %41 = getelementptr inbounds %"class.siscone_spherical::sph_hash_cones", ptr %9, i32 0, i32 2
  %42 = load i32, ptr %41, align 4, !tbaa !15
  %43 = add nsw i32 %42, -1
  store i32 %43, ptr %41, align 4, !tbaa !15
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %56, %28
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = getelementptr inbounds %"class.siscone_spherical::sph_hash_cones", ptr %9, i32 0, i32 2
  %47 = load i32, ptr %46, align 4, !tbaa !15
  %48 = add nsw i32 %47, 1
  %49 = icmp slt i32 %45, %48
  br i1 %49, label %50, label %59

50:                                               ; preds = %44
  %51 = getelementptr inbounds %"class.siscone_spherical::sph_hash_cones", ptr %9, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = load i32, ptr %7, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds ptr, ptr %52, i64 %54
  store ptr null, ptr %55, align 8, !tbaa !5
  br label %56

56:                                               ; preds = %50
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %7, align 4, !tbaa !9
  br label %44, !llvm.loop !17

59:                                               ; preds = %44
  %60 = load double, ptr %6, align 8, !tbaa !11
  %61 = call double @tan(double noundef %60) #5
  %62 = getelementptr inbounds %"class.siscone_spherical::sph_hash_cones", ptr %9, i32 0, i32 4
  store double %61, ptr %62, align 8, !tbaa !19
  %63 = getelementptr inbounds %"class.siscone_spherical::sph_hash_cones", ptr %9, i32 0, i32 4
  %64 = load double, ptr %63, align 8, !tbaa !19
  %65 = getelementptr inbounds %"class.siscone_spherical::sph_hash_cones", ptr %9, i32 0, i32 4
  %66 = load double, ptr %65, align 8, !tbaa !19
  %67 = fmul double %66, %64
  store double %67, ptr %65, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare double @log(double noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #4

; Function Attrs: nounwind
declare double @tan(double noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { mustprogress 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 willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { nobuiltin allocsize(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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }

!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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTSN17siscone_spherical14sph_hash_conesE", !6, i64 0, !10, i64 8, !10, i64 12, !12, i64 16, !12, i64 24}
!15 = !{!14, !10, i64 12}
!16 = !{!14, !6, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!14, !12, i64 24}


; 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 uwtable
define dso_local void @_ZN17siscone_spherical14sph_hash_conesC2Eid(ptr nocapture noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1, double noundef %2) unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 0, ptr %4, align 8, !tbaa !5
  %5 = sitofp i32 %1 to double
  %6 = fmul double %5, %2
  %7 = fmul double %6, %2
  %8 = fmul double %7, %5
  %9 = fmul double %8, 2.500000e-01
  %10 = tail call double @log(double noundef %9) #4
  %11 = fdiv double %10, 0x3FE62E42FEFA39EF
  %12 = fptosi double %11 to i32
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %12, i32 1)
  %13 = shl nuw i32 1, %spec.store.select
  %14 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %13, ptr %14, align 4, !tbaa !12
  %15 = sext i32 %13 to i64
  %16 = icmp eq i32 %12, 31
  %17 = shl nsw i64 %15, 3
  %18 = select i1 %16, i64 -1, i64 %17
  %19 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %18) #5
  store ptr %19, ptr %0, align 8, !tbaa !13
  %20 = add nsw i32 %13, -1
  store i32 %20, ptr %14, align 4, !tbaa !12
  br i1 %16, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %smax = tail call i32 @llvm.smax.i32(i32 %13, i32 1)
  %wide.trip.count = zext nneg i32 %smax to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %21 = icmp slt i32 %13, 4
  br i1 %21, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %22 = load ptr, ptr %0, align 8, !tbaa !13
  %23 = getelementptr inbounds ptr, ptr %22, i64 %indvars.iv
  store ptr null, ptr %23, align 8, !tbaa !14
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %24 = load ptr, ptr %0, align 8, !tbaa !13
  %25 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv.next
  store ptr null, ptr %25, align 8, !tbaa !14
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %26 = load ptr, ptr %0, align 8, !tbaa !13
  %27 = getelementptr inbounds ptr, ptr %26, i64 %indvars.iv.next.1
  store ptr null, ptr %27, align 8, !tbaa !14
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %28 = load ptr, ptr %0, align 8, !tbaa !13
  %29 = getelementptr inbounds ptr, ptr %28, i64 %indvars.iv.next.2
  store ptr null, ptr %29, align 8, !tbaa !14
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !15

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %30 = load ptr, ptr %0, align 8, !tbaa !13
  %31 = getelementptr inbounds ptr, ptr %30, i64 %indvars.iv.epil
  store ptr null, ptr %31, align 8, !tbaa !14
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !17

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %3
  %32 = tail call double @tan(double noundef %2) #4
  %33 = getelementptr inbounds i8, ptr %0, i64 24
  %34 = fmul double %32, %32
  store double %34, ptr %33, align 8, !tbaa !19
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log(double noundef) local_unnamed_addr #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @tan(double noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress 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 nofree nounwind willreturn memory(write) "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 = { nobuiltin allocsize(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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }
attributes #5 = { builtin allocsize(0) }

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


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