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

; 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.freq2freq_gain_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 @freq2freq_gain_process(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %103, %4
  %17 = load i32, ptr %9, align 4, !tbaa !9
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.freqs_obj, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !11
  %21 = icmp ult i32 %17, %20
  br i1 %21, label %22, label %106

22:                                               ; preds = %16
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %99, %22
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.freq2freq_gain_obj, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 4, !tbaa !13
  %28 = icmp ult i32 %24, %27
  br i1 %28, label %29, label %102

29:                                               ; preds = %23
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.freqs_obj, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds ptr, ptr %32, i64 %34
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = mul i32 %37, 2
  %39 = add i32 %38, 0
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds float, ptr %36, i64 %40
  %42 = load float, ptr %41, align 4, !tbaa !16
  store float %42, ptr %11, align 4, !tbaa !16
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.freqs_obj, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds ptr, ptr %45, i64 %47
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = load i32, ptr %10, align 4, !tbaa !9
  %51 = mul i32 %50, 2
  %52 = add i32 %51, 1
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds float, ptr %49, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !16
  store float %55, ptr %12, align 4, !tbaa !16
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.envs_obj, ptr %56, i32 0, i32 2
  %58 = load ptr, ptr %57, align 8, !tbaa !18
  %59 = load i32, ptr %9, align 4, !tbaa !9
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds ptr, ptr %58, i64 %60
  %62 = load ptr, ptr %61, align 8, !tbaa !5
  %63 = load i32, ptr %10, align 4, !tbaa !9
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds float, ptr %62, i64 %64
  %66 = load float, ptr %65, align 4, !tbaa !16
  store float %66, ptr %13, align 4, !tbaa !16
  %67 = load float, ptr %13, align 4, !tbaa !16
  %68 = load float, ptr %11, align 4, !tbaa !16
  %69 = fmul float %67, %68
  store float %69, ptr %14, align 4, !tbaa !16
  %70 = load float, ptr %13, align 4, !tbaa !16
  %71 = load float, ptr %12, align 4, !tbaa !16
  %72 = fmul float %70, %71
  store float %72, ptr %15, align 4, !tbaa !16
  %73 = load float, ptr %14, align 4, !tbaa !16
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.freqs_obj, ptr %74, i32 0, i32 2
  %76 = load ptr, ptr %75, align 8, !tbaa !15
  %77 = load i32, ptr %9, align 4, !tbaa !9
  %78 = zext i32 %77 to i64
  %79 = getelementptr inbounds ptr, ptr %76, i64 %78
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  %81 = load i32, ptr %10, align 4, !tbaa !9
  %82 = mul i32 %81, 2
  %83 = add i32 %82, 0
  %84 = zext i32 %83 to i64
  %85 = getelementptr inbounds float, ptr %80, i64 %84
  store float %73, ptr %85, align 4, !tbaa !16
  %86 = load float, ptr %15, align 4, !tbaa !16
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.freqs_obj, ptr %87, i32 0, i32 2
  %89 = load ptr, ptr %88, align 8, !tbaa !15
  %90 = load i32, ptr %9, align 4, !tbaa !9
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds ptr, ptr %89, i64 %91
  %93 = load ptr, ptr %92, align 8, !tbaa !5
  %94 = load i32, ptr %10, align 4, !tbaa !9
  %95 = mul i32 %94, 2
  %96 = add i32 %95, 1
  %97 = zext i32 %96 to i64
  %98 = getelementptr inbounds float, ptr %93, i64 %97
  store float %86, ptr %98, align 4, !tbaa !16
  br label %99

99:                                               ; preds = %29
  %100 = load i32, ptr %10, align 4, !tbaa !9
  %101 = add i32 %100, 1
  store i32 %101, ptr %10, align 4, !tbaa !9
  br label %23, !llvm.loop !20

102:                                              ; preds = %23
  br label %103

103:                                              ; preds = %102
  %104 = load i32, ptr %9, align 4, !tbaa !9
  %105 = add i32 %104, 1
  store i32 %105, ptr %9, align 4, !tbaa !9
  br label %16, !llvm.loop !22

106:                                              ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  ret void
}

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 = { 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 = !{!"freq2freq_gain_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 @freq2freq_gain_process(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = load i32, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %._crit_edge29, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %4
  %6 = load i32, ptr %0, align 4, !tbaa !11
  %.not30 = icmp eq i32 %6, 0
  br i1 %.not30, label %._crit_edge29, label %.preheader.lr.ph.split.us

.preheader.lr.ph.split.us:                        ; preds = %.preheader.lr.ph
  %7 = getelementptr inbounds i8, ptr %3, i64 8
  %8 = getelementptr inbounds i8, ptr %2, i64 8
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = load ptr, ptr %8, align 8, !tbaa !14
  %12 = load ptr, ptr %7, align 8, !tbaa !13
  %wide.trip.count36 = zext i32 %5 to i64
  %wide.trip.count = zext i32 %6 to i64
  %13 = add nsw i64 %wide.trip.count, -1
  %14 = shl nuw nsw i64 %wide.trip.count, 2
  %15 = shl nuw nsw i64 %wide.trip.count, 3
  %min.iters.check = icmp ult i32 %6, 16
  %16 = icmp ugt i64 %13, 4294967295
  %mul.result = shl nsw i64 %13, 3
  %mul.result39 = shl nsw i64 %13, 3
  %n.vec = and i64 %wide.trip.count, 4294967292
  %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
  %17 = add nsw i64 %wide.trip.count, -1
  br label %.preheader.us

.preheader.us:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph.split.us
  %indvars.iv33 = phi i64 [ %indvars.iv.next34, %._crit_edge.us ], [ 0, %.preheader.lr.ph.split.us ]
  %18 = getelementptr inbounds ptr, ptr %10, i64 %indvars.iv33
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %20 = getelementptr inbounds ptr, ptr %11, i64 %indvars.iv33
  %21 = load ptr, ptr %20, align 8, !tbaa !16
  %22 = getelementptr inbounds ptr, ptr %12, i64 %indvars.iv33
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.preheader.us
  %24 = getelementptr i8, ptr %23, i64 %mul.result
  %25 = icmp ult ptr %24, %23
  %scevgep = getelementptr i8, ptr %23, i64 4
  %26 = getelementptr i8, ptr %scevgep, i64 %mul.result39
  %27 = icmp ult ptr %26, %scevgep
  %28 = or i1 %25, %16
  %29 = or i1 %27, %28
  br i1 %29, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %vector.scevcheck
  %scevgep41 = getelementptr i8, ptr %21, i64 %14
  %scevgep42 = getelementptr i8, ptr %23, i64 %15
  %scevgep43 = getelementptr i8, ptr %19, i64 %15
  %bound0 = icmp ult ptr %21, %scevgep42
  %bound1 = icmp ult ptr %23, %scevgep41
  %found.conflict = and i1 %bound0, %bound1
  %bound044 = icmp ult ptr %23, %scevgep43
  %bound145 = icmp ult ptr %19, %scevgep42
  %found.conflict46 = and i1 %bound044, %bound145
  %conflict.rdx = or i1 %found.conflict, %found.conflict46
  br i1 %conflict.rdx, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %invariant.gep = getelementptr i8, ptr %23, i64 -4
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %30 = trunc i64 %index to i32
  %31 = shl i32 %30, 1
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds float, ptr %19, i64 %32
  %wide.vec = load <8 x float>, ptr %33, 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.vec47 = shufflevector <8 x float> %wide.vec, <8 x float> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
  %34 = or disjoint i32 %31, 1
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds float, ptr %21, i64 %index
  %wide.load = load <4 x float>, ptr %36, align 4, !tbaa !17, !alias.scope !19, !noalias !22
  %37 = fmul <4 x float> %strided.vec, %wide.load
  %38 = fmul <4 x float> %strided.vec47, %wide.load
  %gep = getelementptr float, ptr %invariant.gep, i64 %35
  %interleaved.vec = shufflevector <4 x float> %37, <4 x float> %38, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
  store <8 x float> %interleaved.vec, ptr %gep, align 4, !tbaa !17
  %index.next = add nuw i64 %index, 4
  %39 = icmp eq i64 %index.next, %n.vec
  br i1 %39, 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, %vector.scevcheck, %.preheader.us
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %vector.scevcheck ], [ 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
  %40 = shl nuw nsw i64 %indvars.iv.ph, 1
  %41 = and i64 %40, 4294967288
  %42 = getelementptr inbounds float, ptr %19, i64 %41
  %43 = getelementptr inbounds float, ptr %21, i64 %indvars.iv.ph
  %44 = load float, ptr %43, align 4, !tbaa !17
  %45 = getelementptr inbounds float, ptr %23, i64 %41
  %46 = load <2 x float>, ptr %42, align 4, !tbaa !17
  %47 = insertelement <2 x float> poison, float %44, i64 0
  %48 = shufflevector <2 x float> %47, <2 x float> poison, <2 x i32> zeroinitializer
  %49 = fmul <2 x float> %46, %48
  store <2 x float> %49, ptr %45, 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 ]
  %50 = icmp eq i64 %indvars.iv.ph, %17
  br i1 %50, 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 ]
  %51 = shl i64 %indvars.iv, 1
  %52 = and i64 %51, 4294967294
  %53 = getelementptr inbounds float, ptr %19, i64 %52
  %54 = getelementptr inbounds float, ptr %21, i64 %indvars.iv
  %55 = load float, ptr %54, align 4, !tbaa !17
  %56 = getelementptr inbounds float, ptr %23, i64 %52
  %57 = load <2 x float>, ptr %53, align 4, !tbaa !17
  %58 = insertelement <2 x float> poison, float %55, i64 0
  %59 = shufflevector <2 x float> %58, <2 x float> poison, <2 x i32> zeroinitializer
  %60 = fmul <2 x float> %57, %59
  store <2 x float> %60, ptr %56, align 4, !tbaa !17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %61 = shl i64 %indvars.iv.next, 1
  %62 = and i64 %61, 4294967294
  %63 = getelementptr inbounds float, ptr %19, i64 %62
  %64 = getelementptr inbounds float, ptr %21, i64 %indvars.iv.next
  %65 = load float, ptr %64, align 4, !tbaa !17
  %66 = getelementptr inbounds float, ptr %23, i64 %62
  %67 = load <2 x float>, ptr %63, align 4, !tbaa !17
  %68 = insertelement <2 x float> poison, float %65, i64 0
  %69 = shufflevector <2 x float> %68, <2 x float> poison, <2 x i32> zeroinitializer
  %70 = fmul <2 x float> %67, %69
  store <2 x float> %70, ptr %66, 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.next34 = add nuw nsw i64 %indvars.iv33, 1
  %exitcond37.not = icmp eq i64 %indvars.iv.next34, %wide.trip.count36
  br i1 %exitcond37.not, label %._crit_edge29, label %.preheader.us, !llvm.loop !29

._crit_edge29:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph, %4
  ret void
}

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

!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 = !{!"freq2freq_gain_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,GlobalDCEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass