; LLVM IR from rdguez-mariano/fast_imas_IPOL :: libSimuTilts/library.ll (Z6samplePfS_fii)

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

; 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
define dso_local void @_Z6samplePfS_fii(ptr noundef %0, ptr noundef %1, float noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store float %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %16 = load i32, ptr %9, align 4, !tbaa !11
  %17 = sitofp i32 %16 to float
  %18 = load float, ptr %8, align 4, !tbaa !9
  %19 = fdiv float %17, %18
  %20 = fptosi float %19 to i32
  store i32 %20, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %21 = load i32, ptr %10, align 4, !tbaa !11
  %22 = sitofp i32 %21 to float
  %23 = load float, ptr %8, align 4, !tbaa !9
  %24 = fdiv float %22, %23
  %25 = fptosi float %24 to i32
  store i32 %25, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  store i32 0, ptr %13, align 4, !tbaa !11
  br label %26

26:                                               ; preds = %67, %5
  %27 = load i32, ptr %13, align 4, !tbaa !11
  %28 = load i32, ptr %12, align 4, !tbaa !11
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  br label %70

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #2
  store i32 0, ptr %15, align 4, !tbaa !11
  br label %32

32:                                               ; preds = %63, %31
  %33 = load i32, ptr %15, align 4, !tbaa !11
  %34 = load i32, ptr %11, align 4, !tbaa !11
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #2
  br label %66

37:                                               ; preds = %32
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load i32, ptr %13, align 4, !tbaa !11
  %40 = sitofp i32 %39 to float
  %41 = load float, ptr %8, align 4, !tbaa !9
  %42 = fmul float %40, %41
  %43 = fptosi float %42 to i32
  %44 = load i32, ptr %9, align 4, !tbaa !11
  %45 = mul nsw i32 %43, %44
  %46 = load i32, ptr %15, align 4, !tbaa !11
  %47 = sitofp i32 %46 to float
  %48 = load float, ptr %8, align 4, !tbaa !9
  %49 = fmul float %47, %48
  %50 = fptosi float %49 to i32
  %51 = add nsw i32 %45, %50
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds float, ptr %38, i64 %52
  %54 = load float, ptr %53, align 4, !tbaa !9
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = load i32, ptr %13, align 4, !tbaa !11
  %57 = load i32, ptr %11, align 4, !tbaa !11
  %58 = mul nsw i32 %56, %57
  %59 = load i32, ptr %15, align 4, !tbaa !11
  %60 = add nsw i32 %58, %59
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds float, ptr %55, i64 %61
  store float %54, ptr %62, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %37
  %64 = load i32, ptr %15, align 4, !tbaa !11
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %15, align 4, !tbaa !11
  br label %32, !llvm.loop !13

66:                                               ; preds = %36
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %13, align 4, !tbaa !11
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %13, align 4, !tbaa !11
  br label %26, !llvm.loop !15

70:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @_Z6samplePfS_fii(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, float noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = insertelement <2 x i32> poison, i32 %3, i64 0
  %7 = insertelement <2 x i32> %6, i32 %4, i64 1
  %8 = sitofp <2 x i32> %7 to <2 x float>
  %9 = insertelement <2 x float> poison, float %2, i64 0
  %10 = shufflevector <2 x float> %9, <2 x float> poison, <2 x i32> zeroinitializer
  %11 = fdiv <2 x float> %8, %10
  %12 = fptosi <2 x float> %11 to <2 x i32>
  %13 = icmp sgt <2 x i32> %12, zeroinitializer
  %14 = extractelement <2 x i1> %13, i64 0
  %15 = extractelement <2 x i1> %13, i64 1
  %or.cond = select i1 %15, i1 %14, i1 false
  br i1 %or.cond, label %.preheader.us.preheader, label %._crit_edge23

.preheader.us.preheader:                          ; preds = %5
  %16 = extractelement <2 x i32> %12, i64 0
  %17 = zext nneg i32 %16 to i64
  %18 = extractelement <2 x i32> %12, i64 1
  %wide.trip.count29 = zext nneg i32 %18 to i64
  %xtraiter = and i64 %17, 1
  %19 = icmp eq i32 %16, 1
  %unroll_iter = and i64 %17, 2147483646
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv26 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next27, %._crit_edge.us ]
  %20 = trunc nuw nsw i64 %indvars.iv26 to i32
  %21 = uitofp nneg i32 %20 to float
  %22 = fmul float %21, %2
  %23 = fptosi float %22 to i32
  %24 = mul nsw i32 %23, %3
  %25 = mul nuw nsw i64 %indvars.iv26, %17
  %invariant.gep = getelementptr inbounds float, ptr %1, i64 %25
  br i1 %19, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %niter = phi i64 [ %niter.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %26 = trunc nuw nsw i64 %indvars.iv to i32
  %27 = uitofp nneg i32 %26 to float
  %28 = fmul float %27, %2
  %29 = fptosi float %28 to i32
  %30 = add nsw i32 %24, %29
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds float, ptr %0, i64 %31
  %33 = load float, ptr %32, align 4, !tbaa !5
  %gep = getelementptr inbounds float, ptr %invariant.gep, i64 %indvars.iv
  store float %33, ptr %gep, align 4, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %34 = trunc nuw nsw i64 %indvars.iv.next to i32
  %35 = uitofp nneg i32 %34 to float
  %36 = fmul float %35, %2
  %37 = fptosi float %36 to i32
  %38 = add nsw i32 %24, %37
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %0, i64 %39
  %41 = load float, ptr %40, align 4, !tbaa !5
  %gep.1 = getelementptr inbounds float, ptr %invariant.gep, i64 %indvars.iv.next
  store float %41, ptr %gep.1, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !9

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader.us.new, %.preheader.us
  %indvars.iv.unr = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next.1, %.preheader.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %._crit_edge.us.epilog-lcssa

._crit_edge.us.epilog-lcssa:                      ; preds = %._crit_edge.us.unr-lcssa
  %42 = trunc nuw nsw i64 %indvars.iv.unr to i32
  %43 = uitofp nneg i32 %42 to float
  %44 = fmul float %43, %2
  %45 = fptosi float %44 to i32
  %46 = add nsw i32 %24, %45
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds float, ptr %0, i64 %47
  %49 = load float, ptr %48, align 4, !tbaa !5
  %gep.epil = getelementptr inbounds float, ptr %invariant.gep, i64 %indvars.iv.unr
  store float %49, ptr %gep.epil, align 4, !tbaa !5
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %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_edge23, label %.preheader.us, !llvm.loop !11

._crit_edge23:                                    ; preds = %._crit_edge.us, %5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(argmem: readwrite) 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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass