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

; 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: 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
define dso_local zeroext i8 @TypeChecker__canFitSigned__(i64 noundef %0, ptr %1, ptr %2) #1 {
  %4 = alloca i8, align 1
  %5 = alloca %struct.tag_____Tag__, align 8
  %6 = alloca i64, align 8
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = getelementptr inbounds { ptr, ptr }, ptr %5, i32 0, i32 0
  store ptr %1, ptr %10, align 8
  %11 = getelementptr inbounds { ptr, ptr }, ptr %5, i32 0, i32 1
  store ptr %2, ptr %11, align 8
  store i64 %0, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.tag_____Tag__, ptr %5, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.tag_____Namespace__, ptr %13, i32 0, i32 13
  %15 = load i32, ptr %14, align 8, !tbaa !12
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %31

17:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #2
  %18 = load i64, ptr %6, align 8, !tbaa !5
  %19 = icmp sle i64 -128, %18
  %20 = zext i1 %19 to i32
  %21 = trunc i32 %20 to i8
  store i8 %21, ptr %7, align 1, !tbaa !16
  %22 = load i8, ptr %7, align 1, !tbaa !16
  %23 = icmp ne i8 %22, 0
  br i1 %23, label %24, label %29

24:                                               ; preds = %17
  %25 = load i64, ptr %6, align 8, !tbaa !5
  %26 = icmp sle i64 %25, 127
  %27 = zext i1 %26 to i32
  %28 = trunc i32 %27 to i8
  store i8 %28, ptr %7, align 1, !tbaa !16
  br label %29

29:                                               ; preds = %24, %17
  %30 = load i8, ptr %7, align 1, !tbaa !16
  store i8 %30, ptr %4, align 1
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  br label %72

31:                                               ; preds = %3
  %32 = getelementptr inbounds %struct.tag_____Tag__, ptr %5, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.tag_____Namespace__, ptr %33, i32 0, i32 13
  %35 = load i32, ptr %34, align 8, !tbaa !12
  %36 = icmp eq i32 %35, 2
  br i1 %36, label %37, label %51

37:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #2
  %38 = load i64, ptr %6, align 8, !tbaa !5
  %39 = icmp sle i64 -32768, %38
  %40 = zext i1 %39 to i32
  %41 = trunc i32 %40 to i8
  store i8 %41, ptr %8, align 1, !tbaa !16
  %42 = load i8, ptr %8, align 1, !tbaa !16
  %43 = icmp ne i8 %42, 0
  br i1 %43, label %44, label %49

44:                                               ; preds = %37
  %45 = load i64, ptr %6, align 8, !tbaa !5
  %46 = icmp sle i64 %45, 32767
  %47 = zext i1 %46 to i32
  %48 = trunc i32 %47 to i8
  store i8 %48, ptr %8, align 1, !tbaa !16
  br label %49

49:                                               ; preds = %44, %37
  %50 = load i8, ptr %8, align 1, !tbaa !16
  store i8 %50, ptr %4, align 1
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  br label %72

51:                                               ; preds = %31
  %52 = getelementptr inbounds %struct.tag_____Tag__, ptr %5, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.tag_____Namespace__, ptr %53, i32 0, i32 13
  %55 = load i32, ptr %54, align 8, !tbaa !12
  %56 = icmp sle i32 %55, 6
  br i1 %56, label %57, label %71

57:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #2
  %58 = load i64, ptr %6, align 8, !tbaa !5
  %59 = icmp sle i64 -2147483648, %58
  %60 = zext i1 %59 to i32
  %61 = trunc i32 %60 to i8
  store i8 %61, ptr %9, align 1, !tbaa !16
  %62 = load i8, ptr %9, align 1, !tbaa !16
  %63 = icmp ne i8 %62, 0
  br i1 %63, label %64, label %69

64:                                               ; preds = %57
  %65 = load i64, ptr %6, align 8, !tbaa !5
  %66 = icmp sle i64 %65, 2147483647
  %67 = zext i1 %66 to i32
  %68 = trunc i32 %67 to i8
  store i8 %68, ptr %9, align 1, !tbaa !16
  br label %69

69:                                               ; preds = %64, %57
  %70 = load i8, ptr %9, align 1, !tbaa !16
  store i8 %70, ptr %4, align 1
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #2
  br label %72

71:                                               ; preds = %51
  store i8 1, ptr %4, align 1
  br label %72

72:                                               ; preds = %71, %69, %49, %29
  %73 = load i8, ptr %4, align 1
  ret i8 %73
}

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 = !{!"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}
!16 = !{!7, !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__canFitSigned__(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 = add i64 %0, 128
  %narrow22 = icmp ult i64 %7, 256
  br label %14

8:                                                ; preds = %3
  %9 = add i64 %0, 32768
  %narrow = icmp ult i64 %9, 65536
  br label %14

10:                                               ; preds = %3
  %11 = icmp slt i32 %5, 7
  br i1 %11, label %12, label %14

12:                                               ; preds = %10
  %13 = add i64 %0, 2147483648
  %narrow23 = icmp ult i64 %13, 4294967296
  br label %14

14:                                               ; preds = %10, %12, %8, %6
  %.017.shrunk = phi i1 [ %narrow22, %6 ], [ %narrow, %8 ], [ %narrow23, %12 ], [ true, %10 ]
  %.017 = zext i1 %.017.shrunk to i8
  ret i8 %.017
}

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,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass