; LLVM IR from kmilo17pet/QuarkTS-cpp :: src/input.ll (ZN3qOS5input13analogChannel7setTimeENS0_5eventEm)

; 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::input::analogChannel" = type { %"class.qOS::input::channel", i32, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i64 }
%"class.qOS::input::channel" = type { %"class.qOS::node", i32, i8, ptr, ptr, i64, i64, i64 }
%"class.qOS::node" = type { ptr, ptr, ptr, ptr }

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN3qOS5input13analogChannel7setTimeENS0_5eventEm(ptr noundef nonnull align 8 dereferenceable(152) %0, i32 noundef %1, i64 noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !11
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #2
  store i8 1, ptr %7, align 1, !tbaa !13
  %9 = load i64, ptr %6, align 8, !tbaa !11
  %10 = icmp ugt i64 %9, 0
  br i1 %10, label %11, label %24

11:                                               ; preds = %3
  %12 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %12, label %22 [
    i32 13, label %13
    i32 11, label %16
    i32 12, label %19
  ]

13:                                               ; preds = %11
  %14 = load i64, ptr %6, align 8, !tbaa !11
  %15 = getelementptr inbounds %"class.qOS::input::analogChannel", ptr %8, i32 0, i32 12
  store i64 %14, ptr %15, align 8, !tbaa !15
  br label %23

16:                                               ; preds = %11
  %17 = load i64, ptr %6, align 8, !tbaa !11
  %18 = getelementptr inbounds %"class.qOS::input::channel", ptr %8, i32 0, i32 6
  store i64 %17, ptr %18, align 8, !tbaa !20
  br label %23

19:                                               ; preds = %11
  %20 = load i64, ptr %6, align 8, !tbaa !11
  %21 = getelementptr inbounds %"class.qOS::input::channel", ptr %8, i32 0, i32 7
  store i64 %20, ptr %21, align 8, !tbaa !21
  br label %23

22:                                               ; preds = %11
  store i8 0, ptr %7, align 1, !tbaa !13
  br label %23

23:                                               ; preds = %22, %19, %16, %13
  br label %25

24:                                               ; preds = %3
  store i8 0, ptr %7, align 1, !tbaa !13
  br label %25

25:                                               ; preds = %24, %23
  %26 = load i8, ptr %7, align 1, !tbaa !13, !range !22, !noundef !23
  %27 = trunc i8 %26 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  ret i1 %27
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !10, i64 0}
!10 = !{!"_ZTSN3qOS5input5eventE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!16, !12, i64 144}
!16 = !{!"_ZTSN3qOS5input13analogChannelE", !17, i64 0, !19, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !19, i64 112, !19, i64 116, !19, i64 120, !19, i64 124, !19, i64 128, !19, i64 132, !19, i64 136, !12, i64 144}
!17 = !{!"_ZTSN3qOS5input7channelE", !18, i64 0, !10, i64 32, !7, i64 36, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 64, !12, i64 72}
!18 = !{!"_ZTSN3qOS4nodeE", !6, i64 8, !6, i64 16, !6, i64 24}
!19 = !{!"int", !7, i64 0}
!20 = !{!17, !12, i64 64}
!21 = !{!17, !12, i64 72}
!22 = !{i8 0, i8 2}
!23 = !{}


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

@switch.table._ZN3qOS5input13analogChannel7setTimeENS0_5eventEm = private unnamed_addr constant [3 x i64] [i64 64, i64 72, i64 144], align 8

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local noundef zeroext i1 @_ZN3qOS5input13analogChannel7setTimeENS0_5eventEm(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(152) %0, i32 noundef %1, i64 noundef %2) unnamed_addr #0 align 2 {
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %8, label %4

4:                                                ; preds = %3
  %switch.tableidx = add i32 %1, -11
  %5 = icmp ult i32 %switch.tableidx, 3
  br i1 %5, label %switch.lookup, label %8

switch.lookup:                                    ; preds = %4
  %6 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [3 x i64], ptr @switch.table._ZN3qOS5input13analogChannel7setTimeENS0_5eventEm, i64 0, i64 %6
  %switch.load = load i64, ptr %switch.gep, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 %switch.load
  store i64 %2, ptr %7, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %4, %switch.lookup, %3
  %.0 = phi i1 [ false, %4 ], [ false, %3 ], [ true, %switch.lookup ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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