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

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

@.str = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface5setupEPFvPvcEPcmS4_m(ptr noundef nonnull align 8 dereferenceable(248) %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5) #1 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, 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 i64 %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store i64 %5, ptr %12, align 8, !tbaa !9
  %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 %8, align 8, !tbaa !5
  %16 = icmp ne ptr null, %15
  br i1 %16, label %17, label %40

17:                                               ; preds = %6
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.qOS::commandLineInterface", ptr %14, i32 0, i32 9
  store ptr %18, ptr %19, align 8, !tbaa !13
  %20 = load i64, ptr %12, align 8, !tbaa !9
  %21 = getelementptr inbounds %"class.qOS::commandLineInterface", ptr %14, i32 0, i32 10
  store i64 %20, ptr %21, align 8, !tbaa !20
  %22 = load ptr, ptr %11, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.qOS::commandLineInterface", ptr %14, i32 0, i32 2
  %24 = getelementptr inbounds %"class.qOS::cli::commandHandler", ptr %23, i32 0, i32 7
  store ptr %22, ptr %24, align 8, !tbaa !21
  %25 = getelementptr inbounds %"class.qOS::commandLineInterface", ptr %14, i32 0, i32 2
  %26 = getelementptr inbounds %"class.qOS::cli::commandHandler", ptr %25, i32 0, i32 0
  store ptr %14, ptr %26, align 8, !tbaa !22
  %27 = getelementptr inbounds %"class.qOS::commandLineInterface", ptr %14, i32 0, i32 6
  store ptr @.str, ptr %27, align 8, !tbaa !23
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds %"class.qOS::cli::input", ptr %14, i32 0, i32 1
  store ptr %28, ptr %29, align 8, !tbaa !24
  %30 = load i64, ptr %10, align 8, !tbaa !9
  %31 = getelementptr inbounds %"class.qOS::cli::input", ptr %14, i32 0, i32 4
  store i64 %30, ptr %31, align 8, !tbaa !25
  %32 = load i64, ptr %10, align 8, !tbaa !9
  %33 = sub i64 %32, 1
  %34 = getelementptr inbounds %"class.qOS::cli::input", ptr %14, i32 0, i32 3
  store i64 %33, ptr %34, align 8, !tbaa !26
  %35 = getelementptr inbounds %"class.qOS::commandLineInterface", ptr %14, i32 0, i32 2
  %36 = getelementptr inbounds %"class.qOS::cli::commandHandler", ptr %35, i32 0, i32 7
  %37 = load ptr, ptr %36, align 8, !tbaa !21
  %38 = getelementptr inbounds %"class.qOS::commandLineInterface", ptr %14, i32 0, i32 10
  %39 = load i64, ptr %38, align 8, !tbaa !20
  call void @llvm.memset.p0.i64(ptr align 1 %37, i8 0, i64 %39, i1 false)
  store i8 1, ptr %13, align 1, !tbaa !11
  br label %40

40:                                               ; preds = %17, %6
  %41 = load i8, ptr %13, align 1, !tbaa !11, !range !27, !noundef !28
  %42 = trunc i8 %41 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #3
  ret i1 %42
}

; 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

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

!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, !6, i64 216}
!14 = !{!"_ZTSN3qOS20commandLineInterfaceE", !15, i64 0, !16, i64 48, !18, i64 104, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !7, i64 208, !6, i64 216, !10, i64 224, !6, i64 232, !6, i64 240}
!15 = !{!"_ZTSN3qOS3cli5inputE", !6, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !12, i64 40}
!16 = !{!"_ZTSN3qOS4listE", !17, i64 0, !6, i64 32, !6, i64 40, !10, i64 48}
!17 = !{!"_ZTSN3qOS4nodeE", !6, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!"_ZTSN3qOS3cli14commandHandlerE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 40, !19, i64 48, !6, i64 56}
!19 = !{!"_ZTSN3qOS3cli11commandTypeE", !7, i64 0}
!20 = !{!14, !10, i64 224}
!21 = !{!14, !6, i64 160}
!22 = !{!14, !6, i64 104}
!23 = !{!14, !6, i64 192}
!24 = !{!15, !6, i64 8}
!25 = !{!15, !10, i64 32}
!26 = !{!15, !10, i64 24}
!27 = !{i8 0, i8 2}
!28 = !{}


; 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 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local noundef zeroext i1 @_ZN3qOS20commandLineInterface5setupEPFvPvcEPcmS4_m(ptr noundef nonnull align 8 dereferenceable(248) %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5) local_unnamed_addr #1 align 2 {
  %.not = icmp ne ptr %1, null
  br i1 %.not, label %7, label %17

7:                                                ; preds = %6
  %8 = getelementptr inbounds i8, ptr %0, i64 216
  store ptr %1, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 224
  store i64 %5, ptr %9, align 8, !tbaa !17
  %10 = getelementptr inbounds i8, ptr %0, i64 104
  %11 = getelementptr inbounds i8, ptr %0, i64 160
  store ptr %4, ptr %11, align 8, !tbaa !18
  store ptr %0, ptr %10, align 8, !tbaa !19
  %12 = getelementptr inbounds i8, ptr %0, i64 192
  store ptr @.str, ptr %12, align 8, !tbaa !20
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %2, ptr %13, align 8, !tbaa !21
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %3, ptr %14, align 8, !tbaa !22
  %15 = add i64 %3, -1
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %15, ptr %16, align 8, !tbaa !23
  tail call void @llvm.memset.p0.i64(ptr align 1 %4, i8 0, i64 %5, i1 false)
  br label %17

17:                                               ; preds = %7, %6
  ret i1 %.not
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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, !8, i64 216}
!6 = !{!"_ZTSN3qOS20commandLineInterfaceE", !7, i64 0, !13, i64 48, !15, i64 104, !8, i64 168, !8, i64 176, !8, i64 184, !8, i64 192, !8, i64 200, !9, i64 208, !8, i64 216, !11, i64 224, !8, i64 232, !8, i64 240}
!7 = !{!"_ZTSN3qOS3cli5inputE", !8, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !12, i64 40}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{!"_ZTSN3qOS4listE", !14, i64 0, !8, i64 32, !8, i64 40, !11, i64 48}
!14 = !{!"_ZTSN3qOS4nodeE", !8, i64 8, !8, i64 16, !8, i64 24}
!15 = !{!"_ZTSN3qOS3cli14commandHandlerE", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !11, i64 32, !11, i64 40, !16, i64 48, !8, i64 56}
!16 = !{!"_ZTSN3qOS3cli11commandTypeE", !9, i64 0}
!17 = !{!6, !11, i64 224}
!18 = !{!6, !8, i64 160}
!19 = !{!6, !8, i64 104}
!20 = !{!6, !8, i64 192}
!21 = !{!7, !8, i64 8}
!22 = !{!7, !11, i64 32}
!23 = !{!7, !11, i64 24}


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