; LLVM IR from introlab/odas :: src/system (freq2env)

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

%struct.freqs_obj = type { i32, i32, ptr }
%struct.freq2env_obj = type { i32 }
%struct.envs_obj = type { i32, i32, 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: nounwind uwtable
define dso_local void @freq2env_process(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %73, %3
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.freqs_obj, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = icmp ult i32 %13, %16
  br i1 %17, label %18, label %76

18:                                               ; preds = %12
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %69, %18
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.freq2env_obj, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = icmp ult i32 %20, %23
  br i1 %24, label %25, label %72

25:                                               ; preds = %19
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.freqs_obj, ptr %26, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds ptr, ptr %28, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = mul i32 %33, 2
  %35 = add i32 %34, 0
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds float, ptr %32, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !16
  store float %38, ptr %9, align 4, !tbaa !16
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.freqs_obj, ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds ptr, ptr %41, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = mul i32 %46, 2
  %48 = add i32 %47, 1
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds float, ptr %45, i64 %49
  %51 = load float, ptr %50, align 4, !tbaa !16
  store float %51, ptr %10, align 4, !tbaa !16
  %52 = load float, ptr %9, align 4, !tbaa !16
  %53 = load float, ptr %9, align 4, !tbaa !16
  %54 = load float, ptr %10, align 4, !tbaa !16
  %55 = load float, ptr %10, align 4, !tbaa !16
  %56 = fmul float %54, %55
  %57 = call float @llvm.fmuladd.f32(float %52, float %53, float %56)
  store float %57, ptr %11, align 4, !tbaa !16
  %58 = load float, ptr %11, align 4, !tbaa !16
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.envs_obj, ptr %59, i32 0, i32 2
  %61 = load ptr, ptr %60, align 8, !tbaa !18
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds ptr, ptr %61, i64 %63
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %65, i64 %67
  store float %58, ptr %68, align 4, !tbaa !16
  br label %69

69:                                               ; preds = %25
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = add i32 %70, 1
  store i32 %71, ptr %8, align 4, !tbaa !9
  br label %19, !llvm.loop !20

72:                                               ; preds = %19
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %7, align 4, !tbaa !9
  %75 = add i32 %74, 1
  store i32 %75, ptr %7, align 4, !tbaa !9
  br label %12, !llvm.loop !22

76:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"freqs_obj", !10, i64 0, !10, i64 4, !6, i64 8}
!13 = !{!14, !10, i64 0}
!14 = !{!"freq2env_obj", !10, i64 0}
!15 = !{!12, !6, i64 8}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!19, !6, i64 8}
!19 = !{!"envs_obj", !10, i64 0, !10, i64 4, !6, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @freq2env_process(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = load i32, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %._crit_edge22, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %3
  %5 = load i32, ptr %0, align 4, !tbaa !11
  %.not23 = icmp eq i32 %5, 0
  br i1 %.not23, label %._crit_edge22, label %.preheader.lr.ph.split.us

.preheader.lr.ph.split.us:                        ; preds = %.preheader.lr.ph
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = load ptr, ptr %6, align 8, !tbaa !14
  %wide.trip.count29 = zext i32 %4 to i64
  %wide.trip.count = zext i32 %5 to i64
  %10 = shl nuw nsw i64 %wide.trip.count, 2
  %11 = shl nuw nsw i64 %wide.trip.count, 3
  %min.iters.check = icmp ult i32 %5, 8
  %n.vec = and i64 %wide.trip.count, 4294967288
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  %xtraiter = and i64 %wide.trip.count, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  %12 = add nsw i64 %wide.trip.count, -1
  br label %.preheader.us

.preheader.us:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph.split.us
  %indvars.iv26 = phi i64 [ %indvars.iv.next27, %._crit_edge.us ], [ 0, %.preheader.lr.ph.split.us ]
  %13 = getelementptr inbounds ptr, ptr %8, i64 %indvars.iv26
  %14 = load ptr, ptr %13, align 8, !tbaa !16
  %15 = getelementptr inbounds ptr, ptr %9, i64 %indvars.iv26
  %16 = load ptr, ptr %15, align 8, !tbaa !16
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %.preheader.us
  %scevgep = getelementptr i8, ptr %16, i64 %10
  %scevgep31 = getelementptr i8, ptr %14, i64 %11
  %bound0 = icmp ult ptr %16, %scevgep31
  %bound1 = icmp ult ptr %14, %scevgep
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %vector.memcheck, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.memcheck ]
  %17 = shl i64 %index, 1
  %18 = shl i64 %index, 1
  %19 = and i64 %17, 4294967280
  %20 = and i64 %18, 4294967280
  %21 = or disjoint i64 %20, 8
  %22 = getelementptr inbounds float, ptr %14, i64 %19
  %23 = getelementptr inbounds float, ptr %14, i64 %21
  %wide.vec = load <8 x float>, ptr %22, align 4, !tbaa !17
  %wide.vec32 = load <8 x float>, ptr %23, align 4, !tbaa !17
  %strided.vec = shufflevector <8 x float> %wide.vec, <8 x float> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
  %strided.vec33 = shufflevector <8 x float> %wide.vec32, <8 x float> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
  %24 = fmul <8 x float> %wide.vec, %wide.vec
  %25 = shufflevector <8 x float> %24, <8 x float> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
  %26 = fmul <8 x float> %wide.vec32, %wide.vec32
  %27 = shufflevector <8 x float> %26, <8 x float> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
  %28 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %strided.vec, <4 x float> %strided.vec, <4 x float> %25)
  %29 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %strided.vec33, <4 x float> %strided.vec33, <4 x float> %27)
  %30 = getelementptr inbounds float, ptr %16, i64 %index
  %31 = getelementptr inbounds i8, ptr %30, i64 16
  store <4 x float> %28, ptr %30, align 4, !tbaa !17, !alias.scope !19, !noalias !22
  store <4 x float> %29, ptr %31, align 4, !tbaa !17, !alias.scope !19, !noalias !22
  %index.next = add nuw i64 %index, 8
  %32 = icmp eq i64 %index.next, %n.vec
  br i1 %32, label %middle.block, label %vector.body, !llvm.loop !24

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.preheader.us
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.preheader.us ], [ %n.vec, %middle.block ]
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %33 = trunc nuw i64 %indvars.iv.ph to i32
  %34 = shl i32 %33, 1
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds float, ptr %14, i64 %35
  %37 = load float, ptr %36, align 4, !tbaa !17
  %38 = or disjoint i32 %34, 1
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %14, i64 %39
  %41 = load float, ptr %40, align 4, !tbaa !17
  %42 = fmul float %41, %41
  %43 = tail call float @llvm.fmuladd.f32(float %37, float %37, float %42)
  %44 = getelementptr inbounds float, ptr %16, i64 %indvars.iv.ph
  store float %43, ptr %44, align 4, !tbaa !17
  %indvars.iv.next.prol = or disjoint i64 %indvars.iv.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %45 = icmp eq i64 %indvars.iv.ph, %12
  br i1 %45, label %._crit_edge.us, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %scalar.ph ], [ %indvars.iv.unr, %scalar.ph.prol.loopexit ]
  %46 = trunc nuw i64 %indvars.iv to i32
  %47 = shl i32 %46, 1
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds float, ptr %14, i64 %48
  %50 = load float, ptr %49, align 4, !tbaa !17
  %51 = or disjoint i32 %47, 1
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds float, ptr %14, i64 %52
  %54 = load float, ptr %53, align 4, !tbaa !17
  %55 = fmul float %54, %54
  %56 = tail call float @llvm.fmuladd.f32(float %50, float %50, float %55)
  %57 = getelementptr inbounds float, ptr %16, i64 %indvars.iv
  store float %56, ptr %57, align 4, !tbaa !17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %58 = trunc nuw i64 %indvars.iv.next to i32
  %59 = shl i32 %58, 1
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds float, ptr %14, i64 %60
  %62 = load float, ptr %61, align 4, !tbaa !17
  %63 = or disjoint i32 %59, 1
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds float, ptr %14, i64 %64
  %66 = load float, ptr %65, align 4, !tbaa !17
  %67 = fmul float %66, %66
  %68 = tail call float @llvm.fmuladd.f32(float %62, float %62, float %67)
  %69 = getelementptr inbounds float, ptr %16, i64 %indvars.iv.next
  store float %68, ptr %69, align 4, !tbaa !17
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, %wide.trip.count
  br i1 %exitcond.not.1, label %._crit_edge.us, label %scalar.ph, !llvm.loop !28

._crit_edge.us:                                   ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %exitcond30.not = icmp eq i64 %indvars.iv.next27, %wide.trip.count29
  br i1 %exitcond30.not, label %._crit_edge22, label %.preheader.us, !llvm.loop !29

._crit_edge22:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph, %3
  ret void
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #2

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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) }
attributes #2 = { 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, !7, i64 0}
!6 = !{!"freqs_obj", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"freq2env_obj", !7, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!15, !10, i64 8}
!15 = !{!"envs_obj", !7, i64 0, !7, i64 4, !10, i64 8}
!16 = !{!10, !10, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !8, i64 0}
!19 = !{!20}
!20 = distinct !{!20, !21}
!21 = distinct !{!21, !"LVerDomain"}
!22 = !{!23}
!23 = distinct !{!23, !21}
!24 = distinct !{!24, !25, !26, !27}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!"llvm.loop.isvectorized", i32 1}
!27 = !{!"llvm.loop.unroll.runtime.disable"}
!28 = distinct !{!28, !25, !26}
!29 = distinct !{!29, !25}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass