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

; 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 void @_Z3dfsi(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca %struct.Hash, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %3) #4
  %6 = getelementptr inbounds %struct.Hash, ptr %3, i32 0, i32 0
  store i32 0, ptr %6, align 4, !tbaa !9
  %7 = getelementptr inbounds %struct.Hash, ptr %3, i32 0, i32 1
  store i32 1, ptr %7, align 4, !tbaa !11
  %8 = getelementptr inbounds %struct.Hash, ptr %3, i32 0, i32 2
  store i32 0, ptr %8, align 4, !tbaa !12
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %10
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %3, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 12, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %119, %1
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 26
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %122

16:                                               ; preds = %12
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %18
  %20 = getelementptr inbounds %struct.Trie, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [26 x i32], ptr %20, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %104

26:                                               ; preds = %16
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %28
  %30 = getelementptr inbounds %struct.Trie, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [26 x i32], ptr %30, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  call void @_Z3dfsi(i32 noundef %34)
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %36
  %38 = getelementptr inbounds %struct.Hash, ptr %37, i32 0, i32 0
  %39 = load i32, ptr %38, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = mul nsw i64 %40, 901013
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %43
  %45 = getelementptr inbounds %struct.Trie, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [26 x i32], ptr %45, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %50
  %52 = getelementptr inbounds %struct.Hash, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = mul nsw i64 %54, 17
  %56 = add nsw i64 %41, %55
  %57 = srem i64 %56, 99999983
  %58 = trunc i64 %57 to i32
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.Hash, ptr %61, i32 0, i32 0
  store i32 %58, ptr %62, align 4, !tbaa !9
  %63 = load i32, ptr %2, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %64
  %66 = getelementptr inbounds %struct.Trie, ptr %65, i32 0, i32 0
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [26 x i32], ptr %66, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %71
  %73 = getelementptr inbounds %struct.Hash, ptr %72, i32 0, i32 1
  %74 = load i32, ptr %73, align 4, !tbaa !11
  %75 = load i32, ptr %2, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %76
  %78 = getelementptr inbounds %struct.Hash, ptr %77, i32 0, i32 1
  %79 = load i32, ptr %78, align 4, !tbaa !11
  %80 = add nsw i32 %79, %74
  store i32 %80, ptr %78, align 4, !tbaa !11
  %81 = load i32, ptr %2, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %82
  %84 = getelementptr inbounds %struct.Hash, ptr %83, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %85 = load i32, ptr %2, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %86
  %88 = getelementptr inbounds %struct.Trie, ptr %87, i32 0, i32 0
  %89 = load i32, ptr %4, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [26 x i32], ptr %88, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %93
  %95 = getelementptr inbounds %struct.Hash, ptr %94, i32 0, i32 2
  %96 = load i32, ptr %95, align 4, !tbaa !12
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %5, align 4, !tbaa !5
  %98 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %84, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = load i32, ptr %2, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %101
  %103 = getelementptr inbounds %struct.Hash, ptr %102, i32 0, i32 2
  store i32 %99, ptr %103, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %118

104:                                              ; preds = %16
  %105 = load i32, ptr %2, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %106
  %108 = getelementptr inbounds %struct.Hash, ptr %107, i32 0, i32 0
  %109 = load i32, ptr %108, align 4, !tbaa !9
  %110 = sext i32 %109 to i64
  %111 = mul nsw i64 %110, 901013
  %112 = srem i64 %111, 99999983
  %113 = trunc i64 %112 to i32
  %114 = load i32, ptr %2, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %115
  %117 = getelementptr inbounds %struct.Hash, ptr %116, i32 0, i32 0
  store i32 %113, ptr %117, align 4, !tbaa !9
  br label %118

118:                                              ; preds = %104, %26
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %4, align 4, !tbaa !5
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %4, align 4, !tbaa !5
  br label %12, !llvm.loop !14

122:                                              ; preds = %15
  %123 = load i32, ptr %2, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %124
  %126 = getelementptr inbounds %struct.Trie, ptr %125, i32 0, i32 1
  %127 = load i8, ptr %126, align 4, !tbaa !16, !range !19, !noundef !20
  %128 = trunc i8 %127 to i1
  %129 = zext i1 %128 to i64
  %130 = select i1 %128, i32 1879997, i32 4381013
  %131 = load i32, ptr %2, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %132
  %134 = getelementptr inbounds %struct.Hash, ptr %133, i32 0, i32 0
  %135 = load i32, ptr %134, align 4, !tbaa !9
  %136 = xor i32 %135, %130
  store i32 %136, ptr %134, align 4, !tbaa !9
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS4Hash", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 8}
!13 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !18, i64 104}
!17 = !{!"_ZTS4Trie", !7, i64 0, !18, i64 104}
!18 = !{!"bool", !7, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}


; 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 local_unnamed_addr global [155031 x %struct.Trie], align 16
@p = external dso_local global [155031 x %struct.Hash], align 16

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z3dfsi(i32 noundef %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  %3 = sext i32 %0 to i64
  %4 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %3
  store i32 0, ptr %4, align 4, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 4
  store i32 1, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store i32 0, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !5
  %5 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %3
  br label %13

6:                                                ; preds = %44
  %7 = getelementptr inbounds [155031 x %struct.Trie], ptr @e, i64 0, i64 %3, i32 1
  %8 = load i8, ptr %7, align 4, !tbaa !9, !range !12, !noundef !13
  %9 = trunc nuw i8 %8 to i1
  %10 = select i1 %9, i32 1879997, i32 4381013
  %11 = load i32, ptr %4, align 4, !tbaa !14
  %12 = xor i32 %10, %11
  store i32 %12, ptr %4, align 4, !tbaa !14
  ret void

13:                                               ; preds = %1, %44
  %indvars.iv = phi i64 [ 0, %1 ], [ %indvars.iv.next, %44 ]
  %14 = getelementptr inbounds [26 x i32], ptr %5, i64 0, i64 %indvars.iv
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %.not = icmp eq i32 %15, 0
  br i1 %.not, label %38, label %16

16:                                               ; preds = %13
  call void @_Z3dfsi(i32 noundef %15)
  %17 = load i32, ptr %4, align 4, !tbaa !14
  %18 = sext i32 %17 to i64
  %19 = mul nsw i64 %18, 901013
  %20 = load i32, ptr %14, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !14
  %24 = sext i32 %23 to i64
  %25 = mul nsw i64 %24, 17
  %26 = add nsw i64 %25, %19
  %27 = srem i64 %26, 99999983
  %28 = trunc nsw i64 %27 to i32
  store i32 %28, ptr %4, align 4, !tbaa !14
  %29 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %21, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !16
  %31 = load i32, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !16
  %32 = add nsw i32 %31, %30
  store i32 %32, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  %33 = getelementptr inbounds [155031 x %struct.Hash], ptr @p, i64 0, i64 %21, i32 2
  %34 = load i32, ptr %33, align 4, !tbaa !17
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %2, align 4, !tbaa !5
  %36 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %.sroa.5.0..sroa_idx, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %37 = load i32, ptr %36, align 4, !tbaa !5
  store i32 %37, ptr %.sroa.5.0..sroa_idx, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  br label %44

38:                                               ; preds = %13
  %39 = load i32, ptr %4, align 4, !tbaa !14
  %40 = sext i32 %39 to i64
  %41 = mul nsw i64 %40, 901013
  %42 = srem i64 %41, 99999983
  %43 = trunc nsw i64 %42 to i32
  store i32 %43, ptr %4, align 4, !tbaa !14
  br label %44

44:                                               ; preds = %16, %38
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 26
  br i1 %exitcond.not, label %6, label %13, !llvm.loop !18
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 104}
!10 = !{!"_ZTS4Trie", !7, i64 0, !11, i64 104}
!11 = !{!"bool", !7, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTS4Hash", !6, i64 0, !6, i64 4, !6, i64 8}
!16 = !{!15, !6, i64 4}
!17 = !{!15, !6, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass