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

; 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] }>
%"class.qOS::commandLineInterface" = type { %"class.qOS::cli::input.base", %"class.qOS::list", %"class.qOS::cli::commandHandler", ptr, ptr, ptr, ptr, ptr, i8, ptr, i64, ptr, ptr }
%"class.qOS::cli::input.base" = type <{ ptr, ptr, i64, i64, i64, i8 }>
%"class.qOS::list" = type { %"class.qOS::node", ptr, ptr, i64 }
%"class.qOS::node" = type { ptr, ptr, ptr, ptr }
%"class.qOS::cli::commandHandler" = type { ptr, ptr, ptr, ptr, i64, i64, i16, ptr }

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1

; 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: nounwind
declare noundef i64 @_ZN3qOS4util6strlenEPKcm(ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL8inputFixPcm(ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef signext i16 @_ZN3qOS20commandLineInterface4execEPKc(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef) #3 align 2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface10inputFlushEv(ptr noundef nonnull align 8 dereferenceable(248)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3qOS20commandLineInterface14handleResponseENS_3cli8responseE(ptr noundef nonnull align 8 dereferenceable(248), i16 noundef signext) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface3runEv(ptr noundef nonnull align 8 dereferenceable(248) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i16, align 2
  %5 = alloca i16, align 2
  %6 = alloca ptr, align 8
  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) #5
  store i8 0, ptr %3, align 1, !tbaa !9
  %8 = getelementptr inbounds %"class.qOS::cli::input", ptr %7, i32 0, i32 5
  %9 = load volatile i8, ptr %8, align 8, !tbaa !11, !range !14, !noundef !15
  %10 = trunc i8 %9 to i1
  br i1 %10, label %11, label %77

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 2, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %12 = getelementptr inbounds %"class.qOS::cli::input", ptr %7, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  store ptr %13, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.qOS::cli::input", ptr %7, i32 0, i32 3
  %16 = load i64, ptr %15, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %14, i64 %16
  store i8 0, ptr %17, align 1, !tbaa !18
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.qOS::cli::input", ptr %7, i32 0, i32 4
  %20 = load i64, ptr %19, align 8, !tbaa !19
  %21 = call noundef ptr @_ZL8inputFixPcm(ptr noundef %18, i64 noundef %20)
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.qOS::cli::input", ptr %7, i32 0, i32 4
  %24 = load i64, ptr %23, align 8, !tbaa !19
  %25 = call i32 @strncmp(ptr noundef %22, ptr noundef @.str.2, i64 noundef %24) #6
  %26 = icmp eq i32 0, %25
  br i1 %26, label %27, label %28

27:                                               ; preds = %11
  store i16 1, ptr %4, align 2, !tbaa !20
  br label %54

28:                                               ; preds = %11
  %29 = getelementptr inbounds %"class.qOS::cli::input", ptr %7, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  %31 = call noundef signext i16 @_ZN3qOS20commandLineInterface4execEPKc(ptr noundef nonnull align 8 dereferenceable(248) %7, ptr noundef %30)
  store i16 %31, ptr %5, align 2, !tbaa !20
  %32 = sext i16 %31 to i32
  %33 = icmp ne i32 32766, %32
  br i1 %33, label %34, label %36

34:                                               ; preds = %28
  %35 = load i16, ptr %5, align 2, !tbaa !20
  store i16 %35, ptr %4, align 2, !tbaa !20
  br label %53

36:                                               ; preds = %28
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %"class.qOS::cli::input", ptr %7, i32 0, i32 4
  %39 = load i64, ptr %38, align 8, !tbaa !19
  %40 = call i32 @strncmp(ptr noundef %37, ptr noundef @.str.3, i64 noundef %39) #6
  %41 = icmp eq i32 0, %40
  br i1 %41, label %42, label %43

42:                                               ; preds = %36
  store i16 32765, ptr %4, align 2, !tbaa !20
  br label %52

43:                                               ; preds = %36
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %"class.qOS::cli::input", ptr %7, i32 0, i32 4
  %46 = load i64, ptr %45, align 8, !tbaa !19
  %47 = call noundef i64 @_ZN3qOS4util6strlenEPKcm(ptr noundef %44, i64 noundef %46) #5
  %48 = icmp uge i64 %47, 3
  br i1 %48, label %49, label %50

49:                                               ; preds = %43
  store i16 32766, ptr %4, align 2, !tbaa !20
  br label %51

50:                                               ; preds = %43
  store i16 0, ptr %4, align 2, !tbaa !20
  br label %51

51:                                               ; preds = %50, %49
  br label %52

52:                                               ; preds = %51, %42
  br label %53

53:                                               ; preds = %52, %34
  br label %54

54:                                               ; preds = %53, %27
  %55 = getelementptr inbounds %"class.qOS::commandLineInterface", ptr %7, i32 0, i32 2
  %56 = getelementptr inbounds %"class.qOS::cli::commandHandler", ptr %55, i32 0, i32 7
  %57 = load ptr, ptr %56, align 8, !tbaa !22
  %58 = icmp ne ptr null, %57
  br i1 %58, label %59, label %69

59:                                               ; preds = %54
  %60 = getelementptr inbounds %"class.qOS::commandLineInterface", ptr %7, i32 0, i32 2
  %61 = getelementptr inbounds %"class.qOS::cli::commandHandler", ptr %60, i32 0, i32 7
  %62 = load ptr, ptr %61, align 8, !tbaa !22
  %63 = getelementptr inbounds i8, ptr %62, i64 0
  %64 = load i8, ptr %63, align 1, !tbaa !18
  %65 = sext i8 %64 to i32
  %66 = icmp ne i32 0, %65
  br i1 %66, label %67, label %68

67:                                               ; preds = %59
  call void @_ZN3qOS20commandLineInterface14handleResponseENS_3cli8responseE(ptr noundef nonnull align 8 dereferenceable(248) %7, i16 noundef signext 32767)
  br label %68

68:                                               ; preds = %67, %59
  br label %69

69:                                               ; preds = %68, %54
  %70 = load i16, ptr %4, align 2, !tbaa !20
  call void @_ZN3qOS20commandLineInterface14handleResponseENS_3cli8responseE(ptr noundef nonnull align 8 dereferenceable(248) %7, i16 noundef signext %70)
  %71 = getelementptr inbounds %"class.qOS::commandLineInterface", ptr %7, i32 0, i32 2
  %72 = getelementptr inbounds %"class.qOS::cli::commandHandler", ptr %71, i32 0, i32 7
  %73 = load ptr, ptr %72, align 8, !tbaa !22
  %74 = getelementptr inbounds i8, ptr %73, i64 0
  store i8 0, ptr %74, align 1, !tbaa !18
  %75 = call noundef zeroext i1 @_ZN3qOS20commandLineInterface10inputFlushEv(ptr noundef nonnull align 8 dereferenceable(248) %7)
  %76 = zext i1 %75 to i8
  store i8 %76, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #5
  br label %77

77:                                               ; preds = %69, %1
  %78 = load i8, ptr %3, align 1, !tbaa !9, !range !14, !noundef !15
  %79 = trunc i8 %78 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #5
  ret i1 %79
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"bool", !7, i64 0}
!11 = !{!12, !10, i64 40}
!12 = !{!"_ZTSN3qOS3cli5inputE", !6, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !10, i64 40}
!13 = !{!"long", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!12, !6, i64 8}
!17 = !{!12, !13, i64 24}
!18 = !{!7, !7, i64 0}
!19 = !{!12, !13, i64 32}
!20 = !{!21, !21, i64 0}
!21 = !{!"_ZTSN3qOS3cli8responseE", !7, i64 0}
!22 = !{!23, !6, i64 160}
!23 = !{!"_ZTSN3qOS20commandLineInterfaceE", !12, i64 0, !24, i64 48, !26, i64 104, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !7, i64 208, !6, i64 216, !13, i64 224, !6, i64 232, !6, i64 240}
!24 = !{!"_ZTSN3qOS4listE", !25, i64 0, !6, i64 32, !6, i64 40, !13, i64 48}
!25 = !{!"_ZTSN3qOS4nodeE", !6, i64 8, !6, i64 16, !6, i64 24}
!26 = !{!"_ZTSN3qOS3cli14commandHandlerE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !13, i64 40, !27, i64 48, !6, i64 56}
!27 = !{!"_ZTSN3qOS3cli11commandTypeE", !7, i64 0}


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

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind
declare noundef i64 @_ZN3qOS4util6strlenEPKcm(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef ptr @_ZL8inputFixPcm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef signext i16 @_ZN3qOS20commandLineInterface4execEPKc(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface10inputFlushEv(ptr noundef nonnull align 8 dereferenceable(248)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3qOS20commandLineInterface14handleResponseENS_3cli8responseE(ptr noundef nonnull align 8 dereferenceable(248), i16 noundef signext) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface3runEv(ptr noundef nonnull align 8 dereferenceable(248) %0) local_unnamed_addr #2 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load volatile i8, ptr %2, align 8, !tbaa !5, !range !12, !noundef !13
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %5, label %36

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i64, ptr %8, align 8, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %7, i64 %9
  store i8 0, ptr %10, align 1, !tbaa !16
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load i64, ptr %11, align 8, !tbaa !17
  %13 = tail call noundef ptr @_ZL8inputFixPcm(ptr noundef %7, i64 noundef %12)
  %14 = load i64, ptr %11, align 8, !tbaa !17
  %15 = tail call i32 @strncmp(ptr noundef %7, ptr noundef nonnull @.str.2, i64 noundef %14) #4
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %27, label %17

17:                                               ; preds = %5
  %18 = load ptr, ptr %6, align 8, !tbaa !14
  %19 = tail call noundef signext i16 @_ZN3qOS20commandLineInterface4execEPKc(ptr noundef nonnull align 8 dereferenceable(248) %0, ptr noundef %18)
  %.not = icmp eq i16 %19, 32766
  br i1 %.not, label %20, label %27

20:                                               ; preds = %17
  %21 = load i64, ptr %11, align 8, !tbaa !17
  %22 = tail call i32 @strncmp(ptr noundef nonnull %7, ptr noundef nonnull @.str.3, i64 noundef %21) #4
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %27, label %24

24:                                               ; preds = %20
  %25 = tail call noundef i64 @_ZN3qOS4util6strlenEPKcm(ptr noundef nonnull %7, i64 noundef %21) #5
  %26 = icmp ugt i64 %25, 2
  %. = select i1 %26, i16 32766, i16 0
  br label %27

27:                                               ; preds = %24, %20, %17, %5
  %.08 = phi i16 [ 1, %5 ], [ %19, %17 ], [ 32765, %20 ], [ %., %24 ]
  %28 = getelementptr inbounds i8, ptr %0, i64 160
  %29 = load ptr, ptr %28, align 8, !tbaa !18
  %.not10 = icmp eq ptr %29, null
  br i1 %.not10, label %33, label %30

30:                                               ; preds = %27
  %31 = load i8, ptr %29, align 1, !tbaa !16
  %.not11 = icmp eq i8 %31, 0
  br i1 %.not11, label %33, label %32

32:                                               ; preds = %30
  tail call void @_ZN3qOS20commandLineInterface14handleResponseENS_3cli8responseE(ptr noundef nonnull align 8 dereferenceable(248) %0, i16 noundef signext 32767)
  br label %33

33:                                               ; preds = %30, %32, %27
  tail call void @_ZN3qOS20commandLineInterface14handleResponseENS_3cli8responseE(ptr noundef nonnull align 8 dereferenceable(248) %0, i16 noundef signext %.08)
  %34 = load ptr, ptr %28, align 8, !tbaa !18
  store i8 0, ptr %34, align 1, !tbaa !16
  %35 = tail call noundef zeroext i1 @_ZN3qOS20commandLineInterface10inputFlushEv(ptr noundef nonnull align 8 dereferenceable(248) %0)
  br label %36

36:                                               ; preds = %33, %1
  %.0 = phi i1 [ %35, %33 ], [ false, %1 ]
  ret i1 %.0
}

attributes #0 = { 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 #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 = { 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 #3 = { mustprogress nofree nounwind willreturn memory(argmem: 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 #4 = { nounwind willreturn memory(read) }
attributes #5 = { 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, !7, i64 8}
!15 = !{!6, !10, i64 24}
!16 = !{!8, !8, i64 0}
!17 = !{!6, !10, i64 32}
!18 = !{!19, !7, i64 160}
!19 = !{!"_ZTSN3qOS20commandLineInterfaceE", !6, i64 0, !20, i64 48, !22, i64 104, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200, !8, i64 208, !7, i64 216, !10, i64 224, !7, i64 232, !7, i64 240}
!20 = !{!"_ZTSN3qOS4listE", !21, i64 0, !7, i64 32, !7, i64 40, !10, i64 48}
!21 = !{!"_ZTSN3qOS4nodeE", !7, i64 8, !7, i64 16, !7, i64 24}
!22 = !{!"_ZTSN3qOS3cli14commandHandlerE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 40, !23, i64 48, !7, i64 56}
!23 = !{!"_ZTSN3qOS3cli11commandTypeE", !8, i64 0}


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