; LLVM IR from certik/mlc :: mlc_clib (kernels)

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

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

16:                                               ; preds = %67, %6
  %17 = load i32, ptr %13, align 4, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %16
  %22 = load ptr, ptr %12, align 8, !tbaa !9
  %23 = load i32, ptr %13, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds float, ptr %22, i64 %24
  store float 0.000000e+00, ptr %25, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %52, %21
  %27 = load i32, ptr %15, align 4, !tbaa !5
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = icmp slt i32 %27, %28
  br i1 %29, label %31, label %30

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

31:                                               ; preds = %26
  %32 = load ptr, ptr %9, align 8, !tbaa !9
  %33 = load i32, ptr %13, align 4, !tbaa !5
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = mul nsw i32 %33, %34
  %36 = load i32, ptr %15, align 4, !tbaa !5
  %37 = add nsw i32 %35, %36
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds float, ptr %32, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !11
  %41 = load ptr, ptr %10, align 8, !tbaa !9
  %42 = load i32, ptr %15, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %41, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !11
  %46 = load ptr, ptr %12, align 8, !tbaa !9
  %47 = load i32, ptr %13, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds float, ptr %46, i64 %48
  %50 = load float, ptr %49, align 4, !tbaa !11
  %51 = call float @llvm.fmuladd.f32(float %40, float %45, float %50)
  store float %51, ptr %49, align 4, !tbaa !11
  br label %52

52:                                               ; preds = %31
  %53 = load i32, ptr %15, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %15, align 4, !tbaa !5
  br label %26, !llvm.loop !13

55:                                               ; preds = %30
  %56 = load ptr, ptr %11, align 8, !tbaa !9
  %57 = load i32, ptr %13, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds float, ptr %56, i64 %58
  %60 = load float, ptr %59, align 4, !tbaa !11
  %61 = load ptr, ptr %12, align 8, !tbaa !9
  %62 = load i32, ptr %13, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds float, ptr %61, i64 %63
  %65 = load float, ptr %64, align 4, !tbaa !11
  %66 = fadd float %65, %60
  store float %66, ptr %64, align 4, !tbaa !11
  br label %67

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

70:                                               ; preds = %20
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @saxpy(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #1 {
  %7 = icmp sgt i32 %0, 0
  br i1 %7, label %.lr.ph24, label %._crit_edge25

.lr.ph24:                                         ; preds = %6
  %8 = icmp sgt i32 %1, 0
  br i1 %8, label %.lr.ph.us.preheader, label %.lr.ph24.split.preheader

.lr.ph24.split.preheader:                         ; preds = %.lr.ph24
  %wide.trip.count = zext nneg i32 %0 to i64
  %min.iters.check = icmp ult i32 %0, 8
  br i1 %min.iters.check, label %.lr.ph24.split.preheader42, label %vector.memcheck

.lr.ph24.split.preheader42:                       ; preds = %middle.block, %vector.memcheck, %.lr.ph24.split.preheader
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph24.split.preheader ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph24.split.prol.loopexit, label %.lr.ph24.split.prol

.lr.ph24.split.prol:                              ; preds = %.lr.ph24.split.preheader42
  %9 = getelementptr inbounds float, ptr %5, i64 %indvars.iv.ph
  store float 0.000000e+00, ptr %9, align 4, !tbaa !5
  %10 = getelementptr inbounds float, ptr %4, i64 %indvars.iv.ph
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = fadd float %11, 0.000000e+00
  store float %12, ptr %9, align 4, !tbaa !5
  %indvars.iv.next.prol = or disjoint i64 %indvars.iv.ph, 1
  br label %.lr.ph24.split.prol.loopexit

.lr.ph24.split.prol.loopexit:                     ; preds = %.lr.ph24.split.prol, %.lr.ph24.split.preheader42
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %.lr.ph24.split.preheader42 ], [ %indvars.iv.next.prol, %.lr.ph24.split.prol ]
  %13 = add nsw i64 %wide.trip.count, -1
  %14 = icmp eq i64 %indvars.iv.ph, %13
  br i1 %14, label %._crit_edge25, label %.lr.ph24.split

vector.memcheck:                                  ; preds = %.lr.ph24.split.preheader
  %15 = shl nuw nsw i64 %wide.trip.count, 2
  %scevgep = getelementptr i8, ptr %5, i64 %15
  %scevgep40 = getelementptr i8, ptr %4, i64 %15
  %bound0 = icmp ugt ptr %scevgep40, %5
  %bound1 = icmp ugt ptr %scevgep, %4
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %.lr.ph24.split.preheader42, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %16 = getelementptr inbounds float, ptr %5, i64 %index
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  store <4 x float> zeroinitializer, ptr %16, align 4, !tbaa !5, !alias.scope !9, !noalias !12
  store <4 x float> zeroinitializer, ptr %17, align 4, !tbaa !5, !alias.scope !9, !noalias !12
  %18 = getelementptr inbounds float, ptr %4, i64 %index
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %wide.load = load <4 x float>, ptr %18, align 4, !tbaa !5, !alias.scope !12
  %wide.load41 = load <4 x float>, ptr %19, align 4, !tbaa !5, !alias.scope !12
  %20 = fadd <4 x float> %wide.load, zeroinitializer
  %21 = fadd <4 x float> %wide.load41, zeroinitializer
  store <4 x float> %20, ptr %16, align 4, !tbaa !5, !alias.scope !9, !noalias !12
  store <4 x float> %21, ptr %17, align 4, !tbaa !5, !alias.scope !9, !noalias !12
  %index.next = add nuw i64 %index, 8
  %22 = icmp eq i64 %index.next, %n.vec
  br i1 %22, label %middle.block, label %vector.body, !llvm.loop !14

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge25, label %.lr.ph24.split.preheader42

.lr.ph.us.preheader:                              ; preds = %.lr.ph24
  %23 = zext nneg i32 %1 to i64
  %wide.trip.count36 = zext nneg i32 %0 to i64
  %xtraiter44 = and i64 %23, 1
  %24 = icmp eq i32 %1, 1
  %unroll_iter = and i64 %23, 2147483646
  %lcmp.mod45.not = icmp eq i64 %xtraiter44, 0
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %._crit_edge.us
  %indvars.iv33 = phi i64 [ 0, %.lr.ph.us.preheader ], [ %indvars.iv.next34, %._crit_edge.us ]
  %25 = getelementptr inbounds float, ptr %5, i64 %indvars.iv33
  store float 0.000000e+00, ptr %25, align 4, !tbaa !5
  %26 = mul nuw nsw i64 %indvars.iv33, %23
  %invariant.gep = getelementptr inbounds float, ptr %2, i64 %26
  br i1 %24, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.new

.lr.ph.us.new:                                    ; preds = %.lr.ph.us, %.lr.ph.us.new
  %indvars.iv28 = phi i64 [ %indvars.iv.next29.1, %.lr.ph.us.new ], [ 0, %.lr.ph.us ]
  %27 = phi float [ %35, %.lr.ph.us.new ], [ 0.000000e+00, %.lr.ph.us ]
  %niter = phi i64 [ %niter.next.1, %.lr.ph.us.new ], [ 0, %.lr.ph.us ]
  %gep = getelementptr inbounds float, ptr %invariant.gep, i64 %indvars.iv28
  %28 = load float, ptr %gep, align 4, !tbaa !5
  %29 = getelementptr inbounds float, ptr %3, i64 %indvars.iv28
  %30 = load float, ptr %29, align 4, !tbaa !5
  %31 = tail call float @llvm.fmuladd.f32(float %28, float %30, float %27)
  store float %31, ptr %25, align 4, !tbaa !5
  %indvars.iv.next29 = or disjoint i64 %indvars.iv28, 1
  %gep.1 = getelementptr inbounds float, ptr %invariant.gep, i64 %indvars.iv.next29
  %32 = load float, ptr %gep.1, align 4, !tbaa !5
  %33 = getelementptr inbounds float, ptr %3, i64 %indvars.iv.next29
  %34 = load float, ptr %33, align 4, !tbaa !5
  %35 = tail call float @llvm.fmuladd.f32(float %32, float %34, float %31)
  store float %35, ptr %25, align 4, !tbaa !5
  %indvars.iv.next29.1 = add nuw nsw i64 %indvars.iv28, 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 %.lr.ph.us.new, !llvm.loop !18

._crit_edge.us.unr-lcssa:                         ; preds = %.lr.ph.us.new, %.lr.ph.us
  %.lcssa.ph = phi float [ poison, %.lr.ph.us ], [ %35, %.lr.ph.us.new ]
  %indvars.iv28.unr = phi i64 [ 0, %.lr.ph.us ], [ %indvars.iv.next29.1, %.lr.ph.us.new ]
  %.unr = phi float [ 0.000000e+00, %.lr.ph.us ], [ %35, %.lr.ph.us.new ]
  br i1 %lcmp.mod45.not, label %._crit_edge.us, label %._crit_edge.us.epilog-lcssa

._crit_edge.us.epilog-lcssa:                      ; preds = %._crit_edge.us.unr-lcssa
  %gep.epil = getelementptr inbounds float, ptr %invariant.gep, i64 %indvars.iv28.unr
  %36 = load float, ptr %gep.epil, align 4, !tbaa !5
  %37 = getelementptr inbounds float, ptr %3, i64 %indvars.iv28.unr
  %38 = load float, ptr %37, align 4, !tbaa !5
  %39 = tail call float @llvm.fmuladd.f32(float %36, float %38, float %.unr)
  store float %39, ptr %25, align 4, !tbaa !5
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %.lcssa = phi float [ %.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %39, %._crit_edge.us.epilog-lcssa ]
  %40 = getelementptr inbounds float, ptr %4, i64 %indvars.iv33
  %41 = load float, ptr %40, align 4, !tbaa !5
  %42 = fadd float %41, %.lcssa
  store float %42, ptr %25, align 4, !tbaa !5
  %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_edge25, label %.lr.ph.us, !llvm.loop !19

._crit_edge25:                                    ; preds = %.lr.ph24.split.prol.loopexit, %.lr.ph24.split, %._crit_edge.us, %middle.block, %6
  ret void

.lr.ph24.split:                                   ; preds = %.lr.ph24.split.prol.loopexit, %.lr.ph24.split
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph24.split ], [ %indvars.iv.unr, %.lr.ph24.split.prol.loopexit ]
  %43 = getelementptr inbounds float, ptr %5, i64 %indvars.iv
  store float 0.000000e+00, ptr %43, align 4, !tbaa !5
  %44 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  %45 = load float, ptr %44, align 4, !tbaa !5
  %46 = fadd float %45, 0.000000e+00
  store float %46, ptr %43, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %47 = getelementptr inbounds float, ptr %5, i64 %indvars.iv.next
  store float 0.000000e+00, ptr %47, align 4, !tbaa !5
  %48 = getelementptr inbounds float, ptr %4, i64 %indvars.iv.next
  %49 = load float, ptr %48, align 4, !tbaa !5
  %50 = fadd float %49, 0.000000e+00
  store float %50, ptr %47, align 4, !tbaa !5
  %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_edge25, label %.lr.ph24.split, !llvm.loop !20
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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/C++ TBAA"}
!9 = !{!10}
!10 = distinct !{!10, !11}
!11 = distinct !{!11, !"LVerDomain"}
!12 = !{!13}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !15, !16, !17}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !15}
!19 = distinct !{!19, !15}
!20 = distinct !{!20, !15, !16}


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