; LLVM IR from nickmqb/muon :: bootstrap/mu.ll_TypeCheckerFirstPass (getConstantString__)

; 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_____Error__ = type { ptr, %struct.tag_____IntRange__, %struct.string__ }
%struct.tag_____IntRange__ = type { i32, i32 }
%struct.tag_____Maybe__string____ = type { %struct.string__, i8 }
%struct.Node__ = type { i32, ptr }
%struct.tag_____TypeCheckerContext__ = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, i32, i8 }
%struct.tag_____StringExpression__ = type { ptr, %struct.string__, i32 }

@mu_____string0 = external dso_local global %struct.string__, align 8
@mu_____string112 = external dso_local global %struct.string__, align 8
@mu_____string111 = external dso_local global %struct.string__, align 8
@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 zeroext i8 @string__equals__(ptr, i32, ptr, i32) #4

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

; Function Attrs: nounwind uwtable
declare dso_local void @Error__at__(ptr dead_on_unwind noalias writable sret(%struct.tag_____Error__) align 8, ptr noundef, i64, ptr, i32) #4

; Function Attrs: nounwind uwtable
define dso_local void @TypeCheckerFirstPass__getConstantString__(ptr dead_on_unwind noalias writable sret(%struct.tag_____Maybe__string____) align 8 %0, ptr noundef %1, i32 %2, ptr %3) #4 {
  %5 = alloca %struct.Node__, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %struct.tag_____Error__, align 8
  %8 = alloca %struct.tag_____IntRange__, align 4
  %9 = alloca %struct.Node__, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.tag_____Error__, align 8
  %12 = alloca %struct.tag_____IntRange__, align 4
  %13 = alloca i32, align 4
  %14 = getelementptr inbounds { i32, ptr }, ptr %5, i32 0, i32 0
  store i32 %2, ptr %14, align 8
  %15 = getelementptr inbounds { i32, ptr }, ptr %5, i32 0, i32 1
  store ptr %3, ptr %15, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.Node__, ptr %5, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !9
  %18 = icmp eq i32 %17, 20
  br i1 %18, label %34, label %19

19:                                               ; preds = %4
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !12
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %23, i32 0, i32 5
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = getelementptr inbounds { i32, ptr }, ptr %5, i32 0, i32 0
  %27 = load i32, ptr %26, align 8
  %28 = getelementptr inbounds { i32, ptr }, ptr %5, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8
  %30 = call i64 @RangeFinder__find__(i32 %27, ptr %29)
  store i64 %30, ptr %8, align 4
  %31 = load i64, ptr %8, align 4
  %32 = load ptr, ptr @mu_____string111, align 8
  %33 = load i32, ptr getelementptr inbounds ({ ptr, i32 }, ptr @mu_____string111, i32 0, i32 1), align 8
  call void @Error__at__(ptr dead_on_unwind writable sret(%struct.tag_____Error__) align 8 %7, ptr noundef %25, i64 %31, ptr %32, i32 %33)
  call void @List__add__Error____(ptr noundef %22, ptr noundef byval(%struct.tag_____Error__) align 8 %7)
  call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 24, i1 false)
  br label %77

34:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %5, i64 16, i1 false), !tbaa.struct !15
  %35 = getelementptr inbounds %struct.Node__, ptr %9, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !9
  %37 = icmp eq i32 %36, 20
  br i1 %37, label %41, label %38

38:                                               ; preds = %34
  %39 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  call void %40(i32 noundef -4)
  br label %41

41:                                               ; preds = %38, %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %42 = getelementptr inbounds %struct.Node__, ptr %9, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !17
  store ptr %43, ptr %10, align 8, !tbaa !5
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.tag_____StringExpression__, ptr %44, i32 0, i32 1
  %46 = getelementptr inbounds { ptr, i32 }, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8
  %48 = getelementptr inbounds { ptr, i32 }, ptr %45, i32 0, i32 1
  %49 = load i32, ptr %48, align 8
  %50 = load ptr, ptr @mu_____string0, align 8
  %51 = load i32, ptr getelementptr inbounds ({ ptr, i32 }, ptr @mu_____string0, i32 0, i32 1), align 8
  %52 = call zeroext i8 @string__equals__(ptr %47, i32 %49, ptr %50, i32 %51)
  %53 = icmp ne i8 %52, 0
  br i1 %53, label %54, label %69

54:                                               ; preds = %41
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %55, i32 0, i32 2
  %57 = load ptr, ptr %56, align 8, !tbaa !12
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %58, i32 0, i32 5
  %60 = load ptr, ptr %59, align 8, !tbaa !14
  %61 = getelementptr inbounds { i32, ptr }, ptr %5, i32 0, i32 0
  %62 = load i32, ptr %61, align 8
  %63 = getelementptr inbounds { i32, ptr }, ptr %5, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8
  %65 = call i64 @RangeFinder__find__(i32 %62, ptr %64)
  store i64 %65, ptr %12, align 4
  %66 = load i64, ptr %12, align 4
  %67 = load ptr, ptr @mu_____string112, align 8
  %68 = load i32, ptr getelementptr inbounds ({ ptr, i32 }, ptr @mu_____string112, i32 0, i32 1), align 8
  call void @Error__at__(ptr dead_on_unwind writable sret(%struct.tag_____Error__) align 8 %11, ptr noundef %60, i64 %66, ptr %67, i32 %68)
  call void @List__add__Error____(ptr noundef %57, ptr noundef byval(%struct.tag_____Error__) align 8 %11)
  call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 24, i1 false)
  store i32 1, ptr %13, align 4
  br label %76

69:                                               ; preds = %41
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.tag_____StringExpression__, ptr %70, i32 0, i32 1
  %72 = getelementptr inbounds { ptr, i32 }, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8
  %74 = getelementptr inbounds { ptr, i32 }, ptr %71, i32 0, i32 1
  %75 = load i32, ptr %74, align 8
  call void @Maybe__from__string____(ptr dead_on_unwind writable sret(%struct.tag_____Maybe__string____) align 8 %0, ptr %73, i32 %75)
  store i32 1, ptr %13, align 4
  br label %76

76:                                               ; preds = %69, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  br label %77

77:                                               ; preds = %76, %19
  ret void
}

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

; Function Attrs: nounwind uwtable
declare dso_local void @Maybe__from__string____(ptr dead_on_unwind noalias writable sret(%struct.tag_____Maybe__string____) align 8, ptr, i32) #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, !11, i64 0}
!10 = !{!"", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 16}
!13 = !{!"tag_____TypeCheckerContext__", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !11, i64 120, !11, i64 124, !6, i64 128, !11, i64 136, !7, i64 140}
!14 = !{!13, !6, i64 40}
!15 = !{i64 0, i64 4, !16, i64 8, i64 8, !5}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !6, i64 8}


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

@mu_____string0 = external dso_local local_unnamed_addr global %struct.string__, align 8
@mu_____string112 = external dso_local local_unnamed_addr global %struct.string__, align 8
@mu_____string111 = external dso_local local_unnamed_addr global %struct.string__, align 8

; 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: nounwind uwtable
declare dso_local zeroext i8 @string__equals__(ptr, i32, ptr, i32) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @List__add__Error____(ptr noundef, ptr noundef byval(%struct.tag_____Error__) align 8) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @Error__at__(ptr dead_on_unwind noalias writable sret(%struct.tag_____Error__) align 8, ptr noundef, i64, ptr, i32) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @TypeCheckerFirstPass__getConstantString__(ptr dead_on_unwind noalias writable sret(%struct.tag_____Maybe__string____) align 8 %0, ptr nocapture noundef readonly %1, i32 %2, ptr %3) local_unnamed_addr #1 {
  %5 = alloca %struct.tag_____Error__, align 8
  %6 = alloca %struct.tag_____Error__, align 8
  %7 = icmp eq i32 %2, 20
  br i1 %7, label %16, label %8

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 40
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = tail call i64 @RangeFinder__find__(i32 %2, ptr %3)
  %14 = load ptr, ptr @mu_____string111, align 8
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @mu_____string111, i64 8), align 8
  call void @Error__at__(ptr dead_on_unwind nonnull writable sret(%struct.tag_____Error__) align 8 %5, ptr noundef %12, i64 %13, ptr %14, i32 %15)
  call void @List__add__Error____(ptr noundef %10, ptr noundef nonnull byval(%struct.tag_____Error__) align 8 %5)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %0, i8 0, i64 24, i1 false)
  br label %35

16:                                               ; preds = %4
  %17 = getelementptr inbounds i8, ptr %3, i64 8
  %18 = load ptr, ptr %17, align 8
  %19 = getelementptr inbounds i8, ptr %3, i64 16
  %20 = load i32, ptr %19, align 8
  %21 = load ptr, ptr @mu_____string0, align 8
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @mu_____string0, i64 8), align 8
  %23 = tail call zeroext i8 @string__equals__(ptr %18, i32 %20, ptr %21, i32 %22)
  %.not = icmp eq i8 %23, 0
  br i1 %.not, label %32, label %24

24:                                               ; preds = %16
  %25 = getelementptr inbounds i8, ptr %1, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %1, i64 40
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = tail call i64 @RangeFinder__find__(i32 20, ptr nonnull %3)
  %30 = load ptr, ptr @mu_____string112, align 8
  %31 = load i32, ptr getelementptr inbounds (i8, ptr @mu_____string112, i64 8), align 8
  call void @Error__at__(ptr dead_on_unwind nonnull writable sret(%struct.tag_____Error__) align 8 %6, ptr noundef %28, i64 %29, ptr %30, i32 %31)
  call void @List__add__Error____(ptr noundef %26, ptr noundef nonnull byval(%struct.tag_____Error__) align 8 %6)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %0, i8 0, i64 24, i1 false)
  br label %35

32:                                               ; preds = %16
  %33 = load ptr, ptr %17, align 8
  %34 = load i32, ptr %19, align 8
  tail call void @Maybe__from__string____(ptr dead_on_unwind writable sret(%struct.tag_____Maybe__string____) align 8 %0, ptr %33, i32 %34)
  br label %35

35:                                               ; preds = %24, %32, %8
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local i64 @RangeFinder__find__(i32, ptr) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @Maybe__from__string____(ptr dead_on_unwind noalias writable sret(%struct.tag_____Maybe__string____) align 8, ptr, i32) local_unnamed_addr #1

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

!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 16}
!6 = !{!"tag_____TypeCheckerContext__", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !10, i64 120, !10, i64 124, !7, i64 128, !10, i64 136, !8, i64 140}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 40}


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