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

; 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_____Tag__ = type { ptr, ptr }
%struct.Node__ = type { i32, ptr }
%struct.tag_____IfStatement__ = type { ptr, %struct.Node__, ptr, ptr, ptr, %struct.Node__ }
%struct.tag_____Namespace__ = type { %struct.string__, ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32 }
%struct.tag_____TypeCheckerContext__ = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, ptr, i32, i8 }

@mu_____string272 = 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

; 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) #3

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

; Function Attrs: nounwind uwtable
declare dso_local { ptr, ptr } @TypeChecker__checkExpression__(ptr noundef, i32, ptr) #3

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__checkIfStatement__(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.tag_____Tag__, align 8
  %6 = alloca i8, align 1
  %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 ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.tag_____IfStatement__, ptr %13, i32 0, i32 1
  %15 = getelementptr inbounds { i32, ptr }, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8
  %17 = getelementptr inbounds { i32, ptr }, ptr %14, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8
  %19 = call { ptr, ptr } @TypeChecker__checkExpression__(ptr noundef %12, i32 %16, ptr %18)
  %20 = getelementptr inbounds { ptr, ptr }, ptr %5, i32 0, i32 0
  %21 = extractvalue { ptr, ptr } %19, 0
  store ptr %21, ptr %20, align 8
  %22 = getelementptr inbounds { ptr, ptr }, ptr %5, i32 0, i32 1
  %23 = extractvalue { ptr, ptr } %19, 1
  store ptr %23, ptr %22, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #4
  %24 = getelementptr inbounds %struct.tag_____Tag__, ptr %5, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = icmp ne ptr %25, null
  %27 = zext i1 %26 to i32
  %28 = trunc i32 %27 to i8
  store i8 %28, ptr %6, align 1, !tbaa !11
  %29 = load i8, ptr %6, align 1, !tbaa !11
  %30 = icmp ne i8 %29, 0
  br i1 %30, label %31, label %40

31:                                               ; preds = %2
  %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 3
  %35 = load i32, ptr %34, align 4, !tbaa !12
  %36 = and i32 %35, 8
  %37 = icmp eq i32 %36, 0
  %38 = zext i1 %37 to i32
  %39 = trunc i32 %38 to i8
  store i8 %39, ptr %6, align 1, !tbaa !11
  br label %40

40:                                               ; preds = %31, %2
  %41 = load i8, ptr %6, align 1, !tbaa !11
  %42 = icmp ne i8 %41, 0
  br i1 %42, label %43, label %60

43:                                               ; preds = %40
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !16
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %47, i32 0, i32 5
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.tag_____IfStatement__, ptr %50, i32 0, i32 1
  %52 = getelementptr inbounds { i32, ptr }, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 8
  %54 = getelementptr inbounds { i32, ptr }, ptr %51, i32 0, i32 1
  %55 = load ptr, ptr %54, align 8
  %56 = call i64 @RangeFinder__find__(i32 %53, ptr %55)
  store i64 %56, ptr %8, align 4
  %57 = load i64, ptr %8, align 4
  %58 = load ptr, ptr @mu_____string272, align 8
  %59 = load i32, ptr getelementptr inbounds ({ ptr, i32 }, ptr @mu_____string272, i32 0, i32 1), align 8
  call void @Error__at__(ptr dead_on_unwind writable sret(%struct.tag_____Error__) align 8 %7, ptr noundef %49, i64 %57, ptr %58, i32 %59)
  call void @List__add__Error____(ptr noundef %46, ptr noundef byval(%struct.tag_____Error__) align 8 %7)
  br label %60

60:                                               ; preds = %43, %40
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.tag_____IfStatement__, ptr %61, i32 0, i32 3
  %63 = load ptr, ptr %62, align 8, !tbaa !19
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %70

65:                                               ; preds = %60
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.tag_____IfStatement__, ptr %67, i32 0, i32 3
  %69 = load ptr, ptr %68, align 8, !tbaa !19
  call void @TypeChecker__checkBlockStatement__(ptr noundef %66, ptr noundef %69)
  br label %70

70:                                               ; preds = %65, %60
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.tag_____IfStatement__, ptr %71, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %72, i64 16, i1 false), !tbaa.struct !22
  %73 = getelementptr inbounds %struct.Node__, ptr %9, i32 0, i32 0
  %74 = load i32, ptr %73, align 8, !tbaa !24
  switch i32 %74, label %86 [
    i32 25, label %75
    i32 5, label %80
    i32 0, label %85
  ]

75:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %76 = getelementptr inbounds %struct.Node__, ptr %9, i32 0, i32 1
  %77 = load ptr, ptr %76, align 8, !tbaa !25
  store ptr %77, ptr %10, align 8, !tbaa !5
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = load ptr, ptr %10, align 8, !tbaa !5
  call void @TypeChecker__checkIfStatement__(ptr noundef %78, ptr noundef %79)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %89

80:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %81 = getelementptr inbounds %struct.Node__, ptr %9, i32 0, i32 1
  %82 = load ptr, ptr %81, align 8, !tbaa !25
  store ptr %82, ptr %11, align 8, !tbaa !5
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = load ptr, ptr %11, align 8, !tbaa !5
  call void @TypeChecker__checkBlockStatement__(ptr noundef %83, ptr noundef %84)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %89

85:                                               ; preds = %70
  br label %89

86:                                               ; preds = %70
  %87 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %88 = load ptr, ptr %87, align 8, !tbaa !5
  call void %88(i32 noundef -5)
  br label %89

89:                                               ; preds = %86, %85, %80, %75
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @TypeChecker__checkBlockStatement__(ptr noundef, ptr noundef) #3

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: readwrite) }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"tag_____Tag__", !6, i64 0, !6, i64 8}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !15, i64 28}
!13 = !{!"tag_____Namespace__", !14, i64 0, !6, i64 16, !15, i64 24, !15, i64 28, !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, !15, i64 104}
!14 = !{!"", !6, i64 0, !15, i64 8}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !6, i64 16}
!17 = !{!"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, !15, i64 120, !15, i64 124, !6, i64 128, !15, i64 136, !7, i64 140}
!18 = !{!17, !6, i64 40}
!19 = !{!20, !6, i64 32}
!20 = !{!"tag_____IfStatement__", !6, i64 0, !21, i64 8, !6, i64 24, !6, i64 32, !6, i64 40, !21, i64 48}
!21 = !{!"", !15, i64 0, !6, i64 8}
!22 = !{i64 0, i64 4, !23, i64 8, i64 8, !5}
!23 = !{!15, !15, i64 0}
!24 = !{!21, !15, i64 0}
!25 = !{!21, !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 }

@mu_____string272 = external dso_local local_unnamed_addr global %struct.string__, align 8
@top_____abandonFn__ = external dso_local thread_local local_unnamed_addr global ptr, align 8

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

; 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
declare dso_local i64 @RangeFinder__find__(i32, ptr) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local { ptr, ptr } @TypeChecker__checkExpression__(ptr noundef, i32, ptr) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__checkIfStatement__(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = alloca %struct.tag_____Error__, align 8
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load i32, ptr %4, align 8
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = load ptr, ptr %6, align 8
  %8 = tail call { ptr, ptr } @TypeChecker__checkExpression__(ptr noundef %0, i32 %5, ptr %7)
  %9 = extractvalue { ptr, ptr } %8, 0
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %.critedge, label %10

10:                                               ; preds = %2
  %11 = getelementptr inbounds i8, ptr %9, i64 28
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = and i32 %12, 8
  %.not23 = icmp eq i32 %13, 0
  br i1 %.not23, label %14, label %.critedge

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %19 = load i32, ptr %4, align 8
  %20 = load ptr, ptr %6, align 8
  %21 = tail call i64 @RangeFinder__find__(i32 %19, ptr %20)
  %22 = load ptr, ptr @mu_____string272, align 8
  %23 = load i32, ptr getelementptr inbounds (i8, ptr @mu_____string272, i64 8), align 8
  call void @Error__at__(ptr dead_on_unwind nonnull writable sret(%struct.tag_____Error__) align 8 %3, ptr noundef %18, i64 %21, ptr %22, i32 %23)
  call void @List__add__Error____(ptr noundef %16, ptr noundef nonnull byval(%struct.tag_____Error__) align 8 %3)
  br label %.critedge

.critedge:                                        ; preds = %2, %14, %10
  %24 = getelementptr inbounds i8, ptr %1, i64 32
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %.not22 = icmp eq ptr %25, null
  br i1 %.not22, label %27, label %26

26:                                               ; preds = %.critedge
  call void @TypeChecker__checkBlockStatement__(ptr noundef %0, ptr noundef nonnull %25)
  br label %27

27:                                               ; preds = %26, %.critedge
  %28 = getelementptr inbounds i8, ptr %1, i64 48
  %.sroa.0.0.copyload = load i32, ptr %28, align 8, !tbaa !18
  %.sroa.42.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 56
  %.sroa.42.0.copyload = load ptr, ptr %.sroa.42.0..sroa_idx, align 8, !tbaa !19
  switch i32 %.sroa.0.0.copyload, label %31 [
    i32 25, label %29
    i32 5, label %30
    i32 0, label %34
  ]

29:                                               ; preds = %27
  call void @TypeChecker__checkIfStatement__(ptr noundef %0, ptr noundef %.sroa.42.0.copyload)
  br label %34

30:                                               ; preds = %27
  call void @TypeChecker__checkBlockStatement__(ptr noundef %0, ptr noundef %.sroa.42.0.copyload)
  br label %34

31:                                               ; preds = %27
  %32 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @top_____abandonFn__)
  %33 = load ptr, ptr %32, align 8, !tbaa !19
  call void %33(i32 noundef -5) #2
  br label %34

34:                                               ; preds = %27, %31, %30, %29
  ret void
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !11, i64 28}
!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}
!12 = !{!13, !8, i64 16}
!13 = !{!"tag_____TypeCheckerContext__", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !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, !8, i64 104, !8, i64 112, !11, i64 120, !11, i64 124, !8, i64 128, !11, i64 136, !9, i64 140}
!14 = !{!13, !8, i64 40}
!15 = !{!16, !8, i64 32}
!16 = !{!"tag_____IfStatement__", !8, i64 0, !17, i64 8, !8, i64 24, !8, i64 32, !8, i64 40, !17, i64 48}
!17 = !{!"", !11, i64 0, !8, i64 8}
!18 = !{!11, !11, i64 0}
!19 = !{!8, !8, i64 0}


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