; LLVM IR from nickmqb/muon :: bootstrap/mu.ll_CommandLineArgsParser (error__)

; 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.string__ = type { ptr, i32 }
%struct.tag_____CommandLineArgsParserError__ = type { i32, %struct.tag_____IntRange__, %struct.string__ }
%struct.tag_____IntRange__ = type { i32, i32 }
%struct.tag_____CommandLineArgsParser__ = type { i32, ptr, ptr }
%struct.tag_____Array__string____ = type { ptr, i32 }

@top_____abandonFn__ = external dso_local thread_local global ptr, align 8

; 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 speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #1

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare dso_local i64 @IntRange__cons__(i32 noundef, i32 noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @CommandLineArgsParser__error__(ptr noundef %0, ptr %1, i32 %2) #4 {
  %4 = alloca %struct.string__, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.string__, align 8
  %9 = alloca %struct.tag_____CommandLineArgsParserError__, align 8
  %10 = alloca %struct.tag_____IntRange__, align 4
  %11 = getelementptr inbounds { ptr, i32 }, ptr %4, i32 0, i32 0
  store ptr %1, ptr %11, align 8
  %12 = getelementptr inbounds { ptr, i32 }, ptr %4, i32 0, i32 1
  store i32 %2, ptr %12, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.tag_____CommandLineArgsParser__, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  store ptr %15, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.tag_____CommandLineArgsParser__, ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !12
  %19 = sub nsw i32 %18, 1
  store i32 %19, ptr %7, align 4, !tbaa !13
  %20 = load i32, ptr %7, align 4, !tbaa !13
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.tag_____Array__string____, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !14
  %24 = icmp ult i32 %20, %23
  br i1 %24, label %28, label %25

25:                                               ; preds = %3
  %26 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  call void %27(i32 noundef -3)
  br label %28

28:                                               ; preds = %25, %3
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.tag_____Array__string____, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = load i32, ptr %7, align 4, !tbaa !13
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds %struct.string__, ptr %31, i64 %33
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %34, i64 16, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #5
  call void @llvm.memset.p0.i64(ptr align 8 %9, i8 0, i64 32, i1 false)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.tag_____CommandLineArgsParser__, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !12
  %38 = sub nsw i32 %37, 1
  %39 = getelementptr inbounds %struct.tag_____CommandLineArgsParserError__, ptr %9, i32 0, i32 0
  store i32 %38, ptr %39, align 8, !tbaa !18
  %40 = getelementptr inbounds %struct.tag_____CommandLineArgsParserError__, ptr %9, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %41 = getelementptr inbounds %struct.string__, ptr %8, i32 0, i32 1
  %42 = load i32, ptr %41, align 8, !tbaa !22
  %43 = call i64 @IntRange__cons__(i32 noundef 0, i32 noundef %42)
  store i64 %43, ptr %10, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %40, ptr align 4 %10, i64 8, i1 false), !tbaa.struct !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %44 = getelementptr inbounds %struct.tag_____CommandLineArgsParserError__, ptr %9, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %44, ptr align 8 %4, i64 16, i1 false), !tbaa.struct !17
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.tag_____CommandLineArgsParser__, ptr %45, i32 0, i32 2
  %47 = load ptr, ptr %46, align 8, !tbaa !24
  call void @List__add__CommandLineArgsParserError____(ptr noundef %47, ptr noundef byval(%struct.tag_____CommandLineArgsParserError__) align 8 %9)
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @List__add__CommandLineArgsParserError____(ptr noundef, ptr noundef byval(%struct.tag_____CommandLineArgsParserError__) align 8) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"tag_____CommandLineArgsParser__", !11, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !11, i64 8}
!15 = !{!"tag_____Array__string____", !6, i64 0, !11, i64 8}
!16 = !{!15, !6, i64 0}
!17 = !{i64 0, i64 8, !5, i64 8, i64 4, !13}
!18 = !{!19, !11, i64 0}
!19 = !{!"tag_____CommandLineArgsParserError__", !11, i64 0, !20, i64 4, !21, i64 16}
!20 = !{!"tag_____IntRange__", !11, i64 0, !11, i64 4}
!21 = !{!"", !6, i64 0, !11, i64 8}
!22 = !{!21, !11, i64 8}
!23 = !{i64 0, i64 4, !13, i64 4, i64 4, !13}
!24 = !{!10, !6, i64 16}


; 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.tag_____CommandLineArgsParserError__ = type { i32, %struct.tag_____IntRange__, %struct.string__ }
%struct.tag_____IntRange__ = type { i32, i32 }
%struct.string__ = type { ptr, i32 }

@top_____abandonFn__ = external dso_local thread_local local_unnamed_addr global ptr, align 8

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @IntRange__cons__(i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @CommandLineArgsParser__error__(ptr nocapture noundef readonly %0, ptr %1, i32 %2) local_unnamed_addr #3 {
  %4 = alloca %struct.tag_____CommandLineArgsParserError__, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = load i32, ptr %0, align 8, !tbaa !11
  %8 = add nsw i32 %7, -1
  %9 = getelementptr inbounds i8, ptr %6, i64 8
  %10 = load i32, ptr %9, align 8, !tbaa !12
  %11 = icmp ult i32 %8, %10
  br i1 %11, label %15, label %12

12:                                               ; preds = %3
  %13 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  tail call void %14(i32 noundef -3) #4
  %.pre = load i32, ptr %0, align 8, !tbaa !11
  %.pre10 = add nsw i32 %.pre, -1
  br label %15

15:                                               ; preds = %12, %3
  %.pre-phi = phi i32 [ %.pre10, %12 ], [ %8, %3 ]
  %16 = load ptr, ptr %6, align 8, !tbaa !15
  %17 = zext i32 %8 to i64
  %.sroa.3.0..sroa_idx = getelementptr inbounds %struct.string__, ptr %16, i64 %17, i32 1
  %.sroa.3.0.copyload = load i32, ptr %.sroa.3.0..sroa_idx, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #4
  %18 = getelementptr inbounds i8, ptr %4, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %18, i8 0, i64 24, i1 false)
  store i32 %.pre-phi, ptr %4, align 8, !tbaa !17
  %19 = getelementptr inbounds i8, ptr %4, i64 4
  %20 = tail call i64 @IntRange__cons__(i32 noundef 0, i32 noundef %.sroa.3.0.copyload)
  store i64 %20, ptr %19, align 4
  %21 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr %1, ptr %21, align 8, !tbaa !14
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 24
  store i32 %2, ptr %.sroa.2.0..sroa_idx, align 8, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %0, i64 16
  %23 = load ptr, ptr %22, align 8, !tbaa !21
  tail call void @List__add__CommandLineArgsParserError____(ptr noundef %23, ptr noundef nonnull byval(%struct.tag_____CommandLineArgsParserError__) align 8 %4)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @List__add__CommandLineArgsParserError____(ptr noundef, ptr noundef byval(%struct.tag_____CommandLineArgsParserError__) align 8) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #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, !10, i64 8}
!6 = !{!"tag_____CommandLineArgsParser__", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!13, !7, i64 8}
!13 = !{!"tag_____Array__string____", !10, i64 0, !7, i64 8}
!14 = !{!10, !10, i64 0}
!15 = !{!13, !10, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !7, i64 0}
!18 = !{!"tag_____CommandLineArgsParserError__", !7, i64 0, !19, i64 4, !20, i64 16}
!19 = !{!"tag_____IntRange__", !7, i64 0, !7, i64 4}
!20 = !{!"", !10, i64 0, !7, i64 8}
!21 = !{!6, !10, i64 16}


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass