; LLVM IR from snowballstem/snowball :: compiler (generator)

; 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.node = type { ptr, ptr, ptr, ptr, ptr, i8, i8, i8, ptr, ptr, ptr, i32, i32, i32 }
%struct.generator = type { ptr, ptr, i32, i32, ptr, ptr, i32, i32, i32, ptr, i32, i32, i32, i32, [10 x ptr], [10 x ptr], [10 x i32], [5 x ptr], [5 x ptr], i32, i32, i32, i32, i32 }
%struct.analyser = type { ptr, ptr, ptr, ptr, i8, i8, ptr, ptr, [6 x i32], ptr, ptr, i32, i32, i32, ptr, ptr, ptr, i32, i8 }
%struct.tokeniser = type { ptr, ptr, i32, ptr, i32, i32, ptr, ptr, i32, i32, i32, ptr, i32, i32, i32, i32, i8, i8, i32, i32, ptr, i32, [94 x i8] }

@stderr = external global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [13 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 i32 @check_possible_signals_list(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %69, %4
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %70

16:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = call i32 @check_possible_signals(ptr noundef %17, ptr noundef %18, i32 noundef %19)
  store i32 %20, ptr %11, align 4, !tbaa !9
  %21 = load i32, ptr %11, align 4, !tbaa !9
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %58

23:                                               ; preds = %16
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.node, ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %56

28:                                               ; preds = %23
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.node, ptr %29, i32 0, i32 4
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.node, ptr %31, i32 0, i32 5
  %33 = load i8, ptr %32, align 8, !tbaa !13
  %34 = zext i8 %33 to i32
  %35 = icmp ne i32 %34, 89
  br i1 %35, label %36, label %53

36:                                               ; preds = %28
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.generator, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  %41 = getelementptr inbounds %struct.analyser, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !16
  %43 = getelementptr inbounds %struct.tokeniser, ptr %42, i32 0, i32 3
  %44 = load ptr, ptr %43, align 8, !tbaa !18
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.node, ptr %45, i32 0, i32 12
  %47 = load i32, ptr %46, align 4, !tbaa !20
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = icmp eq i32 %48, 7
  %50 = zext i1 %49 to i64
  %51 = select i1 %49, ptr @.str.14, ptr @.str.15
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef @.str.13, ptr noundef %44, i32 noundef %47, ptr noundef %51) #3
  br label %53

53:                                               ; preds = %36, %28
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.node, ptr %54, i32 0, i32 4
  store ptr null, ptr %55, align 8, !tbaa !11
  br label %56

56:                                               ; preds = %53, %23
  %57 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %57, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %67

58:                                               ; preds = %16
  %59 = load i32, ptr %11, align 4, !tbaa !9
  %60 = icmp slt i32 %59, 0
  br i1 %60, label %61, label %63

61:                                               ; preds = %58
  %62 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %62, ptr %10, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %61, %58
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.node, ptr %64, i32 0, i32 4
  %66 = load ptr, ptr %65, align 8, !tbaa !11
  store ptr %66, ptr %7, align 8, !tbaa !5
  store i32 0, ptr %12, align 4
  br label %67

67:                                               ; preds = %63, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  %68 = load i32, ptr %12, align 4
  switch i32 %68, label %72 [
    i32 0, label %69
  ]

69:                                               ; preds = %67
  br label %13, !llvm.loop !21

70:                                               ; preds = %13
  %71 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %71, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %72

72:                                               ; preds = %70, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %73 = load i32, ptr %5, align 4
  ret i32 %73
}

; Function Attrs: nounwind uwtable
declare hidden i32 @check_possible_signals(ptr noundef, ptr noundef, i32 noundef) #2

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 32}
!12 = !{!"node", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !7, i64 40, !7, i64 41, !7, i64 42, !6, i64 48, !6, i64 56, !6, i64 64, !10, i64 72, !10, i64 76, !10, i64 80}
!13 = !{!12, !7, i64 40}
!14 = !{!15, !6, i64 0}
!15 = !{!"generator", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !6, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !7, i64 80, !7, i64 160, !7, i64 240, !7, i64 280, !7, i64 320, !10, i64 360, !10, i64 364, !10, i64 368, !10, i64 372, !10, i64 376}
!16 = !{!17, !6, i64 0}
!17 = !{!"analyser", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32, !7, i64 33, !6, i64 40, !6, i64 48, !7, i64 56, !6, i64 80, !6, i64 88, !10, i64 96, !10, i64 100, !10, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !10, i64 136, !7, i64 140}
!18 = !{!19, !6, i64 24}
!19 = !{!"tokeniser", !6, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !6, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !7, i64 96, !7, i64 97, !10, i64 100, !10, i64 104, !6, i64 112, !10, i64 120, !7, i64 124}
!20 = !{!12, !10, i64 76}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str.13 = external hidden unnamed_addr constant [76 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [13 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: nounwind uwtable
define dso_local i32 @check_possible_signals_list(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %.not33 = icmp eq ptr %1, null
  br i1 %.not33, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %4, %24
  %.01835 = phi i32 [ %spec.select, %24 ], [ 1, %4 ]
  %.02134 = phi ptr [ %27, %24 ], [ %1, %4 ]
  %5 = tail call i32 @check_possible_signals(ptr noundef %0, ptr noundef nonnull %.02134, i32 noundef %3)
  %.not28 = icmp eq i32 %5, 0
  br i1 %.not28, label %6, label %24

6:                                                ; preds = %.lr.ph
  %7 = getelementptr inbounds i8, ptr %.02134, i64 32
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %.not26 = icmp eq ptr %8, null
  br i1 %.not26, label %.thread, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %8, i64 40
  %11 = load i8, ptr %10, align 8, !tbaa !11
  %.not27 = icmp eq i8 %11, 89
  br i1 %.not27, label %23, label %12

12:                                               ; preds = %9
  %13 = load ptr, ptr @stderr, align 8, !tbaa !12
  %14 = load ptr, ptr %0, align 8, !tbaa !13
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %15, i64 24
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %.02134, i64 76
  %19 = load i32, ptr %18, align 4, !tbaa !19
  %20 = icmp eq i32 %2, 7
  %21 = select i1 %20, ptr @.str.14, ptr @.str.15
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.13, ptr noundef %17, i32 noundef %19, ptr noundef nonnull %21) #2
  br label %23

23:                                               ; preds = %12, %9
  store ptr null, ptr %7, align 8, !tbaa !5
  br label %.thread

24:                                               ; preds = %.lr.ph
  %25 = icmp slt i32 %5, 0
  %spec.select = select i1 %25, i32 %5, i32 %.01835
  %26 = getelementptr inbounds i8, ptr %.02134, i64 32
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %.not = icmp eq ptr %27, null
  br i1 %.not, label %.thread, label %.lr.ph, !llvm.loop !20

.thread:                                          ; preds = %24, %4, %23, %6
  %.2 = phi i32 [ 0, %6 ], [ 0, %23 ], [ 1, %4 ], [ %spec.select, %24 ]
  ret i32 %.2
}

; Function Attrs: nounwind uwtable
declare hidden i32 @check_possible_signals(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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 = { 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 = { cold 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 32}
!6 = !{!"node", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !8, i64 40, !8, i64 41, !8, i64 42, !7, i64 48, !7, i64 56, !7, i64 64, !10, i64 72, !10, i64 76, !10, i64 80}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !8, i64 40}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !7, i64 0}
!14 = !{!"generator", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !7, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !8, i64 80, !8, i64 160, !8, i64 240, !8, i64 280, !8, i64 320, !10, i64 360, !10, i64 364, !10, i64 368, !10, i64 372, !10, i64 376}
!15 = !{!16, !7, i64 0}
!16 = !{!"analyser", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !8, i64 32, !8, i64 33, !7, i64 40, !7, i64 48, !8, i64 56, !7, i64 80, !7, i64 88, !10, i64 96, !10, i64 100, !10, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !10, i64 136, !8, i64 140}
!17 = !{!18, !7, i64 24}
!18 = !{!"tokeniser", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !7, i64 40, !7, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !7, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !8, i64 96, !8, i64 97, !10, i64 100, !10, i64 104, !7, i64 112, !10, i64 120, !8, i64 124}
!19 = !{!6, !10, i64 76}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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