; LLVM IR from bbenligiray/stag :: src/ED/NFA.ll (ZN6NFALUTC2Eidd)

; 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.NFALUT = type { ptr, i32, double, double }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6NFALUTC2Eidd(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1, double noundef %2, double noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !11
  store double %3, ptr %8, align 8, !tbaa !11
  %13 = load ptr, ptr %5, align 8
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 1
  store i32 %14, ptr %15, align 8, !tbaa !13
  %16 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 1
  %17 = load i32, ptr %16, align 8, !tbaa !13
  %18 = sext i32 %17 to i64
  %19 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %18, i64 4)
  %20 = extractvalue { i64, i1 } %19, 1
  %21 = extractvalue { i64, i1 } %19, 0
  %22 = select i1 %20, i64 -1, i64 %21
  %23 = call noalias noundef nonnull ptr @_Znam(i64 noundef %22) #4
  %24 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 0
  store ptr %23, ptr %24, align 8, !tbaa !15
  %25 = load double, ptr %7, align 8, !tbaa !11
  %26 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 2
  store double %25, ptr %26, align 8, !tbaa !16
  %27 = load double, ptr %8, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 3
  store double %27, ptr %28, align 8, !tbaa !17
  %29 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = getelementptr inbounds i32, ptr %30, i64 0
  store i32 1, ptr %31, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 1, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %90, %4
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 1
  %35 = load i32, ptr %34, align 8, !tbaa !13
  %36 = icmp slt i32 %33, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %32
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %93

38:                                               ; preds = %32
  %39 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 1
  %40 = load i32, ptr %39, align 8, !tbaa !13
  %41 = add nsw i32 %40, 1
  %42 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !15
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i32, ptr %43, i64 %45
  store i32 %41, ptr %46, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 2
  %50 = load double, ptr %49, align 8, !tbaa !16
  %51 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 3
  %52 = load double, ptr %51, align 8, !tbaa !17
  %53 = call noundef double @_Z3nfaiidd(i32 noundef %47, i32 noundef %48, double noundef %50, double noundef %52)
  store double %53, ptr %12, align 8, !tbaa !11
  %54 = load double, ptr %12, align 8, !tbaa !11
  %55 = fcmp olt double %54, 0.000000e+00
  br i1 %55, label %56, label %80

56:                                               ; preds = %38
  br label %57

57:                                               ; preds = %74, %56
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = load i32, ptr %10, align 4, !tbaa !9
  %60 = icmp slt i32 %58, %59
  br i1 %60, label %61, label %75

61:                                               ; preds = %57
  %62 = load i32, ptr %9, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %9, align 4, !tbaa !9
  %64 = load i32, ptr %10, align 4, !tbaa !9
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 2
  %67 = load double, ptr %66, align 8, !tbaa !16
  %68 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 3
  %69 = load double, ptr %68, align 8, !tbaa !17
  %70 = call noundef double @_Z3nfaiidd(i32 noundef %64, i32 noundef %65, double noundef %67, double noundef %69)
  store double %70, ptr %12, align 8, !tbaa !11
  %71 = load double, ptr %12, align 8, !tbaa !11
  %72 = fcmp oge double %71, 0.000000e+00
  br i1 %72, label %73, label %74

73:                                               ; preds = %61
  br label %75

74:                                               ; preds = %61
  br label %57, !llvm.loop !18

75:                                               ; preds = %73, %57
  %76 = load double, ptr %12, align 8, !tbaa !11
  %77 = fcmp olt double %76, 0.000000e+00
  br i1 %77, label %78, label %79

78:                                               ; preds = %75
  store i32 4, ptr %11, align 4
  br label %87

79:                                               ; preds = %75
  br label %80

80:                                               ; preds = %79, %38
  %81 = load i32, ptr %9, align 4, !tbaa !9
  %82 = getelementptr inbounds %struct.NFALUT, ptr %13, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8, !tbaa !15
  %84 = load i32, ptr %10, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds i32, ptr %83, i64 %85
  store i32 %81, ptr %86, align 4, !tbaa !9
  store i32 0, ptr %11, align 4
  br label %87

87:                                               ; preds = %80, %78
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  %88 = load i32, ptr %11, align 4
  switch i32 %88, label %94 [
    i32 0, label %89
    i32 4, label %90
  ]

89:                                               ; preds = %87
  br label %90

90:                                               ; preds = %89, %87
  %91 = load i32, ptr %10, align 4, !tbaa !9
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %10, align 4, !tbaa !9
  br label %32, !llvm.loop !20

93:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret void

