; LLVM IR from BitFunnel/NativeJIT :: src/NativeJIT/Node.ll (ZN9NativeJIT8NodeBase20DecrementParentCountEv)

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

%"class.NativeJIT::NodeBase" = type <{ ptr, i32, i32, i8, i8, [6 x i8] }>

@.str = external hidden unnamed_addr constant [76 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [60 x i8], align 1
@__FUNCTION__._ZN9NativeJIT8NodeBase20DecrementParentCountEv = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [59 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK9NativeJIT8NodeBase5GetIdEv(ptr noundef nonnull align 8 dereferenceable(18)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK9NativeJIT8NodeBase16HasBeenEvaluatedEv(ptr noundef nonnull align 8 dereferenceable(18)) #0 align 2

declare void @_ZN9NativeJIT12LogThrowImplEPKcS1_jS1_S1_z(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9NativeJIT8NodeBase20DecrementParentCountEv(ptr noundef nonnull align 8 dereferenceable(18) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  br label %4

4:                                                ; preds = %1
  %5 = call noundef zeroext i1 @_ZNK9NativeJIT8NodeBase16HasBeenEvaluatedEv(ptr noundef nonnull align 8 dereferenceable(18) %3)
  br i1 %5, label %6, label %7

6:                                                ; preds = %4
  call void (ptr, ptr, i32, ptr, ptr, ...) @_ZN9NativeJIT12LogThrowImplEPKcS1_jS1_S1_z(ptr noundef @.str, ptr noundef @__FUNCTION__._ZN9NativeJIT8NodeBase20DecrementParentCountEv, i32 noundef 63, ptr noundef @.str.1, ptr noundef @.str.2)
  br label %7

7:                                                ; preds = %6, %4
  br label %8

8:                                                ; preds = %7
  br label %9

9:                                                ; preds = %8
  %10 = getelementptr inbounds %"class.NativeJIT::NodeBase", ptr %3, i32 0, i32 2
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = icmp ugt i32 %11, 0
  br i1 %12, label %15, label %13

13:                                               ; preds = %9
  %14 = call noundef i32 @_ZNK9NativeJIT8NodeBase5GetIdEv(ptr noundef nonnull align 8 dereferenceable(18) %3)
  call void (ptr, ptr, i32, ptr, ptr, ...) @_ZN9NativeJIT12LogThrowImplEPKcS1_jS1_S1_z(ptr noundef @.str, ptr noundef @__FUNCTION__._ZN9NativeJIT8NodeBase20DecrementParentCountEv, i32 noundef 66, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef %14)
  br label %15

15:                                               ; preds = %13, %9
  br label %16

16:                                               ; preds = %15
  %17 = getelementptr inbounds %"class.NativeJIT::NodeBase", ptr %3, i32 0, i32 2
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = add i32 %18, -1
  store i32 %19, ptr %17, align 4, !tbaa !9
  ret void
}

attributes #0 = { mustprogress 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 = { mustprogress 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" }

!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++ TBAA"}
!9 = !{!10, !11, i64 12}
!10 = !{!"_ZTSN9NativeJIT8NodeBaseE", !11, i64 8, !11, i64 12, !12, i64 16, !12, i64 17}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}


; 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 [76 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [60 x i8], align 1
@__FUNCTION__._ZN9NativeJIT8NodeBase20DecrementParentCountEv = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [59 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK9NativeJIT8NodeBase5GetIdEv(ptr noundef nonnull align 8 dereferenceable(18)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK9NativeJIT8NodeBase16HasBeenEvaluatedEv(ptr noundef nonnull align 8 dereferenceable(18)) local_unnamed_addr #0 align 2

declare void @_ZN9NativeJIT12LogThrowImplEPKcS1_jS1_S1_z(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9NativeJIT8NodeBase20DecrementParentCountEv(ptr noundef nonnull align 8 dereferenceable(18) %0) local_unnamed_addr #2 align 2 {
  %2 = tail call noundef zeroext i1 @_ZNK9NativeJIT8NodeBase16HasBeenEvaluatedEv(ptr noundef nonnull align 8 dereferenceable(18) %0)
  br i1 %2, label %3, label %4

3:                                                ; preds = %1
  tail call void (ptr, ptr, i32, ptr, ptr, ...) @_ZN9NativeJIT12LogThrowImplEPKcS1_jS1_S1_z(ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__._ZN9NativeJIT8NodeBase20DecrementParentCountEv, i32 noundef 63, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2)
  br label %4

4:                                                ; preds = %3, %1
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %9

7:                                                ; preds = %4
  %8 = tail call noundef i32 @_ZNK9NativeJIT8NodeBase5GetIdEv(ptr noundef nonnull align 8 dereferenceable(18) %0)
  tail call void (ptr, ptr, i32, ptr, ptr, ...) @_ZN9NativeJIT12LogThrowImplEPKcS1_jS1_S1_z(ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__._ZN9NativeJIT8NodeBase20DecrementParentCountEv, i32 noundef 66, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef %8)
  %.pre = load i32, ptr %5, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %4, %7
  %10 = phi i32 [ %6, %4 ], [ %.pre, %7 ]
  %11 = add i32 %10, -1
  store i32 %11, ptr %5, align 4, !tbaa !5
  ret void
}

attributes #0 = { mustprogress 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 = { mustprogress 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" }

!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, !7, i64 12}
!6 = !{!"_ZTSN9NativeJIT8NodeBaseE", !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 17}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass