; 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.46 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [35 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @sb_vec_malloc(i64 noundef, i8 noundef signext) #0

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

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

; 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
declare dso_local void @sb_vec_free(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @sb_vec_fread(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call i64 @fread(ptr noundef %5, i64 noundef 8, i64 noundef 1, ptr noundef %9)
  store i64 %10, ptr %4, align 8, !tbaa !9
  br label %11

11:                                               ; preds = %1
  %12 = load i64, ptr %4, align 8, !tbaa !9
  %13 = icmp ne i64 %12, 1
  br i1 %13, label %14, label %33

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.46) #4
  %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) #4
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %127

33:                                               ; preds = %11
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = call i64 @fread(ptr noundef %7, i64 noundef 1, i64 noundef 1, ptr noundef %36)
  store i64 %37, ptr %4, align 8, !tbaa !9
  br label %38

38:                                               ; preds = %35
  %39 = load i64, ptr %4, align 8, !tbaa !9
  %40 = icmp ne i64 %39, 1
  br i1 %40, label %41, label %60

41:                                               ; preds = %38
  %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 = %41
  %45 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %48

46:                                               ; preds = %41
  %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.46) #4
  %51 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %55

53:                                               ; preds = %48
  %54 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %57

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

57:                                               ; preds = %55, %53
  %58 = phi ptr [ %54, %53 ], [ %56, %55 ]
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %58, ptr noundef @.str.1) #4
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %126

60:                                               ; preds = %38
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %63 = load i64, ptr %5, align 8, !tbaa !9
  %64 = load i8, ptr %7, align 1, !tbaa !11
  %65 = call ptr @sb_vec_malloc(i64 noundef %63, i8 noundef signext %64)
  store ptr %65, ptr %8, align 8, !tbaa !5
  br label %66

66:                                               ; preds = %62
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %88, label %69

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

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

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

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

81:                                               ; preds = %76
  %82 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %85

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

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

88:                                               ; preds = %66
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.sb_vec, ptr %91, i32 0, i32 1
  %93 = load ptr, ptr %92, align 8, !tbaa !12
  %94 = load i64, ptr %5, align 8, !tbaa !9
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = call i64 @fread(ptr noundef %93, i64 noundef 8, i64 noundef %94, ptr noundef %95)
  store i64 %96, ptr %4, align 8, !tbaa !9
  br label %97

97:                                               ; preds = %90
  %98 = load i64, ptr %4, align 8, !tbaa !9
  %99 = load i64, ptr %5, align 8, !tbaa !9
  %100 = icmp ne i64 %98, %99
  br i1 %100, label %101, label %121

101:                                              ; preds = %97
  %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 = %101
  %105 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %108

106:                                              ; preds = %101
  %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.46) #4
  %111 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  %112 = icmp ne ptr %111, null
  br i1 %112, label %113, label %115

113:                                              ; preds = %108
  %114 = load ptr, ptr @sb_error_log, align 8, !tbaa !5
  br label %117

115:                                              ; preds = %108
  %116 = load ptr, ptr @stderr, align 8, !tbaa !5
  br label %117

117:                                              ; preds = %115, %113
  %118 = phi ptr [ %114, %113 ], [ %116, %115 ]
  %119 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %118, ptr noundef @.str.1) #4
  %120 = load ptr, ptr %8, align 8, !tbaa !5
  call void @sb_vec_free(ptr noundef %120)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %125

121:                                              ; preds = %97
  br label %122

122:                                              ; preds = %121
  br label %123

123:                                              ; preds = %122
  %124 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %124, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %125

125:                                              ; preds = %123, %117, %85
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %126

126:                                              ; preds = %125, %57
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  br label %127

127:                                              ; preds = %126, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %128 = load ptr, ptr %2, align 8
  ret ptr %128
}

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #3

attributes #0 = { 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 #1 = { 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 = { "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 }

!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, !6, i64 8}
!13 = !{!"", !10, i64 0, !6, i64 8, !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.46 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [35 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @sb_vec_malloc(i64 noundef, i8 noundef signext) 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @sb_vec_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @sb_vec_fread(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = alloca i64, align 8
  %3 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %4 = call i64 @fread(ptr noundef nonnull %2, i64 noundef 8, i64 noundef 1, ptr noundef %0)
  %.not = icmp eq i64 %4, 1
  br i1 %.not, label %14, label %5

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

14:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #3
  %15 = call i64 @fread(ptr noundef nonnull %3, i64 noundef 1, i64 noundef 1, ptr noundef %0)
  %.not11 = icmp eq i64 %15, 1
  br i1 %.not11, label %25, label %16

16:                                               ; preds = %14
  %17 = load ptr, ptr @sb_error_log, align 8
  %.not18 = icmp eq ptr %17, null
  %18 = load ptr, ptr @stderr, align 8
  %19 = select i1 %.not18, ptr %18, ptr %17
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.46) #3
  %21 = load ptr, ptr @sb_error_log, align 8
  %.not19 = icmp eq ptr %21, null
  %22 = load ptr, ptr @stderr, align 8
  %23 = select i1 %.not19, ptr %22, ptr %21
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef nonnull @.str.1) #3
  br label %51

25:                                               ; preds = %14
  %26 = load i64, ptr %2, align 8, !tbaa !5
  %27 = load i8, ptr %3, align 1, !tbaa !9
  %28 = tail call ptr @sb_vec_malloc(i64 noundef %26, i8 noundef signext %27)
  %.not12 = icmp eq ptr %28, null
  br i1 %.not12, label %29, label %38

29:                                               ; preds = %25
  %30 = load ptr, ptr @sb_error_log, align 8
  %.not13 = icmp eq ptr %30, null
  %31 = load ptr, ptr @stderr, align 8
  %32 = select i1 %.not13, ptr %31, ptr %30
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str.47) #3
  %34 = load ptr, ptr @sb_error_log, align 8
  %.not14 = icmp eq ptr %34, null
  %35 = load ptr, ptr @stderr, align 8
  %36 = select i1 %.not14, ptr %35, ptr %34
  %37 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str.1) #3
  br label %51

38:                                               ; preds = %25
  %39 = getelementptr inbounds i8, ptr %28, i64 8
  %40 = load ptr, ptr %39, align 8, !tbaa !10
  %41 = tail call i64 @fread(ptr noundef %40, i64 noundef 8, i64 noundef %26, ptr noundef %0)
  %.not15 = icmp eq i64 %41, %26
  br i1 %.not15, label %51, label %42

42:                                               ; preds = %38
  %43 = load ptr, ptr @sb_error_log, align 8
  %.not16 = icmp eq ptr %43, null
  %44 = load ptr, ptr @stderr, align 8
  %45 = select i1 %.not16, ptr %44, ptr %43
  %46 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef nonnull @.str.46) #3
  %47 = load ptr, ptr @sb_error_log, align 8
  %.not17 = icmp eq ptr %47, null
  %48 = load ptr, ptr @stderr, align 8
  %49 = select i1 %.not17, ptr %48, ptr %47
  %50 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef nonnull @.str.1) #3
  tail call void @sb_vec_free(ptr noundef nonnull %28)
  br label %51

51:                                               ; preds = %29, %42, %38, %16
  %.1 = phi ptr [ null, %16 ], [ null, %42 ], [ null, %29 ], [ %28, %38 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #3
  br label %52

52:                                               ; preds = %51, %5
  %.2 = phi ptr [ null, %5 ], [ %.1, %51 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  ret ptr %.2
}

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #1

attributes #0 = { 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 #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 8}
!11 = !{!"", !6, i64 0, !12, i64 8, !7, i64 16}
!12 = !{!"any pointer", !7, i64 0}


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