; LLVM IR from aferikoglou/GenHLSOptimizer :: dataset/rodinia-backprop-0-baseline-back (backprop_kernel)

; 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: mustprogress nounwind uwtable
define dso_local void @workload(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, 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) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds float, ptr %13, i64 0
  store float 1.000000e+00, ptr %14, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %4
  store i32 1, ptr %12, align 4, !tbaa !11
  br label %16

16:                                               ; preds = %72, %15
  %17 = load i32, ptr %12, align 4, !tbaa !11
  %18 = icmp slt i32 %17, 17
  br i1 %18, label %19, label %75

19:                                               ; preds = %16
  br label %20

20:                                               ; preds = %19
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %68, %20
  %22 = load i32, ptr %10, align 4, !tbaa !11
  %23 = icmp slt i32 %22, 65537
  br i1 %23, label %24, label %71

24:                                               ; preds = %21
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load i32, ptr %12, align 4, !tbaa !11
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds float, ptr %25, i64 %27
  %29 = load float, ptr %28, align 4, !tbaa !9
  %30 = fpext float %29 to double
  %31 = fmul double 3.000000e-01, %30
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load i32, ptr %10, align 4, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds float, ptr %32, i64 %34
  %36 = load float, ptr %35, align 4, !tbaa !9
  %37 = fpext float %36 to double
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = load i32, ptr %10, align 4, !tbaa !11
  %40 = mul nsw i32 %39, 17
  %41 = load i32, ptr %12, align 4, !tbaa !11
  %42 = add nsw i32 %40, %41
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %38, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !9
  %46 = fpext float %45 to double
  %47 = fmul double 3.000000e-01, %46
  %48 = call double @llvm.fmuladd.f64(double %31, double %37, double %47)
  %49 = fptrunc double %48 to float
  store float %49, ptr %9, align 4, !tbaa !9
  %50 = load float, ptr %9, align 4, !tbaa !9
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = load i32, ptr %10, align 4, !tbaa !11
  %53 = mul nsw i32 %52, 17
  %54 = load i32, ptr %12, align 4, !tbaa !11
  %55 = add nsw i32 %53, %54
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds float, ptr %51, i64 %56
  %58 = load float, ptr %57, align 4, !tbaa !9
  %59 = fadd float %58, %50
  store float %59, ptr %57, align 4, !tbaa !9
  %60 = load float, ptr %9, align 4, !tbaa !9
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = load i32, ptr %10, align 4, !tbaa !11
  %63 = mul nsw i32 %62, 17
  %64 = load i32, ptr %12, align 4, !tbaa !11
  %65 = add nsw i32 %63, %64
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds float, ptr %61, i64 %66
  store float %60, ptr %67, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %24
  %69 = load i32, ptr %10, align 4, !tbaa !11
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %10, align 4, !tbaa !11
  br label %21, !llvm.loop !13

71:                                               ; preds = %21
  br label %72

72:                                               ; preds = %71
  %73 = load i32, ptr %12, align 4, !tbaa !11
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %12, align 4, !tbaa !11
  br label %16, !llvm.loop !15

75:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  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
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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 @workload(ptr nocapture noundef readonly %0, ptr nocapture noundef %1, ptr nocapture noundef %2, ptr nocapture noundef %3) local_unnamed_addr #0 {
  store float 1.000000e+00, ptr %1, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %4, %24
  %indvars.iv23 = phi i64 [ 1, %4 ], [ %indvars.iv.next24, %24 ]
  %5 = getelementptr inbounds float, ptr %0, i64 %indvars.iv23
  br label %6

6:                                                ; preds = %.preheader, %6
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %6 ]
  %7 = load float, ptr %5, align 4, !tbaa !5
  %8 = fpext float %7 to double
  %9 = fmul double %8, 3.000000e-01
  %10 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = fpext float %11 to double
  %13 = mul nuw nsw i64 %indvars.iv, 17
  %14 = add nuw nsw i64 %13, %indvars.iv23
  %15 = getelementptr inbounds float, ptr %3, i64 %14
  %16 = load float, ptr %15, align 4, !tbaa !5
  %17 = fpext float %16 to double
  %18 = fmul double %17, 3.000000e-01
  %19 = tail call double @llvm.fmuladd.f64(double %9, double %12, double %18)
  %20 = fptrunc double %19 to float
  %21 = getelementptr inbounds float, ptr %2, i64 %14
  %22 = load float, ptr %21, align 4, !tbaa !5
  %23 = fadd float %22, %20
  store float %23, ptr %21, align 4, !tbaa !5
  store float %20, ptr %15, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 65537
  br i1 %exitcond.not, label %24, label %6, !llvm.loop !9

24:                                               ; preds = %6
  %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
  %exitcond26.not = icmp eq i64 %indvars.iv.next24, 17
  br i1 %exitcond26.not, label %25, label %.preheader, !llvm.loop !11

25:                                               ; preds = %24
  ret void
}

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

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" }
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 = !{!"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: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass