; LLVM IR from sysprog21/shecc :: src (ssa)

; 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.block = type { [1600 x %struct.var], i32, ptr, ptr, ptr, i32, ptr }
%struct.var = type { [32 x i8], [32 x i8], i32, i8, i8, i32, i32, i32, i32, i32, ptr, i32, [64 x ptr], i32, %struct.rename_t, %struct.ref_block_list, ptr, ptr, ptr, i32, i8, i8, i8 }
%struct.rename_t = type { i32, [64 x i32], i32 }
%struct.ref_block_list = type { ptr, ptr }
%struct.func = type { %struct.var, [8 x %struct.var], i32, i32, i32, ptr, ptr, %struct.symbol_list_t, i32, i32, ptr }
%struct.symbol_list_t = type { ptr, ptr }

; 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 i1 @var_check_in_scope(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.block, ptr %11, i32 0, i32 3
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %13, ptr %6, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %45, %2
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %49

17:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !12
  br label %18

18:                                               ; preds = %40, %17
  %19 = load i32, ptr %7, align 4, !tbaa !12
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.block, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 8, !tbaa !13
  %23 = icmp slt i32 %19, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %18
  store i32 4, ptr %8, align 4
  br label %43

25:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.block, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds [1600 x %struct.var], ptr %27, i64 0, i64 0
  store ptr %28, ptr %9, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = load i32, ptr %7, align 4, !tbaa !12
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds %struct.var, ptr %30, i64 %32
  %34 = icmp eq ptr %29, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %25
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %37

36:                                               ; preds = %25
  store i32 0, ptr %8, align 4
  br label %37

37:                                               ; preds = %36, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  %38 = load i32, ptr %8, align 4
  switch i32 %38, label %43 [
    i32 0, label %39
  ]

39:                                               ; preds = %37
  br label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %7, align 4, !tbaa !12
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %7, align 4, !tbaa !12
  br label %18, !llvm.loop !14

43:                                               ; preds = %37, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  %44 = load i32, ptr %8, align 4
  switch i32 %44, label %73 [
    i32 4, label %45
  ]

45:                                               ; preds = %43
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.block, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  store ptr %48, ptr %5, align 8, !tbaa !5
  br label %14, !llvm.loop !17

49:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  store i32 0, ptr %10, align 4, !tbaa !12
  br label %50

50:                                               ; preds = %67, %49
  %51 = load i32, ptr %10, align 4, !tbaa !12
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.func, ptr %52, i32 0, i32 2
  %54 = load i32, ptr %53, align 8, !tbaa !18
  %55 = icmp slt i32 %51, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %50
  store i32 7, ptr %8, align 4
  br label %70

57:                                               ; preds = %50
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.func, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %10, align 4, !tbaa !12
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [8 x %struct.var], ptr %59, i64 0, i64 %61
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = icmp eq ptr %62, %63
  br i1 %64, label %65, label %66

65:                                               ; preds = %57
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %70

66:                                               ; preds = %57
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %10, align 4, !tbaa !12
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %10, align 4, !tbaa !12
  br label %50, !llvm.loop !25

70:                                               ; preds = %65, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  %71 = load i32, ptr %8, align 4
  switch i32 %71, label %73 [
    i32 7, label %72
  ]

72:                                               ; preds = %70
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %73

73:                                               ; preds = %72, %70, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %74 = load i1, ptr %3, align 1
  ret i1 %74
}

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 1510416}
!10 = !{!"block", !7, i64 0, !11, i64 1510400, !6, i64 1510408, !6, i64 1510416, !6, i64 1510424, !11, i64 1510432, !6, i64 1510440}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 1510400}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !6, i64 1510408}
!17 = distinct !{!17, !15}
!18 = !{!19, !11, i64 8496}
!19 = !{!"func", !20, i64 0, !7, i64 944, !11, i64 8496, !11, i64 8500, !11, i64 8504, !6, i64 8512, !6, i64 8520, !24, i64 8528, !11, i64 8544, !11, i64 8548, !6, i64 8552}
!20 = !{!"var", !7, i64 0, !7, i64 32, !11, i64 64, !21, i64 68, !21, i64 69, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !6, i64 96, !11, i64 104, !7, i64 112, !11, i64 624, !22, i64 628, !23, i64 896, !6, i64 912, !6, i64 920, !6, i64 928, !11, i64 936, !21, i64 940, !21, i64 941, !21, i64 942}
!21 = !{!"_Bool", !7, i64 0}
!22 = !{!"", !11, i64 0, !7, i64 4, !11, i64 260}
!23 = !{!"ref_block_list", !6, i64 0, !6, i64 8}
!24 = !{!"", !6, i64 0, !6, i64 8}
!25 = distinct !{!25, !15}


; 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.var = type { [32 x i8], [32 x i8], i32, i8, i8, i32, i32, i32, i32, i32, ptr, i32, [64 x ptr], i32, %struct.rename_t, %struct.ref_block_list, ptr, ptr, ptr, i32, i8, i8, i8 }
%struct.rename_t = type { i32, [64 x i32], i32 }
%struct.ref_block_list = type { ptr, ptr }

; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local zeroext i1 @var_check_in_scope(ptr noundef readnone %0, ptr noundef readonly %1) local_unnamed_addr #0 {
.preheader34.preheader:
  %2 = getelementptr inbounds i8, ptr %1, i64 1510416
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  br label %.preheader34

.preheader34:                                     ; preds = %.preheader34.preheader, %.critedge
  %.02639 = phi ptr [ %13, %.critedge ], [ %1, %.preheader34.preheader ]
  %4 = getelementptr inbounds i8, ptr %.02639, i64 1510400
  %5 = load i32, ptr %4, align 8, !tbaa !11
  %.not2936 = icmp sgt i32 %5, 0
  br i1 %.not2936, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %.preheader34
  %wide.trip.count = zext nneg i32 %5 to i64
  br label %.lr.ph

.preheader:                                       ; preds = %.critedge
  %6 = getelementptr inbounds i8, ptr %3, i64 8496
  %7 = load i32, ptr %6, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %3, i64 944
  %9 = sext i32 %7 to i64
  br label %14

10:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.critedge, label %.lr.ph, !llvm.loop !19

.lr.ph:                                           ; preds = %.lr.ph.preheader, %10
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %10 ]
  %11 = getelementptr inbounds %struct.var, ptr %.02639, i64 %indvars.iv
  %.not28 = icmp eq ptr %11, %0
  br i1 %.not28, label %.loopexit, label %10

.critedge:                                        ; preds = %10, %.preheader34
  %12 = getelementptr inbounds i8, ptr %.02639, i64 1510408
  %13 = load ptr, ptr %12, align 8, !tbaa !21
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %.preheader, label %.preheader34, !llvm.loop !22

14:                                               ; preds = %14, %.preheader
  %indvars.iv42 = phi i64 [ %indvars.iv.next43, %14 ], [ 0, %.preheader ]
  %.not27 = icmp slt i64 %indvars.iv42, %9
  %15 = getelementptr inbounds [8 x %struct.var], ptr %8, i64 0, i64 %indvars.iv42
  %16 = icmp ne ptr %15, %0
  %or.cond.not = select i1 %.not27, i1 %16, i1 false
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  br i1 %or.cond.not, label %14, label %.loopexit, !llvm.loop !23

.loopexit:                                        ; preds = %.lr.ph, %14
  %.5 = phi i1 [ %.not27, %14 ], [ true, %.lr.ph ]
  ret i1 %.5
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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, !10, i64 1510416}
!6 = !{!"block", !7, i64 0, !9, i64 1510400, !10, i64 1510408, !10, i64 1510416, !10, i64 1510424, !9, i64 1510432, !10, i64 1510440}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!6, !9, i64 1510400}
!12 = !{!13, !9, i64 8496}
!13 = !{!"func", !14, i64 0, !7, i64 944, !9, i64 8496, !9, i64 8500, !9, i64 8504, !10, i64 8512, !10, i64 8520, !18, i64 8528, !9, i64 8544, !9, i64 8548, !10, i64 8552}
!14 = !{!"var", !7, i64 0, !7, i64 32, !9, i64 64, !15, i64 68, !15, i64 69, !9, i64 72, !9, i64 76, !9, i64 80, !9, i64 84, !9, i64 88, !10, i64 96, !9, i64 104, !7, i64 112, !9, i64 624, !16, i64 628, !17, i64 896, !10, i64 912, !10, i64 920, !10, i64 928, !9, i64 936, !15, i64 940, !15, i64 941, !15, i64 942}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!"", !9, i64 0, !7, i64 4, !9, i64 260}
!17 = !{!"ref_block_list", !10, i64 0, !10, i64 8}
!18 = !{!"", !10, i64 0, !10, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!6, !10, i64 1510408}
!22 = distinct !{!22, !20}
!23 = distinct !{!23, !20}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass