; LLVM IR from HRI-EU/Rcs :: src/RcsCore/Rcs_cmdLine.ll (ZNK3Rcs13CmdLineParser11getArgumentEPKcPcS2_z)

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

%struct.__va_list_tag = type { i32, i32, ptr, ptr }

@_ZN3Rcs13CmdLineParser4argvE = external dso_local global ptr, align 8
@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@RCS_GLOBAL_RLOG_CB = external global ptr, align 8
@__func__._ZNK3Rcs13CmdLineParser11getArgumentEPKcPcS2_z = external hidden unnamed_addr constant [12 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [23 x i8], align 1
@RcsLogLevel = external global i32, align 4
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3Rcs13CmdLineParser11getArgumentEPKcPcS2_z(ptr noundef nonnull align 1 dereferenceable(1) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ...) #2 align 2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca [1 x %struct.__va_list_tag], align 16
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %34

16:                                               ; preds = %4
  br label %17

17:                                               ; preds = %16
  %18 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %22

20:                                               ; preds = %17
  %21 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  call void (i32, ptr, ptr, i32, ptr, ...) %21(i32 noundef 4, ptr noundef @.str.2, ptr noundef @__func__._ZNK3Rcs13CmdLineParser11getArgumentEPKcPcS2_z, i32 noundef 89, ptr noundef @.str.9)
  br label %22

22:                                               ; preds = %20, %17
  %23 = load i32, ptr @RcsLogLevel, align 4, !tbaa !9
  %24 = icmp sle i32 4, %23
  br i1 %24, label %25, label %32

25:                                               ; preds = %22
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.10, ptr noundef @.str.2, ptr noundef @__func__._ZNK3Rcs13CmdLineParser11getArgumentEPKcPcS2_z, i32 noundef 89) #4
  %28 = load ptr, ptr @stderr, align 8, !tbaa !5
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.9) #4
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.8) #4
  br label %32

32:                                               ; preds = %25, %22
  br label %33

33:                                               ; preds = %32
  store i1 false, ptr %5, align 1
  br label %63

34:                                               ; preds = %4
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %43

37:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #4
  %38 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %10, i64 0, i64 0
  call void @llvm.va_start.p0(ptr %38)
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %10, i64 0, i64 0
  call void @_ZNK3Rcs13CmdLineParser17appendDescriptionEPKcS2_P13__va_list_tag(ptr noundef nonnull align 1 dereferenceable(1) %13, ptr noundef %39, ptr noundef %40, ptr noundef %41)
  %42 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %10, i64 0, i64 0
  call void @llvm.va_end.p0(ptr %42)
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #4
  br label %43

43:                                               ; preds = %37, %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = call noundef i32 @_ZNK3Rcs13CmdLineParser11getTagIndexEPKc(ptr noundef nonnull align 1 dereferenceable(1) %13, ptr noundef %44)
  store i32 %45, ptr %11, align 4, !tbaa !9
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = icmp eq i32 %46, -1
  br i1 %47, label %48, label %49

48:                                               ; preds = %43
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %62

49:                                               ; preds = %43
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %52, label %61

52:                                               ; preds = %49
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = load ptr, ptr @_ZN3Rcs13CmdLineParser4argvE, align 8, !tbaa !5
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds ptr, ptr %54, i64 %57
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = call ptr @strcpy(ptr noundef %53, ptr noundef %59) #4
  br label %61

61:                                               ; preds = %52, %49
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %62

62:                                               ; preds = %61, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %63

63:                                               ; preds = %62, %33
  %64 = load i1, ptr %5, align 1
  ret i1 %64
}

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_start.p0(ptr) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3Rcs13CmdLineParser17appendDescriptionEPKcS2_P13__va_list_tag(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef, ptr noundef, ptr noundef) #2 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK3Rcs13CmdLineParser11getTagIndexEPKc(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef) #2 align 2

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind willreturn }
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, !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 = !{!"int", !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"

%struct.__va_list_tag = type { i32, i32, ptr, ptr }

@_ZN3Rcs13CmdLineParser4argvE = external dso_local local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@RCS_GLOBAL_RLOG_CB = external local_unnamed_addr global ptr, align 8
@__func__._ZNK3Rcs13CmdLineParser11getArgumentEPKcPcS2_z = external hidden unnamed_addr constant [12 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [23 x i8], align 1
@RcsLogLevel = external local_unnamed_addr global i32, align 4
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3Rcs13CmdLineParser11getArgumentEPKcPcS2_z(ptr noundef nonnull align 1 dereferenceable(1) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ...) local_unnamed_addr #2 align 2 {
  %5 = alloca [1 x %struct.__va_list_tag], align 16
  %6 = icmp eq ptr %1, null
  br i1 %6, label %7, label %20

7:                                                ; preds = %4
  %8 = load ptr, ptr @RCS_GLOBAL_RLOG_CB, align 8, !tbaa !5
  %.not16 = icmp eq ptr %8, null
  br i1 %.not16, label %10, label %9

9:                                                ; preds = %7
  tail call void (i32, ptr, ptr, i32, ptr, ...) %8(i32 noundef 4, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__._ZNK3Rcs13CmdLineParser11getArgumentEPKcPcS2_z, i32 noundef 89, ptr noundef nonnull @.str.9)
  br label %10

10:                                               ; preds = %9, %7
  %11 = load i32, ptr @RcsLogLevel, align 4, !tbaa !9
  %12 = icmp sgt i32 %11, 3
  br i1 %12, label %13, label %32

13:                                               ; preds = %10
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.2, ptr noundef nonnull @__func__._ZNK3Rcs13CmdLineParser11getArgumentEPKcPcS2_z, i32 noundef 89) #5
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.9) #5
  %18 = load ptr, ptr @stderr, align 8, !tbaa !5
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.8) #5
  br label %32

20:                                               ; preds = %4
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %22, label %21

21:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #6
  call void @llvm.va_start.p0(ptr nonnull %5)
  call void @_ZNK3Rcs13CmdLineParser17appendDescriptionEPKcS2_P13__va_list_tag(ptr noundef nonnull align 1 dereferenceable(1) %0, ptr noundef nonnull %1, ptr noundef nonnull %3, ptr noundef nonnull %5)
  call void @llvm.va_end.p0(ptr nonnull %5)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  br label %22

22:                                               ; preds = %21, %20
  %23 = call noundef i32 @_ZNK3Rcs13CmdLineParser11getTagIndexEPKc(ptr noundef nonnull align 1 dereferenceable(1) %0, ptr noundef nonnull %1)
  %24 = icmp ne i32 %23, -1
  %.not15 = icmp ne ptr %2, null
  %or.cond.not = and i1 %.not15, %24
  br i1 %or.cond.not, label %25, label %32

25:                                               ; preds = %22
  %26 = load ptr, ptr @_ZN3Rcs13CmdLineParser4argvE, align 8, !tbaa !5
  %27 = sext i32 %23 to i64
  %28 = getelementptr ptr, ptr %26, i64 %27
  %29 = getelementptr i8, ptr %28, i64 8
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) %30) #6
  br label %32

32:                                               ; preds = %22, %25, %13, %10
  %.1 = phi i1 [ false, %10 ], [ false, %13 ], [ true, %25 ], [ %24, %22 ]
  ret i1 %.1
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_start.p0(ptr) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3Rcs13CmdLineParser17appendDescriptionEPKcS2_P13__va_list_tag(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK3Rcs13CmdLineParser11getTagIndexEPKc(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #4

attributes #0 = { nofree 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 nocallback nofree nosync nounwind willreturn }
attributes #4 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { cold nounwind }
attributes #6 = { 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 = !{!"int", !7, i64 0}


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