; LLVM IR from nickmqb/muon :: bootstrap/mu.ll_TypeChecker (canFitUnsigned__)

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @TypeChecker__canFitUnsigned__(i64 noundef %0, ptr %1, ptr %2) #0 {
  %4 = alloca i8, align 1
  %5 = alloca %struct.tag_____Tag__, align 8
  %6 = alloca i64, align 8
  %7 = getelementptr inbounds { ptr, ptr }, ptr %5, i32 0, i32 0
  store ptr %1, ptr %7, align 8
  %8 = getelementptr inbounds { ptr, ptr }, ptr %5, i32 0, i32 1
  store ptr %2, ptr %8, align 8
  store i64 %0, ptr %6, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.tag_____Tag__, ptr %5, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.tag_____Namespace__, ptr %10, i32 0, i32 13
  %12 = load i32, ptr %11, align 8, !tbaa !12
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %14, label %19

14:                                               ; preds = %3
  %15 = load i64, ptr %6, align 8, !tbaa !5
  %16 = icmp ule i64 %15, 255
  %17 = zext i1 %16 to i32
  %18 = trunc i32 %17 to i8
  store i8 %18, ptr %4, align 1
  br label %42

19:                                               ; preds = %3
  %20 = getelementptr inbounds %struct.tag_____Tag__, ptr %5, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.tag_____Namespace__, ptr %21, i32 0, i32 13
  %23 = load i32, ptr %22, align 8, !tbaa !12
  %24 = icmp eq i32 %23, 2
  br i1 %24, label %25, label %30

25:                                               ; preds = %19
  %26 = load i64, ptr %6, align 8, !tbaa !5
  %27 = icmp ule i64 %26, 65535
  %28 = zext i1 %27 to i32
  %29 = trunc i32 %28 to i8
  store i8 %29, ptr %4, align 1
  br label %42

30:                                               ; preds = %19
  %31 = getelementptr inbounds %struct.tag_____Tag__, ptr %5, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.tag_____Namespace__, ptr %32, i32 0, i32 13
  %34 = load i32, ptr %33, align 8, !tbaa !12
  %35 = icmp sle i32 %34, 6
  br i1 %35, label %36, label %41

36:                                               ; preds = %30
  %37 = load i64, ptr %6, align 8, !tbaa !5
  %38 = icmp ule i64 %37, 4294967295
  %39 = zext i1 %38 to i32
  %40 = trunc i32 %39 to i8
  store i8 %40, ptr %4, align 1
  br label %42

41:                                               ; preds = %30
  store i8 1, ptr %4, align 1
  br label %42

42:                                               ; preds = %41, %36, %25, %14
  %43 = load i8, ptr %4, align 1
  ret i8 %43
}

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, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"tag_____Tag__", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !15, i64 104}
!13 = !{!"tag_____Namespace__", !14, i64 0, !11, i64 16, !15, i64 24, !15, i64 28, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !15, i64 104}
!14 = !{!"", !11, i64 0, !15, i64 8}
!15 = !{!"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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local zeroext range(i8 0, 2) i8 @TypeChecker__canFitUnsigned__(i64 noundef %0, ptr nocapture readonly %1, ptr nocapture readnone %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %1, i64 104
  %5 = load i32, ptr %4, align 8, !tbaa !5
  switch i32 %5, label %10 [
    i32 1, label %6
    i32 2, label %8
  ]

6:                                                ; preds = %3
  %7 = icmp ult i64 %0, 256
  br label %13

8:                                                ; preds = %3
  %9 = icmp ult i64 %0, 65536
  br label %13

10:                                               ; preds = %3
  %11 = icmp sgt i32 %5, 6
  %12 = icmp ult i64 %0, 4294967296
  %spec.select = or i1 %12, %11
  br label %13

13:                                               ; preds = %10, %8, %6
  %.0.shrunk = phi i1 [ %7, %6 ], [ %9, %8 ], [ %spec.select, %10 ]
  %.0 = zext i1 %.0.shrunk to i8
  ret i8 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !11, i64 104}
!6 = !{!"tag_____Namespace__", !7, i64 0, !8, i64 16, !11, i64 24, !11, i64 28, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !8, i64 64, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !11, i64 104}
!7 = !{!"", !8, i64 0, !11, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass