; LLVM IR from jgaeddert/liquid-dsp :: src/matrix/tests (matrixf_autotest)

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

@.str = external hidden unnamed_addr constant [90 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@liquid_autotest_verbose = external global i32, align 4
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [13 x i8], align 1
@matrixf_data_inv_x = external global [0 x float], align 4
@.str.20 = external hidden unnamed_addr constant [6 x i8], align 1
@matrixf_data_inv_y = external global [0 x float], align 4
@.str.21 = external hidden unnamed_addr constant [36 x i8], align 1

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #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 speculatable willreturn memory(none)
declare i1 @llvm.is.fpclass.f32(float, i32 immarg) #2

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) #3

declare void @liquid_autotest_passed(...) #3

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

declare i32 @printf(ptr noundef, ...) #3

declare i32 @matrixf_print(ptr noundef, i32 noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @autotest_matrixf_inv() #4 {
  %1 = alloca float, align 4
  %2 = alloca [25 x float], align 16
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #6
  store float 0x3EB0C6F7A0000000, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 100, ptr %2) #6
  %4 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 0
  call void @llvm.memmove.p0.p0.i64(ptr align 16 %4, ptr align 4 @matrixf_data_inv_x, i64 100, i1 false)
  %5 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 0
  %6 = call i32 @matrixf_inv(ptr noundef %5, i32 noundef 5, i32 noundef 5)
  %7 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !9
  %8 = icmp ne i32 %7, 0
  br i1 %8, label %9, label %18

9:                                                ; preds = %0
  %10 = call i32 (ptr, ...) @printf(ptr noundef @.str.20)
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %12 = call i32 @matrixf_print(ptr noundef @matrixf_data_inv_x, i32 noundef 5, i32 noundef 5)
  %13 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  %14 = call i32 @matrixf_print(ptr noundef @matrixf_data_inv_y, i32 noundef 5, i32 noundef 5)
  %15 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %16 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 0
  %17 = call i32 @matrixf_print(ptr noundef %16, i32 noundef 5, i32 noundef 5)
  br label %18

18:                                               ; preds = %9, %0
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %139, %18
  %20 = load i32, ptr %3, align 4, !tbaa !9
  %21 = icmp ult i32 %20, 25
  br i1 %21, label %22, label %142

22:                                               ; preds = %19
  %23 = load i32, ptr %3, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds [0 x float], ptr @matrixf_data_inv_y, i64 0, i64 %24
  %26 = load float, ptr %25, align 4, !tbaa !5
  %27 = load i32, ptr %3, align 4, !tbaa !9
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 %28
  %30 = load float, ptr %29, align 4, !tbaa !5
  %31 = fsub float %26, %30
  %32 = fpext float %31 to double
  %33 = load i32, ptr %3, align 4, !tbaa !9
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds [0 x float], ptr @matrixf_data_inv_y, i64 0, i64 %34
  %36 = load float, ptr %35, align 4, !tbaa !5
  %37 = load i32, ptr %3, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !5
  %41 = fsub float %36, %40
  %42 = fpext float %41 to double
  %43 = load i32, ptr %3, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds [0 x float], ptr @matrixf_data_inv_y, i64 0, i64 %44
  %46 = load float, ptr %45, align 4, !tbaa !5
  %47 = load i32, ptr %3, align 4, !tbaa !9
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 %48
  %50 = load float, ptr %49, align 4, !tbaa !5
  %51 = fsub float %46, %50
  %52 = fpext float %51 to double
  %53 = load i32, ptr %3, align 4, !tbaa !9
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds [0 x float], ptr @matrixf_data_inv_y, i64 0, i64 %54
  %56 = load float, ptr %55, align 4, !tbaa !5
  %57 = load i32, ptr %3, align 4, !tbaa !9
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 %58
  %60 = load float, ptr %59, align 4, !tbaa !5
  %61 = fsub float %56, %60
  %62 = fpext float %61 to double
  %63 = call double @llvm.fmuladd.f64(double %32, double %42, double 0.000000e+00)
  %64 = call double @sqrt(double noundef %63) #6
  %65 = load float, ptr %1, align 4, !tbaa !5
  %66 = fpext float %65 to double
  %67 = fcmp ogt double %64, %66
  br i1 %67, label %92, label %68

