; 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.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 }

@.str.90 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.98 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.99 = external hidden unnamed_addr constant [3 x i8], align 1

; 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
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local void @RulePrint(ptr noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.rule, ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = getelementptr inbounds %struct.symbol, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef @.str.98, ptr noundef %15) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %88, %3
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.rule, ptr %19, i32 0, i32 4
  %21 = load i32, ptr %20, align 8, !tbaa !15
  %22 = icmp sle i32 %18, %21
  br i1 %22, label %23, label %91

23:                                               ; preds = %17
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = icmp eq i32 %24, %25
  br i1 %26, label %27, label %30

27:                                               ; preds = %23
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.99) #3
  br label %30

30:                                               ; preds = %27, %23
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.rule, ptr %32, i32 0, i32 4
  %34 = load i32, ptr %33, align 8, !tbaa !15
  %35 = icmp eq i32 %31, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  br label %91

37:                                               ; preds = %30
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.rule, ptr %38, i32 0, i32 5
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds ptr, ptr %40, i64 %42
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  store ptr %44, ptr %7, align 8, !tbaa !5
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.symbol, ptr %45, i32 0, i32 2
  %47 = load i32, ptr %46, align 4, !tbaa !17
  %48 = icmp eq i32 %47, 2
  br i1 %48, label %49, label %81

49:                                               ; preds = %37
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.symbol, ptr %51, i32 0, i32 16
  %53 = load ptr, ptr %52, align 8, !tbaa !18
  %54 = getelementptr inbounds ptr, ptr %53, i64 0
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.symbol, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !13
  %58 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef @.str.90, ptr noundef %57) #3
  store i32 1, ptr %9, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %77, %49
  %60 = load i32, ptr %9, align 4, !tbaa !9
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.symbol, ptr %61, i32 0, i32 15
  %63 = load i32, ptr %62, align 8, !tbaa !19
  %64 = icmp slt i32 %60, %63
  br i1 %64, label %65, label %80

65:                                               ; preds = %59
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.symbol, ptr %67, i32 0, i32 16
  %69 = load ptr, ptr %68, align 8, !tbaa !18
  %70 = load i32, ptr %9, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds ptr, ptr %69, i64 %71
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.symbol, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !13
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef @.str.91, ptr noundef %75) #3
  br label %77

77:                                               ; preds = %65
  %78 = load i32, ptr %9, align 4, !tbaa !9
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %9, align 4, !tbaa !9
  br label %59, !llvm.loop !20

80:                                               ; preds = %59
  br label %87

81:                                               ; preds = %37
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.symbol, ptr %83, i32 0, i32 0
  %85 = load ptr, ptr %84, align 8, !tbaa !13
  %86 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %82, ptr noundef @.str.90, ptr noundef %85) #3
  br label %87

87:                                               ; preds = %81, %80
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %8, align 4, !tbaa !9
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %8, align 4, !tbaa !9
  br label %17, !llvm.loop !22

91:                                               ; preds = %36, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 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 #3 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"rule", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !6, i64 120, !6, i64 128}
!13 = !{!14, !6, i64 0}
!14 = !{!"symbol", !6, i64 0, !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !6, i64 40, !10, i64 48, !10, i64 52, !6, i64 56, !10, i64 64, !6, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !6, i64 96}
!15 = !{!12, !10, i64 24}
!16 = !{!12, !6, i64 32}
!17 = !{!14, !10, i64 12}
!18 = !{!14, !6, i64 96}
!19 = !{!14, !10, i64 88}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


; 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"

@.str.90 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.98 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.99 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local void @RulePrint(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  %6 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.98, ptr noundef %5) #2
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = load i32, ptr %7, align 8, !tbaa !13
  %.not24 = icmp slt i32 %8, 0
  br i1 %.not24, label %._crit_edge, label %.lr.ph26

.lr.ph26:                                         ; preds = %3
  %9 = getelementptr inbounds i8, ptr %1, i64 32
  %10 = zext i32 %2 to i64
  br label %11

11:                                               ; preds = %.lr.ph26, %.loopexit
  %12 = phi i32 [ %8, %.lr.ph26 ], [ %47, %.loopexit ]
  %indvars.iv29 = phi i64 [ 0, %.lr.ph26 ], [ %indvars.iv.next30, %.loopexit ]
  %13 = icmp eq i64 %indvars.iv29, %10
  br i1 %13, label %14, label %16

14:                                               ; preds = %11
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.99) #2
  %.pre = load i32, ptr %7, align 8, !tbaa !13
  br label %16

16:                                               ; preds = %14, %11
  %17 = phi i32 [ %.pre, %14 ], [ %12, %11 ]
  %18 = zext i32 %17 to i64
  %19 = icmp eq i64 %indvars.iv29, %18
  br i1 %19, label %._crit_edge, label %20

20:                                               ; preds = %16
  %21 = load ptr, ptr %9, align 8, !tbaa !14
  %22 = getelementptr inbounds ptr, ptr %21, i64 %indvars.iv29
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = getelementptr inbounds i8, ptr %23, i64 12
  %25 = load i32, ptr %24, align 4, !tbaa !16
  %26 = icmp eq i32 %25, 2
  br i1 %26, label %27, label %44

27:                                               ; preds = %20
  %28 = getelementptr inbounds i8, ptr %23, i64 96
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.90, ptr noundef %31) #2
  %33 = getelementptr inbounds i8, ptr %23, i64 88
  %34 = load i32, ptr %33, align 8, !tbaa !18
  %35 = icmp sgt i32 %34, 1
  br i1 %35, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %27, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %27 ]
  %36 = load ptr, ptr %28, align 8, !tbaa !17
  %37 = getelementptr inbounds ptr, ptr %36, i64 %indvars.iv
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.91, ptr noundef %39) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %41 = load i32, ptr %33, align 8, !tbaa !18
  %42 = sext i32 %41 to i64
  %43 = icmp slt i64 %indvars.iv.next, %42
  br i1 %43, label %.lr.ph, label %.loopexit, !llvm.loop !19

44:                                               ; preds = %20
  %45 = load ptr, ptr %23, align 8, !tbaa !11
  %46 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.90, ptr noundef %45) #2
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %27, %44
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %47 = load i32, ptr %7, align 8, !tbaa !13
  %48 = sext i32 %47 to i64
  %.not.not = icmp slt i64 %indvars.iv29, %48
  br i1 %.not.not, label %11, label %._crit_edge, !llvm.loop !21

._crit_edge:                                      ; preds = %.loopexit, %16, %3
  ret void
}

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


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