; 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 }

@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_rehash = external hidden unnamed_addr constant [27 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

declare ptr @obvector_new(i32 noundef) #1

; 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) #2

declare ptr @obdeque_head_iterator(ptr noundef) #1

declare ptr @ob_release(ptr noundef) #1

declare zeroext i8 @obdeque_iterate_next(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @obmap_rehash(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  br label %10

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

10:                                               ; preds = %8
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.obmap_struct, ptr %11, i32 0, i32 2
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = call ptr @ob_release(ptr noundef %13)
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.obmap_struct, ptr %15, i32 0, i32 1
  %17 = load i8, ptr %16, align 8, !tbaa !12
  %18 = zext i8 %17 to i64
  %19 = getelementptr inbounds [26 x i32], ptr @MAP_CAPACITIES, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %21 = call ptr @obvector_new(i32 noundef %20)
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.obmap_struct, ptr %22, i32 0, i32 2
  store ptr %21, ptr %23, align 8, !tbaa !9
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.obmap_struct, ptr %24, i32 0, i32 3
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  %27 = call ptr @obdeque_head_iterator(ptr noundef %26)
  store ptr %27, ptr %3, align 8, !tbaa !5
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %31, label %30

30:                                               ; preds = %10
  store i32 1, ptr %5, align 4
  br label %49

31:                                               ; preds = %10
  br label %32

32:                                               ; preds = %39, %31
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = call ptr @obdeque_copy_iterator(ptr noundef %33)
  store ptr %34, ptr %4, align 8, !tbaa !5
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  call void @obmap_add_to_table(ptr noundef %35, ptr noundef %36)
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = call ptr @ob_release(ptr noundef %37)
  br label %39

39:                                               ; preds = %32
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.obmap_struct, ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %41, align 8, !tbaa !14
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = call zeroext i8 @obdeque_iterate_next(ptr noundef %42, ptr noundef %43)
  %45 = icmp ne i8 %44, 0
  br i1 %45, label %32, label %46, !llvm.loop !15

46:                                               ; preds = %39
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = call ptr @ob_release(ptr noundef %47)
  store i32 1, ptr %5, align 4
  br label %49

49:                                               ; preds = %46, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

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

declare ptr @obdeque_copy_iterator(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 = { 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 #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 16}
!10 = !{!"obmap_struct", !6, i64 0, !7, i64 8, !6, i64 16, !6, i64 24, !11, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !7, i64 8}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 24}
!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"

@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_rehash = external hidden unnamed_addr constant [27 x i8], align 1

declare ptr @obvector_new(i32 noundef) local_unnamed_addr #0

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

declare ptr @obdeque_head_iterator(ptr noundef) local_unnamed_addr #0

declare ptr @ob_release(ptr noundef) local_unnamed_addr #0

declare zeroext i8 @obdeque_iterate_next(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = tail call ptr @ob_release(ptr noundef %5) #4
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load i8, ptr %7, align 8, !tbaa !11
  %9 = zext i8 %8 to i64
  %10 = getelementptr inbounds [26 x i32], ptr @MAP_CAPACITIES, i64 0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !12
  %12 = tail call ptr @obvector_new(i32 noundef %11) #4
  store ptr %12, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = tail call ptr @obdeque_head_iterator(ptr noundef %14) #4
  %.not13 = icmp eq ptr %15, null
  br i1 %.not13, label %22, label %.preheader

.preheader:                                       ; preds = %3, %.preheader
  %16 = tail call ptr @obdeque_copy_iterator(ptr noundef nonnull %15) #4
  tail call void @obmap_add_to_table(ptr noundef nonnull %0, ptr noundef %16)
  %17 = tail call ptr @ob_release(ptr noundef %16) #4
  %18 = load ptr, ptr %13, align 8, !tbaa !13
  %19 = tail call zeroext i8 @obdeque_iterate_next(ptr noundef %18, ptr noundef nonnull %15) #4
  %.not14 = icmp eq i8 %19, 0
  br i1 %.not14, label %20, label %.preheader, !llvm.loop !14

20:                                               ; preds = %.preheader
  %21 = tail call ptr @ob_release(ptr noundef nonnull %15) #4
  br label %22

22:                                               ; preds = %3, %20
  ret void
}

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

declare ptr @obdeque_copy_iterator(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 = { 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 = { 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 16}
!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 = !{!6, !8, i64 8}
!12 = !{!10, !10, i64 0}
!13 = !{!6, !7, i64 24}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass