; 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.5 = external hidden unnamed_addr constant [20 x i8], align 1
@__PRETTY_FUNCTION__.obvector_concat = external hidden unnamed_addr constant [45 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [63 x i8], align 1

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

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

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

declare ptr @ob_retain(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @obvector_concat(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %6 = load ptr, ptr %3, 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.5, ptr noundef @.str.1, i32 noundef 96, ptr noundef @__PRETTY_FUNCTION__.obvector_concat) #5
  unreachable

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

13:                                               ; preds = %10
  br label %15

14:                                               ; preds = %10
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 97, ptr noundef @__PRETTY_FUNCTION__.obvector_concat) #5
  unreachable

15:                                               ; preds = %13
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.obvector_struct, ptr %16, i32 0, i32 2
  %18 = load i32, ptr %17, align 8, !tbaa !9
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.obvector_struct, ptr %19, i32 0, i32 2
  %21 = load i32, ptr %20, align 8, !tbaa !9
  %22 = add i32 %18, %21
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.obvector_struct, ptr %23, i32 0, i32 2
  %25 = load i32, ptr %24, align 8, !tbaa !9
  %26 = icmp uge i32 %22, %25
  br i1 %26, label %27, label %28

27:                                               ; preds = %15
  br label %29

28:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 99, ptr noundef @__PRETTY_FUNCTION__.obvector_concat) #5
  unreachable

29:                                               ; preds = %27
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.obvector_struct, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 8, !tbaa !9
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.obvector_struct, ptr %34, i32 0, i32 2
  %36 = load i32, ptr %35, align 8, !tbaa !9
  %37 = add i32 %33, %36
  %38 = sub i32 %37, 1
  call void @obvector_resize(ptr noundef %30, i32 noundef %38)
  store i64 0, ptr %5, align 8, !tbaa !12
  br label %39

39:                                               ; preds = %70, %29
  %40 = load i64, ptr %5, align 8, !tbaa !12
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.obvector_struct, ptr %41, i32 0, i32 2
  %43 = load i32, ptr %42, align 8, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = icmp ult i64 %40, %44
  br i1 %45, label %46, label %73

46:                                               ; preds = %39
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.obvector_struct, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !14
  %50 = load i64, ptr %5, align 8, !tbaa !12
  %51 = getelementptr inbounds ptr, ptr %49, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = call ptr @ob_retain(ptr noundef %52)
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.obvector_struct, ptr %54, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !14
  %57 = load i64, ptr %5, align 8, !tbaa !12
  %58 = getelementptr inbounds ptr, ptr %56, i64 %57
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.obvector_struct, ptr %60, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8, !tbaa !14
  %63 = load i64, ptr %5, align 8, !tbaa !12
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.obvector_struct, ptr %64, i32 0, i32 2
  %66 = load i32, ptr %65, align 8, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = add i64 %63, %67
  %69 = getelementptr inbounds ptr, ptr %62, i64 %68
  store ptr %59, ptr %69, align 8, !tbaa !5
  br label %70

70:                                               ; preds = %46
  %71 = load i64, ptr %5, align 8, !tbaa !12
  %72 = add i64 %71, 1
  store i64 %72, ptr %5, align 8, !tbaa !12
  br label %39, !llvm.loop !15

73:                                               ; preds = %39
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.obvector_struct, ptr %74, i32 0, i32 2
  %76 = load i32, ptr %75, align 8, !tbaa !9
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.obvector_struct, ptr %77, i32 0, i32 2
  %79 = load i32, ptr %78, align 8, !tbaa !9
  %80 = add i32 %79, %76
  store i32 %80, ptr %78, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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, !11, i64 16}
!10 = !{!"obvector_struct", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !6, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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.5 = external hidden unnamed_addr constant [20 x i8], align 1
@__PRETTY_FUNCTION__.obvector_concat = external hidden unnamed_addr constant [45 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [63 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
declare dso_local void @obvector_resize(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @obvector_concat(ptr noundef %0, ptr noundef readonly %1) local_unnamed_addr #2 {
  %.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.5, ptr noundef nonnull @.str.1, i32 noundef 96, ptr noundef nonnull @__PRETTY_FUNCTION__.obvector_concat) #3
  unreachable

4:                                                ; preds = %2
  %.not22 = icmp eq ptr %1, null
  br i1 %.not22, label %5, label %6

5:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 97, ptr noundef nonnull @__PRETTY_FUNCTION__.obvector_concat) #3
  unreachable

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = load i32, ptr %9, align 8, !tbaa !5
  %11 = add i32 %10, %8
  %.not23 = icmp ult i32 %11, %8
  br i1 %.not23, label %12, label %13

12:                                               ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 99, ptr noundef nonnull @__PRETTY_FUNCTION__.obvector_concat) #3
  unreachable

13:                                               ; preds = %6
  %14 = add i32 %11, -1
  tail call void @obvector_resize(ptr noundef nonnull %0, i32 noundef %14)
  %15 = load i32, ptr %9, align 8, !tbaa !5
  %.not25 = icmp eq i32 %15, 0
  br i1 %.not25, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %13
  %.pre = load i32, ptr %7, align 8, !tbaa !5
  br label %._crit_edge

.lr.ph:                                           ; preds = %13
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  br label %18

18:                                               ; preds = %.lr.ph, %18
  %.024 = phi i64 [ 0, %.lr.ph ], [ %31, %18 ]
  %19 = load ptr, ptr %16, align 8, !tbaa !11
  %20 = getelementptr inbounds ptr, ptr %19, i64 %.024
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = tail call ptr @ob_retain(ptr noundef %21) #4
  %23 = load ptr, ptr %16, align 8, !tbaa !11
  %24 = getelementptr inbounds ptr, ptr %23, i64 %.024
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %26 = load ptr, ptr %17, align 8, !tbaa !11
  %27 = load i32, ptr %7, align 8, !tbaa !5
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds ptr, ptr %26, i64 %.024
  %30 = getelementptr inbounds ptr, ptr %29, i64 %28
  store ptr %25, ptr %30, align 8, !tbaa !12
  %31 = add nuw nsw i64 %.024, 1
  %32 = load i32, ptr %9, align 8, !tbaa !5
  %33 = zext i32 %32 to i64
  %34 = icmp ult i64 %31, %33
  br i1 %34, label %18, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %18, %.._crit_edge_crit_edge
  %35 = phi i32 [ %.pre, %.._crit_edge_crit_edge ], [ %27, %18 ]
  %.lcssa = phi i32 [ 0, %.._crit_edge_crit_edge ], [ %32, %18 ]
  %36 = add i32 %35, %.lcssa
  store i32 %36, ptr %7, align 8, !tbaa !5
  ret void
}

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}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass