; LLVM IR from kmilo17pet/QuarkTS-cpp :: src/response.ll (ZN3qOS8response10isrHandlerEc)

; 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::response" = type <{ ptr, ptr, %"class.qOS::timer", i64, i64, i64, i8, [7 x i8] }>
%"class.qOS::timer" = type { ptr, i64, i64 }

; 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 @_ZN3qOS8response10isrHandlerEc(ptr noundef nonnull align 8 dereferenceable(65) %0, i8 noundef signext %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  store i8 0, ptr %5, align 1, !tbaa !10
  %7 = getelementptr inbounds %"class.qOS::response", ptr %6, i32 0, i32 6
  %8 = load volatile i8, ptr %7, align 8, !tbaa !12, !range !16, !noundef !17
  %9 = trunc i8 %8 to i1
  br i1 %9, label %43, label %10

10:                                               ; preds = %2
  %11 = getelementptr inbounds %"class.qOS::response", ptr %6, i32 0, i32 4
  %12 = load i64, ptr %11, align 8, !tbaa !18
  %13 = icmp ugt i64 %12, 0
  br i1 %13, label %14, label %43

14:                                               ; preds = %10
  %15 = getelementptr inbounds %"class.qOS::response", ptr %6, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !19
  %17 = getelementptr inbounds %"class.qOS::response", ptr %6, i32 0, i32 5
  %18 = load volatile i64, ptr %17, align 8, !tbaa !20
  %19 = getelementptr inbounds i8, ptr %16, i64 %18
  %20 = load i8, ptr %19, align 1, !tbaa !9
  %21 = sext i8 %20 to i32
  %22 = load i8, ptr %4, align 1, !tbaa !9
  %23 = sext i8 %22 to i32
  %24 = icmp eq i32 %21, %23
  br i1 %24, label %25, label %42

25:                                               ; preds = %14
  %26 = getelementptr inbounds %"class.qOS::response", ptr %6, i32 0, i32 5
  %27 = load volatile i64, ptr %26, align 8, !tbaa !20
  %28 = add i64 %27, 1
  %29 = getelementptr inbounds %"class.qOS::response", ptr %6, i32 0, i32 5
  store volatile i64 %28, ptr %29, align 8, !tbaa !20
  %30 = getelementptr inbounds %"class.qOS::response", ptr %6, i32 0, i32 5
  %31 = load volatile i64, ptr %30, align 8, !tbaa !20
  %32 = getelementptr inbounds %"class.qOS::response", ptr %6, i32 0, i32 4
  %33 = load i64, ptr %32, align 8, !tbaa !18
  %34 = icmp eq i64 %31, %33
  br i1 %34, label %35, label %41

35:                                               ; preds = %25
  %36 = getelementptr inbounds %"class.qOS::response", ptr %6, i32 0, i32 6
  store volatile i8 1, ptr %36, align 8, !tbaa !12
  %37 = getelementptr inbounds %"class.qOS::response", ptr %6, i32 0, i32 6
  %38 = load volatile i8, ptr %37, align 8, !tbaa !12, !range !16, !noundef !17
  %39 = trunc i8 %38 to i1
  %40 = zext i1 %39 to i8
  store i8 %40, ptr %5, align 1, !tbaa !10
  br label %41

41:                                               ; preds = %35, %25
  br label %42

42:                                               ; preds = %41, %14
  br label %43

43:                                               ; preds = %42, %10, %2
  %44 = load i8, ptr %5, align 1, !tbaa !10, !range !16, !noundef !17
  %45 = trunc i8 %44 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  ret i1 %45
}

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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"bool", !7, i64 0}
!12 = !{!13, !11, i64 64}
!13 = !{!"_ZTSN3qOS8responseE", !6, i64 8, !14, i64 16, !15, i64 40, !15, i64 48, !15, i64 56, !11, i64 64}
!14 = !{!"_ZTSN3qOS5timerE", !15, i64 8, !15, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!13, !15, i64 48}
!19 = !{!13, !6, i64 8}
!20 = !{!13, !15, 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 nofree norecurse nounwind memory(read, argmem: readwrite, inaccessiblemem: readwrite) uwtable
define dso_local noundef zeroext i1 @_ZN3qOS8response10isrHandlerEc(ptr noundef nonnull align 8 dereferenceable(65) %0, i8 noundef signext %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 64
  %4 = load volatile i8, ptr %3, align 8, !tbaa !5, !range !13, !noundef !14
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %25, label %6

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = load i64, ptr %7, align 8, !tbaa !15
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %25, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  %12 = getelementptr inbounds i8, ptr %0, i64 56
  %13 = load volatile i64, ptr %12, align 8, !tbaa !17
  %14 = getelementptr inbounds i8, ptr %11, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !18
  %16 = icmp eq i8 %15, %1
  br i1 %16, label %17, label %25

17:                                               ; preds = %9
  %18 = load volatile i64, ptr %12, align 8, !tbaa !17
  %19 = add i64 %18, 1
  store volatile i64 %19, ptr %12, align 8, !tbaa !17
  %20 = load volatile i64, ptr %12, align 8, !tbaa !17
  %21 = icmp eq i64 %20, %8
  br i1 %21, label %22, label %25

22:                                               ; preds = %17
  store volatile i8 1, ptr %3, align 8, !tbaa !5
  %23 = load volatile i8, ptr %3, align 8, !tbaa !5, !range !13, !noundef !14
  %24 = trunc nuw i8 %23 to i1
  br label %25

25:                                               ; preds = %9, %22, %17, %6, %2
  %.0 = phi i1 [ false, %2 ], [ %24, %22 ], [ false, %17 ], [ false, %9 ], [ false, %6 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nounwind memory(read, argmem: readwrite, inaccessiblemem: readwrite) 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, !12, i64 64}
!6 = !{!"_ZTSN3qOS8responseE", !7, i64 8, !10, i64 16, !11, i64 40, !11, i64 48, !11, i64 56, !12, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN3qOS5timerE", !11, i64 8, !11, i64 16}
!11 = !{!"long", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !11, i64 48}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !11, i64 56}
!18 = !{!8, !8, i64 0}


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