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

; 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.obvector_struct = type { ptr, ptr, i32, i32 }

@.str.1 = external hidden unnamed_addr constant [77 x i8], align 1
@obvector_hash.init = external hidden global i8, align 1
@obvector_hash.seed = external hidden global i64, align 8
@.str.15 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__.obvector_hash = external hidden unnamed_addr constant [37 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [34 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

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

9:                                                ; preds = %1
  br label %11

10:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.1, i32 noundef 309, ptr noundef @__PRETTY_FUNCTION__.obvector_hash) #6
  unreachable

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

15:                                               ; preds = %11
  br label %17

16:                                               ; preds = %11
  call void @__assert_fail(ptr noundef @.str.17, ptr noundef @.str.1, i32 noundef 310, ptr noundef @__PRETTY_FUNCTION__.obvector_hash) #6
  unreachable

17:                                               ; preds = %15
  %18 = load i8, ptr @obvector_hash.init, align 1, !tbaa !9
  %19 = sext i8 %18 to i32
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %26

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

26:                                               ; preds = %21, %17
  %27 = load i64, ptr @obvector_hash.seed, align 8, !tbaa !10
  store i64 %27, ptr %4, align 8, !tbaa !10
  store i32 0, ptr %3, align 4, !tbaa !12
  br label %28

28:                                               ; preds = %53, %26
  %29 = load i32, ptr %3, align 4, !tbaa !12
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.obvector_struct, ptr %30, i32 0, i32 2
  %32 = load i32, ptr %31, align 8, !tbaa !14
  %33 = icmp ult i32 %29, %32
  br i1 %33, label %34, label %56

34:                                               ; preds = %28
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.obvector_struct, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  %38 = load i32, ptr %3, align 4, !tbaa !12
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds ptr, ptr %37, i64 %39
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = call i64 @ob_hash(ptr noundef %41)
  %43 = load i64, ptr %4, align 8, !tbaa !10
  %44 = add i64 %43, %42
  store i64 %44, ptr %4, align 8, !tbaa !10
  %45 = load i64, ptr %4, align 8, !tbaa !10
  %46 = shl i64 %45, 10
  %47 = load i64, ptr %4, align 8, !tbaa !10
  %48 = add i64 %47, %46
  store i64 %48, ptr %4, align 8, !tbaa !10
  %49 = load i64, ptr %4, align 8, !tbaa !10
  %50 = lshr i64 %49, 6
  %51 = load i64, ptr %4, align 8, !tbaa !10
  %52 = xor i64 %51, %50
  store i64 %52, ptr %4, align 8, !tbaa !10
  br label %53

53:                                               ; preds = %34
  %54 = load i32, ptr %3, align 4, !tbaa !12
  %55 = add i32 %54, 1
  store i32 %55, ptr %3, align 4, !tbaa !12
  br label %28, !llvm.loop !17

56:                                               ; preds = %28
  %57 = load i64, ptr %4, align 8, !tbaa !10
  %58 = shl i64 %57, 3
  %59 = load i64, ptr %4, align 8, !tbaa !10
  %60 = add i64 %59, %58
  store i64 %60, ptr %4, align 8, !tbaa !10
  %61 = load i64, ptr %4, align 8, !tbaa !10
  %62 = lshr i64 %61, 11
  %63 = load i64, ptr %4, align 8, !tbaa !10
  %64 = xor i64 %63, %62
  store i64 %64, ptr %4, align 8, !tbaa !10
  %65 = load i64, ptr %4, align 8, !tbaa !10
  %66 = shl i64 %65, 15
  %67 = load i64, ptr %4, align 8, !tbaa !10
  %68 = add i64 %67, %66
  store i64 %68, ptr %4, align 8, !tbaa !10
  %69 = load i64, ptr %4, align 8, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret i64 %69
}

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

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

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

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

declare i64 @ob_hash(ptr noundef) #3

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 = { 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 = { "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 "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, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 16}
!15 = !{!"obvector_struct", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 20}
!16 = !{!15, !6, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"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 [77 x i8], align 1
@obvector_hash.init = external hidden local_unnamed_addr global i8, align 1
@obvector_hash.seed = external hidden local_unnamed_addr global i64, align 8
@.str.15 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__.obvector_hash = external hidden unnamed_addr constant [37 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [34 x i8], align 1

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

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

3:                                                ; preds = %1
  %4 = tail call zeroext i8 @ob_has_class(ptr noundef nonnull %0, ptr noundef nonnull @.str.16) #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.17, ptr noundef nonnull @.str.1, i32 noundef 310, ptr noundef nonnull @__PRETTY_FUNCTION__.obvector_hash) #4
  unreachable

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

._crit_edge26:                                    ; preds = %6
  %.pre = load i64, ptr @obvector_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 @obvector_hash.seed, align 8, !tbaa !8
  store i8 1, ptr @obvector_hash.init, align 1, !tbaa !5
  br label %14

14:                                               ; preds = %._crit_edge26, %9
  %15 = phi i64 [ %.pre, %._crit_edge26 ], [ %13, %9 ]
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load i32, ptr %16, align 8, !tbaa !10
  %.not24 = icmp eq i32 %17, 0
  br i1 %.not24, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %14
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  br label %19

19:                                               ; preds = %.lr.ph, %19
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %19 ]
  %.01922 = phi i64 [ %15, %.lr.ph ], [ %27, %19 ]
  %20 = load ptr, ptr %18, align 8, !tbaa !14
  %21 = getelementptr inbounds ptr, ptr %20, i64 %indvars.iv
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = tail call i64 @ob_hash(ptr noundef %22) #5
  %24 = add i64 %23, %.01922
  %25 = mul i64 %24, 1025
  %26 = lshr i64 %25, 6
  %27 = xor i64 %26, %25
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = load i32, ptr %16, align 8, !tbaa !10
  %29 = zext i32 %28 to i64
  %30 = icmp ult i64 %indvars.iv.next, %29
  br i1 %30, label %19, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %19, %14
  %.019.lcssa = phi i64 [ %15, %14 ], [ %27, %19 ]
  %31 = mul i64 %.019.lcssa, 9
  %32 = lshr i64 %31, 11
  %33 = xor i64 %32, %31
  %34 = mul i64 %33, 32769
  ret i64 %34
}

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

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

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

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

declare i64 @ob_hash(ptr noundef) local_unnamed_addr #2

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 = { 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 = { 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 = { 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, !13, i64 16}
!11 = !{!"obvector_struct", !12, i64 0, !12, i64 8, !13, i64 16, !13, i64 20}
!12 = !{!"any pointer", !6, i64 0}
!13 = !{!"int", !6, i64 0}
!14 = !{!11, !12, i64 8}
!15 = !{!12, !12, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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