; LLVM IR from CerebusOSS/CereLink :: cbhwlib/cbHwlibHi.ll (Z14cbSetNspStatusj10NSP_STATUS)

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

@.str.2 = external hidden unnamed_addr constant [75 x i8], align 1
@cb_pc_status_buffer_ptr = external global [4 x ptr], align 16
@.str.20 = external hidden unnamed_addr constant [29 x i8], align 1
@__PRETTY_FUNCTION__._Z14cbSetNspStatusj10NSP_STATUS = external hidden unnamed_addr constant [42 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z14cbSetNspStatusj10NSP_STATUS(i32 noundef %0, i32 noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = sub i32 %5, 1
  %7 = icmp ult i32 %6, 3
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  br label %11

9:                                                ; preds = %2
  call void @__assert_fail(ptr noundef @.str.20, ptr noundef @.str.2, i32 noundef 1194, ptr noundef @__PRETTY_FUNCTION__._Z14cbSetNspStatusj10NSP_STATUS) #3
  unreachable

10:                                               ; No predecessors!
  br label %11

11:                                               ; preds = %10, %8
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = sub i32 %12, 1
  %14 = icmp ult i32 %13, 3
  br i1 %14, label %15, label %20

15:                                               ; preds = %11
  %16 = load ptr, ptr @cb_pc_status_buffer_ptr, align 16, !tbaa !11
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = sub i32 %17, 1
  %19 = load i32, ptr %4, align 4, !tbaa !9
  call void @_ZN10cbPcStatus14cbSetNspStatusEj10NSP_STATUS(ptr noundef nonnull align 1 dereferenceable(6160) %16, i32 noundef %18, i32 noundef %19)
  br label %20

20:                                               ; preds = %15, %11
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10cbPcStatus14cbSetNspStatusEj10NSP_STATUS(ptr noundef nonnull align 1 dereferenceable(6160), i32 noundef, i32 noundef) #2 align 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 = { 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" }
attributes #2 = { 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 #3 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_ZTS10NSP_STATUS", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !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.2 = external hidden unnamed_addr constant [75 x i8], align 1
@cb_pc_status_buffer_ptr = external local_unnamed_addr global [4 x ptr], align 16
@.str.20 = external hidden unnamed_addr constant [29 x i8], align 1
@__PRETTY_FUNCTION__._Z14cbSetNspStatusj10NSP_STATUS = external hidden unnamed_addr constant [42 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: mustprogress nounwind uwtable
define dso_local void @_Z14cbSetNspStatusj10NSP_STATUS(i32 noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = add i32 %0, -1
  %4 = icmp ult i32 %3, 3
  br i1 %4, label %6, label %5

5:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.2, i32 noundef 1194, ptr noundef nonnull @__PRETTY_FUNCTION__._Z14cbSetNspStatusj10NSP_STATUS) #2
  unreachable

6:                                                ; preds = %2
  %7 = load ptr, ptr @cb_pc_status_buffer_ptr, align 16, !tbaa !5
  tail call void @_ZN10cbPcStatus14cbSetNspStatusEj10NSP_STATUS(ptr noundef nonnull align 1 dereferenceable(6160) %7, i32 noundef %3, i32 noundef %1)
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10cbPcStatus14cbSetNspStatusEj10NSP_STATUS(ptr noundef nonnull align 1 dereferenceable(6160), i32 noundef, i32 noundef) local_unnamed_addr #1 align 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 = { 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 #2 = { 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++ TBAA"}


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