; LLVM IR from tangjz/acm-icpc :: TDL_training/2015-10-05/L - Language Recognition - tjz.ll (Z5equivRKiS0_)

; 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.Trie = type { [26 x i32], i8 }
%struct.Hash = type { i32, i32, i32 }

@e = external dso_local global [155031 x %struct.Trie], align 16
@p = external dso_local global [155031 x %struct.Hash], align 16

; 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: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z5equivRKiS0_(ptr noundef nonnull align 4 dereferenceable(4) %0, ptr noundef nonnull align 4 dereferenceable(4) %1) #1 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = load i32, ptr %8, align 4, !tbaa !9
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %10
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %14
  %16 = call noundef zeroext i1 @_ZNK4HasheqERKS_(ptr noundef nonnull align 4 dereferenceable(12) %11, ptr noundef nonnull align 4 dereferenceable(12) %15)
  br i1 %16, label %18, label %17

17:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %94

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

19:                                               ; preds = %88, %18
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = icmp slt i32 %20, 26
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  store i32 2, ptr %7, align 4
  br label %91

23:                                               ; preds = %19
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.Trie, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [26 x i32], ptr %28, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !9
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %65

34:                                               ; preds = %23
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %37
  %39 = getelementptr inbounds %struct.Trie, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [26 x i32], ptr %39, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %65

45:                                               ; preds = %34
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = load i32, ptr %46, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %48
  %50 = getelementptr inbounds %struct.Trie, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [26 x i32], ptr %50, i64 0, i64 %52
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %56
  %58 = getelementptr inbounds %struct.Trie, ptr %57, i32 0, i32 0
  %59 = load i32, ptr %6, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [26 x i32], ptr %58, i64 0, i64 %60
  %62 = call noundef zeroext i1 @_Z5equivRKiS0_(ptr noundef nonnull align 4 dereferenceable(4) %53, ptr noundef nonnull align 4 dereferenceable(4) %61)
  br i1 %62, label %64, label %63

63:                                               ; preds = %45
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

64:                                               ; preds = %45
  br label %87

65:                                               ; preds = %34, %23
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = load i32, ptr %66, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %68
  %70 = getelementptr inbounds %struct.Trie, ptr %69, i32 0, i32 0
  %71 = load i32, ptr %6, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [26 x i32], ptr %70, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !9
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = load i32, ptr %75, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %77
  %79 = getelementptr inbounds %struct.Trie, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %6, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [26 x i32], ptr %79, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = icmp ne i32 %74, %83
  br i1 %84, label %85, label %86

85:                                               ; preds = %65
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

86:                                               ; preds = %65
  br label %87

87:                                               ; preds = %86, %64
  br label %88

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

91:                                               ; preds = %85, %63, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %92 = load i32, ptr %7, align 4
  switch i32 %92, label %96 [
    i32 2, label %93
    i32 1, label %94
  ]

93:                                               ; preds = %91
  store i1 true, ptr %3, align 1
  br label %94

94:                                               ; preds = %93, %91, %17
  %95 = load i1, ptr %3, align 1
  ret i1 %95

96:                                               ; preds = %91
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4HasheqERKS_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

%struct.Trie = type { [26 x i32], i8 }
%struct.Hash = type { i32, i32, i32 }

@e = external dso_local global [155031 x %struct.Trie], align 16
@p = external dso_local global [155031 x %struct.Hash], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5equivRKiS0_(ptr nocapture noundef nonnull readonly align 4 dereferenceable(4) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(4) %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %0, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  %5 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %4
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %7
  %9 = tail call noundef zeroext i1 @_ZNK4HasheqERKS_(ptr noundef nonnull align 4 dereferenceable(12) %5, ptr noundef nonnull align 4 dereferenceable(12) %8)
  br i1 %9, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %2, %19
  %indvars.iv = phi i64 [ %indvars.iv.next, %19 ], [ 0, %2 ]
  %10 = load i32, ptr %0, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %11
  %13 = getelementptr inbounds [26 x i32], ptr %12, i64 0, i64 %indvars.iv
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %.not = icmp eq i32 %14, 0
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  %.phi.trans.insert = sext i32 %.pre to i64
  %.phi.trans.insert23 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %.phi.trans.insert
  %.phi.trans.insert24 = getelementptr inbounds [26 x i32], ptr %.phi.trans.insert23, i64 0, i64 %indvars.iv
  %.pre25 = load i32, ptr %.phi.trans.insert24, align 4, !tbaa !5
  br i1 %.not, label %18, label %15

15:                                               ; preds = %.preheader
  %.not19 = icmp eq i32 %.pre25, 0
  br i1 %.not19, label %.loopexit, label %16

16:                                               ; preds = %15
  %17 = tail call noundef zeroext i1 @_Z5equivRKiS0_(ptr noundef nonnull align 4 dereferenceable(4) %13, ptr noundef nonnull align 4 dereferenceable(4) %.phi.trans.insert24)
  br i1 %17, label %19, label %.loopexit

18:                                               ; preds = %.preheader
  %.not20 = icmp eq i32 %14, %.pre25
  br i1 %.not20, label %19, label %.loopexit

19:                                               ; preds = %16, %18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv.next, 26
  br i1 %exitcond, label %.loopexit.loopexit.split.loop.exit29, label %.preheader, !llvm.loop !9

.loopexit.loopexit.split.loop.exit29:             ; preds = %19
  %20 = icmp ugt i64 %indvars.iv, 24
  br label %.loopexit

.loopexit:                                        ; preds = %18, %16, %15, %.loopexit.loopexit.split.loop.exit29, %2
  %.1 = phi i1 [ false, %2 ], [ %20, %.loopexit.loopexit.split.loop.exit29 ], [ false, %15 ], [ false, %16 ], [ false, %18 ]
  ret i1 %.1
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4HasheqERKS_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0 align 2

attributes #0 = { mustprogress 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" }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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