; LLVM IR from kylechampley/XrayPhysics :: src/xsource.ll (ZN10xraySource11muTotal_jklEiii)

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

; 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 uwtable
define dso_local noundef float @_ZN10xraySource11muTotal_jklEiii(ptr noundef nonnull align 8 dereferenceable(48) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store float 0.000000e+00, ptr %9, align 4, !tbaa !11
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %29

13:                                               ; preds = %4
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %22

16:                                               ; preds = %13
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  store float 0x4049BBF7C0000000, ptr %9, align 4, !tbaa !11
  br label %21

20:                                               ; preds = %16
  store float 0x4043418C80000000, ptr %9, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %20, %19
  br label %28

22:                                               ; preds = %13
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  store float 0x40BCEF4A40000000, ptr %9, align 4, !tbaa !11
  br label %27

26:                                               ; preds = %22
  store float 0x409933E140000000, ptr %9, align 4, !tbaa !11
  br label %27

27:                                               ; preds = %26, %25
  br label %28

28:                                               ; preds = %27, %21
  br label %89

29:                                               ; preds = %4
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = icmp eq i32 %30, 1
  br i1 %31, label %32, label %48

32:                                               ; preds = %29
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %41

35:                                               ; preds = %32
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  store float 0x4032C6E980000000, ptr %9, align 4, !tbaa !11
  br label %40

39:                                               ; preds = %35
  store float 0x402AC7FCC0000000, ptr %9, align 4, !tbaa !11
  br label %40

40:                                               ; preds = %39, %38
  br label %47

41:                                               ; preds = %32
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %45

44:                                               ; preds = %41
  store float 0x4083208B40000000, ptr %9, align 4, !tbaa !11
  br label %46

45:                                               ; preds = %41
  store float 0x408552C6A0000000, ptr %9, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %45, %44
  br label %47

47:                                               ; preds = %46, %40
  br label %88

48:                                               ; preds = %29
  %49 = load i32, ptr %6, align 4, !tbaa !9
  %50 = icmp eq i32 %49, 2
  br i1 %50, label %51, label %67

51:                                               ; preds = %48
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %60

54:                                               ; preds = %51
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %54
  store float 0x400ECB19A0000000, ptr %9, align 4, !tbaa !11
  br label %59

58:                                               ; preds = %54
  store float 0x4005034C20000000, ptr %9, align 4, !tbaa !11
  br label %59

59:                                               ; preds = %58, %57
  br label %66

60:                                               ; preds = %51
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %63, label %64

63:                                               ; preds = %60
  store float 0x405A0D3F80000000, ptr %9, align 4, !tbaa !11
  br label %65

64:                                               ; preds = %60
  store float 0x4062C60420000000, ptr %9, align 4, !tbaa !11
  br label %65

65:                                               ; preds = %64, %63
  br label %66

66:                                               ; preds = %65, %59
  br label %87

67:                                               ; preds = %48
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = icmp eq i32 %68, 3
  br i1 %69, label %70, label %86

70:                                               ; preds = %67
  %71 = load i32, ptr %7, align 4, !tbaa !9
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %79

73:                                               ; preds = %70
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = icmp eq i32 %74, 0
  br i1 %75, label %76, label %77

76:                                               ; preds = %73
  store float 0x4009C2B940000000, ptr %9, align 4, !tbaa !11
  br label %78

77:                                               ; preds = %73
  store float 0x4002229200000000, ptr %9, align 4, !tbaa !11
  br label %78

78:                                               ; preds = %77, %76
  br label %85

79:                                               ; preds = %70
  %80 = load i32, ptr %8, align 4, !tbaa !9
  %81 = icmp eq i32 %80, 0
  br i1 %81, label %82, label %83

82:                                               ; preds = %79
  store float 0x4054B8A3E0000000, ptr %9, align 4, !tbaa !11
  br label %84

83:                                               ; preds = %79
  store float 0x405FA5B220000000, ptr %9, align 4, !tbaa !11
  br label %84

84:                                               ; preds = %83, %82
  br label %85

85:                                               ; preds = %84, %78
  br label %86

86:                                               ; preds = %85, %67
  br label %87

87:                                               ; preds = %86, %66
  br label %88

88:                                               ; preds = %87, %47
  br label %89

89:                                               ; preds = %88, %28
  %90 = getelementptr inbounds %class.xraySource, ptr %10, i32 0, i32 7
  %91 = load ptr, ptr %90, align 8, !tbaa !13
  %92 = getelementptr inbounds %class.xraySource, ptr %10, i32 0, i32 1
  %93 = load i32, ptr %92, align 4, !tbaa !15
  %94 = call noundef float @_ZN4xsec13getAtomicMassEi(ptr noundef nonnull align 8 dereferenceable(2400) %91, i32 noundef %93)
  %95 = getelementptr inbounds %class.xraySource, ptr %10, i32 0, i32 1
  %96 = load i32, ptr %95, align 4, !tbaa !15
  %97 = sitofp i32 %96 to float
  %98 = fdiv float %94, %97
  %99 = load float, ptr %9, align 4, !tbaa !11
  %100 = fmul float %99, %98
  store float %100, ptr %9, align 4, !tbaa !11
  %101 = load float, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret float %101
}

declare noundef float @_ZN4xsec13getAtomicMassEi(ptr noundef nonnull align 8 dereferenceable(2400), i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !6, i64 40}
!14 = !{!"_ZTS10xraySource", !12, i64 0, !10, i64 4, !12, i64 8, !6, i64 16, !10, i64 24, !12, i64 28, !12, i64 32, !6, i64 40}
!15 = !{!14, !10, i64 4}


; 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 noundef float @_ZN10xraySource11muTotal_jklEiii(ptr nocapture noundef nonnull readonly align 8 dereferenceable(48) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 align 2 {
  switch i32 %1, label %25 [
    i32 0, label %5
    i32 1, label %10
    i32 2, label %15
    i32 3, label %20
  ]

5:                                                ; preds = %4
  %6 = icmp eq i32 %2, 0
  %7 = icmp eq i32 %3, 0
  br i1 %6, label %8, label %9

8:                                                ; preds = %5
  %. = select i1 %7, float 0x4049BBF7C0000000, float 0x4043418C80000000
  br label %25

9:                                                ; preds = %5
  %.19 = select i1 %7, float 0x40BCEF4A40000000, float 0x409933E140000000
  br label %25

10:                                               ; preds = %4
  %11 = icmp eq i32 %2, 0
  %12 = icmp eq i32 %3, 0
  br i1 %11, label %13, label %14

13:                                               ; preds = %10
  %.20 = select i1 %12, float 0x4032C6E980000000, float 0x402AC7FCC0000000
  br label %25

14:                                               ; preds = %10
  %.21 = select i1 %12, float 0x4083208B40000000, float 0x408552C6A0000000
  br label %25

15:                                               ; preds = %4
  %16 = icmp eq i32 %2, 0
  %17 = icmp eq i32 %3, 0
  br i1 %16, label %18, label %19

18:                                               ; preds = %15
  %.22 = select i1 %17, float 0x400ECB19A0000000, float 0x4005034C20000000
  br label %25

19:                                               ; preds = %15
  %.23 = select i1 %17, float 0x405A0D3F80000000, float 0x4062C60420000000
  br label %25

20:                                               ; preds = %4
  %21 = icmp eq i32 %2, 0
  %22 = icmp eq i32 %3, 0
  br i1 %21, label %23, label %24

23:                                               ; preds = %20
  %.24 = select i1 %22, float 0x4009C2B940000000, float 0x4002229200000000
  br label %25

24:                                               ; preds = %20
  %.25 = select i1 %22, float 0x4054B8A3E0000000, float 0x405FA5B220000000
  br label %25

25:                                               ; preds = %24, %23, %4, %19, %18, %14, %13, %9, %8
  %.0 = phi float [ %., %8 ], [ %.19, %9 ], [ %.20, %13 ], [ %.21, %14 ], [ %.22, %18 ], [ %.23, %19 ], [ 0.000000e+00, %4 ], [ %.24, %23 ], [ %.25, %24 ]
  %26 = getelementptr inbounds i8, ptr %0, i64 40
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %0, i64 4
  %29 = load i32, ptr %28, align 4, !tbaa !12
  %30 = tail call noundef float @_ZN4xsec13getAtomicMassEi(ptr noundef nonnull align 8 dereferenceable(2400) %27, i32 noundef %29)
  %31 = load i32, ptr %28, align 4, !tbaa !12
  %32 = sitofp i32 %31 to float
  %33 = fdiv float %30, %32
  %34 = fmul float %.0, %33
  ret float %34
}

declare noundef float @_ZN4xsec13getAtomicMassEi(ptr noundef nonnull align 8 dereferenceable(2400), i32 noundef) local_unnamed_addr #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 = { "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" }

!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, !11, i64 40}
!6 = !{!"_ZTS10xraySource", !7, i64 0, !10, i64 4, !7, i64 8, !11, i64 16, !10, i64 24, !7, i64 28, !7, i64 32, !11, i64 40}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !10, i64 4}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass