; 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.22 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [50 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @sb_vec_memcpy(ptr noalias noundef %0, ptr noalias noundef %1) #3 {
  %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.22) #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.23) #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_vec, ptr %54, i32 0, i32 2
  %56 = load i8, ptr %55, align 8, !tbaa !9
  %57 = sext i8 %56 to i32
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.sb_vec, ptr %58, i32 0, i32 2
  %60 = load i8, ptr %59, align 8, !tbaa !9
  %61 = sext i8 %60 to i32
  %62 = icmp ne i32 %57, %61
  br i1 %62, label %63, label %82

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

66:                                               ; preds = %63
  %67 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %70

68:                                               ; preds = %63
  %69 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %70

70:                                               ; preds = %68, %66
  %71 = phi ptr [ %67, %66 ], [ %69, %68 ]
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef @.str.24) #4
  %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 = %70
  %76 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %79

77:                                               ; preds = %70
  %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.1) #4
  call void @abort() #5
  unreachable

82:                                               ; preds = %53
  br label %83

83:                                               ; preds = %82
  br label %84

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

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

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

97:                                               ; preds = %92
  %98 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %99

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

104:                                              ; preds = %99
  %105 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %108

106:                                              ; preds = %99
  %107 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %108

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

111:                                              ; preds = %84
  br label %112

112:                                              ; preds = %111
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.sb_vec, ptr %113, i32 0, i32 1
  %115 = load ptr, ptr %114, align 8, !tbaa !13
  %116 = load ptr, ptr %4, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.sb_vec, ptr %116, i32 0, i32 1
  %118 = load ptr, ptr %117, align 8, !tbaa !13
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.sb_vec, ptr %119, i32 0, i32 0
  %121 = load i64, ptr %120, align 8, !tbaa !12
  %122 = mul i64 %121, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %115, ptr align 8 %118, i64 %122, i1 false)
  %123 = load ptr, ptr %3, align 8, !tbaa !5
  ret ptr %123
}

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 nounwind willreturn memory(argmem: readwrite) }
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, !7, i64 16}
!10 = !{!"", !11, i64 0, !6, i64 8, !7, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !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.22 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [50 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 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) #2

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @sb_vec_memcpy(ptr noalias noundef readonly returned %0, ptr noalias noundef readonly %1) local_unnamed_addr #3 {
  %.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.22) #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.23) #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 = getelementptr inbounds i8, ptr %0, i64 16
  %24 = load i8, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %1, i64 16
  %26 = load i8, ptr %25, align 8, !tbaa !5
  %.not17 = icmp eq i8 %24, %26
  br i1 %.not17, label %36, label %27

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

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

39:                                               ; preds = %36
  %40 = load ptr, ptr @sb_error_log, align 8
  %.not19 = icmp eq ptr %40, null
  %41 = load ptr, ptr @stderr, align 8
  %42 = select i1 %.not19, ptr %41, ptr %40
  %43 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef nonnull @.str.25) #4
  %44 = load ptr, ptr @sb_error_log, align 8
  %.not20 = icmp eq ptr %44, null
  %45 = load ptr, ptr @stderr, align 8
  %46 = select i1 %.not20, 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 = %36
  %49 = getelementptr inbounds i8, ptr %0, i64 8
  %50 = load ptr, ptr %49, align 8, !tbaa !12
  %51 = getelementptr inbounds i8, ptr %1, i64 8
  %52 = load ptr, ptr %51, align 8, !tbaa !12
  %53 = shl i64 %37, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %50, ptr align 8 %52, i64 %53, i1 false)
  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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!6, !10, i64 8}


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