; LLVM IR from kmilo17pet/QuarkTS-cpp :: src (fsm)

; 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.qOS::stateMachine" = type { %"class.qOS::sm::stateHandler", ptr, ptr, ptr, ptr, ptr, ptr, %"class.qOS::sm::state", %"struct.qOS::sm::signal_t", ptr, ptr }
%"class.qOS::sm::stateHandler" = type { ptr, ptr, ptr, ptr, ptr, i8, i16, i32, ptr, ptr, ptr }
%"class.qOS::sm::state" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, ptr }
%"struct.qOS::sm::signal_t" = type { i32, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN3qOS12stateMachine7smSetupEPFNS_2sm6statusERNS1_12stateHandlerEEPNS1_5stateEPFvS4_EPv(ptr noundef nonnull align 8 dereferenceable(240) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %11 = load ptr, ptr %6, align 8
  %12 = getelementptr inbounds %"class.qOS::stateMachine", ptr %11, i32 0, i32 1
  store ptr null, ptr %12, align 8, !tbaa !9
  %13 = getelementptr inbounds %"class.qOS::stateMachine", ptr %11, i32 0, i32 2
  store ptr null, ptr %13, align 8, !tbaa !18
  %14 = getelementptr inbounds %"class.qOS::stateMachine", ptr %11, i32 0, i32 3
  store ptr null, ptr %14, align 8, !tbaa !19
  %15 = load ptr, ptr %10, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.qOS::stateMachine", ptr %11, i32 0, i32 10
  store ptr %15, ptr %16, align 8, !tbaa !20
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.qOS::stateMachine", ptr %11, i32 0, i32 6
  store ptr %17, ptr %18, align 8, !tbaa !21
  %19 = getelementptr inbounds %"class.qOS::sm::stateHandler", ptr %11, i32 0, i32 3
  store ptr %11, ptr %19, align 8, !tbaa !22
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = getelementptr inbounds %"class.qOS::sm::stateHandler", ptr %11, i32 0, i32 9
  store ptr %20, ptr %21, align 8, !tbaa !23
  %22 = getelementptr inbounds %"class.qOS::stateMachine", ptr %11, i32 0, i32 7
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN3qOS2sm5state7topSelfERKPFNS0_6statusERNS0_12stateHandlerEEPS1_(ptr noundef nonnull align 8 dereferenceable(88) %22, ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef %23) #1
  ret i1 true
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3qOS2sm5state7topSelfERKPFNS0_6statusERNS0_12stateHandlerEEPS1_(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0 align 2

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 = { 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"}
!9 = !{!10, !6, i64 72}
!10 = !{!"_ZTSN3qOS12stateMachineE", !11, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !15, i64 120, !17, i64 208, !6, i64 224, !6, i64 232}
!11 = !{!"_ZTSN3qOS2sm12stateHandlerE", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !13, i64 42, !14, i64 44, !6, i64 48, !6, i64 56, !6, i64 64}
!12 = !{!"_ZTSN3qOS2sm11historyModeE", !7, i64 0}
!13 = !{!"_ZTSN3qOS2sm6statusE", !7, i64 0}
!14 = !{!"_ZTSN3qOS2sm8signalIDE", !7, i64 0}
!15 = !{!"_ZTSN3qOS2sm5stateE", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !16, i64 64, !16, i64 72, !6, i64 80}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN3qOS2sm8signal_tE", !14, i64 0, !6, i64 8}
!18 = !{!10, !6, i64 80}
!19 = !{!10, !6, i64 88}
!20 = !{!10, !6, i64 232}
!21 = !{!10, !6, i64 112}
!22 = !{!11, !6, i64 24}
!23 = !{!11, !6, i64 56}


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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN3qOS12stateMachine7smSetupEPFNS_2sm6statusERNS1_12stateHandlerEEPNS1_5stateEPFvS4_EPv(ptr noundef nonnull align 8 dereferenceable(240) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 align 2 {
  %6 = alloca ptr, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 72
  %8 = getelementptr inbounds i8, ptr %0, i64 232
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %7, i8 0, i64 24, i1 false)
  store ptr %4, ptr %8, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %0, i64 112
  store ptr %3, ptr %9, align 8, !tbaa !18
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %0, ptr %10, align 8, !tbaa !19
  %11 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %4, ptr %11, align 8, !tbaa !20
  %12 = getelementptr inbounds i8, ptr %0, i64 120
  call void @_ZN3qOS2sm5state7topSelfERKPFNS0_6statusERNS0_12stateHandlerEEPS1_(ptr noundef nonnull align 8 dereferenceable(88) %12, ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef %2) #2
  ret i1 true
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3qOS2sm5state7topSelfERKPFNS0_6statusERNS0_12stateHandlerEEPS1_(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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"}
!9 = !{!10, !6, i64 232}
!10 = !{!"_ZTSN3qOS12stateMachineE", !11, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !15, i64 120, !17, i64 208, !6, i64 224, !6, i64 232}
!11 = !{!"_ZTSN3qOS2sm12stateHandlerE", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !13, i64 42, !14, i64 44, !6, i64 48, !6, i64 56, !6, i64 64}
!12 = !{!"_ZTSN3qOS2sm11historyModeE", !7, i64 0}
!13 = !{!"_ZTSN3qOS2sm6statusE", !7, i64 0}
!14 = !{!"_ZTSN3qOS2sm8signalIDE", !7, i64 0}
!15 = !{!"_ZTSN3qOS2sm5stateE", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !16, i64 64, !16, i64 72, !6, i64 80}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN3qOS2sm8signal_tE", !14, i64 0, !6, i64 8}
!18 = !{!10, !6, i64 112}
!19 = !{!11, !6, i64 24}
!20 = !{!11, !6, i64 56}


; Effective O3 passes: GlobalOptPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass