; LLVM IR from korzhimanov/vlasov-solver :: src/particle.ll (ZN8Particle8MakeStepEdPdS0_)

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

; 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 double @_ZN8Particle8GetGammaEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8Particle8MakeStepEdPdS0_(ptr noundef nonnull align 8 dereferenceable(32) %0, double noundef %1, ptr noundef %2, ptr noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %13 = call noundef double @_ZN8Particle8GetGammaEv(ptr noundef nonnull align 8 dereferenceable(32) %12)
  store double %13, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %14

14:                                               ; preds = %133, %4
  %15 = load i32, ptr %11, align 4, !tbaa !11
  %16 = icmp slt i32 %15, 3
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %136

18:                                               ; preds = %14
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load i32, ptr %11, align 4, !tbaa !11
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds double, ptr %19, i64 %21
  %23 = load double, ptr %22, align 8, !tbaa !9
  store double %23, ptr %9, align 8, !tbaa !9
  %24 = load i32, ptr %11, align 4, !tbaa !11
  switch i32 %24, label %91 [
    i32 0, label %25
    i32 1, label %47
    i32 2, label %69
  ]

25:                                               ; preds = %18
  %26 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = getelementptr inbounds double, ptr %27, i64 1
  %29 = load double, ptr %28, align 8, !tbaa !9
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds double, ptr %30, i64 2
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  %35 = getelementptr inbounds double, ptr %34, i64 2
  %36 = load double, ptr %35, align 8, !tbaa !9
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds double, ptr %37, i64 1
  %39 = load double, ptr %38, align 8, !tbaa !9
  %40 = fmul double %36, %39
  %41 = fneg double %40
  %42 = call double @llvm.fmuladd.f64(double %29, double %32, double %41)
  %43 = load double, ptr %10, align 8, !tbaa !9
  %44 = fdiv double %42, %43
  %45 = load double, ptr %9, align 8, !tbaa !9
  %46 = fadd double %45, %44
  store double %46, ptr %9, align 8, !tbaa !9
  br label %91

47:                                               ; preds = %18
  %48 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = getelementptr inbounds double, ptr %49, i64 2
  %51 = load double, ptr %50, align 8, !tbaa !9
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = getelementptr inbounds double, ptr %52, i64 0
  %54 = load double, ptr %53, align 8, !tbaa !9
  %55 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !13
  %57 = getelementptr inbounds double, ptr %56, i64 0
  %58 = load double, ptr %57, align 8, !tbaa !9
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds double, ptr %59, i64 2
  %61 = load double, ptr %60, align 8, !tbaa !9
  %62 = fmul double %58, %61
  %63 = fneg double %62
  %64 = call double @llvm.fmuladd.f64(double %51, double %54, double %63)
  %65 = load double, ptr %10, align 8, !tbaa !9
  %66 = fdiv double %64, %65
  %67 = load double, ptr %9, align 8, !tbaa !9
  %68 = fadd double %67, %66
  store double %68, ptr %9, align 8, !tbaa !9
  br label %91

69:                                               ; preds = %18
  %70 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 1
  %71 = load ptr, ptr %70, align 8, !tbaa !13
  %72 = getelementptr inbounds double, ptr %71, i64 0
  %73 = load double, ptr %72, align 8, !tbaa !9
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds double, ptr %74, i64 1
  %76 = load double, ptr %75, align 8, !tbaa !9
  %77 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !13
  %79 = getelementptr inbounds double, ptr %78, i64 1
  %80 = load double, ptr %79, align 8, !tbaa !9
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = getelementptr inbounds double, ptr %81, i64 0
  %83 = load double, ptr %82, align 8, !tbaa !9
  %84 = fmul double %80, %83
  %85 = fneg double %84
  %86 = call double @llvm.fmuladd.f64(double %73, double %76, double %85)
  %87 = load double, ptr %10, align 8, !tbaa !9
  %88 = fdiv double %86, %87
  %89 = load double, ptr %9, align 8, !tbaa !9
  %90 = fadd double %89, %88
  store double %90, ptr %9, align 8, !tbaa !9
  br label %91

91:                                               ; preds = %69, %47, %25, %18
  %92 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 2
  %93 = load i32, ptr %92, align 8, !tbaa !15
  %94 = sub nsw i32 0, %93
  %95 = sitofp i32 %94 to double
  %96 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 3
  %97 = load double, ptr %96, align 8, !tbaa !16
  %98 = fdiv double %95, %97
  %99 = load double, ptr %9, align 8, !tbaa !9
  %100 = fmul double %99, %98
  store double %100, ptr %9, align 8, !tbaa !9
  %101 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 1
  %102 = load ptr, ptr %101, align 8, !tbaa !13
  %103 = load i32, ptr %11, align 4, !tbaa !11
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds double, ptr %102, i64 %104
  %106 = load double, ptr %105, align 8, !tbaa !9
  %107 = load double, ptr %10, align 8, !tbaa !9
  %108 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 3
  %109 = load double, ptr %108, align 8, !tbaa !16
  %110 = fmul double %107, %109
  %111 = fdiv double %106, %110
  %112 = load double, ptr %9, align 8, !tbaa !9
  %113 = fmul double 5.000000e-01, %112
  %114 = load double, ptr %6, align 8, !tbaa !9
  %115 = call double @llvm.fmuladd.f64(double %113, double %114, double %111)
  %116 = load double, ptr %6, align 8, !tbaa !9
  %117 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 0
  %118 = load ptr, ptr %117, align 8, !tbaa !17
  %119 = load i32, ptr %11, align 4, !tbaa !11
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds double, ptr %118, i64 %120
  %122 = load double, ptr %121, align 8, !tbaa !9
  %123 = call double @llvm.fmuladd.f64(double %115, double %116, double %122)
  store double %123, ptr %121, align 8, !tbaa !9
  %124 = load double, ptr %9, align 8, !tbaa !9
  %125 = load double, ptr %6, align 8, !tbaa !9
  %126 = getelementptr inbounds %class.Particle, ptr %12, i32 0, i32 1
  %127 = load ptr, ptr %126, align 8, !tbaa !13
  %128 = load i32, ptr %11, align 4, !tbaa !11
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds double, ptr %127, i64 %129
  %131 = load double, ptr %130, align 8, !tbaa !9
  %132 = call double @llvm.fmuladd.f64(double %124, double %125, double %131)
  store double %132, ptr %130, align 8, !tbaa !9
  br label %133

133:                                              ; preds = %91
  %134 = load i32, ptr %11, align 4, !tbaa !11
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %11, align 4, !tbaa !11
  br label %14, !llvm.loop !18

136:                                              ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void
}

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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 8}
!14 = !{!"_ZTS8Particle", !6, i64 0, !6, i64 8, !12, i64 16, !10, i64 24}
!15 = !{!14, !12, i64 16}
!16 = !{!14, !10, i64 24}
!17 = !{!14, !6, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN8Particle8GetGammaEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8Particle8MakeStepEdPdS0_(ptr noundef nonnull align 8 dereferenceable(32) %0, double noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 align 2 {
  %5 = tail call noundef double @_ZN8Particle8GetGammaEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load ptr, ptr %6, align 8
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  %9 = getelementptr inbounds i8, ptr %7, i64 8
  %10 = getelementptr inbounds i8, ptr %7, i64 16
  %11 = getelementptr inbounds i8, ptr %3, i64 16
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load i32, ptr %12, align 8
  %14 = sub nsw i32 0, %13
  %15 = sitofp i32 %14 to double
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  %17 = load ptr, ptr %0, align 8
  %18 = load double, ptr %2, align 8, !tbaa !5
  %.pre = load double, ptr %7, align 8, !tbaa !5
  %19 = load double, ptr %9, align 8, !tbaa !5
  %20 = load double, ptr %11, align 8, !tbaa !5
  %21 = load double, ptr %8, align 8, !tbaa !5
  %22 = load double, ptr %10, align 8, !tbaa !5
  %23 = fneg double %22
  %24 = fmul double %21, %23
  %25 = tail call double @llvm.fmuladd.f64(double %19, double %20, double %24)
  %.pn = fdiv double %25, %5
  %.027 = fadd double %18, %.pn
  %26 = load double, ptr %16, align 8, !tbaa !9
  %27 = fdiv double %15, %26
  %28 = fmul double %.027, %27
  %29 = fmul double %5, %26
  %30 = fdiv double %.pre, %29
  %31 = fmul double %28, 5.000000e-01
  %32 = tail call double @llvm.fmuladd.f64(double %31, double %1, double %30)
  %33 = load double, ptr %17, align 8, !tbaa !5
  %34 = tail call double @llvm.fmuladd.f64(double %32, double %1, double %33)
  store double %34, ptr %17, align 8, !tbaa !5
  %35 = load double, ptr %7, align 8, !tbaa !5
  %36 = tail call double @llvm.fmuladd.f64(double %28, double %1, double %35)
  store double %36, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %2, i64 8
  %38 = load double, ptr %37, align 8, !tbaa !5
  %.pre31 = load double, ptr %9, align 8, !tbaa !5
  %39 = load double, ptr %10, align 8, !tbaa !5
  %40 = load double, ptr %3, align 8, !tbaa !5
  %41 = load double, ptr %11, align 8, !tbaa !5
  %42 = fneg double %36
  %43 = fmul double %41, %42
  %44 = tail call double @llvm.fmuladd.f64(double %39, double %40, double %43)
  %.pn.1 = fdiv double %44, %5
  %.027.1 = fadd double %38, %.pn.1
  %45 = load double, ptr %16, align 8, !tbaa !9
  %46 = fdiv double %15, %45
  %47 = fmul double %.027.1, %46
  %48 = fmul double %5, %45
  %49 = fdiv double %.pre31, %48
  %50 = fmul double %47, 5.000000e-01
  %51 = tail call double @llvm.fmuladd.f64(double %50, double %1, double %49)
  %52 = getelementptr inbounds i8, ptr %17, i64 8
  %53 = load double, ptr %52, align 8, !tbaa !5
  %54 = tail call double @llvm.fmuladd.f64(double %51, double %1, double %53)
  store double %54, ptr %52, align 8, !tbaa !5
  %55 = load double, ptr %9, align 8, !tbaa !5
  %56 = tail call double @llvm.fmuladd.f64(double %47, double %1, double %55)
  store double %56, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %2, i64 16
  %58 = load double, ptr %57, align 8, !tbaa !5
  %.pre32 = load double, ptr %10, align 8, !tbaa !5
  %59 = load double, ptr %7, align 8, !tbaa !5
  %60 = load double, ptr %8, align 8, !tbaa !5
  %61 = load double, ptr %3, align 8, !tbaa !5
  %62 = fneg double %56
  %63 = fmul double %61, %62
  %64 = tail call double @llvm.fmuladd.f64(double %59, double %60, double %63)
  %.pn.2 = fdiv double %64, %5
  %.027.2 = fadd double %58, %.pn.2
  %65 = load double, ptr %16, align 8, !tbaa !9
  %66 = fdiv double %15, %65
  %67 = fmul double %.027.2, %66
  %68 = fmul double %5, %65
  %69 = fdiv double %.pre32, %68
  %70 = fmul double %67, 5.000000e-01
  %71 = tail call double @llvm.fmuladd.f64(double %70, double %1, double %69)
  %72 = getelementptr inbounds i8, ptr %17, i64 16
  %73 = load double, ptr %72, align 8, !tbaa !5
  %74 = tail call double @llvm.fmuladd.f64(double %71, double %1, double %73)
  store double %74, ptr %72, align 8, !tbaa !5
  %75 = load double, ptr %10, align 8, !tbaa !5
  %76 = tail call double @llvm.fmuladd.f64(double %67, double %1, double %75)
  store double %76, ptr %10, align 8, !tbaa !5
  ret void
}

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) }

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass