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

; 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.tag_____WhileStatement__ = type { ptr, %struct.Node__, ptr, ptr }
%struct.Node__ = type { i32, ptr }
%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

; 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 void @List__add__Error____(ptr noundef, ptr noundef byval(%struct.tag_____Error__) align 8) #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) #1

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

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

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

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

28:                                               ; preds = %2
  %29 = getelementptr inbounds %struct.tag_____Tag__, ptr %5, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.tag_____Namespace__, ptr %30, i32 0, i32 3
  %32 = load i32, ptr %31, align 4, !tbaa !12
  %33 = and i32 %32, 8
  %34 = icmp eq i32 %33, 0
  %35 = zext i1 %34 to i32
  %36 = trunc i32 %35 to i8
  store i8 %36, ptr %6, align 1, !tbaa !11
  br label %37

37:                                               ; preds = %28, %2
  %38 = load i8, ptr %6, align 1, !tbaa !11
  %39 = icmp ne i8 %38, 0
  br i1 %39, label %40, label %57

40:                                               ; preds = %37
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !16
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %44, i32 0, i32 5
  %46 = load ptr, ptr %45, align 8, !tbaa !18
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.tag_____WhileStatement__, ptr %47, i32 0, i32 1
  %49 = getelementptr inbounds { i32, ptr }, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 8
  %51 = getelementptr inbounds { i32, ptr }, ptr %48, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8
  %53 = call i64 @RangeFinder__find__(i32 %50, ptr %52)
  store i64 %53, ptr %8, align 4
  %54 = load i64, ptr %8, align 4
  %55 = load ptr, ptr @mu_____string272, align 8
  %56 = 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 %46, i64 %54, ptr %55, i32 %56)
  call void @List__add__Error____(ptr noundef %43, ptr noundef byval(%struct.tag_____Error__) align 8 %7)
  br label %57

57:                                               ; preds = %40, %37
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.tag_____WhileStatement__, ptr %58, i32 0, i32 3
  %60 = load ptr, ptr %59, align 8, !tbaa !19
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %79

62:                                               ; preds = %57
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %63, i32 0, i32 15
  %65 = load i32, ptr %64, align 8, !tbaa !22
  %66 = add nsw i32 %65, 1
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %67, i32 0, i32 15
  store i32 %66, ptr %68, align 8, !tbaa !22
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.tag_____WhileStatement__, ptr %70, i32 0, i32 3
  %72 = load ptr, ptr %71, align 8, !tbaa !19
  call void @TypeChecker__checkBlockStatement__(ptr noundef %69, ptr noundef %72)
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %73, i32 0, i32 15
  %75 = load i32, ptr %74, align 8, !tbaa !22
  %76 = sub nsw i32 %75, 1
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.tag_____TypeCheckerContext__, ptr %77, i32 0, i32 15
  store i32 %76, ptr %78, align 8, !tbaa !22
  br label %79

79:                                               ; preds = %62, %57
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #2
  ret void
}

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, !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_____WhileStatement__", !6, i64 0, !21, i64 8, !6, i64 24, !6, i64 32}
!21 = !{!"", !15, i64 0, !6, i64 8}
!22 = !{!17, !15, i64 120}


; 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

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

; 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 #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @TypeChecker__checkWhileStatement__(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %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
  %.not18 = icmp eq i32 %13, 0
  br i1 %.not18, 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
  %.not17 = icmp eq ptr %25, null
  br i1 %.not17, label %32, label %26

26:                                               ; preds = %.critedge
  %27 = getelementptr inbounds i8, ptr %0, i64 120
  %28 = load i32, ptr %27, align 8, !tbaa !18
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %27, align 8, !tbaa !18
  call void @TypeChecker__checkBlockStatement__(ptr noundef %0, ptr noundef nonnull %25)
  %30 = load i32, ptr %27, align 8, !tbaa !18
  %31 = add nsw i32 %30, -1
  store i32 %31, ptr %27, align 8, !tbaa !18
  br label %32

32:                                               ; preds = %26, %.critedge
  ret void
}

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, !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_____WhileStatement__", !8, i64 0, !17, i64 8, !8, i64 24, !8, i64 32}
!17 = !{!"", !11, i64 0, !8, i64 8}
!18 = !{!13, !11, i64 120}


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