; 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
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@__PRETTY_FUNCTION__.obvector_obj_at_index = external hidden unnamed_addr constant [54 x i8], align 1

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

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

8:                                                ; preds = %2
  br label %10

9:                                                ; preds = %2
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 80, ptr noundef @__PRETTY_FUNCTION__.obvector_obj_at_index) #2
  unreachable

10:                                               ; preds = %8
  %11 = load i64, ptr %5, align 8, !tbaa !9
  %12 = icmp slt i64 %11, 0
  br i1 %12, label %13, label %20

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

20:                                               ; preds = %13, %10
  %21 = load i64, ptr %5, align 8, !tbaa !9
  %22 = icmp slt i64 %21, 4294967295
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  br label %25

24:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 84, ptr noundef @__PRETTY_FUNCTION__.obvector_obj_at_index) #2
  unreachable

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

28:                                               ; preds = %25
  br label %30

29:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 85, ptr noundef @__PRETTY_FUNCTION__.obvector_obj_at_index) #2
  unreachable

30:                                               ; preds = %28
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.obvector_struct, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 8, !tbaa !11
  %35 = zext i32 %34 to i64
  %36 = icmp slt i64 %31, %35
  br i1 %36, label %37, label %44

37:                                               ; preds = %30
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.obvector_struct, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  %41 = load i64, ptr %5, align 8, !tbaa !9
  %42 = getelementptr inbounds ptr, ptr %40, i64 %41
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  store ptr %43, ptr %3, align 8
  br label %45

44:                                               ; preds = %30
  store ptr null, ptr %3, align 8
  br label %45

45:                                               ; preds = %44, %37
  %46 = load ptr, ptr %3, align 8
  ret ptr %46
}

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 = { 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 #2 = { 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
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@__PRETTY_FUNCTION__.obvector_obj_at_index = external hidden unnamed_addr constant [54 x i8], align 1

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

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

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

4:                                                ; preds = %2
  %5 = icmp slt i64 %1, 0
  br i1 %5, label %9, label %6

6:                                                ; preds = %4
  %7 = icmp ult i64 %1, 4294967295
  br i1 %7, label %..thread15_crit_edge, label %8

..thread15_crit_edge:                             ; preds = %6
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 16
  %.pre = load i32, ptr %.phi.trans.insert, align 8, !tbaa !5
  %.pre18 = zext i32 %.pre to i64
  br label %.thread15

8:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 84, ptr noundef nonnull @__PRETTY_FUNCTION__.obvector_obj_at_index) #2
  unreachable

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

15:                                               ; preds = %9
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 85, ptr noundef nonnull @__PRETTY_FUNCTION__.obvector_obj_at_index) #2
  unreachable

.thread15:                                        ; preds = %..thread15_crit_edge, %9
  %.pre-phi = phi i64 [ %.pre18, %..thread15_crit_edge ], [ %12, %9 ]
  %.01417 = phi i64 [ %1, %..thread15_crit_edge ], [ %13, %9 ]
  %16 = icmp ult i64 %.01417, %.pre-phi
  br i1 %16, label %17, label %22

17:                                               ; preds = %.thread15
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds ptr, ptr %19, i64 %.01417
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  br label %22

22:                                               ; preds = %.thread15, %17
  %.010 = phi ptr [ %21, %17 ], [ null, %.thread15 ]
  ret ptr %.010
}

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 = { 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 #2 = { 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, !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: BDCEPass,CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass