; 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_vec = type { i64, ptr, i8 }
%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.30 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [34 x i8], align 1

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

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

declare void @cblas_dcopy(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @sb_mat_set_row(ptr noalias noundef %0, i64 noundef %1, ptr noalias noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %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.30) #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.31) #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 %6, 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 = icmp ne i32 %59, 114
  br i1 %60, label %61, label %80

61:                                               ; preds = %55
  %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.32) #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 = %55
  br label %81

81:                                               ; preds = %80
  br label %82

82:                                               ; preds = %81
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.sb_vec, ptr %83, i32 0, i32 0
  %85 = load i64, ptr %84, align 8, !tbaa !13
  %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 !14
  %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.33) #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
  br label %111

111:                                              ; preds = %110
  %112 = load i64, ptr %5, align 8, !tbaa !9
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.sb_mat, ptr %113, i32 0, i32 0
  %115 = load i64, ptr %114, align 8, !tbaa !16
  %116 = icmp uge i64 %112, %115
  br i1 %116, label %117, label %136

117:                                              ; preds = %111
  %118 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %119 = icmp ne ptr %118, null
  br i1 %119, label %120, label %122

120:                                              ; preds = %117
  %121 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %124

122:                                              ; preds = %117
  %123 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %124

124:                                              ; preds = %122, %120
  %125 = phi ptr [ %121, %120 ], [ %123, %122 ]
  %126 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %125, ptr noundef @.str.34) #4
  %127 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %128 = icmp ne ptr %127, null
  br i1 %128, label %129, label %131

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

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

133:                                              ; preds = %131, %129
  %134 = phi ptr [ %130, %129 ], [ %132, %131 ]
  %135 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %134, ptr noundef @.str.1) #4
  call void @abort() #5
  unreachable

136:                                              ; preds = %111
  br label %137

137:                                              ; preds = %136
  %138 = load ptr, ptr %4, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.sb_mat, ptr %138, i32 0, i32 1
  %140 = load i64, ptr %139, align 8, !tbaa !14
  %141 = trunc i64 %140 to i32
  %142 = load ptr, ptr %6, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.sb_vec, ptr %142, i32 0, i32 1
  %144 = load ptr, ptr %143, align 8, !tbaa !17
  %145 = load ptr, ptr %4, align 8, !tbaa !5
  %146 = getelementptr inbounds %struct.sb_mat, ptr %145, i32 0, i32 3
  %147 = load ptr, ptr %146, align 8, !tbaa !18
  %148 = load i64, ptr %5, align 8, !tbaa !9
  %149 = getelementptr inbounds double, ptr %147, i64 %148
  %150 = load ptr, ptr %4, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.sb_mat, ptr %150, i32 0, i32 0
  %152 = load i64, ptr %151, align 8, !tbaa !16
  %153 = trunc i64 %152 to i32
  call void @cblas_dcopy(i32 noundef %141, ptr noundef %144, i32 noundef 1, ptr noundef %149, i32 noundef %153)
  %154 = load ptr, ptr %4, align 8, !tbaa !5
  ret ptr %154
}

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 = { "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 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 #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 = !{!"long", !7, i64 0}
!11 = !{!12, !7, i64 16}
!12 = !{!"", !10, i64 0, !6, i64 8, !7, i64 16}
!13 = !{!12, !10, i64 0}
!14 = !{!15, !10, i64 8}
!15 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !6, i64 24}
!16 = !{!15, !10, i64 0}
!17 = !{!12, !6, i64 8}
!18 = !{!15, !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.30 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [34 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

declare void @cblas_dcopy(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @sb_mat_set_row(ptr noalias noundef readonly returned %0, i64 noundef %1, ptr noalias noundef readonly %2) local_unnamed_addr #3 {
  %.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
  %.not16 = icmp eq ptr %5, null
  %6 = load ptr, ptr @stderr, align 8
  %7 = select i1 %.not16, ptr %6, ptr %5
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.30) #4
  %9 = load ptr, ptr @sb_error_log, align 8
  %.not17 = icmp eq ptr %9, null
  %10 = load ptr, ptr @stderr, align 8
  %11 = select i1 %.not17, 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
  %.not18 = icmp eq ptr %2, null
  br i1 %.not18, label %14, label %23

14:                                               ; preds = %13
  %15 = load ptr, ptr @sb_error_log, align 8
  %.not19 = icmp eq ptr %15, null
  %16 = load ptr, ptr @stderr, align 8
  %17 = select i1 %.not19, ptr %16, ptr %15
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef nonnull @.str.31) #4
  %19 = load ptr, ptr @sb_error_log, align 8
  %.not20 = icmp eq ptr %19, null
  %20 = load ptr, ptr @stderr, align 8
  %21 = select i1 %.not20, 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 %2, i64 16
  %25 = load i8, ptr %24, align 8, !tbaa !5
  %.not21 = icmp eq i8 %25, 114
  br i1 %.not21, label %35, label %26

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

35:                                               ; preds = %23
  %36 = load i64, ptr %2, align 8, !tbaa !11
  %37 = getelementptr inbounds i8, ptr %0, i64 8
  %38 = load i64, ptr %37, align 8, !tbaa !12
  %.not22 = icmp eq i64 %36, %38
  br i1 %.not22, label %48, label %39

39:                                               ; preds = %35
  %40 = load ptr, ptr @sb_error_log, align 8
  %.not26 = icmp eq ptr %40, null
  %41 = load ptr, ptr @stderr, align 8
  %42 = select i1 %.not26, ptr %41, ptr %40
  %43 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef nonnull @.str.33) #4
  %44 = load ptr, ptr @sb_error_log, align 8
  %.not27 = icmp eq ptr %44, null
  %45 = load ptr, ptr @stderr, align 8
  %46 = select i1 %.not27, 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 = %35
  %49 = load i64, ptr %0, align 8, !tbaa !14
  %.not23 = icmp ugt i64 %49, %1
  br i1 %.not23, label %59, label %50

50:                                               ; preds = %48
  %51 = load ptr, ptr @sb_error_log, align 8
  %.not24 = icmp eq ptr %51, null
  %52 = load ptr, ptr @stderr, align 8
  %53 = select i1 %.not24, ptr %52, ptr %51
  %54 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %53, ptr noundef nonnull @.str.34) #4
  %55 = load ptr, ptr @sb_error_log, align 8
  %.not25 = icmp eq ptr %55, null
  %56 = load ptr, ptr @stderr, align 8
  %57 = select i1 %.not25, ptr %56, ptr %55
  %58 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef nonnull @.str.1) #4
  tail call void @abort() #5
  unreachable

59:                                               ; preds = %48
  %60 = trunc i64 %36 to i32
  %61 = getelementptr inbounds i8, ptr %2, i64 8
  %62 = load ptr, ptr %61, align 8, !tbaa !15
  %63 = getelementptr inbounds i8, ptr %0, i64 24
  %64 = load ptr, ptr %63, align 8, !tbaa !16
  %65 = getelementptr inbounds double, ptr %64, i64 %1
  %66 = trunc i64 %49 to i32
  tail call void @cblas_dcopy(i32 noundef %60, ptr noundef %62, i32 noundef 1, ptr noundef %65, i32 noundef %66) #4
  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 = { "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 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 #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 = !{!13, !7, i64 8}
!13 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!14 = !{!13, !7, i64 0}
!15 = !{!6, !10, i64 8}
!16 = !{!13, !10, i64 24}


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