; 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 double @llvm.fabs.f64(double) #1

; Function Attrs: nounwind uwtable
define dso_local float @nifti_mat33_colnorm(ptr noundef byval(%struct.mat33) align 8 %0) #2 {
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %5 = getelementptr inbounds %struct.mat33, ptr %0, i32 0, i32 0
  %6 = getelementptr inbounds [3 x [3 x float]], ptr %5, i64 0, i64 0
  %7 = getelementptr inbounds [3 x float], ptr %6, i64 0, i64 0
  %8 = load float, ptr %7, align 8, !tbaa !5
  %9 = fpext float %8 to double
  %10 = call double @llvm.fabs.f64(double %9)
  %11 = getelementptr inbounds %struct.mat33, ptr %0, i32 0, i32 0
  %12 = getelementptr inbounds [3 x [3 x float]], ptr %11, i64 0, i64 1
  %13 = getelementptr inbounds [3 x float], ptr %12, i64 0, i64 0
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = fpext float %14 to double
  %16 = call double @llvm.fabs.f64(double %15)
  %17 = fadd double %10, %16
  %18 = getelementptr inbounds %struct.mat33, ptr %0, i32 0, i32 0
  %19 = getelementptr inbounds [3 x [3 x float]], ptr %18, i64 0, i64 2
  %20 = getelementptr inbounds [3 x float], ptr %19, i64 0, i64 0
  %21 = load float, ptr %20, align 8, !tbaa !5
  %22 = fpext float %21 to double
  %23 = call double @llvm.fabs.f64(double %22)
  %24 = fadd double %17, %23
  %25 = fptrunc double %24 to float
  store float %25, ptr %2, align 4, !tbaa !5
  %26 = getelementptr inbounds %struct.mat33, ptr %0, i32 0, i32 0
  %27 = getelementptr inbounds [3 x [3 x float]], ptr %26, i64 0, i64 0
  %28 = getelementptr inbounds [3 x float], ptr %27, i64 0, i64 1
  %29 = load float, ptr %28, align 4, !tbaa !5
  %30 = fpext float %29 to double
  %31 = call double @llvm.fabs.f64(double %30)
  %32 = getelementptr inbounds %struct.mat33, ptr %0, i32 0, i32 0
  %33 = getelementptr inbounds [3 x [3 x float]], ptr %32, i64 0, i64 1
  %34 = getelementptr inbounds [3 x float], ptr %33, i64 0, i64 1
  %35 = load float, ptr %34, align 4, !tbaa !5
  %36 = fpext float %35 to double
  %37 = call double @llvm.fabs.f64(double %36)
  %38 = fadd double %31, %37
  %39 = getelementptr inbounds %struct.mat33, ptr %0, i32 0, i32 0
  %40 = getelementptr inbounds [3 x [3 x float]], ptr %39, i64 0, i64 2
  %41 = getelementptr inbounds [3 x float], ptr %40, i64 0, i64 1
  %42 = load float, ptr %41, align 4, !tbaa !5
  %43 = fpext float %42 to double
  %44 = call double @llvm.fabs.f64(double %43)
  %45 = fadd double %38, %44
  %46 = fptrunc double %45 to float
  store float %46, ptr %3, align 4, !tbaa !5
  %47 = getelementptr inbounds %struct.mat33, ptr %0, i32 0, i32 0
  %48 = getelementptr inbounds [3 x [3 x float]], ptr %47, i64 0, i64 0
  %49 = getelementptr inbounds [3 x float], ptr %48, i64 0, i64 2
  %50 = load float, ptr %49, align 8, !tbaa !5
  %51 = fpext float %50 to double
  %52 = call double @llvm.fabs.f64(double %51)
  %53 = getelementptr inbounds %struct.mat33, ptr %0, i32 0, i32 0
  %54 = getelementptr inbounds [3 x [3 x float]], ptr %53, i64 0, i64 1
  %55 = getelementptr inbounds [3 x float], ptr %54, i64 0, i64 2
  %56 = load float, ptr %55, align 4, !tbaa !5
  %57 = fpext float %56 to double
  %58 = call double @llvm.fabs.f64(double %57)
  %59 = fadd double %52, %58
  %60 = getelementptr inbounds %struct.mat33, ptr %0, i32 0, i32 0
  %61 = getelementptr inbounds [3 x [3 x float]], ptr %60, i64 0, i64 2
  %62 = getelementptr inbounds [3 x float], ptr %61, i64 0, i64 2
  %63 = load float, ptr %62, align 8, !tbaa !5
  %64 = fpext float %63 to double
  %65 = call double @llvm.fabs.f64(double %64)
  %66 = fadd double %59, %65
  %67 = fptrunc double %66 to float
  store float %67, ptr %4, align 4, !tbaa !5
  %68 = load float, ptr %2, align 4, !tbaa !5
  %69 = load float, ptr %3, align 4, !tbaa !5
  %70 = fcmp olt float %68, %69
  br i1 %70, label %71, label %73

71:                                               ; preds = %1
  %72 = load float, ptr %3, align 4, !tbaa !5
  store float %72, ptr %2, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %71, %1
  %74 = load float, ptr %2, align 4, !tbaa !5
  %75 = load float, ptr %4, align 4, !tbaa !5
  %76 = fcmp olt float %74, %75
  br i1 %76, label %77, label %79

77:                                               ; preds = %73
  %78 = load float, ptr %4, align 4, !tbaa !5
  store float %78, ptr %2, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %77, %73
  %80 = load float, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret float %80
}

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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local float @nifti_mat33_colnorm(ptr nocapture noundef readonly byval(%struct.mat33) align 8 %0) local_unnamed_addr #0 {
  %2 = load <4 x float>, ptr %0, align 8
  %3 = shufflevector <4 x float> %2, <4 x float> poison, <2 x i32> <i32 0, i32 poison>
  %4 = getelementptr inbounds i8, ptr %0, i64 12
  %5 = load float, ptr %4, align 4, !tbaa !5
  %6 = insertelement <2 x float> %3, float %5, i64 1
  %7 = tail call <2 x float> @llvm.fabs.v2f32(<2 x float> %6)
  %8 = fpext <2 x float> %7 to <2 x double>
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  %11 = load <4 x float>, ptr %10, align 4
  %12 = shufflevector <4 x float> %11, <4 x float> poison, <2 x i32> <i32 0, i32 poison>
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load float, ptr %13, align 8, !tbaa !5
  %15 = insertelement <2 x float> %12, float %14, i64 1
  %16 = tail call <2 x float> @llvm.fabs.v2f32(<2 x float> %15)
  %17 = fpext <2 x float> %16 to <2 x double>
  %18 = shufflevector <2 x double> %8, <2 x double> %17, <2 x i32> <i32 0, i32 2>
  %19 = shufflevector <2 x double> %8, <2 x double> %17, <2 x i32> <i32 1, i32 3>
  %20 = fadd <2 x double> %18, %19
  %21 = load <2 x float>, ptr %9, align 8, !tbaa !5
  %22 = tail call <2 x float> @llvm.fabs.v2f32(<2 x float> %21)
  %23 = fpext <2 x float> %22 to <2 x double>
  %24 = fadd <2 x double> %20, %23
  %25 = fptrunc <2 x double> %24 to <2 x float>
  %26 = getelementptr inbounds i8, ptr %0, i64 8
  %27 = load <4 x float>, ptr %26, align 8
  %28 = shufflevector <4 x float> %27, <4 x float> poison, <2 x i32> <i32 0, i32 poison>
  %29 = getelementptr inbounds i8, ptr %0, i64 20
  %30 = load float, ptr %29, align 4, !tbaa !5
  %31 = insertelement <2 x float> %28, float %30, i64 1
  %32 = tail call <2 x float> @llvm.fabs.v2f32(<2 x float> %31)
  %33 = fpext <2 x float> %32 to <2 x double>
  %shift = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %34 = fadd <2 x double> %shift, %33
  %35 = extractelement <2 x double> %34, i64 0
  %36 = getelementptr inbounds i8, ptr %0, i64 32
  %37 = load float, ptr %36, align 8, !tbaa !5
  %38 = tail call float @llvm.fabs.f32(float %37)
  %39 = fpext float %38 to double
  %40 = fadd double %35, %39
  %41 = fptrunc double %40 to float
  %42 = extractelement <2 x float> %25, i64 0
  %43 = extractelement <2 x float> %25, i64 1
  %44 = fcmp olt float %42, %43
  %.0 = select i1 %44, float %43, float %42
  %45 = fcmp olt float %.0, %41
  %.1 = select i1 %45, float %41, float %.0
  ret float %.1
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fabs.v2f32(<2 x float>) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 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,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass