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

; 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.obmap_struct = type { ptr, i8, ptr, ptr, i32 }
%struct.obmap_pair_struct = type { ptr, ptr, ptr }

@MAP_CAPACITIES = external dso_local constant [26 x i32], align 16
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.obmap_add_to_table = external hidden unnamed_addr constant [53 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [3 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 @obdeque_obj_at_iterator(ptr noundef, ptr noundef) #2

declare ptr @obvector_obj_at_index(ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @obmap_add_to_table(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  br label %12

11:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 439, ptr noundef @__PRETTY_FUNCTION__.obmap_add_to_table) #5
  unreachable

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

15:                                               ; preds = %12
  br label %17

16:                                               ; preds = %12
  call void @__assert_fail(ptr noundef @.str.27, ptr noundef @.str.1, i32 noundef 440, ptr noundef @__PRETTY_FUNCTION__.obmap_add_to_table) #5
  unreachable

17:                                               ; preds = %15
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.obmap_struct, ptr %18, i32 0, i32 3
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = call ptr @obdeque_obj_at_iterator(ptr noundef %20, ptr noundef %21)
  store ptr %22, ptr %7, align 8, !tbaa !5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.obmap_pair_struct, ptr %23, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %26 = call i64 @ob_hash(ptr noundef %25)
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.obmap_struct, ptr %27, i32 0, i32 1
  %29 = load i8, ptr %28, align 8, !tbaa !14
  %30 = zext i8 %29 to i64
  %31 = getelementptr inbounds [26 x i32], ptr @MAP_CAPACITIES, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !15
  %33 = zext i32 %32 to i64
  %34 = urem i64 %26, %33
  store i64 %34, ptr %5, align 8, !tbaa !16
  store i64 0, ptr %6, align 8, !tbaa !16
  br label %35

35:                                               ; preds = %42, %17
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.obmap_struct, ptr %36, i32 0, i32 2
  %38 = load ptr, ptr %37, align 8, !tbaa !18
  %39 = load i64, ptr %5, align 8, !tbaa !16
  %40 = call ptr @obvector_obj_at_index(ptr noundef %38, i64 noundef %39)
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %60

42:                                               ; preds = %35
  %43 = load i64, ptr %6, align 8, !tbaa !16
  %44 = call i64 @obmap_offset_collision(i64 noundef %43)
  store i64 %44, ptr %6, align 8, !tbaa !16
  %45 = load i64, ptr %5, align 8, !tbaa !16
  %46 = load i64, ptr %6, align 8, !tbaa !16
  %47 = add i64 %45, %46
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.obmap_struct, ptr %48, i32 0, i32 1
  %50 = load i8, ptr %49, align 8, !tbaa !14
  %51 = zext i8 %50 to i64
  %52 = getelementptr inbounds [26 x i32], ptr @MAP_CAPACITIES, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !15
  %54 = zext i32 %53 to i64
  %55 = urem i64 %47, %54
  store i64 %55, ptr %5, align 8, !tbaa !16
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.obmap_struct, ptr %56, i32 0, i32 4
  %58 = load i32, ptr %57, align 8, !tbaa !19
  %59 = add i32 %58, 1
  store i32 %59, ptr %57, align 8, !tbaa !19
  br label %35, !llvm.loop !20

60:                                               ; preds = %35
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.obmap_struct, ptr %61, i32 0, i32 2
  %63 = load ptr, ptr %62, align 8, !tbaa !18
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = load i64, ptr %5, align 8, !tbaa !16
  call void @obvector_store_at_index(ptr noundef %63, ptr noundef %64, i64 noundef %65)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

declare i64 @ob_hash(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i64 @obmap_offset_collision(i64 noundef) #3

declare void @obvector_store_at_index(ptr noundef, ptr noundef, i64 noundef) #2

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, !6, i64 24}
!10 = !{!"obmap_struct", !6, i64 0, !7, i64 8, !6, i64 16, !6, i64 24, !11, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 8}
!13 = !{!"obmap_pair_struct", !6, i64 0, !6, i64 8, !6, i64 16}
!14 = !{!10, !7, i64 8}
!15 = !{!11, !11, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!10, !6, i64 16}
!19 = !{!10, !11, i64 32}
!20 = distinct !{!20, !21}
!21 = !{!"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"

@MAP_CAPACITIES = external dso_local local_unnamed_addr constant [26 x i32], align 16
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__.obmap_add_to_table = external hidden unnamed_addr constant [53 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [3 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 @obdeque_obj_at_iterator(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @obvector_obj_at_index(ptr noundef, i64 noundef) local_unnamed_addr #1

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

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

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

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = tail call ptr @obdeque_obj_at_iterator(ptr noundef %8, ptr noundef nonnull %1) #4
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = tail call i64 @ob_hash(ptr noundef %11) #4
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load i8, ptr %13, align 8, !tbaa !13
  %15 = zext i8 %14 to i64
  %16 = getelementptr inbounds [26 x i32], ptr @MAP_CAPACITIES, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !14
  %18 = zext i32 %17 to i64
  %19 = urem i64 %12, %18
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = tail call ptr @obvector_obj_at_index(ptr noundef %21, i64 noundef %19) #4
  %.not1920 = icmp eq ptr %22, null
  br i1 %.not1920, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %6
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  br label %24

24:                                               ; preds = %.lr.ph, %24
  %.022 = phi i64 [ %19, %.lr.ph ], [ %32, %24 ]
  %.01521 = phi i64 [ 0, %.lr.ph ], [ %25, %24 ]
  %25 = tail call i64 @obmap_offset_collision(i64 noundef %.01521)
  %26 = add i64 %25, %.022
  %27 = load i8, ptr %13, align 8, !tbaa !13
  %28 = zext i8 %27 to i64
  %29 = getelementptr inbounds [26 x i32], ptr @MAP_CAPACITIES, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !14
  %31 = zext i32 %30 to i64
  %32 = urem i64 %26, %31
  %33 = load i32, ptr %23, align 8, !tbaa !16
  %34 = add i32 %33, 1
  store i32 %34, ptr %23, align 8, !tbaa !16
  %35 = load ptr, ptr %20, align 8, !tbaa !15
  %36 = tail call ptr @obvector_obj_at_index(ptr noundef %35, i64 noundef %32) #4
  %.not19 = icmp eq ptr %36, null
  br i1 %.not19, label %._crit_edge, label %24, !llvm.loop !17

._crit_edge:                                      ; preds = %24, %6
  %.0.lcssa = phi i64 [ %19, %6 ], [ %32, %24 ]
  %37 = load ptr, ptr %20, align 8, !tbaa !15
  tail call void @obvector_store_at_index(ptr noundef %37, ptr noundef nonnull %1, i64 noundef %.0.lcssa) #4
  ret void
}

declare i64 @ob_hash(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @obmap_offset_collision(i64 noundef) local_unnamed_addr #2

declare void @obvector_store_at_index(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

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, !7, i64 24}
!6 = !{!"obmap_struct", !7, i64 0, !8, i64 8, !7, i64 16, !7, i64 24, !10, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !7, i64 8}
!12 = !{!"obmap_pair_struct", !7, i64 0, !7, i64 8, !7, i64 16}
!13 = !{!6, !8, i64 8}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !7, i64 16}
!16 = !{!6, !10, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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