; LLVM IR from ubaldot/defrecs :: stm32f4x/ADC_Readings/Drivers/CMSIS/DSP/Examples/ARM/arm_bayes_example (main)

; 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.arm_gaussian_naive_bayes_instance_f32 = type { i32, i32, ptr, ptr, ptr, float }

@theta = external dso_local constant [6 x float], align 16
@sigma = external dso_local constant [6 x float], align 16
@classPriors = external dso_local constant [3 x float], align 4
@S = external dso_local global %struct.arm_gaussian_naive_bayes_instance_f32, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [2 x float], align 4
  %3 = alloca [3 x float], align 4
  %4 = alloca [3 x float], align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 2, ptr @S, align 8, !tbaa !5
  store i32 3, ptr getelementptr inbounds (%struct.arm_gaussian_naive_bayes_instance_f32, ptr @S, i32 0, i32 1), align 4, !tbaa !12
  store ptr @theta, ptr getelementptr inbounds (%struct.arm_gaussian_naive_bayes_instance_f32, ptr @S, i32 0, i32 2), align 8, !tbaa !13
  store ptr @sigma, ptr getelementptr inbounds (%struct.arm_gaussian_naive_bayes_instance_f32, ptr @S, i32 0, i32 3), align 8, !tbaa !14
  store ptr @classPriors, ptr getelementptr inbounds (%struct.arm_gaussian_naive_bayes_instance_f32, ptr @S, i32 0, i32 4), align 8, !tbaa !15
  store float 0x3E3297B820000000, ptr getelementptr inbounds (%struct.arm_gaussian_naive_bayes_instance_f32, ptr @S, i32 0, i32 5), align 8, !tbaa !16
  %7 = getelementptr inbounds [2 x float], ptr %2, i64 0, i64 0
  store float 1.500000e+00, ptr %7, align 4, !tbaa !17
  %8 = getelementptr inbounds [2 x float], ptr %2, i64 0, i64 1
  store float 1.000000e+00, ptr %8, align 4, !tbaa !17
  %9 = getelementptr inbounds [2 x float], ptr %2, i64 0, i64 0
  %10 = getelementptr inbounds [3 x float], ptr %3, i64 0, i64 0
  %11 = getelementptr inbounds [3 x float], ptr %4, i64 0, i64 0
  %12 = call i32 @arm_gaussian_naive_bayes_predict_f32(ptr noundef @S, ptr noundef %9, ptr noundef %10, ptr noundef %11)
  store i32 %12, ptr %6, align 4, !tbaa !18
  %13 = load i32, ptr %6, align 4, !tbaa !18
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds [3 x float], ptr %3, i64 0, i64 %14
  %16 = load float, ptr %15, align 4, !tbaa !17
  store float %16, ptr %5, align 4, !tbaa !17
  %17 = getelementptr inbounds [2 x float], ptr %2, i64 0, i64 0
  store float -1.500000e+00, ptr %17, align 4, !tbaa !17
  %18 = getelementptr inbounds [2 x float], ptr %2, i64 0, i64 1
  store float 1.000000e+00, ptr %18, align 4, !tbaa !17
  %19 = getelementptr inbounds [2 x float], ptr %2, i64 0, i64 0
  %20 = getelementptr inbounds [3 x float], ptr %3, i64 0, i64 0
  %21 = getelementptr inbounds [3 x float], ptr %4, i64 0, i64 0
  %22 = call i32 @arm_gaussian_naive_bayes_predict_f32(ptr noundef @S, ptr noundef %19, ptr noundef %20, ptr noundef %21)
  store i32 %22, ptr %6, align 4, !tbaa !18
  %23 = load i32, ptr %6, align 4, !tbaa !18
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds [3 x float], ptr %3, i64 0, i64 %24
  %26 = load float, ptr %25, align 4, !tbaa !17
  store float %26, ptr %5, align 4, !tbaa !17
  %27 = getelementptr inbounds [2 x float], ptr %2, i64 0, i64 0
  store float 0.000000e+00, ptr %27, align 4, !tbaa !17
  %28 = getelementptr inbounds [2 x float], ptr %2, i64 0, i64 1
  store float -3.000000e+00, ptr %28, align 4, !tbaa !17
  %29 = getelementptr inbounds [2 x float], ptr %2, i64 0, i64 0
  %30 = getelementptr inbounds [3 x float], ptr %3, i64 0, i64 0
  %31 = getelementptr inbounds [3 x float], ptr %4, i64 0, i64 0
  %32 = call i32 @arm_gaussian_naive_bayes_predict_f32(ptr noundef @S, ptr noundef %29, ptr noundef %30, ptr noundef %31)
  store i32 %32, ptr %6, align 4, !tbaa !18
  %33 = load i32, ptr %6, align 4, !tbaa !18
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds [3 x float], ptr %3, i64 0, i64 %34
  %36 = load float, ptr %35, align 4, !tbaa !17
  store float %36, ptr %5, align 4, !tbaa !17
  br label %37

37:                                               ; preds = %38, %0
  br label %38

38:                                               ; preds = %37
  br label %37
}

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

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

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 }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !11, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !10, i64 24}
!16 = !{!6, !11, i64 32}
!17 = !{!11, !11, i64 0}
!18 = !{!7, !7, i64 0}


; 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.arm_gaussian_naive_bayes_instance_f32 = type { i32, i32, ptr, ptr, ptr, float }

@theta = external dso_local constant [6 x float], align 16
@sigma = external dso_local constant [6 x float], align 16
@classPriors = external dso_local constant [3 x float], align 4
@S = external dso_local global %struct.arm_gaussian_naive_bayes_instance_f32, align 8

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [2 x float], align 8
  %2 = alloca [3 x float], align 4
  %3 = alloca [3 x float], align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #3
  store i32 2, ptr @S, align 8, !tbaa !5
  store i32 3, ptr getelementptr inbounds (i8, ptr @S, i64 4), align 4, !tbaa !12
  store ptr @theta, ptr getelementptr inbounds (i8, ptr @S, i64 8), align 8, !tbaa !13
  store ptr @sigma, ptr getelementptr inbounds (i8, ptr @S, i64 16), align 8, !tbaa !14
  store ptr @classPriors, ptr getelementptr inbounds (i8, ptr @S, i64 24), align 8, !tbaa !15
  store float 0x3E3297B820000000, ptr getelementptr inbounds (i8, ptr @S, i64 32), align 8, !tbaa !16
  store <2 x float> <float 1.500000e+00, float 1.000000e+00>, ptr %1, align 8, !tbaa !17
  %4 = call i32 @arm_gaussian_naive_bayes_predict_f32(ptr noundef nonnull @S, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3) #3
  store <2 x float> <float -1.500000e+00, float 1.000000e+00>, ptr %1, align 8, !tbaa !17
  %5 = call i32 @arm_gaussian_naive_bayes_predict_f32(ptr noundef nonnull @S, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3) #3
  store <2 x float> <float 0.000000e+00, float -3.000000e+00>, ptr %1, align 8, !tbaa !17
  %6 = call i32 @arm_gaussian_naive_bayes_predict_f32(ptr noundef nonnull @S, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3) #3
  br label %7

7:                                                ; preds = %7, %0
  br label %7
}

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

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

attributes #0 = { noreturn 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 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !11, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !10, i64 24}
!16 = !{!6, !11, i64 32}
!17 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass