; 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.1 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [8 x i8], align 1
@obmap_hash.init = external hidden global i8, align 1
@obmap_hash.seed = external hidden global i64, align 8
@__PRETTY_FUNCTION__.obmap_hash = external hidden unnamed_addr constant [34 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [31 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_head_iterator(ptr noundef) #2

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

declare ptr @ob_release(ptr noundef) #2

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

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

; Function Attrs: nounwind
declare void @srand(i32 noundef) #3

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @rand() #3

declare i64 @ob_hash(ptr noundef) #2

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

11:                                               ; preds = %1
  br label %13

12:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 339, ptr noundef @__PRETTY_FUNCTION__.obmap_hash) #6
  unreachable

13:                                               ; preds = %11
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = call zeroext i8 @ob_has_class(ptr noundef %14, ptr noundef @.str.15)
  %16 = icmp ne i8 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %13
  br label %19

18:                                               ; preds = %13
  call void @__assert_fail(ptr noundef @.str.16, ptr noundef @.str.1, i32 noundef 340, ptr noundef @__PRETTY_FUNCTION__.obmap_hash) #6
  unreachable

19:                                               ; preds = %17
  %20 = load i8, ptr @obmap_hash.init, align 1, !tbaa !9
  %21 = sext i8 %20 to i32
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %28

23:                                               ; preds = %19
  %24 = call i64 @time(ptr noundef null) #5
  %25 = trunc i64 %24 to i32
  call void @srand(i32 noundef %25) #5
  %26 = call i32 @rand() #5
  %27 = sext i32 %26 to i64
  store i64 %27, ptr @obmap_hash.seed, align 8, !tbaa !10
  store i8 1, ptr @obmap_hash.init, align 1, !tbaa !9
  br label %28

28:                                               ; preds = %23, %19
  %29 = load i64, ptr @obmap_hash.seed, align 8, !tbaa !10
  store i64 %29, ptr %4, align 8, !tbaa !10
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.obmap_struct, ptr %30, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !12
  %33 = call ptr @obdeque_head_iterator(ptr noundef %32)
  store ptr %33, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %38, label %36

36:                                               ; preds = %28
  %37 = load i64, ptr %4, align 8, !tbaa !10
  store i64 %37, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %71

38:                                               ; preds = %28
  br label %39

39:                                               ; preds = %48, %38
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.obmap_struct, ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %41, align 8, !tbaa !12
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = call ptr @obdeque_obj_at_iterator(ptr noundef %42, ptr noundef %43)
  %45 = call i64 @ob_hash(ptr noundef %44)
  %46 = load i64, ptr %4, align 8, !tbaa !10
  %47 = add i64 %46, %45
  store i64 %47, ptr %4, align 8, !tbaa !10
  br label %48

48:                                               ; preds = %39
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.obmap_struct, ptr %49, i32 0, i32 3
  %51 = load ptr, ptr %50, align 8, !tbaa !12
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = call zeroext i8 @obdeque_iterate_next(ptr noundef %51, ptr noundef %52)
  %54 = icmp ne i8 %53, 0
  br i1 %54, label %39, label %55, !llvm.loop !15

55:                                               ; preds = %48
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = call ptr @ob_release(ptr noundef %56)
  %58 = load i64, ptr %4, align 8, !tbaa !10
  %59 = shl i64 %58, 3
  %60 = load i64, ptr %4, align 8, !tbaa !10
  %61 = add i64 %60, %59
  store i64 %61, ptr %4, align 8, !tbaa !10
  %62 = load i64, ptr %4, align 8, !tbaa !10
  %63 = lshr i64 %62, 11
  %64 = load i64, ptr %4, align 8, !tbaa !10
  %65 = xor i64 %64, %63
  store i64 %65, ptr %4, align 8, !tbaa !10
  %66 = load i64, ptr %4, align 8, !tbaa !10
  %67 = shl i64 %66, 15
  %68 = load i64, ptr %4, align 8, !tbaa !10
  %69 = add i64 %68, %67
  store i64 %69, ptr %4, align 8, !tbaa !10
  %70 = load i64, ptr %4, align 8, !tbaa !10
  store i64 %70, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %71

71:                                               ; preds = %55, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %72 = load i64, ptr %2, align 8
  ret i64 %72
}

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 "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 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 #5 = { nounwind }
attributes #6 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !6, i64 24}
!13 = !{!"obmap_struct", !6, i64 0, !7, i64 8, !6, i64 16, !6, i64 24, !14, i64 32}
!14 = !{!"int", !7, i64 0}
!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 [74 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [8 x i8], align 1
@obmap_hash.init = external hidden local_unnamed_addr global i8, align 1
@obmap_hash.seed = external hidden local_unnamed_addr global i64, align 8
@__PRETTY_FUNCTION__.obmap_hash = external hidden unnamed_addr constant [34 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [31 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_head_iterator(ptr noundef) local_unnamed_addr #1

declare ptr @obdeque_obj_at_iterator(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

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

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #2

declare i64 @ob_hash(ptr noundef) local_unnamed_addr #1

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

3:                                                ; preds = %1
  %4 = tail call zeroext i8 @ob_has_class(ptr noundef nonnull %0, ptr noundef nonnull @.str.15) #5
  %.not21 = icmp eq i8 %4, 0
  br i1 %.not21, label %5, label %6

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

6:                                                ; preds = %3
  %7 = load i8, ptr @obmap_hash.init, align 1, !tbaa !5
  %8 = icmp eq i8 %7, 0
  br i1 %8, label %9, label %._crit_edge

._crit_edge:                                      ; preds = %6
  %.pre = load i64, ptr @obmap_hash.seed, align 8, !tbaa !8
  br label %14

9:                                                ; preds = %6
  %10 = tail call i64 @time(ptr noundef null) #5
  %11 = trunc i64 %10 to i32
  tail call void @srand(i32 noundef %11) #5
  %12 = tail call i32 @rand() #5
  %13 = sext i32 %12 to i64
  store i64 %13, ptr @obmap_hash.seed, align 8, !tbaa !8
  store i8 1, ptr @obmap_hash.init, align 1, !tbaa !5
  br label %14

14:                                               ; preds = %._crit_edge, %9
  %15 = phi i64 [ %.pre, %._crit_edge ], [ %13, %9 ]
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  %17 = load ptr, ptr %16, align 8, !tbaa !10
  %18 = tail call ptr @obdeque_head_iterator(ptr noundef %17) #5
  %.not22 = icmp eq ptr %18, null
  br i1 %.not22, label %31, label %.preheader

.preheader:                                       ; preds = %14, %.preheader
  %.019 = phi i64 [ %22, %.preheader ], [ %15, %14 ]
  %19 = load ptr, ptr %16, align 8, !tbaa !10
  %20 = tail call ptr @obdeque_obj_at_iterator(ptr noundef %19, ptr noundef nonnull %18) #5
  %21 = tail call i64 @ob_hash(ptr noundef %20) #5
  %22 = add i64 %21, %.019
  %23 = load ptr, ptr %16, align 8, !tbaa !10
  %24 = tail call zeroext i8 @obdeque_iterate_next(ptr noundef %23, ptr noundef nonnull %18) #5
  %.not23 = icmp eq i8 %24, 0
  br i1 %.not23, label %25, label %.preheader, !llvm.loop !14

25:                                               ; preds = %.preheader
  %26 = tail call ptr @ob_release(ptr noundef nonnull %18) #5
  %27 = mul i64 %22, 9
  %28 = lshr i64 %27, 11
  %29 = xor i64 %28, %27
  %30 = mul i64 %29, 32769
  br label %31

31:                                               ; preds = %14, %25
  %.0 = phi i64 [ %30, %25 ], [ %15, %14 ]
  ret i64 %.0
}

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


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