; LLVM IR from kmilo17pet/QuarkTS-cpp :: src/task.ll (ZNK3qOS4task15deadLineReachedEv)

; 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::task" = type <{ %"class.qOS::node", ptr, ptr, ptr, ptr, ptr, i64, [11 x i8], [5 x i8], %"class.qOS::timer", i32, [4 x i8], i64, i32, i32, i32, i8, i8, [2 x i8] }>
%"class.qOS::node" = type { ptr, ptr, ptr, ptr }
%"class.qOS::timer" = type { ptr, i64, i64 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3qOS4task7getFlagEj(ptr noundef nonnull align 8 dereferenceable(150), i32 noundef) #1 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK3qOS4task15deadLineReachedEv(ptr noundef nonnull align 8 dereferenceable(150) %0) #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #4
  store i8 0, ptr %3, align 1, !tbaa !9
  %8 = call noundef zeroext i1 @_ZNK3qOS4task7getFlagEj(ptr noundef nonnull align 8 dereferenceable(150) %7, i32 noundef 2) #4
  br i1 %8, label %9, label %33

9:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %10 = getelementptr inbounds %"class.qOS::task", ptr %7, i32 0, i32 13
  %11 = load i32, ptr %10, align 8, !tbaa !11
  store i32 %11, ptr %4, align 4, !tbaa !18
  %12 = load i32, ptr %4, align 4, !tbaa !18
  %13 = invoke noundef i32 @_Z15TASK_ITER_VALUEi(i32 noundef %12)
          to label %14 unwind label %36

14:                                               ; preds = %9
  %15 = icmp sgt i32 %13, 0
  br i1 %15, label %19, label %16

16:                                               ; preds = %14
  %17 = load i32, ptr %4, align 4, !tbaa !18
  %18 = icmp eq i32 -2147483648, %17
  br i1 %18, label %19, label %32

19:                                               ; preds = %16, %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %20 = getelementptr inbounds %"class.qOS::task", ptr %7, i32 0, i32 9
  %21 = call noundef i64 @_ZNK3qOS5timer11getIntervalEv(ptr noundef nonnull align 8 dereferenceable(24) %20) #4
  store i64 %21, ptr %5, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #4
  %22 = getelementptr inbounds %"class.qOS::task", ptr %7, i32 0, i32 9
  %23 = call noundef zeroext i1 @_ZNK3qOS5timer7expiredEv(ptr noundef nonnull align 8 dereferenceable(24) %22) #4
  %24 = zext i1 %23 to i8
  store i8 %24, ptr %6, align 1, !tbaa !9
  %25 = load i64, ptr %5, align 8, !tbaa !19
  %26 = icmp eq i64 0, %25
  br i1 %26, label %30, label %27

27:                                               ; preds = %19
  %28 = load i8, ptr %6, align 1, !tbaa !9, !range !20, !noundef !21
  %29 = trunc i8 %28 to i1
  br i1 %29, label %30, label %31

30:                                               ; preds = %27, %19
  store i8 1, ptr %3, align 1, !tbaa !9
  br label %31

31:                                               ; preds = %30, %27
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %32

32:                                               ; preds = %31, %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %33

33:                                               ; preds = %32, %1
  %34 = load i8, ptr %3, align 1, !tbaa !9, !range !20, !noundef !21
  %35 = trunc i8 %34 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  ret i1 %35

36:                                               ; preds = %9
  %37 = landingpad { ptr, i32 }
          catch ptr null
  %38 = extractvalue { ptr, i32 } %37, 0
  call void @__clang_call_terminate(ptr %38) #5
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z15TASK_ITER_VALUEi(i32 noundef) #1

; Function Attrs: nounwind
declare noundef i64 @_ZNK3qOS5timer11getIntervalEv(ptr noundef nonnull align 8 dereferenceable(24)) #3

; Function Attrs: nounwind
declare noundef zeroext i1 @_ZNK3qOS5timer7expiredEv(ptr noundef nonnull align 8 dereferenceable(24)) #3

attributes #0 = { noinline noreturn nounwind uwtable "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind }
attributes #5 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !16, i64 136}
!12 = !{!"_ZTSN3qOS4taskE", !13, i64 0, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !14, i64 72, !7, i64 80, !15, i64 96, !16, i64 120, !14, i64 128, !16, i64 136, !16, i64 140, !16, i64 144, !7, i64 148, !17, i64 149}
!13 = !{!"_ZTSN3qOS4nodeE", !6, i64 8, !6, i64 16, !6, i64 24}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSN3qOS5timerE", !14, i64 8, !14, i64 16}
!16 = !{!"int", !7, i64 0}
!17 = !{!"_ZTSN3qOS7triggerE", !7, i64 0}
!18 = !{!16, !16, i64 0}
!19 = !{!14, !14, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}


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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK3qOS4task15deadLineReachedEv(ptr noundef nonnull align 8 dereferenceable(150) %0) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = tail call noundef zeroext i1 @_ZNK3qOS4task7getFlagEj(ptr noundef nonnull align 8 dereferenceable(150) %0, i32 noundef 2) #2
  br i1 %2, label %3, label %14

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 136
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = tail call noundef i32 @_Z15TASK_ITER_VALUEi(i32 noundef %5)
  %7 = icmp sgt i32 %6, 0
  %8 = icmp eq i32 %5, -2147483648
  %or.cond = or i1 %8, %7
  br i1 %or.cond, label %9, label %14

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 96
  %11 = tail call noundef i64 @_ZNK3qOS5timer11getIntervalEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #2
  %12 = tail call noundef zeroext i1 @_ZNK3qOS5timer7expiredEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #2
  %13 = icmp eq i64 %11, 0
  %brmerge = or i1 %13, %12
  br label %14

14:                                               ; preds = %9, %3, %1
  %.2 = phi i1 [ false, %1 ], [ false, %3 ], [ %brmerge, %9 ]
  ret i1 %.2
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z15TASK_ITER_VALUEi(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind
declare noundef i64 @_ZNK3qOS5timer11getIntervalEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

; Function Attrs: nounwind
declare noundef zeroext i1 @_ZNK3qOS5timer7expiredEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #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 = { 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 #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, !13, i64 136}
!6 = !{!"_ZTSN3qOS4taskE", !7, i64 0, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !8, i64 64, !11, i64 72, !9, i64 80, !12, i64 96, !13, i64 120, !11, i64 128, !13, i64 136, !13, i64 140, !13, i64 144, !9, i64 148, !14, i64 149}
!7 = !{!"_ZTSN3qOS4nodeE", !8, i64 8, !8, i64 16, !8, i64 24}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"_ZTSN3qOS5timerE", !11, i64 8, !11, i64 16}
!13 = !{!"int", !9, i64 0}
!14 = !{!"_ZTSN3qOS7triggerE", !9, i64 0}


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