68:                                               ; preds = %22
  %69 = load i32, ptr %3, align 4, !tbaa !9
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds [0 x float], ptr @matrixf_data_inv_y, i64 0, i64 %70
  %72 = load float, ptr %71, align 4, !tbaa !5
  %73 = call i1 @llvm.is.fpclass.f32(float %72, i32 3)
  br i1 %73, label %92, label %74

74:                                               ; preds = %68
  %75 = load i32, ptr %3, align 4, !tbaa !9
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds [0 x float], ptr @matrixf_data_inv_y, i64 0, i64 %76
  %78 = load float, ptr %77, align 4, !tbaa !5
  %79 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %79, label %92, label %80

80:                                               ; preds = %74
  %81 = load i32, ptr %3, align 4, !tbaa !9
  %82 = zext i32 %81 to i64
  %83 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 %82
  %84 = load float, ptr %83, align 4, !tbaa !5
  %85 = call i1 @llvm.is.fpclass.f32(float %84, i32 3)
  br i1 %85, label %92, label %86

86:                                               ; preds = %80
  %87 = load i32, ptr %3, align 4, !tbaa !9
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 %88
  %90 = load float, ptr %89, align 4, !tbaa !5
  %91 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %91, label %92, label %137

92:                                               ; preds = %86, %80, %74, %68, %22
  %93 = load i32, ptr %3, align 4, !tbaa !9
  %94 = zext i32 %93 to i64
  %95 = getelementptr inbounds [0 x float], ptr @matrixf_data_inv_y, i64 0, i64 %94
  %96 = load float, ptr %95, align 4, !tbaa !5
  %97 = load i32, ptr %3, align 4, !tbaa !9
  %98 = zext i32 %97 to i64
  %99 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 %98
  %100 = load float, ptr %99, align 4, !tbaa !5
  %101 = fsub float %96, %100
  %102 = fpext float %101 to double
  %103 = load i32, ptr %3, align 4, !tbaa !9
  %104 = zext i32 %103 to i64
  %105 = getelementptr inbounds [0 x float], ptr @matrixf_data_inv_y, i64 0, i64 %104
  %106 = load float, ptr %105, align 4, !tbaa !5
  %107 = load i32, ptr %3, align 4, !tbaa !9
  %108 = zext i32 %107 to i64
  %109 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 %108
  %110 = load float, ptr %109, align 4, !tbaa !5
  %111 = fsub float %106, %110
  %112 = fpext float %111 to double
  %113 = load i32, ptr %3, align 4, !tbaa !9
  %114 = zext i32 %113 to i64
  %115 = getelementptr inbounds [0 x float], ptr @matrixf_data_inv_y, i64 0, i64 %114
  %116 = load float, ptr %115, align 4, !tbaa !5
  %117 = load i32, ptr %3, align 4, !tbaa !9
  %118 = zext i32 %117 to i64
  %119 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 %118
  %120 = load float, ptr %119, align 4, !tbaa !5
  %121 = fsub float %116, %120
  %122 = fpext float %121 to double
  %123 = load i32, ptr %3, align 4, !tbaa !9
  %124 = zext i32 %123 to i64
  %125 = getelementptr inbounds [0 x float], ptr @matrixf_data_inv_y, i64 0, i64 %124
  %126 = load float, ptr %125, align 4, !tbaa !5
  %127 = load i32, ptr %3, align 4, !tbaa !9
  %128 = zext i32 %127 to i64
  %129 = getelementptr inbounds [25 x float], ptr %2, i64 0, i64 %128
  %130 = load float, ptr %129, align 4, !tbaa !5
  %131 = fsub float %126, %130
  %132 = fpext float %131 to double
  %133 = call double @llvm.fmuladd.f64(double %102, double %112, double 0.000000e+00)
  %134 = call double @sqrt(double noundef %133) #6
  %135 = load float, ptr %1, align 4, !tbaa !5
  %136 = fpext float %135 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 170, ptr noundef @.str.21, double noundef %134, ptr noundef @.str.2, ptr noundef @.str.3, double noundef %136)
  br label %138

137:                                              ; preds = %86
  call void (...) @liquid_autotest_passed()
  br label %138

138:                                              ; preds = %137, %92
  br label %139

139:                                              ; preds = %138
  %140 = load i32, ptr %3, align 4, !tbaa !9
  %141 = add i32 %140, 1
  store i32 %141, ptr %3, align 4, !tbaa !9
  br label %19, !llvm.loop !11

142:                                              ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 100, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #5

declare i32 @matrixf_inv(ptr noundef, i32 noundef, i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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) }
attributes #3 = { "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 #4 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

@.str = external hidden unnamed_addr constant [90 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4
@.str.5 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [13 x i8], align 1
@matrixf_data_inv_x = external global [0 x float], align 4
@.str.20 = external hidden unnamed_addr constant [6 x i8], align 1
@matrixf_data_inv_y = external global [0 x float], align 4
@.str.21 = external hidden unnamed_addr constant [36 x i8], align 1

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

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

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) local_unnamed_addr #2

declare void @liquid_autotest_passed(...) local_unnamed_addr #2

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

declare i32 @matrixf_print(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @autotest_matrixf_inv() local_unnamed_addr #4 {
  %1 = alloca [25 x float], align 16
  call void @llvm.lifetime.start.p0(i64 100, ptr nonnull %1) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(100) %1, ptr noundef nonnull align 4 dereferenceable(100) @matrixf_data_inv_x, i64 100, i1 false)
  %2 = call i32 @matrixf_inv(ptr noundef nonnull %1, i32 noundef 5, i32 noundef 5) #7
  %3 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %.preheader, label %4

4:                                                ; preds = %0
  %5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20)
  %6 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %7 = call i32 @matrixf_print(ptr noundef nonnull @matrixf_data_inv_x, i32 noundef 5, i32 noundef 5) #7
  %8 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %9 = call i32 @matrixf_print(ptr noundef nonnull @matrixf_data_inv_y, i32 noundef 5, i32 noundef 5) #7
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %11 = call i32 @matrixf_print(ptr noundef nonnull %1, i32 noundef 5, i32 noundef 5) #7
  br label %.preheader

.preheader:                                       ; preds = %4, %0
  br label %12

12:                                               ; preds = %.preheader, %25
  %indvars.iv = phi i64 [ %indvars.iv.next, %25 ], [ 0, %.preheader ]
  %13 = getelementptr inbounds [0 x float], ptr @matrixf_data_inv_y, i64 0, i64 %indvars.iv
  %14 = load float, ptr %13, align 4, !tbaa !9
  %15 = getelementptr inbounds [25 x float], ptr %1, i64 0, i64 %indvars.iv
  %16 = load float, ptr %15, align 4, !tbaa !9
  %17 = fsub float %14, %16
  %18 = fpext float %17 to double
  %19 = call double @llvm.fmuladd.f64(double %18, double %18, double 0.000000e+00)
  %sqrt = call double @llvm.sqrt.f64(double %19)
  %20 = fcmp ogt double %sqrt, 0x3EB0C6F7A0000000
  %21 = fcmp uno float %14, 0.000000e+00
  %or.cond = select i1 %20, i1 true, i1 %21
  %22 = fcmp uno float %16, 0.000000e+00
  %or.cond26 = select i1 %or.cond, i1 true, i1 %22
  br i1 %or.cond26, label %23, label %24

23:                                               ; preds = %12
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 170, ptr noundef nonnull @.str.21, double noundef %sqrt, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef 0x3EB0C6F7A0000000) #7
  br label %25

24:                                               ; preds = %12
  call void (...) @liquid_autotest_passed() #7
  br label %25

25:                                               ; preds = %23, %24
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 25
  br i1 %exitcond.not, label %26, label %12, !llvm.loop !11

26:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 100, ptr nonnull %1) #7
  ret void
}

declare i32 @matrixf_inv(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { "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 = { nofree nounwind "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 #4 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopUnrollPass,MemCpyOptPass,SROAPass,SimplifyCFGPass