; 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.7 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [39 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

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

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

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

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

14:                                               ; preds = %11
  %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.7) #6
  %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) #6
  call void @abort() #7
  unreachable

33:                                               ; preds = %11
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  %36 = load i8, ptr %7, align 1, !tbaa !11
  %37 = sext i8 %36 to i32
  %38 = icmp ne i32 %37, 99
  br i1 %38, label %39, label %62

39:                                               ; preds = %35
  %40 = load i8, ptr %7, align 1, !tbaa !11
  %41 = sext i8 %40 to i32
  %42 = icmp ne i32 %41, 114
  br i1 %42, label %43, label %62

43:                                               ; preds = %39
  %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 = %43
  %47 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %50

48:                                               ; preds = %43
  %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.8) #6
  %53 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %57

55:                                               ; preds = %50
  %56 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %59

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

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

62:                                               ; preds = %39, %35
  br label %63

63:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %64 = call noalias ptr @malloc(i64 noundef 24) #8
  store ptr %64, ptr %8, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %63
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = icmp ne ptr %66, null
  br i1 %67, label %87, label %68

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

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

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

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

80:                                               ; preds = %75
  %81 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %84

82:                                               ; preds = %75
  %83 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %84

84:                                               ; preds = %82, %80
  %85 = phi ptr [ %81, %80 ], [ %83, %82 ]
  %86 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %85, ptr noundef @.str.1) #6
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %133

87:                                               ; preds = %65
  br label %88

88:                                               ; preds = %87
  br label %89

89:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %90 = load i64, ptr %6, align 8, !tbaa !9
  %91 = mul i64 %90, 8
  %92 = call noalias ptr @malloc(i64 noundef %91) #8
  store ptr %92, ptr %10, align 8, !tbaa !5
  br label %93

93:                                               ; preds = %89
  %94 = load ptr, ptr %10, align 8, !tbaa !5
  %95 = icmp ne ptr %94, null
  br i1 %95, label %116, label %96

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

99:                                               ; preds = %96
  %100 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %103

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

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

108:                                              ; preds = %103
  %109 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %112

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

112:                                              ; preds = %110, %108
  %113 = phi ptr [ %109, %108 ], [ %111, %110 ]
  %114 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %113, ptr noundef @.str.1) #6
  %115 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %115) #6
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %132

116:                                              ; preds = %93
  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_vec, ptr %120, i32 0, i32 0
  store i64 %119, ptr %121, align 8, !tbaa !12
  %122 = load ptr, ptr %10, align 8, !tbaa !5
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = load i64, ptr %6, align 8, !tbaa !9
  %125 = mul i64 %124, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %122, ptr align 8 %123, i64 %125, i1 false)
  %126 = load ptr, ptr %8, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.sb_vec, ptr %126, i32 0, i32 1
  store ptr %122, ptr %127, align 8, !tbaa !14
  %128 = load i8, ptr %7, align 1, !tbaa !11
  %129 = load ptr, ptr %8, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.sb_vec, ptr %129, i32 0, i32 2
  store i8 %128, ptr %130, align 8, !tbaa !15
  %131 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %131, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %132

132:                                              ; preds = %118, %112
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %133

133:                                              ; preds = %132, %84
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %134 = load ptr, ptr %4, align 8
  ret ptr %134
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { 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 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 0}
!13 = !{!"", !10, i64 0, !6, i64 8, !7, i64 16}
!14 = !{!13, !6, i64 8}
!15 = !{!13, !7, i64 16}


; 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.7 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [39 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: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @sb_vec_of_arr(ptr noundef readonly %0, i64 noundef %1, i8 noundef signext %2) local_unnamed_addr #4 {
  %.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
  %.not21 = icmp eq ptr %5, null
  %6 = load ptr, ptr @stderr, align 8
  %7 = select i1 %.not21, ptr %6, ptr %5
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.7) #6
  %9 = load ptr, ptr @sb_error_log, align 8
  %.not22 = icmp eq ptr %9, null
  %10 = load ptr, ptr @stderr, align 8
  %11 = select i1 %.not22, ptr %10, ptr %9
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.1) #6
  tail call void @abort() #7
  unreachable

13:                                               ; preds = %3
  switch i8 %2, label %14 [
    i8 114, label %23
    i8 99, label %23
  ]

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

23:                                               ; preds = %13, %13
  %24 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #8
  %.not23 = icmp eq ptr %24, null
  br i1 %.not23, label %25, label %34

25:                                               ; preds = %23
  %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.9) #6
  %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) #6
  br label %49

34:                                               ; preds = %23
  %35 = shl i64 %1, 3
  %36 = tail call noalias ptr @malloc(i64 noundef %35) #8
  %.not26 = icmp eq ptr %36, null
  br i1 %.not26, label %37, label %46

37:                                               ; preds = %34
  %38 = load ptr, ptr @sb_error_log, align 8
  %.not27 = icmp eq ptr %38, null
  %39 = load ptr, ptr @stderr, align 8
  %40 = select i1 %.not27, ptr %39, ptr %38
  %41 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef nonnull @.str.10) #6
  %42 = load ptr, ptr @sb_error_log, align 8
  %.not28 = icmp eq ptr %42, null
  %43 = load ptr, ptr @stderr, align 8
  %44 = select i1 %.not28, ptr %43, ptr %42
  %45 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef nonnull @.str.1) #6
  tail call void @free(ptr noundef nonnull %24) #6
  br label %49

46:                                               ; preds = %34
  store i64 %1, ptr %24, align 8, !tbaa !5
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %36, ptr nonnull align 8 %0, i64 %35, i1 false)
  %47 = getelementptr inbounds i8, ptr %24, i64 8
  store ptr %36, ptr %47, align 8, !tbaa !11
  %48 = getelementptr inbounds i8, ptr %24, i64 16
  store i8 %2, ptr %48, align 8, !tbaa !12
  br label %49

49:                                               ; preds = %37, %46, %25
  %.1 = phi ptr [ null, %25 ], [ %24, %46 ], [ null, %37 ]
  ret ptr %.1
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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 = { 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 #3 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { 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, !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}
!12 = !{!6, !8, i64 16}


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