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

@matrixf_data_add_x = external global [0 x float], align 4
@matrixf_data_add_y = external global [0 x float], align 4
@matrixf_data_add_z = external global [0 x float], align 4
@.str = external hidden unnamed_addr constant [90 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [36 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

; Function Attrs: nounwind uwtable
define dso_local void @autotest_matrixf_add() #0 {
  %1 = alloca float, align 4
  %2 = alloca [20 x float], align 16
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store float 0x3EB0C6F7A0000000, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 80, ptr %2) #5
  %4 = getelementptr inbounds [20 x float], ptr %2, i64 0, i64 0
  %5 = call i32 @matrixf_add(ptr noundef @matrixf_data_add_x, ptr noundef @matrixf_data_add_y, ptr noundef %4, i32 noundef 5, i32 noundef 4)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %126, %0
  %7 = load i32, ptr %3, align 4, !tbaa !9
  %8 = icmp ult i32 %7, 20
  br i1 %8, label %9, label %129

9:                                                ; preds = %6
  %10 = load i32, ptr %3, align 4, !tbaa !9
  %11 = zext i32 %10 to i64
  %12 = getelementptr inbounds [0 x float], ptr @matrixf_data_add_z, i64 0, i64 %11
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = load i32, ptr %3, align 4, !tbaa !9
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds [20 x float], ptr %2, i64 0, i64 %15
  %17 = load float, ptr %16, align 4, !tbaa !5
  %18 = fsub float %13, %17
  %19 = fpext float %18 to double
  %20 = load i32, ptr %3, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds [0 x float], ptr @matrixf_data_add_z, i64 0, i64 %21
  %23 = load float, ptr %22, align 4, !tbaa !5
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds [20 x float], ptr %2, i64 0, i64 %25
  %27 = load float, ptr %26, align 4, !tbaa !5
  %28 = fsub float %23, %27
  %29 = fpext float %28 to double
  %30 = load i32, ptr %3, align 4, !tbaa !9
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds [0 x float], ptr @matrixf_data_add_z, i64 0, i64 %31
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = load i32, ptr %3, align 4, !tbaa !9
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds [20 x float], ptr %2, i64 0, i64 %35
  %37 = load float, ptr %36, align 4, !tbaa !5
  %38 = fsub float %33, %37
  %39 = fpext float %38 to double
  %40 = load i32, ptr %3, align 4, !tbaa !9
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds [0 x float], ptr @matrixf_data_add_z, i64 0, i64 %41
  %43 = load float, ptr %42, align 4, !tbaa !5
  %44 = load i32, ptr %3, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds [20 x float], ptr %2, i64 0, i64 %45
  %47 = load float, ptr %46, align 4, !tbaa !5
  %48 = fsub float %43, %47
  %49 = fpext float %48 to double
  %50 = call double @llvm.fmuladd.f64(double %19, double %29, double 0.000000e+00)
  %51 = call double @sqrt(double noundef %50) #5
  %52 = load float, ptr %1, align 4, !tbaa !5
  %53 = fpext float %52 to double
  %54 = fcmp ogt double %51, %53
  br i1 %54, label %79, label %55

55:                                               ; preds = %9
  %56 = load i32, ptr %3, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds [0 x float], ptr @matrixf_data_add_z, i64 0, i64 %57
  %59 = load float, ptr %58, align 4, !tbaa !5
  %60 = call i1 @llvm.is.fpclass.f32(float %59, i32 3)
  br i1 %60, label %79, label %61

61:                                               ; preds = %55
  %62 = load i32, ptr %3, align 4, !tbaa !9
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds [0 x float], ptr @matrixf_data_add_z, i64 0, i64 %63
  %65 = load float, ptr %64, align 4, !tbaa !5
  %66 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %66, label %79, label %67

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

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

79:                                               ; preds = %73, %67, %61, %55, %9
  %80 = load i32, ptr %3, align 4, !tbaa !9
  %81 = zext i32 %80 to i64
  %82 = getelementptr inbounds [0 x float], ptr @matrixf_data_add_z, i64 0, i64 %81
  %83 = load float, ptr %82, align 4, !tbaa !5
  %84 = load i32, ptr %3, align 4, !tbaa !9
  %85 = zext i32 %84 to i64
  %86 = getelementptr inbounds [20 x float], ptr %2, i64 0, i64 %85
  %87 = load float, ptr %86, align 4, !tbaa !5
  %88 = fsub float %83, %87
  %89 = fpext float %88 to double
  %90 = load i32, ptr %3, align 4, !tbaa !9
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds [0 x float], ptr @matrixf_data_add_z, i64 0, i64 %91
  %93 = load float, ptr %92, align 4, !tbaa !5
  %94 = load i32, ptr %3, align 4, !tbaa !9
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds [20 x float], ptr %2, i64 0, i64 %95
  %97 = load float, ptr %96, align 4, !tbaa !5
  %98 = fsub float %93, %97
  %99 = fpext float %98 to double
  %100 = load i32, ptr %3, align 4, !tbaa !9
  %101 = zext i32 %100 to i64
  %102 = getelementptr inbounds [0 x float], ptr @matrixf_data_add_z, i64 0, i64 %101
  %103 = load float, ptr %102, align 4, !tbaa !5
  %104 = load i32, ptr %3, align 4, !tbaa !9
  %105 = zext i32 %104 to i64
  %106 = getelementptr inbounds [20 x float], ptr %2, i64 0, i64 %105
  %107 = load float, ptr %106, align 4, !tbaa !5
  %108 = fsub float %103, %107
  %109 = fpext float %108 to double
  %110 = load i32, ptr %3, align 4, !tbaa !9
  %111 = zext i32 %110 to i64
  %112 = getelementptr inbounds [0 x float], ptr @matrixf_data_add_z, i64 0, i64 %111
  %113 = load float, ptr %112, align 4, !tbaa !5
  %114 = load i32, ptr %3, align 4, !tbaa !9
  %115 = zext i32 %114 to i64
  %116 = getelementptr inbounds [20 x float], ptr %2, i64 0, i64 %115
  %117 = load float, ptr %116, align 4, !tbaa !5
  %118 = fsub float %113, %117
  %119 = fpext float %118 to double
  %120 = call double @llvm.fmuladd.f64(double %89, double %99, double 0.000000e+00)
  %121 = call double @sqrt(double noundef %120) #5
  %122 = load float, ptr %1, align 4, !tbaa !5
  %123 = fpext float %122 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 47, ptr noundef @.str.1, double noundef %121, ptr noundef @.str.2, ptr noundef @.str.3, double noundef %123)
  br label %125

124:                                              ; preds = %73
  call void (...) @liquid_autotest_passed()
  br label %125

125:                                              ; preds = %124, %79
  br label %126

126:                                              ; preds = %125
  %127 = load i32, ptr %3, align 4, !tbaa !9
  %128 = add i32 %127, 1
  store i32 %128, ptr %3, align 4, !tbaa !9
  br label %6, !llvm.loop !11

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

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

declare i32 @matrixf_add(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i1 @llvm.is.fpclass.f32(float, i32 immarg) #4

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

declare void @liquid_autotest_passed(...) #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 = { "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 "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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"

@matrixf_data_add_x = external global [0 x float], align 4
@matrixf_data_add_y = external global [0 x float], align 4
@matrixf_data_add_z = external local_unnamed_addr global [0 x float], align 4
@.str = external hidden unnamed_addr constant [90 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [36 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

; Function Attrs: nounwind uwtable
define dso_local void @autotest_matrixf_add() local_unnamed_addr #0 {
  %1 = alloca [20 x float], align 16
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %1) #5
  %2 = call i32 @matrixf_add(ptr noundef nonnull @matrixf_data_add_x, ptr noundef nonnull @matrixf_data_add_y, ptr noundef nonnull %1, i32 noundef 5, i32 noundef 4) #5
  br label %3

3:                                                ; preds = %0, %16
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %16 ]
  %4 = getelementptr inbounds [0 x float], ptr @matrixf_data_add_z, i64 0, i64 %indvars.iv
  %5 = load float, ptr %4, align 4, !tbaa !5
  %6 = getelementptr inbounds [20 x float], ptr %1, i64 0, i64 %indvars.iv
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = fsub float %5, %7
  %9 = fpext float %8 to double
  %10 = call double @llvm.fmuladd.f64(double %9, double %9, double 0.000000e+00)
  %sqrt = call double @llvm.sqrt.f64(double %10)
  %11 = fcmp ogt double %sqrt, 0x3EB0C6F7A0000000
  %12 = fcmp uno float %5, 0.000000e+00
  %or.cond = select i1 %11, i1 true, i1 %12
  %13 = fcmp uno float %7, 0.000000e+00
  %or.cond26 = select i1 %or.cond, i1 true, i1 %13
  br i1 %or.cond26, label %14, label %15

14:                                               ; preds = %3
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 47, ptr noundef nonnull @.str.1, double noundef %sqrt, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef 0x3EB0C6F7A0000000) #5
  br label %16

15:                                               ; preds = %3
  call void (...) @liquid_autotest_passed() #5
  br label %16

16:                                               ; preds = %14, %15
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 20
  br i1 %exitcond.not, label %17, label %3, !llvm.loop !9

17:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %1) #5
  ret void
}

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

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

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

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) #1

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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