; LLVM IR from musetronstar/tagd :: tagl/src (lemon)

; 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.lemon = type { ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, ptr }
%struct.rule = type { ptr, ptr, i32, i32, i32, ptr, ptr, i32, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i32, ptr, ptr }
%struct.symbol = type { ptr, i32, i32, ptr, ptr, i32, i32, ptr, i32, i32, ptr, i32, ptr, i32, i32, i32, 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 void @FindRulePrecedences(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.lemon, ptr %7, i32 0, i32 1
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %9, ptr %3, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %99, %1
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %103

13:                                               ; preds = %10
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.rule, ptr %14, i32 0, i32 11
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %98

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

19:                                               ; preds = %94, %18
  %20 = load i32, ptr %4, align 4, !tbaa !14
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.rule, ptr %21, i32 0, i32 4
  %23 = load i32, ptr %22, align 8, !tbaa !15
  %24 = icmp slt i32 %20, %23
  br i1 %24, label %25, label %30

25:                                               ; preds = %19
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.rule, ptr %26, i32 0, i32 11
  %28 = load ptr, ptr %27, align 8, !tbaa !12
  %29 = icmp eq ptr %28, null
  br label %30

30:                                               ; preds = %25, %19
  %31 = phi i1 [ false, %19 ], [ %29, %25 ]
  br i1 %31, label %32, label %97

32:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.rule, ptr %33, i32 0, i32 5
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  %36 = load i32, ptr %4, align 4, !tbaa !14
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds ptr, ptr %35, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  store ptr %39, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.symbol, ptr %40, i32 0, i32 2
  %42 = load i32, ptr %41, align 4, !tbaa !17
  %43 = icmp eq i32 %42, 2
  br i1 %43, label %44, label %77

44:                                               ; preds = %32
  store i32 0, ptr %5, align 4, !tbaa !14
  br label %45

45:                                               ; preds = %73, %44
  %46 = load i32, ptr %5, align 4, !tbaa !14
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.symbol, ptr %47, i32 0, i32 15
  %49 = load i32, ptr %48, align 8, !tbaa !19
  %50 = icmp slt i32 %46, %49
  br i1 %50, label %51, label %76

51:                                               ; preds = %45
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.symbol, ptr %52, i32 0, i32 16
  %54 = load ptr, ptr %53, align 8, !tbaa !20
  %55 = load i32, ptr %5, align 4, !tbaa !14
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds ptr, ptr %54, i64 %56
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.symbol, ptr %58, i32 0, i32 5
  %60 = load i32, ptr %59, align 8, !tbaa !21
  %61 = icmp sge i32 %60, 0
  br i1 %61, label %62, label %72

62:                                               ; preds = %51
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.symbol, ptr %63, i32 0, i32 16
  %65 = load ptr, ptr %64, align 8, !tbaa !20
  %66 = load i32, ptr %5, align 4, !tbaa !14
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds ptr, ptr %65, i64 %67
  %69 = load ptr, ptr %68, align 8, !tbaa !5
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.rule, ptr %70, i32 0, i32 11
  store ptr %69, ptr %71, align 8, !tbaa !12
  br label %76

72:                                               ; preds = %51
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %5, align 4, !tbaa !14
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %5, align 4, !tbaa !14
  br label %45, !llvm.loop !22

76:                                               ; preds = %62, %45
  br label %93

77:                                               ; preds = %32
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.symbol, ptr %78, i32 0, i32 5
  %80 = load i32, ptr %79, align 8, !tbaa !21
  %81 = icmp sge i32 %80, 0
  br i1 %81, label %82, label %92

82:                                               ; preds = %77
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.rule, ptr %83, i32 0, i32 5
  %85 = load ptr, ptr %84, align 8, !tbaa !16
  %86 = load i32, ptr %4, align 4, !tbaa !14
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds ptr, ptr %85, i64 %87
  %89 = load ptr, ptr %88, align 8, !tbaa !5
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.rule, ptr %90, i32 0, i32 11
  store ptr %89, ptr %91, align 8, !tbaa !12
  br label %92

92:                                               ; preds = %82, %77
  br label %93

93:                                               ; preds = %92, %76
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %94

94:                                               ; preds = %93
  %95 = load i32, ptr %4, align 4, !tbaa !14
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %4, align 4, !tbaa !14
  br label %19, !llvm.loop !24

97:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %98

98:                                               ; preds = %97, %13
  br label %99

99:                                               ; preds = %98
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.rule, ptr %100, i32 0, i32 20
  %102 = load ptr, ptr %101, align 8, !tbaa !25
  store ptr %102, ptr %3, align 8, !tbaa !5
  br label %10, !llvm.loop !26

103:                                              ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #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 8}
!10 = !{!"lemon", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !6, i64 72, !11, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !11, i64 248, !11, i64 252, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !6, i64 280}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 80}
!13 = !{!"rule", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !6, i64 120, !6, i64 128}
!14 = !{!11, !11, i64 0}
!15 = !{!13, !11, i64 24}
!16 = !{!13, !6, i64 32}
!17 = !{!18, !11, i64 12}
!18 = !{!"symbol", !6, i64 0, !11, i64 8, !11, i64 12, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !6, i64 40, !11, i64 48, !11, i64 52, !6, i64 56, !11, i64 64, !6, i64 72, !11, i64 80, !11, i64 84, !11, i64 88, !6, i64 96}
!19 = !{!18, !11, i64 88}
!20 = !{!18, !6, i64 96}
!21 = !{!18, !11, i64 32}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}
!25 = !{!13, !6, i64 128}
!26 = distinct !{!26, !23}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @FindRulePrecedences(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %.029 = load ptr, ptr %2, align 8, !tbaa !5
  %.not30 = icmp eq ptr %.029, null
  br i1 %.not30, label %._crit_edge, label %.lr.ph33

.lr.ph33:                                         ; preds = %1, %.critedge
  %.031 = phi ptr [ %.0, %.critedge ], [ %.029, %1 ]
  %3 = getelementptr inbounds i8, ptr %.031, i64 80
  %4 = load ptr, ptr %3, align 8, !tbaa !9
  %5 = icmp eq ptr %4, null
  br i1 %5, label %.preheader24, label %.critedge

.preheader24:                                     ; preds = %.lr.ph33
  %6 = getelementptr inbounds i8, ptr %.031, i64 24
  %7 = load i32, ptr %6, align 8, !tbaa !12
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph27, label %.critedge

.lr.ph27:                                         ; preds = %.preheader24
  %9 = getelementptr inbounds i8, ptr %.031, i64 32
  %wide.trip.count39 = zext nneg i32 %7 to i64
  br label %10

10:                                               ; preds = %.lr.ph27, %.loopexit
  %indvars.iv36 = phi i64 [ 0, %.lr.ph27 ], [ %indvars.iv.next37, %.loopexit ]
  %11 = phi ptr [ null, %.lr.ph27 ], [ %36, %.loopexit ]
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %.critedge

13:                                               ; preds = %10
  %14 = load ptr, ptr %9, align 8, !tbaa !13
  %15 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv36
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 12
  %18 = load i32, ptr %17, align 4, !tbaa !14
  %19 = icmp eq i32 %18, 2
  br i1 %19, label %.preheader, label %32

.preheader:                                       ; preds = %13
  %20 = getelementptr inbounds i8, ptr %16, i64 88
  %21 = load i32, ptr %20, align 8, !tbaa !16
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %23 = getelementptr inbounds i8, ptr %16, i64 96
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %wide.trip.count = zext nneg i32 %21 to i64
  br label %26

25:                                               ; preds = %26
  %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 %.loopexit, label %26, !llvm.loop !18

26:                                               ; preds = %.lr.ph, %25
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %25 ]
  %27 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 32
  %30 = load i32, ptr %29, align 8, !tbaa !20
  %31 = icmp sgt i32 %30, -1
  br i1 %31, label %.loopexit.sink.split, label %25

