; LLVM IR from siavashserver/neonrvm :: neonrvm (neonrvm_predict)

; 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 [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [65 x i8], align 1
@__PRETTY_FUNCTION__.neonrvm_predict = external hidden unnamed_addr constant [66 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @is_finite(ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @neonrvm_predict(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store i64 %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = icmp eq ptr null, %11
  br i1 %12, label %21, label %13

13:                                               ; preds = %5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load i64, ptr %8, align 8, !tbaa !9
  %16 = load i64, ptr %9, align 8, !tbaa !9
  %17 = mul i64 %15, %16
  %18 = call zeroext i1 @is_finite(ptr noundef %14, i64 noundef %17)
  %19 = zext i1 %18 to i32
  %20 = icmp eq i32 0, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %13, %5
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 852, ptr noundef @__PRETTY_FUNCTION__.neonrvm_predict) #2
  unreachable

22:                                               ; preds = %13
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = icmp eq ptr null, %23
  br i1 %24, label %31, label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load i64, ptr %9, align 8, !tbaa !9
  %28 = call zeroext i1 @is_finite(ptr noundef %26, i64 noundef %27)
  %29 = zext i1 %28 to i32
  %30 = icmp eq i32 0, %29
  br i1 %30, label %31, label %32

31:                                               ; preds = %25, %22
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 857, ptr noundef @__PRETTY_FUNCTION__.neonrvm_predict) #2
  unreachable

32:                                               ; preds = %25
  %33 = load i64, ptr %8, align 8, !tbaa !9
  %34 = icmp ugt i64 1, %33
  br i1 %34, label %38, label %35

35:                                               ; preds = %32
  %36 = load i64, ptr %8, align 8, !tbaa !9
  %37 = icmp ult i64 2147483647, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %35, %32
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 862, ptr noundef @__PRETTY_FUNCTION__.neonrvm_predict) #2
  unreachable

39:                                               ; preds = %35
  %40 = load i64, ptr %9, align 8, !tbaa !9
  %41 = icmp ugt i64 1, %40
  br i1 %41, label %45, label %42

42:                                               ; preds = %39
  %43 = load i64, ptr %9, align 8, !tbaa !9
  %44 = icmp ult i64 2147483647, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %42, %39
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 867, ptr noundef @__PRETTY_FUNCTION__.neonrvm_predict) #2
  unreachable

46:                                               ; preds = %42
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = icmp eq ptr null, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %46
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 872, ptr noundef @__PRETTY_FUNCTION__.neonrvm_predict) #2
  unreachable

50:                                               ; preds = %46
  %51 = load i64, ptr %8, align 8, !tbaa !9
  %52 = icmp eq i64 1, %51
  br i1 %52, label %53, label %60

53:                                               ; preds = %50
  %54 = load i64, ptr %9, align 8, !tbaa !9
  %55 = trunc i64 %54 to i32
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = call double @cblas_ddot(i32 noundef %55, ptr noundef %56, i32 noundef 1, ptr noundef %57, i32 noundef 1)
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  store double %58, ptr %59, align 8, !tbaa !11
  br label %70

60:                                               ; preds = %50
  %61 = load i64, ptr %8, align 8, !tbaa !9
  %62 = trunc i64 %61 to i32
  %63 = load i64, ptr %9, align 8, !tbaa !9
  %64 = trunc i64 %63 to i32
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = load i64, ptr %8, align 8, !tbaa !9
  %67 = trunc i64 %66 to i32
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  call void @cblas_dgemv(i32 noundef 102, i32 noundef 111, i32 noundef %62, i32 noundef %64, double noundef 1.000000e+00, ptr noundef %65, i32 noundef %67, ptr noundef %68, i32 noundef 1, double noundef 0.000000e+00, ptr noundef %69, i32 noundef 1)
  br label %70

70:                                               ; preds = %60, %53
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = load i64, ptr %8, align 8, !tbaa !9
  %73 = call zeroext i1 @is_finite(ptr noundef %71, i64 noundef %72)
  %74 = zext i1 %73 to i32
  %75 = icmp eq i32 0, %74
  br i1 %75, label %76, label %77

76:                                               ; preds = %70
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 883, ptr noundef @__PRETTY_FUNCTION__.neonrvm_predict) #2
  unreachable

77:                                               ; preds = %70
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare hidden double @cblas_ddot(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @cblas_dgemv(i32 noundef, i32 noundef, i32 noundef, i32 noundef, double noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, double noundef, ptr noundef, i32 noundef) #1

attributes #0 = { noreturn 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 #1 = { 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 #2 = { noreturn 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !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"

@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [65 x i8], align 1
@__PRETTY_FUNCTION__.neonrvm_predict = external hidden unnamed_addr constant [66 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @is_finite(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @neonrvm_predict(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = icmp eq ptr %0, null
  br i1 %6, label %10, label %7

7:                                                ; preds = %5
  %8 = mul i64 %3, %2
  %9 = tail call zeroext i1 @is_finite(ptr noundef nonnull %0, i64 noundef %8)
  br i1 %9, label %11, label %10

10:                                               ; preds = %7, %5
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 852, ptr noundef nonnull @__PRETTY_FUNCTION__.neonrvm_predict) #2
  unreachable

11:                                               ; preds = %7
  %12 = icmp eq ptr %1, null
  br i1 %12, label %15, label %13

13:                                               ; preds = %11
  %14 = tail call zeroext i1 @is_finite(ptr noundef nonnull %1, i64 noundef %3)
  br i1 %14, label %16, label %15

15:                                               ; preds = %13, %11
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 857, ptr noundef nonnull @__PRETTY_FUNCTION__.neonrvm_predict) #2
  unreachable

16:                                               ; preds = %13
  %17 = add i64 %2, -2147483648
  %or.cond = icmp ult i64 %17, -2147483647
  br i1 %or.cond, label %18, label %19

18:                                               ; preds = %16
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 862, ptr noundef nonnull @__PRETTY_FUNCTION__.neonrvm_predict) #2
  unreachable

19:                                               ; preds = %16
  %20 = add i64 %3, -2147483648
  %or.cond3 = icmp ult i64 %20, -2147483647
  br i1 %or.cond3, label %21, label %22

21:                                               ; preds = %19
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 867, ptr noundef nonnull @__PRETTY_FUNCTION__.neonrvm_predict) #2
  unreachable

22:                                               ; preds = %19
  %23 = icmp eq ptr %4, null
  br i1 %23, label %24, label %25

24:                                               ; preds = %22
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 872, ptr noundef nonnull @__PRETTY_FUNCTION__.neonrvm_predict) #2
  unreachable

25:                                               ; preds = %22
  %26 = icmp eq i64 %2, 1
  br i1 %26, label %27, label %30

27:                                               ; preds = %25
  %28 = trunc nuw nsw i64 %3 to i32
  %29 = tail call double @cblas_ddot(i32 noundef %28, ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull %1, i32 noundef 1)
  store double %29, ptr %4, align 8, !tbaa !5
  br label %33

30:                                               ; preds = %25
  %31 = trunc nuw nsw i64 %2 to i32
  %32 = trunc nuw nsw i64 %3 to i32
  tail call void @cblas_dgemv(i32 noundef 102, i32 noundef 111, i32 noundef %31, i32 noundef %32, double noundef 1.000000e+00, ptr noundef nonnull %0, i32 noundef %31, ptr noundef nonnull %1, i32 noundef 1, double noundef 0.000000e+00, ptr noundef nonnull %4, i32 noundef 1)
  br label %33

33:                                               ; preds = %30, %27
  %34 = tail call zeroext i1 @is_finite(ptr noundef nonnull %4, i64 noundef %2)
  br i1 %34, label %36, label %35

35:                                               ; preds = %33
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 883, ptr noundef nonnull @__PRETTY_FUNCTION__.neonrvm_predict) #2
  unreachable

36:                                               ; preds = %33
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare hidden double @cblas_ddot(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @cblas_dgemv(i32 noundef, i32 noundef, i32 noundef, i32 noundef, double noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, double noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { noreturn 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 #1 = { 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 #2 = { noreturn 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass