; LLVM IR from kmilo17pet/QuarkTS-cpp :: src/cli.ll (ZN3qOS20commandLineInterface10isrHandlerEPcm)

; 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::cli::input" = type <{ ptr, ptr, i64, i64, i64, i8, [7 x i8] }>

; 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 uwtable
declare dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface6notifyEv(ptr noundef nonnull align 8 dereferenceable(248)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface10isrHandlerEc(ptr noundef nonnull align 8 dereferenceable(248), i8 noundef signext) #1 align 2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @isgraph(i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface10isrHandlerEPcm(ptr noundef nonnull align 8 dereferenceable(248) %0, ptr noundef %1, i64 noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  store i8 0, ptr %7, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  %11 = getelementptr inbounds %"class.qOS::cli::input", ptr %10, i32 0, i32 5
  %12 = load volatile i8, ptr %11, align 8, !tbaa !13, !range !15, !noundef !16
  %13 = trunc i8 %12 to i1
  %14 = zext i1 %13 to i8
  store i8 %14, ptr %8, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %15 = getelementptr inbounds %"class.qOS::cli::input", ptr %10, i32 0, i32 3
  %16 = load i64, ptr %15, align 8, !tbaa !17
  store i64 %16, ptr %9, align 8, !tbaa !9
  %17 = load i64, ptr %6, align 8, !tbaa !9
  %18 = icmp ugt i64 %17, 0
  br i1 %18, label %19, label %58

19:                                               ; preds = %3
  %20 = load i64, ptr %6, align 8, !tbaa !9
  %21 = load i64, ptr %9, align 8, !tbaa !9
  %22 = icmp ult i64 %20, %21
  br i1 %22, label %23, label %58

23:                                               ; preds = %19
  %24 = load i8, ptr %8, align 1, !tbaa !11, !range !15, !noundef !16
  %25 = trunc i8 %24 to i1
  br i1 %25, label %58, label %26

26:                                               ; preds = %23
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = icmp eq i64 1, %27
  br i1 %28, label %29, label %35

29:                                               ; preds = %26
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %30, i64 0
  %32 = load i8, ptr %31, align 1, !tbaa !18
  %33 = call noundef zeroext i1 @_ZN3qOS20commandLineInterface10isrHandlerEc(ptr noundef nonnull align 8 dereferenceable(248) %10, i8 noundef signext %32)
  %34 = zext i1 %33 to i8
  store i8 %34, ptr %7, align 1, !tbaa !11
  br label %57

35:                                               ; preds = %26
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i64 0
  %38 = load i8, ptr %37, align 1, !tbaa !18
  %39 = sext i8 %38 to i32
  %40 = call i32 @isgraph(i32 noundef %39) #5
  %41 = icmp ne i32 0, %40
  br i1 %41, label %42, label %56

42:                                               ; preds = %35
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load i64, ptr %9, align 8, !tbaa !9
  %45 = call noundef ptr @_ZN3qOS4util6strchrEPKcim(ptr noundef %43, i32 noundef 13, i64 noundef %44) #4
  %46 = icmp ne ptr null, %45
  br i1 %46, label %47, label %55

47:                                               ; preds = %42
  %48 = getelementptr inbounds %"class.qOS::cli::input", ptr %10, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !19
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load i64, ptr %9, align 8, !tbaa !9
  %52 = call noundef i64 @_ZN3qOS4util6strcpyEPcPKcm(ptr noundef %49, ptr noundef %50, i64 noundef %51) #4
  %53 = call noundef zeroext i1 @_ZN3qOS20commandLineInterface6notifyEv(ptr noundef nonnull align 8 dereferenceable(248) %10)
  %54 = zext i1 %53 to i8
  store i8 %54, ptr %7, align 1, !tbaa !11
  br label %55

55:                                               ; preds = %47, %42
  br label %56

56:                                               ; preds = %55, %35
  br label %57

57:                                               ; preds = %56, %29
  br label %58

58:                                               ; preds = %57, %23, %19, %3
  %59 = load i8, ptr %7, align 1, !tbaa !11, !range !15, !noundef !16
  %60 = trunc i8 %59 to i1
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  ret i1 %60
}

; Function Attrs: nounwind
declare noundef ptr @_ZN3qOS4util6strchrEPKcim(ptr noundef, i32 noundef, i64 noundef) #3

; Function Attrs: nounwind
declare noundef i64 @_ZN3qOS4util6strcpyEPcPKcm(ptr noundef, ptr noundef, i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind willreturn memory(read) "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 = { 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 = { nounwind willreturn memory(read) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !12, i64 40}
!14 = !{!"_ZTSN3qOS3cli5inputE", !6, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !12, i64 40}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!14, !10, i64 24}
!18 = !{!7, !7, i64 0}
!19 = !{!14, !6, i64 8}


; 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 uwtable
declare dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface6notifyEv(ptr noundef nonnull align 8 dereferenceable(248)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface10isrHandlerEc(ptr noundef nonnull align 8 dereferenceable(248), i8 noundef signext) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @isgraph(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface10isrHandlerEPcm(ptr noundef nonnull align 8 dereferenceable(248) %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load volatile i8, ptr %4, align 8, !tbaa !5, !range !12, !noundef !13
  %6 = trunc nuw i8 %5 to i1
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load i64, ptr %7, align 8, !tbaa !14
  %.not = icmp eq i64 %2, 0
  %9 = icmp ule i64 %8, %2
  %or.cond.not17 = select i1 %.not, i1 true, i1 %9
  %brmerge = select i1 %or.cond.not17, i1 true, i1 %6
  br i1 %brmerge, label %25, label %10

10:                                               ; preds = %3
  %11 = icmp eq i64 %2, 1
  %12 = load i8, ptr %1, align 1, !tbaa !15
  br i1 %11, label %13, label %15

13:                                               ; preds = %10
  %14 = tail call noundef zeroext i1 @_ZN3qOS20commandLineInterface10isrHandlerEc(ptr noundef nonnull align 8 dereferenceable(248) %0, i8 noundef signext %12)
  br label %25

15:                                               ; preds = %10
  %16 = sext i8 %12 to i32
  %17 = tail call i32 @isgraph(i32 noundef %16) #3
  %.not14 = icmp eq i32 %17, 0
  br i1 %.not14, label %25, label %18

18:                                               ; preds = %15
  %19 = tail call noundef ptr @_ZN3qOS4util6strchrEPKcim(ptr noundef nonnull %1, i32 noundef 13, i64 noundef %8) #4
  %.not15 = icmp eq ptr %19, null
  br i1 %.not15, label %25, label %20

20:                                               ; preds = %18
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  %23 = tail call noundef i64 @_ZN3qOS4util6strcpyEPcPKcm(ptr noundef %22, ptr noundef nonnull %1, i64 noundef %8) #4
  %24 = tail call noundef zeroext i1 @_ZN3qOS20commandLineInterface6notifyEv(ptr noundef nonnull align 8 dereferenceable(248) %0)
  br label %25

25:                                               ; preds = %3, %13, %18, %20, %15
  %.0.shrunk = phi i1 [ %14, %13 ], [ %24, %20 ], [ false, %18 ], [ false, %15 ], [ false, %3 ]
  ret i1 %.0.shrunk
}

; Function Attrs: nounwind
declare noundef ptr @_ZN3qOS4util6strchrEPKcim(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare noundef i64 @_ZN3qOS4util6strcpyEPcPKcm(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn memory(read) "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 "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 = { nounwind willreturn memory(read) }
attributes #4 = { 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, !11, i64 40}
!6 = !{!"_ZTSN3qOS3cli5inputE", !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!6, !10, i64 24}
!15 = !{!8, !8, i64 0}
!16 = !{!6, !7, i64 8}


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