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

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

@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.118 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.119 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.120 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.121 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.122 = 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_mat_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_mat_padd(ptr noalias noundef %0, ptr noalias noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  br label %5

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

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

11:                                               ; preds = %8
  %12 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %15

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

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

20:                                               ; preds = %15
  %21 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %24

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

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

27:                                               ; preds = %5
  br label %28

28:                                               ; preds = %27
  br label %29

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

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

35:                                               ; preds = %32
  %36 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %39

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

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

44:                                               ; preds = %39
  %45 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %48

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

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

51:                                               ; preds = %29
  br label %52

52:                                               ; preds = %51
  br label %53

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

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

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

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

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

73:                                               ; preds = %68
  %74 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %77

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

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

80:                                               ; preds = %53
  br label %81

81:                                               ; preds = %80
  br label %82

82:                                               ; preds = %81
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.sb_mat, ptr %83, i32 0, i32 1
  %85 = load i64, ptr %84, align 8, !tbaa !12
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.sb_mat, ptr %86, i32 0, i32 1
  %88 = load i64, ptr %87, align 8, !tbaa !12
  %89 = icmp ne i64 %85, %88
  br i1 %89, label %90, label %109

90:                                               ; preds = %82
  %91 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %92 = icmp ne ptr %91, null
  br i1 %92, label %93, label %95

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

95:                                               ; preds = %90
  %96 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %97

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

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

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

106:                                              ; preds = %104, %102
  %107 = phi ptr [ %103, %102 ], [ %105, %104 ]
  %108 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %107, ptr noundef @.str.1) #4
  call void @abort() #5
  unreachable

109:                                              ; preds = %82
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr %3, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.sb_mat, ptr %111, i32 0, i32 2
  %113 = load i64, ptr %112, align 8, !tbaa !13
  %114 = trunc i64 %113 to i32
  %115 = load ptr, ptr %4, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.sb_mat, ptr %115, i32 0, i32 3
  %117 = load ptr, ptr %116, align 8, !tbaa !14
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.sb_mat, ptr %118, i32 0, i32 3
  %120 = load ptr, ptr %119, align 8, !tbaa !14
  call void @cblas_daxpy(i32 noundef %114, double noundef 1.000000e+00, ptr noundef %117, i32 noundef 1, ptr noundef %120, i32 noundef 1)
  br label %121

121:                                              ; preds = %110
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = call i32 @sb_mat_is_finite(ptr noundef %122)
  %124 = icmp ne i32 %123, 0
  br i1 %124, label %144, label %125

125:                                              ; preds = %121
  %126 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %127 = icmp ne ptr %126, null
  br i1 %127, label %128, label %130

128:                                              ; preds = %125
  %129 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %132

130:                                              ; preds = %125
  %131 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %132

132:                                              ; preds = %130, %128
  %133 = phi ptr [ %129, %128 ], [ %131, %130 ]
  %134 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %133, ptr noundef @.str.122) #4
  %135 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %136 = icmp ne ptr %135, null
  br i1 %136, label %137, label %139

137:                                              ; preds = %132
  %138 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %141

139:                                              ; preds = %132
  %140 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %141

141:                                              ; preds = %139, %137
  %142 = phi ptr [ %138, %137 ], [ %140, %139 ]
  %143 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %142, ptr noundef @.str.1) #4
  call void @abort() #5
  unreachable

144:                                              ; preds = %121
  br label %145

145:                                              ; preds = %144
  %146 = load ptr, ptr %3, align 8, !tbaa !5
  ret ptr %146
}

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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 8, !11, i64 16, !6, i64 24}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !6, i64 24}


; 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.118 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.119 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.120 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.121 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.122 = 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_mat_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_mat_padd(ptr noalias noundef returned %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
  %.not12 = icmp eq ptr %4, null
  %5 = load ptr, ptr @stderr, align 8
  %6 = select i1 %.not12, ptr %5, ptr %4
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %6, ptr noundef nonnull @.str.118) #4
  %8 = load ptr, ptr @sb_error_log, align 8
  %.not13 = icmp eq ptr %8, null
  %9 = load ptr, ptr @stderr, align 8
  %10 = select i1 %.not13, ptr %9, ptr %8
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.1) #4
  tail call void @abort() #5
  unreachable

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

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

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

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

34:                                               ; preds = %22
  %35 = getelementptr inbounds i8, ptr %0, i64 8
  %36 = load i64, ptr %35, align 8, !tbaa !11
  %37 = getelementptr inbounds i8, ptr %1, i64 8
  %38 = load i64, ptr %37, align 8, !tbaa !11
  %.not18 = icmp eq i64 %36, %38
  br i1 %.not18, label %48, label %39

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

48:                                               ; preds = %34
  %49 = getelementptr inbounds i8, ptr %0, i64 16
  %50 = load i64, ptr %49, align 8, !tbaa !12
  %51 = trunc i64 %50 to i32
  %52 = getelementptr inbounds i8, ptr %1, i64 24
  %53 = load ptr, ptr %52, align 8, !tbaa !13
  %54 = getelementptr inbounds i8, ptr %0, i64 24
  %55 = load ptr, ptr %54, align 8, !tbaa !13
  tail call void @cblas_daxpy(i32 noundef %51, double noundef 1.000000e+00, ptr noundef %53, i32 noundef 1, ptr noundef %55, i32 noundef 1) #4
  %56 = tail call i32 @sb_mat_is_finite(ptr noundef nonnull %0)
  %.not19 = icmp eq i32 %56, 0
  br i1 %.not19, label %57, label %66

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

66:                                               ; preds = %48
  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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!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 8}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !10, i64 24}


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