94:                                               ; preds = %87
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z3nfaiidd(i32 noundef, i32 noundef, double noundef, double noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

attributes #0 = { mustprogress 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nobuiltin allocsize(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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { builtin allocsize(0) }
attributes #5 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTS6NFALUT", !6, i64 0, !10, i64 8, !12, i64 16, !12, i64 24}
!15 = !{!14, !6, i64 0}
!16 = !{!14, !12, i64 16}
!17 = !{!14, !12, i64 24}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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: mustprogress uwtable
define dso_local void @_ZN6NFALUTC2Eidd(ptr nocapture noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1, double noundef %2, double noundef %3) unnamed_addr #0 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %1, ptr %5, align 8, !tbaa !5
  %6 = zext nneg i32 %1 to i64
  %7 = icmp slt i32 %1, 0
  %8 = shl nuw nsw i64 %6, 2
  %9 = select i1 %7, i64 -1, i64 %8
  %10 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %9) #2
  store ptr %10, ptr %0, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  store double %2, ptr %11, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  store double %3, ptr %12, align 8, !tbaa !14
  store i32 1, ptr %10, align 4, !tbaa !15
  %13 = icmp sgt i32 %1, 1
  br i1 %13, label %.lr.ph35, label %._crit_edge36

._crit_edge36:                                    ; preds = %36, %4
  ret void

.lr.ph35:                                         ; preds = %4, %36
  %indvars.iv = phi i64 [ %indvars.iv.next, %36 ], [ 1, %4 ]
  %14 = phi i32 [ %37, %36 ], [ %1, %4 ]
  %.01930 = phi i32 [ %.4, %36 ], [ 1, %4 ]
  %15 = add nsw i32 %14, 1
  %16 = load ptr, ptr %0, align 8, !tbaa !12
  %17 = getelementptr inbounds i32, ptr %16, i64 %indvars.iv
  store i32 %15, ptr %17, align 4, !tbaa !15
  %18 = load double, ptr %11, align 8, !tbaa !13
  %19 = load double, ptr %12, align 8, !tbaa !14
  %20 = trunc nuw nsw i64 %indvars.iv to i32
  %21 = tail call noundef double @_Z3nfaiidd(i32 noundef %20, i32 noundef %.01930, double noundef %18, double noundef %19)
  %22 = fcmp olt double %21, 0.000000e+00
  br i1 %22, label %.preheader, label %33

.preheader:                                       ; preds = %.lr.ph35
  %23 = sext i32 %.01930 to i64
  %24 = icmp sgt i64 %indvars.iv, %23
  br i1 %24, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.12025 = phi i32 [ %25, %.lr.ph ], [ %.01930, %.preheader ]
  %25 = add nsw i32 %.12025, 1
  %26 = load double, ptr %11, align 8, !tbaa !13
  %27 = load double, ptr %12, align 8, !tbaa !14
  %28 = tail call noundef double @_Z3nfaiidd(i32 noundef %20, i32 noundef %25, double noundef %26, double noundef %27)
  %29 = fcmp ult double %28, 0.000000e+00
  %30 = sext i32 %25 to i64
  %31 = icmp sgt i64 %indvars.iv, %30
  %or.cond = and i1 %29, %31
  br i1 %or.cond, label %.lr.ph, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.2 = phi i32 [ %.01930, %.preheader ], [ %25, %.lr.ph ]
  %.1 = phi double [ %21, %.preheader ], [ %28, %.lr.ph ]
  %32 = fcmp olt double %.1, 0.000000e+00
  br i1 %32, label %36, label %33

33:                                               ; preds = %._crit_edge, %.lr.ph35
  %.3 = phi i32 [ %.2, %._crit_edge ], [ %.01930, %.lr.ph35 ]
  %34 = load ptr, ptr %0, align 8, !tbaa !12
  %35 = getelementptr inbounds i32, ptr %34, i64 %indvars.iv
  store i32 %.3, ptr %35, align 4, !tbaa !15
  br label %36

36:                                               ; preds = %._crit_edge, %33
  %.4 = phi i32 [ %.3, %33 ], [ %.2, %._crit_edge ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %37 = load i32, ptr %5, align 8, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = icmp slt i64 %indvars.iv.next, %38
  br i1 %39, label %.lr.ph35, label %._crit_edge36, !llvm.loop !18
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_Z3nfaiidd(i32 noundef, i32 noundef, double noundef, double noundef) local_unnamed_addr #0

attributes #0 = { mustprogress 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 #1 = { nobuiltin allocsize(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 = { builtin allocsize(0) }

!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 8}
!6 = !{!"_ZTS6NFALUT", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !11, i64 16}
!14 = !{!6, !11, i64 24}
!15 = !{!10, !10, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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