; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/MINC/src/libminc/nifti (nifti1_io)

; 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.mat33 = type { [3 x [3 x float]] }

; 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 @nifti_mat33_mul(ptr dead_on_unwind noalias writable sret(%struct.mat33) align 4 %0, ptr noundef byval(%struct.mat33) align 8 %1, ptr noundef byval(%struct.mat33) align 8 %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %64, %3
  %7 = load i32, ptr %4, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 3
  br i1 %8, label %9, label %67

9:                                                ; preds = %6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %60, %9
  %11 = load i32, ptr %5, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 3
  br i1 %12, label %13, label %63

13:                                               ; preds = %10
  %14 = getelementptr inbounds %struct.mat33, ptr %1, i32 0, i32 0
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [3 x [3 x float]], ptr %14, i64 0, i64 %16
  %18 = getelementptr inbounds [3 x float], ptr %17, i64 0, i64 0
  %19 = load float, ptr %18, align 4, !tbaa !9
  %20 = getelementptr inbounds %struct.mat33, ptr %2, i32 0, i32 0
  %21 = getelementptr inbounds [3 x [3 x float]], ptr %20, i64 0, i64 0
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [3 x float], ptr %21, i64 0, i64 %23
  %25 = load float, ptr %24, align 4, !tbaa !9
  %26 = getelementptr inbounds %struct.mat33, ptr %1, i32 0, i32 0
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [3 x [3 x float]], ptr %26, i64 0, i64 %28
  %30 = getelementptr inbounds [3 x float], ptr %29, i64 0, i64 1
  %31 = load float, ptr %30, align 4, !tbaa !9
  %32 = getelementptr inbounds %struct.mat33, ptr %2, i32 0, i32 0
  %33 = getelementptr inbounds [3 x [3 x float]], ptr %32, i64 0, i64 1
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [3 x float], ptr %33, i64 0, i64 %35
  %37 = load float, ptr %36, align 4, !tbaa !9
  %38 = fmul float %31, %37
  %39 = call float @llvm.fmuladd.f32(float %19, float %25, float %38)
  %40 = getelementptr inbounds %struct.mat33, ptr %1, i32 0, i32 0
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [3 x [3 x float]], ptr %40, i64 0, i64 %42
  %44 = getelementptr inbounds [3 x float], ptr %43, i64 0, i64 2
  %45 = load float, ptr %44, align 4, !tbaa !9
  %46 = getelementptr inbounds %struct.mat33, ptr %2, i32 0, i32 0
  %47 = getelementptr inbounds [3 x [3 x float]], ptr %46, i64 0, i64 2
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [3 x float], ptr %47, i64 0, i64 %49
  %51 = load float, ptr %50, align 4, !tbaa !9
  %52 = call float @llvm.fmuladd.f32(float %45, float %51, float %39)
  %53 = getelementptr inbounds %struct.mat33, ptr %0, i32 0, i32 0
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [3 x [3 x float]], ptr %53, i64 0, i64 %55
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [3 x float], ptr %56, i64 0, i64 %58
  store float %52, ptr %59, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %13
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %5, align 4, !tbaa !5
  br label %10, !llvm.loop !11

63:                                               ; preds = %10
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %4, align 4, !tbaa !5
  br label %6, !llvm.loop !13

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


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

%struct.mat33 = type { [3 x [3 x float]] }

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @nifti_mat33_mul(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.mat33) align 4 %0, ptr nocapture noundef readonly byval(%struct.mat33) align 8 %1, ptr nocapture noundef readonly byval(%struct.mat33) align 8 %2) local_unnamed_addr #1 {
.preheader:
  %3 = getelementptr inbounds i8, ptr %2, i64 12
  %4 = getelementptr inbounds i8, ptr %2, i64 24
  %5 = load <4 x float>, ptr %1, align 8
  %6 = getelementptr inbounds i8, ptr %1, i64 4
  %7 = load <4 x float>, ptr %6, align 4
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load <4 x float>, ptr %8, align 8
  %10 = load float, ptr %2, align 8, !tbaa !5
  %11 = load float, ptr %3, align 4, !tbaa !5
  %12 = load float, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %2, i64 4
  %14 = getelementptr inbounds i8, ptr %2, i64 16
  %15 = getelementptr inbounds i8, ptr %2, i64 28
  %16 = load <2 x float>, ptr %13, align 4, !tbaa !5
  %17 = load <2 x float>, ptr %14, align 8, !tbaa !5
  %18 = load <2 x float>, ptr %15, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 12
  %20 = load float, ptr %19, align 4, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %1, i64 16
  %22 = load float, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %1, i64 20
  %24 = load float, ptr %23, align 4, !tbaa !5
  %25 = insertelement <4 x float> %7, float %22, i64 1
  %26 = shufflevector <4 x float> %25, <4 x float> poison, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
  %27 = insertelement <4 x float> poison, float %11, i64 0
  %28 = shufflevector <2 x float> %17, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 1, i32 poison>
  %29 = shufflevector <4 x float> %27, <4 x float> %28, <4 x i32> <i32 0, i32 4, i32 5, i32 poison>
  %30 = shufflevector <4 x float> %29, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %31 = fmul <4 x float> %26, %30
  %32 = insertelement <4 x float> %5, float %20, i64 1
  %33 = shufflevector <4 x float> %32, <4 x float> poison, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
  %34 = insertelement <4 x float> poison, float %10, i64 0
  %35 = shufflevector <2 x float> %16, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 1, i32 poison>
  %36 = shufflevector <4 x float> %34, <4 x float> %35, <4 x i32> <i32 0, i32 4, i32 5, i32 poison>
  %37 = shufflevector <4 x float> %36, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %38 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %33, <4 x float> %37, <4 x float> %31)
  %39 = insertelement <4 x float> %9, float %24, i64 1
  %40 = shufflevector <4 x float> %39, <4 x float> poison, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
  %41 = insertelement <4 x float> poison, float %12, i64 0
  %42 = shufflevector <2 x float> %18, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 1, i32 poison>
  %43 = shufflevector <4 x float> %41, <4 x float> %42, <4 x i32> <i32 0, i32 4, i32 5, i32 poison>
  %44 = shufflevector <4 x float> %43, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %45 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %40, <4 x float> %44, <4 x float> %38)
  store <4 x float> %45, ptr %0, align 4, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %0, i64 16
  %47 = getelementptr inbounds i8, ptr %1, i64 24
  %48 = load float, ptr %47, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %1, i64 28
  %50 = load float, ptr %49, align 4, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %1, i64 32
  %52 = load float, ptr %51, align 8, !tbaa !5
  %53 = insertelement <4 x float> poison, float %22, i64 0
  %54 = insertelement <4 x float> %53, float %50, i64 1
  %55 = shufflevector <4 x float> %54, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
  %56 = insertelement <4 x float> %28, float %11, i64 1
  %57 = shufflevector <4 x float> %56, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %58 = fmul <4 x float> %55, %57
  %59 = insertelement <4 x float> poison, float %20, i64 0
  %60 = insertelement <4 x float> %59, float %48, i64 1
  %61 = shufflevector <4 x float> %60, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
  %62 = insertelement <4 x float> %35, float %10, i64 1
  %63 = shufflevector <4 x float> %62, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %64 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %61, <4 x float> %63, <4 x float> %58)
  %65 = insertelement <4 x float> poison, float %24, i64 0
  %66 = insertelement <4 x float> %65, float %52, i64 1
  %67 = shufflevector <4 x float> %66, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
  %68 = insertelement <4 x float> %42, float %12, i64 1
  %69 = shufflevector <4 x float> %68, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %70 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %67, <4 x float> %69, <4 x float> %64)
  %71 = shufflevector <4 x float> %70, <4 x float> poison, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  store <4 x float> %71, ptr %46, align 4, !tbaa !5
  %72 = extractelement <2 x float> %17, i64 1
  %73 = fmul float %50, %72
  %74 = extractelement <2 x float> %16, i64 1
  %75 = tail call float @llvm.fmuladd.f32(float %48, float %74, float %73)
  %76 = extractelement <2 x float> %18, i64 1
  %77 = tail call float @llvm.fmuladd.f32(float %52, float %76, float %75)
  %78 = getelementptr inbounds i8, ptr %0, i64 32
  store float %77, ptr %78, align 4, !tbaa !5
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn 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 #2 = { 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/C++ TBAA"}


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