; LLVM IR from theck01/offbrand_lib :: src/classes (obvector)

; 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.obvector_struct = type { ptr, ptr, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@__PRETTY_FUNCTION__.obvector_store_at_index = external hidden unnamed_addr constant [57 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

declare ptr @ob_retain(ptr noundef) #1

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

9:                                                ; preds = %3
  br label %11

10:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 55, ptr noundef @__PRETTY_FUNCTION__.obvector_store_at_index) #3
  unreachable

11:                                               ; preds = %9
  %12 = load i64, ptr %6, align 8, !tbaa !9
  %13 = icmp slt i64 %12, 0
  br i1 %13, label %14, label %21

14:                                               ; preds = %11
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.obvector_struct, ptr %15, i32 0, i32 2
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = zext i32 %17 to i64
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = add nsw i64 %19, %18
  store i64 %20, ptr %6, align 8, !tbaa !9
  br label %21

21:                                               ; preds = %14, %11
  %22 = load i64, ptr %6, align 8, !tbaa !9
  %23 = icmp slt i64 %22, 4294967295
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  br label %26

25:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 60, ptr noundef @__PRETTY_FUNCTION__.obvector_store_at_index) #3
  unreachable

26:                                               ; preds = %24
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = icmp sge i64 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  br label %31

30:                                               ; preds = %26
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 61, ptr noundef @__PRETTY_FUNCTION__.obvector_store_at_index) #3
  unreachable

31:                                               ; preds = %29
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load i64, ptr %6, align 8, !tbaa !9
  %34 = trunc i64 %33 to i32
  call void @obvector_resize(ptr noundef %32, i32 noundef %34)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call ptr @ob_retain(ptr noundef %35)
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.obvector_struct, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  %40 = load i64, ptr %6, align 8, !tbaa !9
  %41 = getelementptr inbounds ptr, ptr %39, i64 %40
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = call ptr @ob_release(ptr noundef %42)
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.obvector_struct, ptr %45, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !14
  %48 = load i64, ptr %6, align 8, !tbaa !9
  %49 = getelementptr inbounds ptr, ptr %47, i64 %48
  store ptr %44, ptr %49, align 8, !tbaa !5
  %50 = load i64, ptr %6, align 8, !tbaa !9
  %51 = add nsw i64 %50, 1
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.obvector_struct, ptr %52, i32 0, i32 2
  %54 = load i32, ptr %53, align 8, !tbaa !11
  %55 = zext i32 %54 to i64
  %56 = icmp sge i64 %51, %55
  br i1 %56, label %57, label %67

57:                                               ; preds = %31
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.obvector_struct, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !14
  %61 = load i64, ptr %6, align 8, !tbaa !9
  %62 = trunc i64 %61 to i32
  %63 = call i32 @obvector_find_valid_precursor(ptr noundef %60, i32 noundef %62)
  %64 = add i32 %63, 1
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.obvector_struct, ptr %65, i32 0, i32 2
  store i32 %64, ptr %66, align 8, !tbaa !11
  br label %67

67:                                               ; preds = %57, %31
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @obvector_resize(ptr noundef, i32 noundef) #2

declare ptr @ob_release(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @obvector_find_valid_precursor(ptr noundef, i32 noundef) #2

attributes #0 = { 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 #1 = { "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 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 #3 = { 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, !13, i64 16}
!12 = !{!"obvector_struct", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 20}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !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"

@.str.1 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@__PRETTY_FUNCTION__.obvector_store_at_index = external hidden unnamed_addr constant [57 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare ptr @ob_retain(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @obvector_store_at_index(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 55, ptr noundef nonnull @__PRETTY_FUNCTION__.obvector_store_at_index) #3
  unreachable

5:                                                ; preds = %3
  %6 = icmp slt i64 %2, 0
  br i1 %6, label %10, label %7

7:                                                ; preds = %5
  %8 = icmp ult i64 %2, 4294967295
  br i1 %8, label %.thread23, label %9

9:                                                ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 60, ptr noundef nonnull @__PRETTY_FUNCTION__.obvector_store_at_index) #3
  unreachable

10:                                               ; preds = %5
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load i32, ptr %11, align 8, !tbaa !5
  %13 = zext i32 %12 to i64
  %14 = add nsw i64 %13, %2
  %15 = icmp sgt i64 %14, -1
  br i1 %15, label %.thread23, label %16

16:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 61, ptr noundef nonnull @__PRETTY_FUNCTION__.obvector_store_at_index) #3
  unreachable

.thread23:                                        ; preds = %7, %10
  %.02225 = phi i64 [ %14, %10 ], [ %2, %7 ]
  %17 = trunc nuw i64 %.02225 to i32
  tail call void @obvector_resize(ptr noundef nonnull %0, i32 noundef %17)
  %18 = tail call ptr @ob_retain(ptr noundef %1) #4
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = getelementptr inbounds ptr, ptr %20, i64 %.02225
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  %23 = tail call ptr @ob_release(ptr noundef %22) #4
  %24 = load ptr, ptr %19, align 8, !tbaa !11
  %25 = getelementptr inbounds ptr, ptr %24, i64 %.02225
  store ptr %1, ptr %25, align 8, !tbaa !12
  %26 = add nuw nsw i64 %.02225, 1
  %27 = getelementptr inbounds i8, ptr %0, i64 16
  %28 = load i32, ptr %27, align 8, !tbaa !5
  %29 = zext i32 %28 to i64
  %.not20 = icmp ult i64 %26, %29
  br i1 %.not20, label %34, label %30

30:                                               ; preds = %.thread23
  %31 = load ptr, ptr %19, align 8, !tbaa !11
  %32 = tail call i32 @obvector_find_valid_precursor(ptr noundef %31, i32 noundef %17)
  %33 = add i32 %32, 1
  store i32 %33, ptr %27, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %30, %.thread23
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @obvector_resize(ptr noundef, i32 noundef) local_unnamed_addr #2

declare ptr @ob_release(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @obvector_find_valid_precursor(ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { "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 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 #3 = { noreturn nounwind }
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, !10, i64 16}
!6 = !{!"obvector_struct", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass