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

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__PRETTY_FUNCTION__.obmap_copy = external hidden unnamed_addr constant [33 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: nounwind uwtable
declare dso_local ptr @obmap_create_default() #1

declare ptr @obdeque_new() #2

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

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

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

31:                                               ; preds = %10
  br label %32

32:                                               ; preds = %45, %31
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.obmap_struct, ptr %33, i32 0, i32 3
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = call ptr @obdeque_obj_at_iterator(ptr noundef %35, ptr noundef %36)
  %38 = call ptr @obmap_copy_pair(ptr noundef %37)
  store ptr %38, ptr %4, align 8, !tbaa !5
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.obmap_struct, ptr %39, i32 0, i32 3
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  call void @obdeque_add_at_tail(ptr noundef %41, ptr noundef %42)
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = call ptr @ob_release(ptr noundef %43)
  br label %45

45:                                               ; preds = %32
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.obmap_struct, ptr %46, i32 0, i32 3
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = call zeroext i8 @obdeque_iterate_next(ptr noundef %48, ptr noundef %49)
  %51 = icmp ne i8 %50, 0
  br i1 %51, label %32, label %52, !llvm.loop !14

52:                                               ; preds = %45
  br label %53

53:                                               ; preds = %52, %10
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = call ptr @ob_release(ptr noundef %54)
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  call void @obmap_rehash(ptr noundef %56)
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret ptr %57
}

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

declare ptr @obdeque_head_iterator(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @obmap_copy_pair(ptr noundef) #1

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

declare void @obdeque_add_at_tail(ptr noundef, ptr noundef) #2

declare ptr @ob_release(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @obmap_rehash(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 "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, !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 = !{!10, !11, i64 32}
!13 = !{!10, !6, i64 24}
!14 = distinct !{!14, !15}
!15 = !{!"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 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [74 x i8], align 1
@__PRETTY_FUNCTION__.obmap_copy = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @obmap_create_default() local_unnamed_addr #0

declare ptr @obdeque_new() local_unnamed_addr #1

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

3:                                                ; preds = %1
  %4 = tail call ptr @obmap_create_default()
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i8, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  store i8 %6, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %4, i64 32
  store i32 %9, ptr %10, align 8, !tbaa !11
  %11 = tail call ptr @obdeque_new() #4
  %12 = getelementptr inbounds i8, ptr %4, i64 24
  store ptr %11, ptr %12, align 8, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = tail call ptr @obdeque_head_iterator(ptr noundef %14) #4
  %.not18 = icmp eq ptr %15, null
  br i1 %.not18, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %3, %.preheader
  %16 = load ptr, ptr %13, align 8, !tbaa !12
  %17 = tail call ptr @obdeque_obj_at_iterator(ptr noundef %16, ptr noundef nonnull %15) #4
  %18 = tail call ptr @obmap_copy_pair(ptr noundef %17)
  %19 = load ptr, ptr %12, align 8, !tbaa !12
  tail call void @obdeque_add_at_tail(ptr noundef %19, ptr noundef %18) #4
  %20 = tail call ptr @ob_release(ptr noundef %18) #4
  %21 = load ptr, ptr %13, align 8, !tbaa !12
  %22 = tail call zeroext i8 @obdeque_iterate_next(ptr noundef %21, ptr noundef nonnull %15) #4
  %.not19 = icmp eq i8 %22, 0
  br i1 %.not19, label %.loopexit, label %.preheader, !llvm.loop !13

.loopexit:                                        ; preds = %.preheader, %3
  %23 = tail call ptr @ob_release(ptr noundef %15) #4
  tail call void @obmap_rehash(ptr noundef nonnull %4)
  ret ptr %4
}

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

declare ptr @obdeque_head_iterator(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @obmap_copy_pair(ptr noundef) local_unnamed_addr #0

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

declare void @obdeque_add_at_tail(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ob_release(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @obmap_rehash(ptr noundef) local_unnamed_addr #0

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


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