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

; 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::cli::command" = type { %"class.qOS::node", ptr, i16, i64, ptr, ptr }
%"class.qOS::node" = type { ptr, ptr, ptr, ptr }
%"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::cli::commandHandler" = type { ptr, ptr, ptr, ptr, i64, i64, i16, 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 @_ZN3qOS20commandLineInterface3addERNS_3cli7commandEPcRKPFNS1_8responseERNS1_14commandHandlerEEtPv(ptr noundef nonnull align 8 dereferenceable(248) %0, ptr noundef nonnull align 8 dereferenceable(72) %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %3, i16 noundef zeroext %4, ptr noundef %5) #1 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i16, align 2
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i16 %4, ptr %11, align 2, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !5
  %14 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #3
  store i8 0, ptr %13, align 1, !tbaa !11
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = icmp ne ptr null, %15
  br i1 %16, label %17, label %67

17:                                               ; preds = %6
  %18 = load ptr, ptr %10, align 8, !tbaa !5
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = icmp ne ptr null, %19
  br i1 %20, label %21, label %67

21:                                               ; preds = %17
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.qOS::cli::input", ptr %14, i32 0, i32 4
  %24 = load i64, ptr %23, align 8, !tbaa !13
  %25 = call noundef i64 @_ZN3qOS4util6strlenEPKcm(ptr noundef %22, i64 noundef %24) #3
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds %"class.qOS::cli::command", ptr %26, i32 0, i32 3
  store i64 %25, ptr %27, align 8, !tbaa !16
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.qOS::cli::command", ptr %28, i32 0, i32 3
  %30 = load i64, ptr %29, align 8, !tbaa !16
  %31 = icmp uge i64 %30, 2
  br i1 %31, label %32, label %66

32:                                               ; preds = %21
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i64 0
  %35 = load i8, ptr %34, align 1, !tbaa !19
  %36 = sext i8 %35 to i32
  %37 = icmp eq i32 97, %36
  br i1 %37, label %38, label %65

38:                                               ; preds = %32
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i64 1
  %41 = load i8, ptr %40, align 1, !tbaa !19
  %42 = sext i8 %41 to i32
  %43 = icmp eq i32 116, %42
  br i1 %43, label %44, label %65

44:                                               ; preds = %38
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %"class.qOS::cli::command", ptr %46, i32 0, i32 5
  store ptr %45, ptr %47, align 8, !tbaa !20
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds %"class.qOS::cli::command", ptr %50, i32 0, i32 1
  store ptr %49, ptr %51, align 8, !tbaa !21
  %52 = load i16, ptr %11, align 2, !tbaa !9
  %53 = zext i16 %52 to i32
  %54 = and i32 4095, %53
  %55 = trunc i32 %54 to i16
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %"class.qOS::cli::command", ptr %56, i32 0, i32 2
  store i16 %55, ptr %57, align 8, !tbaa !22
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %"class.qOS::cli::command", ptr %59, i32 0, i32 4
  store ptr %58, ptr %60, align 8, !tbaa !23
  %61 = getelementptr inbounds %"class.qOS::commandLineInterface", ptr %14, i32 0, i32 1
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = call noundef zeroext i1 @_ZN3qOS4list6insertEPvNS_12listPositionE(ptr noundef nonnull align 8 dereferenceable(56) %61, ptr noundef %62, i32 noundef -2) #3
  %64 = zext i1 %63 to i8
  store i8 %64, ptr %13, align 1, !tbaa !11
  br label %65

65:                                               ; preds = %44, %38, %32
  br label %66

66:                                               ; preds = %65, %21
  br label %67

67:                                               ; preds = %66, %17, %6
  %68 = load i8, ptr %13, align 1, !tbaa !11, !range !24, !noundef !25
  %69 = trunc i8 %68 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #3
  ret i1 %69
}

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

; Function Attrs: nounwind
declare noundef zeroext i1 @_ZN3qOS4list6insertEPvNS_12listPositionE(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef, i32 noundef) #2

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

!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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !15, i64 32}
!14 = !{!"_ZTSN3qOS3cli5inputE", !6, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !12, i64 40}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !15, i64 48}
!17 = !{!"_ZTSN3qOS3cli7commandE", !18, i64 0, !6, i64 32, !10, i64 40, !15, i64 48, !6, i64 56, !6, i64 64}
!18 = !{!"_ZTSN3qOS4nodeE", !6, i64 8, !6, i64 16, !6, i64 24}
!19 = !{!7, !7, i64 0}
!20 = !{!17, !6, i64 64}
!21 = !{!17, !6, i64 32}
!22 = !{!17, !10, i64 40}
!23 = !{!17, !6, i64 56}
!24 = !{i8 0, i8 2}
!25 = !{}


; 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 nounwind uwtable
define dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface3addERNS_3cli7commandEPcRKPFNS1_8responseERNS1_14commandHandlerEEtPv(ptr noundef nonnull align 8 dereferenceable(248) %0, ptr noundef nonnull align 8 dereferenceable(72) %1, ptr noundef %2, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %3, i16 noundef zeroext %4, ptr noundef %5) local_unnamed_addr #0 align 2 {
  %.not = icmp eq ptr %2, null
  %7 = load ptr, ptr %3, align 8
  %.not18 = icmp eq ptr %7, null
  %or.cond = select i1 %.not, i1 true, i1 %.not18
  br i1 %or.cond, label %30, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load i64, ptr %9, align 8, !tbaa !5
  %11 = tail call noundef i64 @_ZN3qOS4util6strlenEPKcm(ptr noundef nonnull %2, i64 noundef %10) #2
  %12 = getelementptr inbounds i8, ptr %1, i64 48
  store i64 %11, ptr %12, align 8, !tbaa !12
  %13 = icmp ugt i64 %11, 1
  br i1 %13, label %14, label %30

14:                                               ; preds = %8
  %15 = load i8, ptr %2, align 1, !tbaa !16
  %16 = icmp eq i8 %15, 97
  br i1 %16, label %17, label %30

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %2, i64 1
  %19 = load i8, ptr %18, align 1, !tbaa !16
  %20 = icmp eq i8 %19, 116
  br i1 %20, label %21, label %30

21:                                               ; preds = %17
  %22 = getelementptr inbounds i8, ptr %1, i64 64
  store ptr %2, ptr %22, align 8, !tbaa !17
  %23 = load ptr, ptr %3, align 8, !tbaa !18
  %24 = getelementptr inbounds i8, ptr %1, i64 32
  store ptr %23, ptr %24, align 8, !tbaa !19
  %25 = and i16 %4, 4095
  %26 = getelementptr inbounds i8, ptr %1, i64 40
  store i16 %25, ptr %26, align 8, !tbaa !20
  %27 = getelementptr inbounds i8, ptr %1, i64 56
  store ptr %5, ptr %27, align 8, !tbaa !21
  %28 = getelementptr inbounds i8, ptr %0, i64 48
  %29 = tail call noundef zeroext i1 @_ZN3qOS4list6insertEPvNS_12listPositionE(ptr noundef nonnull align 8 dereferenceable(56) %28, ptr noundef nonnull %1, i32 noundef -2) #2
  br label %30

30:                                               ; preds = %8, %21, %17, %14, %6
  %.0 = phi i1 [ %29, %21 ], [ false, %17 ], [ false, %14 ], [ false, %8 ], [ false, %6 ]
  ret i1 %.0
}

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

; Function Attrs: nounwind
declare noundef zeroext i1 @_ZN3qOS4list6insertEPvNS_12listPositionE(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef, i32 noundef) 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, !10, i64 32}
!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 = !{!13, !10, i64 48}
!13 = !{!"_ZTSN3qOS3cli7commandE", !14, i64 0, !7, i64 32, !15, i64 40, !10, i64 48, !7, i64 56, !7, i64 64}
!14 = !{!"_ZTSN3qOS4nodeE", !7, i64 8, !7, i64 16, !7, i64 24}
!15 = !{!"short", !8, i64 0}
!16 = !{!8, !8, i64 0}
!17 = !{!13, !7, i64 64}
!18 = !{!7, !7, i64 0}
!19 = !{!13, !7, i64 32}
!20 = !{!13, !15, i64 40}
!21 = !{!13, !7, i64 56}


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