; LLVM IR from nickmqb/muon :: bootstrap/mu.ll_ArgsParser (parseMaxErrors__)

; 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_____Maybe__long____ = type { i64, i8 }
%struct.tag_____ArgsParserState__ = type { ptr, ptr, ptr, ptr, ptr, %struct.string__, %struct.string__, i32, %struct.string__, %struct.tag_____IntRange__, ptr }
%struct.tag_____IntRange__ = type { i32, i32 }
%struct.tag_____CompileArgs__ = type { ptr, %struct.string__, %struct.string__, %struct.string__, i8, i8, %struct.string__, %struct.string__, i32, i8, i8, i8 }

@mu_____string0 = external dso_local global %struct.string__, align 8
@mu_____string588 = external dso_local global %struct.string__, align 8
@mu_____string589 = external dso_local global %struct.string__, 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @string__equals__(ptr, i32, ptr, i32) #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i8 } @long__tryParse__(ptr, i32) #1

; Function Attrs: nounwind uwtable
declare dso_local void @ArgsParser__readToken__(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @ArgsParser__parseMaxErrors__(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.tag_____Maybe__long____, align 8
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  call void @ArgsParser__readToken__(ptr noundef %6)
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.tag_____ArgsParserState__, ptr %7, i32 0, i32 8
  %9 = getelementptr inbounds { ptr, i32 }, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8
  %11 = getelementptr inbounds { ptr, i32 }, ptr %8, i32 0, i32 1
  %12 = load i32, ptr %11, align 8
  %13 = load ptr, ptr @mu_____string0, align 8
  %14 = load i32, ptr getelementptr inbounds ({ ptr, i32 }, ptr @mu_____string0, i32 0, i32 1), align 8
  %15 = call zeroext i8 @string__equals__(ptr %10, i32 %12, ptr %13, i32 %14)
  %16 = icmp ne i8 %15, 0
  br i1 %16, label %17, label %21

17:                                               ; preds = %1
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = load ptr, ptr @mu_____string588, align 8
  %20 = load i32, ptr getelementptr inbounds ({ ptr, i32 }, ptr @mu_____string588, i32 0, i32 1), align 8
  call void @ArgsParser__expected__(ptr noundef %18, ptr %19, i32 %20)
  br label %73

21:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #2
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.tag_____ArgsParserState__, ptr %22, i32 0, i32 8
  %24 = getelementptr inbounds { ptr, i32 }, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8
  %26 = getelementptr inbounds { ptr, i32 }, ptr %23, i32 0, i32 1
  %27 = load i32, ptr %26, align 8
  %28 = call { i64, i8 } @long__tryParse__(ptr %25, i32 %27)
  %29 = getelementptr inbounds { i64, i8 }, ptr %3, i32 0, i32 0
  %30 = extractvalue { i64, i8 } %28, 0
  store i64 %30, ptr %29, align 8
  %31 = getelementptr inbounds { i64, i8 }, ptr %3, i32 0, i32 1
  %32 = extractvalue { i64, i8 } %28, 1
  store i8 %32, ptr %31, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #2
  %33 = getelementptr inbounds %struct.tag_____Maybe__long____, ptr %3, i32 0, i32 1
  %34 = load i8, ptr %33, align 8, !tbaa !9
  %35 = icmp ne i8 %34, 0
  %36 = xor i1 %35, true
  %37 = zext i1 %36 to i32
  %38 = trunc i32 %37 to i8
  store i8 %38, ptr %4, align 1, !tbaa !12
  %39 = load i8, ptr %4, align 1, !tbaa !12
  %40 = icmp ne i8 %39, 0
  br i1 %40, label %47, label %41

41:                                               ; preds = %21
  %42 = getelementptr inbounds %struct.tag_____Maybe__long____, ptr %3, i32 0, i32 0
  %43 = load i64, ptr %42, align 8, !tbaa !13
  %44 = icmp sle i64 %43, 0
  %45 = zext i1 %44 to i32
  %46 = trunc i32 %45 to i8
  store i8 %46, ptr %4, align 1, !tbaa !12
  br label %47

47:                                               ; preds = %41, %21
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  %48 = load i8, ptr %4, align 1, !tbaa !12
  store i8 %48, ptr %5, align 1, !tbaa !12
  %49 = load i8, ptr %5, align 1, !tbaa !12
  %50 = icmp ne i8 %49, 0
  br i1 %50, label %57, label %51

51:                                               ; preds = %47
  %52 = getelementptr inbounds %struct.tag_____Maybe__long____, ptr %3, i32 0, i32 0
  %53 = load i64, ptr %52, align 8, !tbaa !13
  %54 = icmp sgt i64 %53, 2147483647
  %55 = zext i1 %54 to i32
  %56 = trunc i32 %55 to i8
  store i8 %56, ptr %5, align 1, !tbaa !12
  br label %57

57:                                               ; preds = %51, %47
  %58 = load i8, ptr %5, align 1, !tbaa !12
  %59 = icmp ne i8 %58, 0
  br i1 %59, label %60, label %64

60:                                               ; preds = %57
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = load ptr, ptr @mu_____string589, align 8
  %63 = load i32, ptr getelementptr inbounds ({ ptr, i32 }, ptr @mu_____string589, i32 0, i32 1), align 8
  call void @ArgsParser__error__(ptr noundef %61, ptr %62, i32 %63)
  br label %64

64:                                               ; preds = %60, %57
  %65 = getelementptr inbounds %struct.tag_____Maybe__long____, ptr %3, i32 0, i32 0
  %66 = load i64, ptr %65, align 8, !tbaa !13
  %67 = trunc i64 %66 to i32
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.tag_____ArgsParserState__, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !14
  %71 = getelementptr inbounds %struct.tag_____CompileArgs__, ptr %70, i32 0, i32 8
  store i32 %67, ptr %71, align 8, !tbaa !19
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  call void @ArgsParser__readToken__(ptr noundef %72)
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #2
  br label %73

73:                                               ; preds = %64, %17
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @ArgsParser__error__(ptr noundef, ptr, i32) #1

; Function Attrs: nounwind uwtable
declare dso_local void @ArgsParser__expected__(ptr noundef, ptr, i32) #1

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

!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, !7, i64 8}
!10 = !{!"tag_____Maybe__long____", !11, i64 0, !7, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!10, !11, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"tag_____ArgsParserState__", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !16, i64 40, !16, i64 56, !17, i64 72, !16, i64 80, !18, i64 96, !6, i64 104}
!16 = !{!"", !6, i64 0, !17, i64 8}
!17 = !{!"int", !7, i64 0}
!18 = !{!"tag_____IntRange__", !17, i64 0, !17, i64 4}
!19 = !{!20, !17, i64 96}
!20 = !{!"tag_____CompileArgs__", !6, i64 0, !16, i64 8, !16, i64 24, !16, i64 40, !7, i64 56, !7, i64 57, !16, i64 64, !16, i64 80, !17, i64 96, !7, i64 100, !7, i64 101, !7, i64 102}


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

@mu_____string0 = external dso_local local_unnamed_addr global %struct.string__, align 8
@mu_____string588 = external dso_local local_unnamed_addr global %struct.string__, align 8
@mu_____string589 = external dso_local local_unnamed_addr global %struct.string__, align 8

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @string__equals__(ptr, i32, ptr, i32) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local { i64, i8 } @long__tryParse__(ptr, i32) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @ArgsParser__readToken__(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @ArgsParser__parseMaxErrors__(ptr noundef %0) local_unnamed_addr #0 {
  tail call void @ArgsParser__readToken__(ptr noundef %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 80
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 88
  %5 = load i32, ptr %4, align 8
  %6 = load ptr, ptr @mu_____string0, align 8
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @mu_____string0, i64 8), align 8
  %8 = tail call zeroext i8 @string__equals__(ptr %3, i32 %5, ptr %6, i32 %7)
  %.not = icmp eq i8 %8, 0
  br i1 %.not, label %12, label %9

9:                                                ; preds = %1
  %10 = load ptr, ptr @mu_____string588, align 8
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @mu_____string588, i64 8), align 8
  tail call void @ArgsParser__expected__(ptr noundef nonnull %0, ptr %10, i32 %11)
  br label %26

12:                                               ; preds = %1
  %13 = load ptr, ptr %2, align 8
  %14 = load i32, ptr %4, align 8
  %15 = tail call { i64, i8 } @long__tryParse__(ptr %13, i32 %14)
  %16 = extractvalue { i64, i8 } %15, 0
  %17 = extractvalue { i64, i8 } %15, 1
  %.not14 = icmp ne i8 %17, 0
  %18 = add i64 %16, -1
  %19 = icmp ult i64 %18, 2147483647
  %or.cond = select i1 %.not14, i1 %19, i1 false
  br i1 %or.cond, label %22, label %.critedge

.critedge:                                        ; preds = %12
  %20 = load ptr, ptr @mu_____string589, align 8
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @mu_____string589, i64 8), align 8
  tail call void @ArgsParser__error__(ptr noundef nonnull %0, ptr %20, i32 %21)
  br label %22

22:                                               ; preds = %12, %.critedge
  %23 = trunc i64 %16 to i32
  %24 = load ptr, ptr %0, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 96
  store i32 %23, ptr %25, align 8, !tbaa !13
  tail call void @ArgsParser__readToken__(ptr noundef nonnull %0)
  br label %26

26:                                               ; preds = %22, %9
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @ArgsParser__error__(ptr noundef, ptr, i32) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @ArgsParser__expected__(ptr noundef, ptr, i32) local_unnamed_addr #0

attributes #0 = { 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" }

!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, !7, i64 0}
!6 = !{!"tag_____ArgsParserState__", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 56, !11, i64 72, !10, i64 80, !12, i64 96, !7, i64 104}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !7, i64 0, !11, i64 8}
!11 = !{!"int", !8, i64 0}
!12 = !{!"tag_____IntRange__", !11, i64 0, !11, i64 4}
!13 = !{!14, !11, i64 96}
!14 = !{!"tag_____CompileArgs__", !7, i64 0, !10, i64 8, !10, i64 24, !10, i64 40, !8, i64 56, !8, i64 57, !10, i64 64, !10, i64 80, !11, i64 96, !8, i64 100, !8, i64 101, !8, i64 102}


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