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

; 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.std::allocator" = type { i8 }
%"class.DetectorModel::Grid" = type { ptr, %"class.std::vector", i64, i64, i64, double, double, double, double, double }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZTVN13DetectorModel4GridE = external dso_local unnamed_addr constant { [27 x 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIdEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13DetectorModel4GridC2Emddm(ptr noundef nonnull align 8 dereferenceable(96) %0, i64 noundef %1, double noundef %2, double noundef %3, i64 noundef %4) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i64, align 8
  %11 = alloca double, align 8
  %12 = alloca %"class.std::allocator", align 1
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store double %2, ptr %8, align 8, !tbaa !11
  store double %3, ptr %9, align 8, !tbaa !11
  store i64 %4, ptr %10, align 8, !tbaa !9
  %15 = load ptr, ptr %6, align 8
  store ptr getelementptr inbounds inrange(-16, 200) ({ [27 x ptr] }, ptr @_ZTVN13DetectorModel4GridE, i32 0, i32 0, i32 2), ptr %15, align 8, !tbaa !13
  %16 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 1
  %17 = load i64, ptr %7, align 8, !tbaa !9
  %18 = load i64, ptr %10, align 8, !tbaa !9
  %19 = mul i64 %17, %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store double 0.000000e+00, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  call void @_ZNSaIdEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %12) #4
  invoke void @_ZNSt6vectorIdSaIdEEC2EmRKdRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %19, ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 1 dereferenceable(1) %12)
          to label %20 unwind label %69

20:                                               ; preds = %5
  call void @_ZNSt15__new_allocatorIdED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %12) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  %21 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 2
  %22 = load i64, ptr %7, align 8, !tbaa !9
  %23 = load i64, ptr %10, align 8, !tbaa !9
  %24 = mul i64 %22, %23
  store i64 %24, ptr %21, align 8, !tbaa !15
  %25 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 3
  %26 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %26, ptr %25, align 8, !tbaa !21
  %27 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 4
  %28 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %28, ptr %27, align 8, !tbaa !22
  %29 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 5
  %30 = load double, ptr %8, align 8, !tbaa !11
  store double %30, ptr %29, align 8, !tbaa !23
  %31 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 6
  %32 = load double, ptr %9, align 8, !tbaa !11
  store double %32, ptr %31, align 8, !tbaa !24
  %33 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 7
  store double 0.000000e+00, ptr %33, align 8, !tbaa !25
  %34 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 8
  store double 0.000000e+00, ptr %34, align 8, !tbaa !26
  %35 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 9
  %36 = call double @asin(double noundef 1.000000e+00) #4
  %37 = fmul double 4.000000e+00, %36
  store double %37, ptr %35, align 8, !tbaa !27
  %38 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 3
  %39 = load i64, ptr %38, align 8, !tbaa !21
  %40 = icmp ne i64 %39, 0
  br i1 %40, label %41, label %51

41:                                               ; preds = %20
  %42 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 6
  %43 = load double, ptr %42, align 8, !tbaa !24
  %44 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 5
  %45 = load double, ptr %44, align 8, !tbaa !23
  %46 = fsub double %43, %45
  %47 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 3
  %48 = load i64, ptr %47, align 8, !tbaa !21
  %49 = uitofp i64 %48 to double
  %50 = fdiv double %46, %49
  br label %52

51:                                               ; preds = %20
  br label %52

52:                                               ; preds = %51, %41
  %53 = phi double [ %50, %41 ], [ 0.000000e+00, %51 ]
  %54 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 7
  store double %53, ptr %54, align 8, !tbaa !25
  %55 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 4
  %56 = load i64, ptr %55, align 8, !tbaa !22
  %57 = icmp ne i64 %56, 0
  br i1 %57, label %58, label %65

58:                                               ; preds = %52
  %59 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 9
  %60 = load double, ptr %59, align 8, !tbaa !27
  %61 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 4
  %62 = load i64, ptr %61, align 8, !tbaa !22
  %63 = uitofp i64 %62 to double
  %64 = fdiv double %60, %63
  br label %66

65:                                               ; preds = %52
  br label %66

66:                                               ; preds = %65, %58
  %67 = phi double [ %64, %58 ], [ 0.000000e+00, %65 ]
  %68 = getelementptr inbounds %"class.DetectorModel::Grid", ptr %15, i32 0, i32 8
  store double %67, ptr %68, align 8, !tbaa !26
  ret void

69:                                               ; preds = %5
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %13, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %14, align 4
  call void @_ZNSt15__new_allocatorIdED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %12) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %73

73:                                               ; preds = %69
  %74 = load ptr, ptr %13, align 8
  %75 = load i32, ptr %14, align 4
  %76 = insertvalue { ptr, i32 } poison, ptr %74, 0
  %77 = insertvalue { ptr, i32 } %76, i32 %75, 1
  resume { ptr, i32 } %77
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIdSaIdEEC2EmRKdRKS0_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIdED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

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 "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 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{!16, !10, i64 32}
!16 = !{!"_ZTSN13DetectorModel4GridE", !17, i64 8, !10, i64 32, !10, i64 40, !10, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88}
!17 = !{!"_ZTSSt6vectorIdSaIdEE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!16, !10, i64 40}
!22 = !{!16, !10, i64 48}
!23 = !{!16, !12, i64 56}
!24 = !{!16, !12, i64 64}
!25 = !{!16, !12, i64 72}
!26 = !{!16, !12, i64 80}
!27 = !{!16, !12, i64 88}


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

%"class.std::allocator" = type { i8 }

@_ZTVN13DetectorModel4GridE = external dso_local unnamed_addr constant { [27 x ptr] }, align 8

; 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 i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIdEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13DetectorModel4GridC2Emddm(ptr noundef nonnull align 8 dereferenceable(96) %0, i64 noundef %1, double noundef %2, double noundef %3, i64 noundef %4) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca double, align 8
  %7 = alloca %"class.std::allocator", align 1
  store ptr getelementptr inbounds inrange(-16, 200) (i8, ptr @_ZTVN13DetectorModel4GridE, i64 16), ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = mul i64 %4, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  store double 0.000000e+00, ptr %6, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %7) #3
  call void @_ZNSaIdEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #3
  invoke void @_ZNSt6vectorIdSaIdEEC2EmRKdRKS0_(ptr noundef nonnull align 8 dereferenceable(24) %8, i64 noundef %9, ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 1 dereferenceable(1) %7)
          to label %10 unwind label %26

10:                                               ; preds = %5
  call void @_ZNSt15__new_allocatorIdED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %9, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  store i64 %1, ptr %12, align 8, !tbaa !19
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  store i64 %4, ptr %13, align 8, !tbaa !20
  %14 = getelementptr inbounds i8, ptr %0, i64 56
  store double %2, ptr %14, align 8, !tbaa !21
  %15 = getelementptr inbounds i8, ptr %0, i64 64
  store double %3, ptr %15, align 8, !tbaa !22
  %16 = getelementptr inbounds i8, ptr %0, i64 72
  %17 = getelementptr inbounds i8, ptr %0, i64 88
  store double 0x401921FB54442D18, ptr %17, align 8, !tbaa !23
  %18 = insertelement <2 x i64> poison, i64 %1, i64 0
  %19 = insertelement <2 x i64> %18, i64 %4, i64 1
  %20 = icmp eq <2 x i64> %19, zeroinitializer
  %21 = fsub double %3, %2
  %22 = uitofp <2 x i64> %19 to <2 x double>
  %23 = insertelement <2 x double> <double poison, double 0x401921FB54442D18>, double %21, i64 0
  %24 = fdiv <2 x double> %23, %22
  %25 = select <2 x i1> %20, <2 x double> zeroinitializer, <2 x double> %24
  store <2 x double> %25, ptr %16, align 8, !tbaa !8
  ret void

26:                                               ; preds = %5
  %27 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt15__new_allocatorIdED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %7) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  resume { ptr, i32 } %27
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIdSaIdEEC2EmRKdRKS0_(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIdED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

attributes #0 = { mustprogress 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 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"double", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !18, i64 32}
!12 = !{!"_ZTSN13DetectorModel4GridE", !13, i64 8, !18, i64 32, !18, i64 40, !18, i64 48, !9, i64 56, !9, i64 64, !9, i64 72, !9, i64 80, !9, i64 88}
!13 = !{!"_ZTSSt6vectorIdSaIdEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!17 = !{!"any pointer", !10, i64 0}
!18 = !{!"long", !10, i64 0}
!19 = !{!12, !18, i64 40}
!20 = !{!12, !18, i64 48}
!21 = !{!12, !9, i64 56}
!22 = !{!12, !9, i64 64}
!23 = !{!12, !9, i64 88}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass