; LLVM IR from robertklee/C-Optimization-DCT :: src/dct (twostep_slow)

; 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: nounwind uwtable
define dso_local void @square_matrix_multiply(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %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 i32, 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
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %62, %3
  %11 = load i32, ptr %7, align 4, !tbaa !9
  %12 = icmp slt i32 %11, 8
  br i1 %12, label %13, label %65

13:                                               ; preds = %10
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %58, %13
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 8
  br i1 %16, label %17, label %61

17:                                               ; preds = %14
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [8 x double], ptr %18, i64 %20
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [8 x double], ptr %21, i64 0, i64 %23
  store double 0.000000e+00, ptr %24, align 8, !tbaa !11
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %54, %17
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = icmp slt i32 %26, 8
  br i1 %27, label %28, label %57

28:                                               ; preds = %25
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load i32, ptr %7, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [8 x double], ptr %29, i64 %31
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [8 x double], ptr %32, i64 0, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !11
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [8 x double], ptr %37, i64 %39
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [8 x double], ptr %40, i64 0, i64 %42
  %44 = load double, ptr %43, align 8, !tbaa !11
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [8 x double], ptr %45, i64 %47
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [8 x double], ptr %48, i64 0, i64 %50
  %52 = load double, ptr %51, align 8, !tbaa !11
  %53 = call double @llvm.fmuladd.f64(double %36, double %44, double %52)
  store double %53, ptr %51, align 8, !tbaa !11
  br label %54

54:                                               ; preds = %28
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %9, align 4, !tbaa !9
  br label %25, !llvm.loop !13

57:                                               ; preds = %25
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %8, align 4, !tbaa !9
  br label %14, !llvm.loop !15

61:                                               ; preds = %14
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %7, align 4, !tbaa !9
  br label %10, !llvm.loop !16

65:                                               ; preds = %10
  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 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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @square_matrix_multiply(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  br label %.preheader

.preheader:                                       ; preds = %3, %46
  %indvars.iv24 = phi i64 [ 0, %3 ], [ %indvars.iv.next25, %46 ]
  %4 = getelementptr inbounds [8 x double], ptr %0, i64 %indvars.iv24, i64 0
  %5 = getelementptr inbounds [8 x double], ptr %0, i64 %indvars.iv24, i64 1
  %6 = getelementptr inbounds [8 x double], ptr %0, i64 %indvars.iv24, i64 2
  %7 = getelementptr inbounds [8 x double], ptr %0, i64 %indvars.iv24, i64 3
  %8 = getelementptr inbounds [8 x double], ptr %0, i64 %indvars.iv24, i64 4
  %9 = getelementptr inbounds [8 x double], ptr %0, i64 %indvars.iv24, i64 5
  %10 = getelementptr inbounds [8 x double], ptr %0, i64 %indvars.iv24, i64 6
  %11 = getelementptr inbounds [8 x double], ptr %0, i64 %indvars.iv24, i64 7
  br label %12

12:                                               ; preds = %.preheader, %12
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %12 ]
  %13 = getelementptr inbounds [8 x double], ptr %2, i64 %indvars.iv24, i64 %indvars.iv
  store double 0.000000e+00, ptr %13, align 8, !tbaa !5
  %14 = load double, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds [8 x double], ptr %1, i64 0, i64 %indvars.iv
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = tail call double @llvm.fmuladd.f64(double %14, double %16, double 0.000000e+00)
  store double %17, ptr %13, align 8, !tbaa !5
  %18 = load double, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds [8 x double], ptr %1, i64 1, i64 %indvars.iv
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = tail call double @llvm.fmuladd.f64(double %18, double %20, double %17)
  store double %21, ptr %13, align 8, !tbaa !5
  %22 = load double, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds [8 x double], ptr %1, i64 2, i64 %indvars.iv
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = tail call double @llvm.fmuladd.f64(double %22, double %24, double %21)
  store double %25, ptr %13, align 8, !tbaa !5
  %26 = load double, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds [8 x double], ptr %1, i64 3, i64 %indvars.iv
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = tail call double @llvm.fmuladd.f64(double %26, double %28, double %25)
  store double %29, ptr %13, align 8, !tbaa !5
  %30 = load double, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds [8 x double], ptr %1, i64 4, i64 %indvars.iv
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = tail call double @llvm.fmuladd.f64(double %30, double %32, double %29)
  store double %33, ptr %13, align 8, !tbaa !5
  %34 = load double, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds [8 x double], ptr %1, i64 5, i64 %indvars.iv
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = tail call double @llvm.fmuladd.f64(double %34, double %36, double %33)
  store double %37, ptr %13, align 8, !tbaa !5
  %38 = load double, ptr %10, align 8, !tbaa !5
  %39 = getelementptr inbounds [8 x double], ptr %1, i64 6, i64 %indvars.iv
  %40 = load double, ptr %39, align 8, !tbaa !5
  %41 = tail call double @llvm.fmuladd.f64(double %38, double %40, double %37)
  store double %41, ptr %13, align 8, !tbaa !5
  %42 = load double, ptr %11, align 8, !tbaa !5
  %43 = getelementptr inbounds [8 x double], ptr %1, i64 7, i64 %indvars.iv
  %44 = load double, ptr %43, align 8, !tbaa !5
  %45 = tail call double @llvm.fmuladd.f64(double %42, double %44, double %41)
  store double %45, ptr %13, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 8
  br i1 %exitcond.not, label %46, label %12, !llvm.loop !9

46:                                               ; preds = %12
  %indvars.iv.next25 = add nuw nsw i64 %indvars.iv24, 1
  %exitcond27.not = icmp eq i64 %indvars.iv.next25, 8
  br i1 %exitcond27.not, label %47, label %.preheader, !llvm.loop !11

47:                                               ; preds = %46
  ret void
}

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

attributes #0 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass