; 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

; 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

declare ptr @obdeque_obj_at_iterator(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @obmap_find_key(ptr noundef %0, ptr noundef %1) #2 {
  %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
  %8 = 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) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call i64 @ob_hash(ptr noundef %9)
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.obmap_struct, ptr %11, i32 0, i32 1
  %13 = load i8, ptr %12, align 8, !tbaa !9
  %14 = zext i8 %13 to i64
  %15 = getelementptr inbounds [26 x i32], ptr @MAP_CAPACITIES, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !12
  %17 = zext i32 %16 to i64
  %18 = urem i64 %10, %17
  store i64 %18, ptr %5, align 8, !tbaa !13
  store i64 0, ptr %6, align 8, !tbaa !13
  br label %19

19:                                               ; preds = %40, %2
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.obmap_struct, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = load i64, ptr %5, align 8, !tbaa !13
  %24 = call ptr @obvector_obj_at_index(ptr noundef %22, i64 noundef %23)
  store ptr %24, ptr %8, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %54

26:                                               ; preds = %19
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.obmap_struct, ptr %27, i32 0, i32 3
  %29 = load ptr, ptr %28, align 8, !tbaa !16
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = call ptr @obdeque_obj_at_iterator(ptr noundef %29, ptr noundef %30)
  store ptr %31, ptr %7, align 8, !tbaa !5
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.obmap_pair_struct, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = call signext i8 @ob_compare(ptr noundef %34, ptr noundef %35)
  %37 = sext i8 %36 to i32
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %26
  br label %54

40:                                               ; preds = %26
  %41 = load i64, ptr %6, align 8, !tbaa !13
  %42 = call i64 @obmap_offset_collision(i64 noundef %41)
  store i64 %42, ptr %6, align 8, !tbaa !13
  %43 = load i64, ptr %5, align 8, !tbaa !13
  %44 = load i64, ptr %6, align 8, !tbaa !13
  %45 = add i64 %43, %44
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.obmap_struct, ptr %46, i32 0, i32 1
  %48 = load i8, ptr %47, align 8, !tbaa !9
  %49 = zext i8 %48 to i64
  %50 = getelementptr inbounds [26 x i32], ptr @MAP_CAPACITIES, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !12
  %52 = zext i32 %51 to i64
  %53 = urem i64 %45, %52
  store i64 %53, ptr %5, align 8, !tbaa !13
  br label %19, !llvm.loop !19

54:                                               ; preds = %39, %19
  %55 = load i64, ptr %5, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i64 %55
}

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

declare i64 @ob_hash(ptr noundef) #1

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

declare signext i8 @ob_compare(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !7, i64 8}
!10 = !{!"obmap_struct", !6, i64 0, !7, i64 8, !6, i64 16, !6, i64 24, !11, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !6, i64 24}
!17 = !{!18, !6, i64 8}
!18 = !{!"obmap_pair_struct", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = distinct !{!19, !20}
!20 = !{!"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

declare ptr @obdeque_obj_at_iterator(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i64 0, 4294967295) i64 @obmap_find_key(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = tail call i64 @ob_hash(ptr noundef %1) #2
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i8, ptr %4, align 8, !tbaa !5
  %6 = zext i8 %5 to i64
  %7 = getelementptr inbounds [26 x i32], ptr @MAP_CAPACITIES, i64 0, i64 %6
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = zext i32 %8 to i64
  %10 = urem i64 %3, %9
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  %14 = tail call ptr @obvector_obj_at_index(ptr noundef %13, i64 noundef %10) #2
  %.not14 = icmp eq ptr %14, null
  br i1 %.not14, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %22
  %15 = phi ptr [ %32, %22 ], [ %14, %2 ]
  %.016 = phi i64 [ %30, %22 ], [ %10, %2 ]
  %.01215 = phi i64 [ %23, %22 ], [ 0, %2 ]
  %16 = load ptr, ptr %11, align 8, !tbaa !13
  %17 = tail call ptr @obdeque_obj_at_iterator(ptr noundef %16, ptr noundef nonnull %15) #2
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = tail call signext i8 @ob_compare(ptr noundef %19, ptr noundef %1) #2
  %21 = icmp eq i8 %20, 0
  br i1 %21, label %._crit_edge, label %22

22:                                               ; preds = %.lr.ph
  %23 = tail call i64 @obmap_offset_collision(i64 noundef %.01215)
  %24 = add i64 %23, %.016
  %25 = load i8, ptr %4, align 8, !tbaa !5
  %26 = zext i8 %25 to i64
  %27 = getelementptr inbounds [26 x i32], ptr @MAP_CAPACITIES, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !11
  %29 = zext i32 %28 to i64
  %30 = urem i64 %24, %29
  %31 = load ptr, ptr %12, align 8, !tbaa !12
  %32 = tail call ptr @obvector_obj_at_index(ptr noundef %31, i64 noundef %30) #2
  %.not = icmp eq ptr %32, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

._crit_edge:                                      ; preds = %22, %.lr.ph, %2
  %.0.lcssa = phi i64 [ %10, %2 ], [ %.016, %.lr.ph ], [ %30, %22 ]
  ret i64 %.0.lcssa
}

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

declare i64 @ob_hash(ptr noundef) local_unnamed_addr #0

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

declare signext i8 @ob_compare(ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #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 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 = { 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, !8, i64 8}
!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 = !{!10, !10, i64 0}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 24}
!14 = !{!15, !7, i64 8}
!15 = !{!"obmap_pair_struct", !7, i64 0, !7, i64 8, !7, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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