; LLVM IR from harharkh/sb_desc :: src (vector)

; 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.sb_vec = type { i64, ptr, i8 }

@sb_error_log = external global ptr, align 8
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.104 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.105 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.106 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.107 = external hidden unnamed_addr constant [35 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

; Function Attrs: noreturn nounwind
declare void @abort() #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local double @sb_vec_dot(ptr noalias noundef %0, ptr noalias noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  br label %6

6:                                                ; preds = %2
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %28, label %9

9:                                                ; preds = %6
  %10 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %14

12:                                               ; preds = %9
  %13 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %16

14:                                               ; preds = %9
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %14, %12
  %17 = phi ptr [ %13, %12 ], [ %15, %14 ]
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str.104) #6
  %19 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %23

21:                                               ; preds = %16
  %22 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %25

23:                                               ; preds = %16
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %23, %21
  %26 = phi ptr [ %22, %21 ], [ %24, %23 ]
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.1) #6
  call void @abort() #7
  unreachable

28:                                               ; preds = %6
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %52, label %33

33:                                               ; preds = %30
  %34 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %38

36:                                               ; preds = %33
  %37 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %40

38:                                               ; preds = %33
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %38, %36
  %41 = phi ptr [ %37, %36 ], [ %39, %38 ]
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef @.str.105) #6
  %43 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %47

45:                                               ; preds = %40
  %46 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %49

47:                                               ; preds = %40
  %48 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %47, %45
  %50 = phi ptr [ %46, %45 ], [ %48, %47 ]
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef @.str.1) #6
  call void @abort() #7
  unreachable

52:                                               ; preds = %30
  br label %53

53:                                               ; preds = %52
  br label %54

54:                                               ; preds = %53
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.sb_vec, ptr %55, i32 0, i32 0
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.sb_vec, ptr %58, i32 0, i32 0
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = icmp ne i64 %57, %60
  br i1 %61, label %62, label %81

62:                                               ; preds = %54
  %63 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %67

65:                                               ; preds = %62
  %66 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %69

67:                                               ; preds = %62
  %68 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %69

69:                                               ; preds = %67, %65
  %70 = phi ptr [ %66, %65 ], [ %68, %67 ]
  %71 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %70, ptr noundef @.str.106) #6
  %72 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %73 = icmp ne ptr %72, null
  br i1 %73, label %74, label %76

74:                                               ; preds = %69
  %75 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %78

76:                                               ; preds = %69
  %77 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %78

78:                                               ; preds = %76, %74
  %79 = phi ptr [ %75, %74 ], [ %77, %76 ]
  %80 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %79, ptr noundef @.str.1) #6
  call void @abort() #7
  unreachable

81:                                               ; preds = %54
  br label %82

82:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.sb_vec, ptr %83, i32 0, i32 0
  %85 = load i64, ptr %84, align 8, !tbaa !9
  %86 = trunc i64 %85 to i32
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.sb_vec, ptr %87, i32 0, i32 1
  %89 = load ptr, ptr %88, align 8, !tbaa !12
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.sb_vec, ptr %90, i32 0, i32 1
  %92 = load ptr, ptr %91, align 8, !tbaa !12
  %93 = call double @cblas_ddot(i32 noundef %86, ptr noundef %89, i32 noundef 1, ptr noundef %92, i32 noundef 1)
  store double %93, ptr %5, align 8, !tbaa !13
  br label %94

94:                                               ; preds = %82
  %95 = load double, ptr %5, align 8, !tbaa !13
  %96 = call i1 @llvm.is.fpclass.f64(double %95, i32 504)
  br i1 %96, label %116, label %97

97:                                               ; preds = %94
  %98 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %99 = icmp ne ptr %98, null
  br i1 %99, label %100, label %102

100:                                              ; preds = %97
  %101 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %104

102:                                              ; preds = %97
  %103 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %104

104:                                              ; preds = %102, %100
  %105 = phi ptr [ %101, %100 ], [ %103, %102 ]
  %106 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %105, ptr noundef @.str.107) #6
  %107 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %108 = icmp ne ptr %107, null
  br i1 %108, label %109, label %111

109:                                              ; preds = %104
  %110 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %113

111:                                              ; preds = %104
  %112 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %113

113:                                              ; preds = %111, %109
  %114 = phi ptr [ %110, %109 ], [ %112, %111 ]
  %115 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %114, ptr noundef @.str.1) #6
  call void @abort() #7
  unreachable

116:                                              ; preds = %94
  br label %117

117:                                              ; preds = %116
  br label %118

118:                                              ; preds = %117
  %119 = load double, ptr %5, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret double %119
}

declare double @cblas_ddot(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #5

attributes #0 = { 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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { "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 #6 = { nounwind }
attributes #7 = { 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, !11, i64 0}
!10 = !{!"", !11, i64 0, !6, i64 8, !7, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"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"

@sb_error_log = external local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.104 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.105 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.106 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.107 = external hidden unnamed_addr constant [35 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local double @sb_vec_dot(ptr noalias noundef readonly %0, ptr noalias noundef readonly %1) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %3, label %12

3:                                                ; preds = %2
  %4 = load ptr, ptr @sb_error_log, align 8
  %.not11 = icmp eq ptr %4, null
  %5 = load ptr, ptr @stderr, align 8
  %6 = select i1 %.not11, ptr %5, ptr %4
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str.104) #5
  %8 = load ptr, ptr @sb_error_log, align 8
  %.not12 = icmp eq ptr %8, null
  %9 = load ptr, ptr @stderr, align 8
  %10 = select i1 %.not12, ptr %9, ptr %8
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.1) #5
  tail call void @abort() #6
  unreachable

12:                                               ; preds = %2
  %.not13 = icmp eq ptr %1, null
  br i1 %.not13, label %13, label %22

13:                                               ; preds = %12
  %14 = load ptr, ptr @sb_error_log, align 8
  %.not14 = icmp eq ptr %14, null
  %15 = load ptr, ptr @stderr, align 8
  %16 = select i1 %.not14, ptr %15, ptr %14
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.105) #5
  %18 = load ptr, ptr @sb_error_log, align 8
  %.not15 = icmp eq ptr %18, null
  %19 = load ptr, ptr @stderr, align 8
  %20 = select i1 %.not15, ptr %19, ptr %18
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str.1) #5
  tail call void @abort() #6
  unreachable

22:                                               ; preds = %12
  %23 = load i64, ptr %0, align 8, !tbaa !5
  %24 = load i64, ptr %1, align 8, !tbaa !5
  %.not16 = icmp eq i64 %23, %24
  br i1 %.not16, label %34, label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr @sb_error_log, align 8
  %.not19 = icmp eq ptr %26, null
  %27 = load ptr, ptr @stderr, align 8
  %28 = select i1 %.not19, ptr %27, ptr %26
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str.106) #5
  %30 = load ptr, ptr @sb_error_log, align 8
  %.not20 = icmp eq ptr %30, null
  %31 = load ptr, ptr @stderr, align 8
  %32 = select i1 %.not20, ptr %31, ptr %30
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str.1) #5
  tail call void @abort() #6
  unreachable

34:                                               ; preds = %22
  %35 = trunc i64 %23 to i32
  %36 = getelementptr inbounds i8, ptr %0, i64 8
  %37 = load ptr, ptr %36, align 8, !tbaa !11
  %38 = getelementptr inbounds i8, ptr %1, i64 8
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = tail call double @cblas_ddot(i32 noundef %35, ptr noundef %37, i32 noundef 1, ptr noundef %39, i32 noundef 1) #5
  %41 = tail call double @llvm.fabs.f64(double %40)
  %42 = fcmp ueq double %41, 0x7FF0000000000000
  br i1 %42, label %43, label %52

43:                                               ; preds = %34
  %44 = load ptr, ptr @sb_error_log, align 8
  %.not17 = icmp eq ptr %44, null
  %45 = load ptr, ptr @stderr, align 8
  %46 = select i1 %.not17, ptr %45, ptr %44
  %47 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef nonnull @.str.107) #5
  %48 = load ptr, ptr @sb_error_log, align 8
  %.not18 = icmp eq ptr %48, null
  %49 = load ptr, ptr @stderr, align 8
  %50 = select i1 %.not18, ptr %49, ptr %48
  %51 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef nonnull @.str.1) #5
  tail call void @abort() #6
  unreachable

52:                                               ; preds = %34
  ret double %40
}

declare double @cblas_ddot(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

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

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


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