; 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.87 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.88 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.89 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [33 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: nounwind uwtable
declare dso_local i32 @sb_vec_is_finite(ptr noundef) #2

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

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

7:                                                ; preds = %3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %29, label %10

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

13:                                               ; preds = %10
  %14 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %17

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

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

22:                                               ; preds = %17
  %23 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %26

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

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

29:                                               ; preds = %7
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %53, label %34

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

37:                                               ; preds = %34
  %38 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %41

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

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

46:                                               ; preds = %41
  %47 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %50

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

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

53:                                               ; preds = %31
  br label %54

54:                                               ; preds = %53
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.sb_vec, ptr %56, i32 0, i32 2
  %58 = load i8, ptr %57, align 8, !tbaa !11
  %59 = sext i8 %58 to i32
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.sb_vec, ptr %60, i32 0, i32 2
  %62 = load i8, ptr %61, align 8, !tbaa !11
  %63 = sext i8 %62 to i32
  %64 = icmp ne i32 %59, %63
  br i1 %64, label %65, label %84

65:                                               ; preds = %55
  %66 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %68, label %70

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

70:                                               ; preds = %65
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %72

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

77:                                               ; preds = %72
  %78 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %81

79:                                               ; preds = %72
  %80 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %81

81:                                               ; preds = %79, %77
  %82 = phi ptr [ %78, %77 ], [ %80, %79 ]
  %83 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %82, ptr noundef @.str.1) #4
  call void @abort() #5
  unreachable

84:                                               ; preds = %55
  br label %85

85:                                               ; preds = %84
  br label %86

86:                                               ; preds = %85
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.sb_vec, ptr %87, i32 0, i32 0
  %89 = load i64, ptr %88, align 8, !tbaa !14
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.sb_vec, ptr %90, i32 0, i32 0
  %92 = load i64, ptr %91, align 8, !tbaa !14
  %93 = icmp ne i64 %89, %92
  br i1 %93, label %94, label %113

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

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

99:                                               ; preds = %94
  %100 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %101

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

106:                                              ; preds = %101
  %107 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %110

108:                                              ; preds = %101
  %109 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %110

110:                                              ; preds = %108, %106
  %111 = phi ptr [ %107, %106 ], [ %109, %108 ]
  %112 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %111, ptr noundef @.str.1) #4
  call void @abort() #5
  unreachable

113:                                              ; preds = %86
  br label %114

114:                                              ; preds = %113
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.sb_vec, ptr %115, i32 0, i32 0
  %117 = load i64, ptr %116, align 8, !tbaa !14
  %118 = trunc i64 %117 to i32
  %119 = load double, ptr %5, align 8, !tbaa !9
  %120 = load ptr, ptr %6, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.sb_vec, ptr %120, i32 0, i32 1
  %122 = load ptr, ptr %121, align 8, !tbaa !15
  %123 = load ptr, ptr %4, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.sb_vec, ptr %123, i32 0, i32 1
  %125 = load ptr, ptr %124, align 8, !tbaa !15
  call void @cblas_daxpy(i32 noundef %118, double noundef %119, ptr noundef %122, i32 noundef 1, ptr noundef %125, i32 noundef 1)
  br label %126

126:                                              ; preds = %114
  %127 = load ptr, ptr %4, align 8, !tbaa !5
  %128 = call i32 @sb_vec_is_finite(ptr noundef %127)
  %129 = icmp ne i32 %128, 0
  br i1 %129, label %149, label %130

130:                                              ; preds = %126
  %131 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %132 = icmp ne ptr %131, null
  br i1 %132, label %133, label %135

133:                                              ; preds = %130
  %134 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %137

135:                                              ; preds = %130
  %136 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %137

137:                                              ; preds = %135, %133
  %138 = phi ptr [ %134, %133 ], [ %136, %135 ]
  %139 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %138, ptr noundef @.str.91) #4
  %140 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %141 = icmp ne ptr %140, null
  br i1 %141, label %142, label %144

142:                                              ; preds = %137
  %143 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %146

144:                                              ; preds = %137
  %145 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %146

146:                                              ; preds = %144, %142
  %147 = phi ptr [ %143, %142 ], [ %145, %144 ]
  %148 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %147, ptr noundef @.str.1) #4
  call void @abort() #5
  unreachable

149:                                              ; preds = %126
  br label %150

150:                                              ; preds = %149
  %151 = load ptr, ptr %4, align 8, !tbaa !5
  ret ptr %151
}

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 = { 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 = { nounwind }
attributes #5 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !7, i64 16}
!12 = !{!"", !13, i64 0, !6, i64 8, !7, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 0}
!15 = !{!12, !6, i64 8}


; 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.87 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.88 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.89 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [33 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
declare dso_local i32 @sb_vec_is_finite(ptr noundef) local_unnamed_addr #2

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

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

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

13:                                               ; preds = %3
  %.not16 = icmp eq ptr %2, null
  br i1 %.not16, label %14, label %23

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

23:                                               ; preds = %13
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  %25 = load i8, ptr %24, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %2, i64 16
  %27 = load i8, ptr %26, align 8, !tbaa !5
  %.not19 = icmp eq i8 %25, %27
  br i1 %.not19, label %37, label %28

28:                                               ; preds = %23
  %29 = load ptr, ptr @sb_error_log, align 8
  %.not26 = icmp eq ptr %29, null
  %30 = load ptr, ptr @stderr, align 8
  %31 = select i1 %.not26, ptr %30, ptr %29
  %32 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef nonnull @.str.89) #4
  %33 = load ptr, ptr @sb_error_log, align 8
  %.not27 = icmp eq ptr %33, null
  %34 = load ptr, ptr @stderr, align 8
  %35 = select i1 %.not27, ptr %34, ptr %33
  %36 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef nonnull @.str.1) #4
  tail call void @abort() #5
  unreachable

37:                                               ; preds = %23
  %38 = load i64, ptr %0, align 8, !tbaa !11
  %39 = load i64, ptr %2, align 8, !tbaa !11
  %.not20 = icmp eq i64 %38, %39
  br i1 %.not20, label %49, label %40

40:                                               ; preds = %37
  %41 = load ptr, ptr @sb_error_log, align 8
  %.not24 = icmp eq ptr %41, null
  %42 = load ptr, ptr @stderr, align 8
  %43 = select i1 %.not24, ptr %42, ptr %41
  %44 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef nonnull @.str.90) #4
  %45 = load ptr, ptr @sb_error_log, align 8
  %.not25 = icmp eq ptr %45, null
  %46 = load ptr, ptr @stderr, align 8
  %47 = select i1 %.not25, ptr %46, ptr %45
  %48 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef nonnull @.str.1) #4
  tail call void @abort() #5
  unreachable

49:                                               ; preds = %37
  %50 = trunc i64 %38 to i32
  %51 = getelementptr inbounds i8, ptr %2, i64 8
  %52 = load ptr, ptr %51, align 8, !tbaa !12
  %53 = getelementptr inbounds i8, ptr %0, i64 8
  %54 = load ptr, ptr %53, align 8, !tbaa !12
  tail call void @cblas_daxpy(i32 noundef %50, double noundef %1, ptr noundef %52, i32 noundef 1, ptr noundef %54, i32 noundef 1) #4
  %55 = tail call i32 @sb_vec_is_finite(ptr noundef nonnull %0)
  %.not21 = icmp eq i32 %55, 0
  br i1 %.not21, label %56, label %65

56:                                               ; preds = %49
  %57 = load ptr, ptr @sb_error_log, align 8
  %.not22 = icmp eq ptr %57, null
  %58 = load ptr, ptr @stderr, align 8
  %59 = select i1 %.not22, ptr %58, ptr %57
  %60 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef nonnull @.str.91) #4
  %61 = load ptr, ptr @sb_error_log, align 8
  %.not23 = icmp eq ptr %61, null
  %62 = load ptr, ptr @stderr, align 8
  %63 = select i1 %.not23, ptr %62, ptr %61
  %64 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef nonnull @.str.1) #4
  tail call void @abort() #5
  unreachable

65:                                               ; preds = %49
  ret ptr %0
}

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 = { nounwind }
attributes #5 = { 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, !8, i64 16}
!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, !7, i64 0}
!12 = !{!6, !10, i64 8}


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