; LLVM IR from theck01/offbrand_lib :: src/tests (obtest_test)

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

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [81 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [99 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 8, 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 = call ptr @obtest_new(i32 noundef 1)
  store ptr %6, ptr %3, align 8, !tbaa !5
  %7 = call ptr @obtest_new(i32 noundef 3)
  store ptr %7, ptr %4, align 8, !tbaa !5
  %8 = call ptr @obtest_new(i32 noundef 3)
  store ptr %8, ptr %5, align 8, !tbaa !5
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %15, %0
  %10 = load i32, ptr %2, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 3
  br i1 %11, label %12, label %18

12:                                               ; preds = %9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = call ptr @ob_retain(ptr noundef %13)
  br label %15

15:                                               ; preds = %12
  %16 = load i32, ptr %2, align 4, !tbaa !9
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %2, align 4, !tbaa !9
  br label %9, !llvm.loop !11

18:                                               ; preds = %9
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call i32 @ob_reference_count(ptr noundef %19)
  %21 = icmp ne i32 %20, 4
  br i1 %21, label %22, label %25

22:                                               ; preds = %18
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str) #5
  call void @exit(i32 noundef 1) #6
  unreachable

25:                                               ; preds = %18
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %36, %25
  %27 = load i32, ptr %2, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %2, align 4, !tbaa !9
  %29 = icmp slt i32 %28, 5
  br i1 %29, label %30, label %34

30:                                               ; preds = %26
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = call ptr @ob_release(ptr noundef %31)
  %33 = icmp ne ptr %32, null
  br label %34

34:                                               ; preds = %30, %26
  %35 = phi i1 [ false, %26 ], [ %33, %30 ]
  br i1 %35, label %36, label %37

36:                                               ; preds = %34
  br label %26, !llvm.loop !13

37:                                               ; preds = %34
  %38 = load i32, ptr %2, align 4, !tbaa !9
  %39 = icmp slt i32 %38, 4
  br i1 %39, label %40, label %43

40:                                               ; preds = %37
  %41 = load ptr, ptr @stderr, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef @.str.1) #5
  call void @exit(i32 noundef 1) #6
  unreachable

43:                                               ; preds = %37
  %44 = load i32, ptr %2, align 4, !tbaa !9
  %45 = icmp sgt i32 %44, 4
  br i1 %45, label %46, label %49

46:                                               ; preds = %43
  %47 = load ptr, ptr @stderr, align 8, !tbaa !5
  %48 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str.2) #5
  call void @exit(i32 noundef 1) #6
  unreachable

49:                                               ; preds = %43
  br label %50

50:                                               ; preds = %49
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = call zeroext i8 @ob_has_same_class(ptr noundef %51, ptr noundef %52)
  %54 = icmp ne i8 %53, 0
  br i1 %54, label %58, label %55

55:                                               ; preds = %50
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str.3) #5
  call void @exit(i32 noundef 1) #6
  unreachable

58:                                               ; preds = %50
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = call zeroext i8 @ob_has_class(ptr noundef %59, ptr noundef @.str.4)
  %61 = icmp ne i8 %60, 0
  br i1 %61, label %65, label %62

62:                                               ; preds = %58
  %63 = load ptr, ptr @stderr, align 8, !tbaa !5
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef @.str.5) #5
  call void @exit(i32 noundef 1) #6
  unreachable

65:                                               ; preds = %58
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = call i64 @ob_hash(ptr noundef %66)
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  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
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

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

declare ptr @obtest_new(i32 noundef) #2

declare ptr @ob_retain(ptr noundef) #2

declare i32 @ob_reference_count(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

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

declare ptr @ob_release(ptr noundef) #2

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

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

declare i64 @ob_hash(ptr noundef) #2

declare i32 @printf(ptr noundef, ...) #2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [81 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [99 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call ptr @obtest_new(i32 noundef 1) #4
  %2 = tail call ptr @obtest_new(i32 noundef 3) #4
  %3 = tail call ptr @obtest_new(i32 noundef 3) #4
  %4 = tail call ptr @ob_retain(ptr noundef %1) #4
  %5 = tail call ptr @ob_retain(ptr noundef %1) #4
  %6 = tail call ptr @ob_retain(ptr noundef %1) #4
  %7 = tail call i32 @ob_reference_count(ptr noundef %1) #4
  %.not = icmp eq i32 %7, 4
  br i1 %.not, label %.preheader.preheader, label %9

.preheader.preheader:                             ; preds = %0
  %8 = tail call ptr @ob_release(ptr noundef %1) #4
  %.not13 = icmp eq ptr %8, null
  br i1 %.not13, label %15, label %.preheader.1, !llvm.loop !5

9:                                                ; preds = %0
  %10 = load ptr, ptr @stderr, align 8, !tbaa !7
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str) #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

.preheader.1:                                     ; preds = %.preheader.preheader
  %12 = tail call ptr @ob_release(ptr noundef %1) #4
  %.not13.1 = icmp eq ptr %12, null
  br i1 %.not13.1, label %15, label %.preheader.2, !llvm.loop !5

.preheader.2:                                     ; preds = %.preheader.1
  %13 = tail call ptr @ob_release(ptr noundef %1) #4
  %.not13.2 = icmp eq ptr %13, null
  br i1 %.not13.2, label %15, label %.preheader.3, !llvm.loop !5

.preheader.3:                                     ; preds = %.preheader.2
  %14 = tail call ptr @ob_release(ptr noundef %1) #4
  %.not13.3 = icmp eq ptr %14, null
  br i1 %.not13.3, label %.critedge, label %.preheader.4, !llvm.loop !5

15:                                               ; preds = %.preheader.preheader, %.preheader.1, %.preheader.2
  %16 = load ptr, ptr @stderr, align 8, !tbaa !7
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.1) #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

.preheader.4:                                     ; preds = %.preheader.3
  %18 = load ptr, ptr @stderr, align 8, !tbaa !7
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.2) #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

.critedge:                                        ; preds = %.preheader.3
  %20 = tail call zeroext i8 @ob_has_same_class(ptr noundef %2, ptr noundef %3) #4
  %.not15 = icmp eq i8 %20, 0
  br i1 %.not15, label %21, label %24

21:                                               ; preds = %.critedge
  %22 = load ptr, ptr @stderr, align 8, !tbaa !7
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str.3) #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

24:                                               ; preds = %.critedge
  %25 = tail call zeroext i8 @ob_has_class(ptr noundef %2, ptr noundef nonnull @.str.4) #4
  %.not16 = icmp eq i8 %25, 0
  br i1 %.not16, label %26, label %29

26:                                               ; preds = %24
  %27 = load ptr, ptr @stderr, align 8, !tbaa !7
  %28 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.5) #5
  tail call void @exit(i32 noundef 1) #6
  unreachable

29:                                               ; preds = %24
  %30 = tail call i64 @ob_hash(ptr noundef %2) #4
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  ret i32 0
}

declare ptr @obtest_new(i32 noundef) local_unnamed_addr #1

declare ptr @ob_retain(ptr noundef) local_unnamed_addr #1

declare i32 @ob_reference_count(ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

declare ptr @ob_release(ptr noundef) local_unnamed_addr #1

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

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

declare i64 @ob_hash(ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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 = { nofree 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 "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 = { cold 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass