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

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

@.str.1 = external hidden unnamed_addr constant [77 x i8], align 1
@obstring_hash.init = external hidden global i8, align 1
@obstring_hash.seed = external hidden global i64, align 8
@.str.14 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__.obstring_hash = external hidden unnamed_addr constant [37 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.16 = 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr 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: nounwind uwtable
define dso_local i64 @obstring_hash(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %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 8, ptr %3) #5
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %6, 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
  %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.14, ptr noundef @.str.1, i32 noundef 236, ptr noundef @__PRETTY_FUNCTION__.obstring_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.15)
  %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.16, ptr noundef @.str.1, i32 noundef 237, ptr noundef @__PRETTY_FUNCTION__.obstring_hash) #6
  unreachable

17:                                               ; preds = %15
  %18 = load i8, ptr @obstring_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 @obstring_hash.seed, align 8, !tbaa !10
  store i8 1, ptr @obstring_hash.init, align 1, !tbaa !9
  br label %26

26:                                               ; preds = %21, %17
  %27 = load i64, ptr @obstring_hash.seed, align 8, !tbaa !10
  store i64 %27, ptr %4, align 8, !tbaa !10
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.obstring_struct, ptr %28, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !12
  store ptr %30, ptr %5, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %36, %26
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load i8, ptr %32, align 1, !tbaa !9
  %34 = sext i8 %33 to i32
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %51

36:                                               ; preds = %31
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i32 1
  store ptr %38, ptr %5, align 8, !tbaa !5
  %39 = load i8, ptr %37, align 1, !tbaa !9
  %40 = sext i8 %39 to i64
  %41 = load i64, ptr %4, align 8, !tbaa !10
  %42 = add i64 %41, %40
  store i64 %42, ptr %4, align 8, !tbaa !10
  %43 = load i64, ptr %4, align 8, !tbaa !10
  %44 = shl i64 %43, 10
  %45 = load i64, ptr %4, align 8, !tbaa !10
  %46 = add i64 %45, %44
  store i64 %46, ptr %4, align 8, !tbaa !10
  %47 = load i64, ptr %4, align 8, !tbaa !10
  %48 = lshr i64 %47, 6
  %49 = load i64, ptr %4, align 8, !tbaa !10
  %50 = xor i64 %49, %48
  store i64 %50, ptr %4, align 8, !tbaa !10
  br label %31, !llvm.loop !15

51:                                               ; preds = %31
  %52 = load i64, ptr %4, align 8, !tbaa !10
  %53 = shl i64 %52, 3
  %54 = load i64, ptr %4, align 8, !tbaa !10
  %55 = add i64 %54, %53
  store i64 %55, ptr %4, align 8, !tbaa !10
  %56 = load i64, ptr %4, align 8, !tbaa !10
  %57 = lshr i64 %56, 11
  %58 = load i64, ptr %4, align 8, !tbaa !10
  %59 = xor i64 %58, %57
  store i64 %59, ptr %4, align 8, !tbaa !10
  %60 = load i64, ptr %4, align 8, !tbaa !10
  %61 = shl i64 %60, 15
  %62 = load i64, ptr %4, align 8, !tbaa !10
  %63 = add i64 %62, %61
  store i64 %63, ptr %4, align 8, !tbaa !10
  %64 = 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 8, ptr %3) #5
  ret i64 %64
}

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

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, !6, i64 8}
!13 = !{!"obstring_struct", !6, i64 0, !6, i64 8, !14, i64 16}
!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 [77 x i8], align 1
@obstring_hash.init = external hidden local_unnamed_addr global i8, align 1
@obstring_hash.seed = external hidden local_unnamed_addr global i64, align 8
@.str.14 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__.obstring_hash = external hidden unnamed_addr constant [37 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.16 = 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 @obstring_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.14, ptr noundef nonnull @.str.1, i32 noundef 236, ptr noundef nonnull @__PRETTY_FUNCTION__.obstring_hash) #4
  unreachable

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

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

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

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

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

.lr.ph:                                           ; preds = %14, %.lr.ph
  %19 = phi i8 [ %26, %.lr.ph ], [ %18, %14 ]
  %.023 = phi ptr [ %20, %.lr.ph ], [ %17, %14 ]
  %.01722 = phi i64 [ %25, %.lr.ph ], [ %15, %14 ]
  %20 = getelementptr inbounds i8, ptr %.023, i64 1
  %21 = sext i8 %19 to i64
  %22 = add i64 %.01722, %21
  %23 = mul i64 %22, 1025
  %24 = lshr i64 %23, 6
  %25 = xor i64 %24, %23
  %26 = load i8, ptr %20, align 1, !tbaa !5
  %.not20 = icmp eq i8 %26, 0
  br i1 %.not20, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %14
  %.017.lcssa = phi i64 [ %15, %14 ], [ %25, %.lr.ph ]
  %27 = mul i64 %.017.lcssa, 9
  %28 = lshr i64 %27, 11
  %29 = xor i64 %28, %27
  %30 = mul i64 %29, 32769
  ret i64 %30
}

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

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, !12, i64 8}
!11 = !{!"obstring_struct", !12, i64 0, !12, i64 8, !13, i64 16}
!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,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass