; 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.181 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.182 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.183 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.184 = external hidden unnamed_addr constant [41 x i8], align 1

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

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

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

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

10:                                               ; preds = %3
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %33, label %14

14:                                               ; preds = %10
  %15 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %19

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

19:                                               ; preds = %14
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %19, %17
  %22 = phi ptr [ %18, %17 ], [ %20, %19 ]
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.181) #5
  %24 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %28

26:                                               ; preds = %21
  %27 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %30

28:                                               ; preds = %21
  %29 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %28, %26
  %31 = phi ptr [ %27, %26 ], [ %29, %28 ]
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef @.str.1) #5
  call void @abort() #6
  unreachable

33:                                               ; preds = %10
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.sb_vec, ptr %37, i32 0, i32 2
  %39 = load i8, ptr %38, align 8, !tbaa !11
  %40 = sext i8 %39 to i32
  %41 = icmp ne i32 %40, 99
  br i1 %41, label %42, label %61

42:                                               ; preds = %35
  %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 = %42
  %46 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %49

47:                                               ; preds = %42
  %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.182) #5
  %52 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %56

54:                                               ; preds = %49
  %55 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %58

56:                                               ; preds = %49
  %57 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %56, %54
  %59 = phi ptr [ %55, %54 ], [ %57, %56 ]
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef @.str.1) #5
  call void @abort() #6
  unreachable

61:                                               ; preds = %35
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.sb_vec, ptr %65, i32 0, i32 0
  %67 = load i64, ptr %66, align 8, !tbaa !13
  %68 = load i64, ptr %6, align 8, !tbaa !9
  %69 = load i64, ptr %7, align 8, !tbaa !9
  %70 = mul i64 %68, %69
  %71 = icmp ne i64 %67, %70
  br i1 %71, label %72, label %91

72:                                               ; preds = %63
  %73 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %74 = icmp ne ptr %73, null
  br i1 %74, label %75, label %77

75:                                               ; preds = %72
  %76 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %79

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

79:                                               ; preds = %77, %75
  %80 = phi ptr [ %76, %75 ], [ %78, %77 ]
  %81 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %80, ptr noundef @.str.183) #5
  %82 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %83 = icmp ne ptr %82, null
  br i1 %83, label %84, label %86

84:                                               ; preds = %79
  %85 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %88

86:                                               ; preds = %79
  %87 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %88

88:                                               ; preds = %86, %84
  %89 = phi ptr [ %85, %84 ], [ %87, %86 ]
  %90 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %89, ptr noundef @.str.1) #5
  call void @abort() #6
  unreachable

91:                                               ; preds = %63
  br label %92

92:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %93 = call noalias ptr @malloc(i64 noundef 32) #7
  store ptr %93, ptr %8, align 8, !tbaa !5
  br label %94

94:                                               ; preds = %92
  %95 = load ptr, ptr %8, align 8, !tbaa !5
  %96 = icmp ne ptr %95, null
  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.184) #5
  %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) #5
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %141

116:                                              ; preds = %94
  br label %117

117:                                              ; preds = %116
  br label %118

118:                                              ; preds = %117
  %119 = load i64, ptr %6, align 8, !tbaa !9
  %120 = load ptr, ptr %8, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.sb_mat, ptr %120, i32 0, i32 0
  store i64 %119, ptr %121, align 8, !tbaa !14
  %122 = load i64, ptr %7, align 8, !tbaa !9
  %123 = load ptr, ptr %8, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.sb_mat, ptr %123, i32 0, i32 1
  store i64 %122, ptr %124, align 8, !tbaa !16
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = load ptr, ptr %125, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.sb_vec, ptr %126, i32 0, i32 0
  %128 = load i64, ptr %127, align 8, !tbaa !13
  %129 = load ptr, ptr %8, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.sb_mat, ptr %129, i32 0, i32 2
  store i64 %128, ptr %130, align 8, !tbaa !17
  %131 = load ptr, ptr %5, align 8, !tbaa !5
  %132 = load ptr, ptr %131, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.sb_vec, ptr %132, i32 0, i32 1
  %134 = load ptr, ptr %133, align 8, !tbaa !18
  %135 = load ptr, ptr %8, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct.sb_mat, ptr %135, i32 0, i32 3
  store ptr %134, ptr %136, align 8, !tbaa !19
  %137 = load ptr, ptr %5, align 8, !tbaa !5
  %138 = load ptr, ptr %137, align 8, !tbaa !5
  call void @free(ptr noundef %138) #5
  %139 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %139, align 8, !tbaa !5
  %140 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %140, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %141

141:                                              ; preds = %118, %113
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %142 = load ptr, ptr %4, align 8
  ret ptr %142
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 = { 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 #3 = { 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 #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 = { nounwind }
attributes #6 = { noreturn nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 0}
!15 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !6, i64 24}
!16 = !{!15, !10, i64 8}
!17 = !{!15, !10, i64 16}
!18 = !{!12, !6, i64 8}
!19 = !{!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.181 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.182 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.183 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.184 = external hidden unnamed_addr constant [41 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @sb_vec_to_mat(ptr nocapture noundef %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #4 {
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %14

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

14:                                               ; preds = %3
  %15 = getelementptr inbounds i8, ptr %4, i64 16
  %16 = load i8, ptr %15, align 8, !tbaa !9
  %.not21 = icmp eq i8 %16, 99
  br i1 %.not21, label %26, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr @sb_error_log, align 8
  %.not28 = icmp eq ptr %18, null
  %19 = load ptr, ptr @stderr, align 8
  %20 = select i1 %.not28, ptr %19, ptr %18
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str.182) #5
  %22 = load ptr, ptr @sb_error_log, align 8
  %.not29 = icmp eq ptr %22, null
  %23 = load ptr, ptr @stderr, align 8
  %24 = select i1 %.not29, ptr %23, ptr %22
  %25 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef nonnull @.str.1) #5
  tail call void @abort() #6
  unreachable

26:                                               ; preds = %14
  %27 = load i64, ptr %4, align 8, !tbaa !12
  %28 = mul i64 %2, %1
  %.not22 = icmp eq i64 %27, %28
  br i1 %.not22, label %38, label %29

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

38:                                               ; preds = %26
  %39 = tail call noalias dereferenceable_or_null(32) ptr @malloc(i64 noundef 32) #7
  %.not23 = icmp eq ptr %39, null
  br i1 %.not23, label %40, label %49

40:                                               ; preds = %38
  %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.184) #5
  %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) #5
  br label %55

49:                                               ; preds = %38
  store i64 %1, ptr %39, align 8, !tbaa !13
  %50 = getelementptr inbounds i8, ptr %39, i64 8
  store i64 %2, ptr %50, align 8, !tbaa !15
  %51 = getelementptr inbounds i8, ptr %39, i64 16
  store i64 %27, ptr %51, align 8, !tbaa !16
  %52 = getelementptr inbounds i8, ptr %4, i64 8
  %53 = load ptr, ptr %52, align 8, !tbaa !17
  %54 = getelementptr inbounds i8, ptr %39, i64 24
  store ptr %53, ptr %54, align 8, !tbaa !18
  tail call void @free(ptr noundef nonnull %4) #5
  store ptr null, ptr %0, align 8, !tbaa !5
  br label %55

55:                                               ; preds = %49, %40
  ret ptr %39
}

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #2 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #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 = { nounwind }
attributes #6 = { noreturn nounwind }
attributes #7 = { nounwind allocsize(0) }

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


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