32:                                               ; preds = %13
  %33 = getelementptr inbounds i8, ptr %16, i64 32
  %34 = load i32, ptr %33, align 8, !tbaa !20
  %35 = icmp sgt i32 %34, -1
  br i1 %35, label %.loopexit.sink.split, label %.loopexit

.loopexit.sink.split:                             ; preds = %26, %32
  %.sink = phi ptr [ %16, %32 ], [ %28, %26 ]
  store ptr %.sink, ptr %3, align 8, !tbaa !9
  br label %.loopexit

.loopexit:                                        ; preds = %25, %.loopexit.sink.split, %.preheader, %32
  %36 = phi ptr [ null, %32 ], [ null, %.preheader ], [ %.sink, %.loopexit.sink.split ], [ null, %25 ]
  %indvars.iv.next37 = add nuw nsw i64 %indvars.iv36, 1
  %exitcond40.not = icmp eq i64 %indvars.iv.next37, %wide.trip.count39
  br i1 %exitcond40.not, label %.critedge, label %10, !llvm.loop !21

.critedge:                                        ; preds = %.loopexit, %10, %.preheader24, %.lr.ph33
  %37 = getelementptr inbounds i8, ptr %.031, i64 128
  %.0 = load ptr, ptr %37, align 8, !tbaa !5
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge, label %.lr.ph33, !llvm.loop !22

._crit_edge:                                      ; preds = %.critedge, %1
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 80}
!10 = !{!"rule", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !11, i64 112, !6, i64 120, !6, i64 128}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 24}
!13 = !{!10, !6, i64 32}
!14 = !{!15, !11, i64 12}
!15 = !{!"symbol", !6, i64 0, !11, i64 8, !11, i64 12, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !6, i64 40, !11, i64 48, !11, i64 52, !6, i64 56, !11, i64 64, !6, i64 72, !11, i64 80, !11, i64 84, !11, i64 88, !6, i64 96}
!16 = !{!15, !11, i64 88}
!17 = !{!15, !6, i64 96}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!15, !11, i64 32}
!21 = distinct !{!21, !19}
!22 = distinct !{!22, !19}


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