; LLVM IR from tangjz/acm-icpc :: uvalive (6133)

; 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 { i32, [26 x i32] }

@trie = external dso_local global [1000010 x %struct.Trie], align 16
@n = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@ans = external dso_local global i64, align 8
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6insertv() #0

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

declare i32 @__isoc99_scanf(ptr noundef, ...) #2

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %4

4:                                                ; preds = %37, %0
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n)
  %6 = icmp eq i32 %5, 1
  br i1 %6, label %7, label %44

7:                                                ; preds = %4
  call void @llvm.memset.p0.i64(ptr align 16 @trie, i8 0, i64 108001080, i1 false)
  store i32 1, ptr @tot, align 4, !tbaa !5
  store i64 0, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %14, %7
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %17

13:                                               ; preds = %8
  call void @_Z6insertv()
  br label %14

14:                                               ; preds = %13
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = add nsw i32 %15, 1
  store i32 %16, ptr %2, align 4, !tbaa !5
  br label %8, !llvm.loop !11

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

18:                                               ; preds = %34, %17
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = icmp slt i32 %19, 26
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %37

22:                                               ; preds = %18
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [26 x i32], ptr getelementptr inbounds (%struct.Trie, ptr @trie, i32 0, i32 1), i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %33

28:                                               ; preds = %22
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [26 x i32], ptr getelementptr inbounds (%struct.Trie, ptr @trie, i32 0, i32 1), i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  call void @_Z3dfsii(i32 noundef %32, i32 noundef 1)
  br label %33

33:                                               ; preds = %28, %22
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %3, align 4, !tbaa !5
  br label %18, !llvm.loop !13

37:                                               ; preds = %21
  %38 = load i64, ptr @ans, align 8, !tbaa !9
  %39 = sitofp i64 %38 to double
  %40 = load i32, ptr @n, align 4, !tbaa !5
  %41 = sitofp i32 %40 to double
  %42 = fdiv double %39, %41
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %42)
  br label %4, !llvm.loop !14

44:                                               ; preds = %4
  ret i32 0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare i32 @printf(ptr noundef, ...) #2

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 willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { mustprogress norecurse 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; 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 { i32, [26 x i32] }

@trie = external dso_local local_unnamed_addr global [1000010 x %struct.Trie], align 16
@n = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6insertv() local_unnamed_addr #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n)
  %2 = icmp eq i32 %1, 1
  br i1 %2, label %.lr.ph10, label %._crit_edge

.lr.ph10:                                         ; preds = %0, %83
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(108001080) @trie, i8 0, i64 108001080, i1 false)
  store i32 1, ptr @tot, align 4, !tbaa !5
  store i64 0, ptr @ans, align 8, !tbaa !9
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %.preheader.thread

.preheader:                                       ; preds = %.lr.ph
  %.pre = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 4), align 4, !tbaa !5
  %.not = icmp eq i32 %.pre, 0
  br i1 %.not, label %.preheader.thread, label %8

.lr.ph:                                           ; preds = %.lr.ph10, %.lr.ph
  %.068 = phi i32 [ %5, %.lr.ph ], [ 0, %.lr.ph10 ]
  tail call void @_Z6insertv()
  %5 = add nuw nsw i32 %.068, 1
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %7 = icmp slt i32 %5, %6
  br i1 %7, label %.lr.ph, label %.preheader, !llvm.loop !11

8:                                                ; preds = %.preheader
  tail call void @_Z3dfsii(i32 noundef %.pre, i32 noundef 1)
  br label %.preheader.thread

.preheader.thread:                                ; preds = %.lr.ph10, %.preheader, %8
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 8), align 8, !tbaa !5
  %.not.1 = icmp eq i32 %9, 0
  br i1 %.not.1, label %11, label %10

10:                                               ; preds = %.preheader.thread
  tail call void @_Z3dfsii(i32 noundef %9, i32 noundef 1)
  br label %11

11:                                               ; preds = %10, %.preheader.thread
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 12), align 4, !tbaa !5
  %.not.2 = icmp eq i32 %12, 0
  br i1 %.not.2, label %14, label %13

13:                                               ; preds = %11
  tail call void @_Z3dfsii(i32 noundef %12, i32 noundef 1)
  br label %14

14:                                               ; preds = %13, %11
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 16), align 16, !tbaa !5
  %.not.3 = icmp eq i32 %15, 0
  br i1 %.not.3, label %17, label %16

16:                                               ; preds = %14
  tail call void @_Z3dfsii(i32 noundef %15, i32 noundef 1)
  br label %17

17:                                               ; preds = %16, %14
  %18 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 20), align 4, !tbaa !5
  %.not.4 = icmp eq i32 %18, 0
  br i1 %.not.4, label %20, label %19

19:                                               ; preds = %17
  tail call void @_Z3dfsii(i32 noundef %18, i32 noundef 1)
  br label %20

20:                                               ; preds = %19, %17
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 24), align 8, !tbaa !5
  %.not.5 = icmp eq i32 %21, 0
  br i1 %.not.5, label %23, label %22

22:                                               ; preds = %20
  tail call void @_Z3dfsii(i32 noundef %21, i32 noundef 1)
  br label %23

23:                                               ; preds = %22, %20
  %24 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 28), align 4, !tbaa !5
  %.not.6 = icmp eq i32 %24, 0
  br i1 %.not.6, label %26, label %25

25:                                               ; preds = %23
  tail call void @_Z3dfsii(i32 noundef %24, i32 noundef 1)
  br label %26

26:                                               ; preds = %25, %23
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 32), align 16, !tbaa !5
  %.not.7 = icmp eq i32 %27, 0
  br i1 %.not.7, label %29, label %28

28:                                               ; preds = %26
  tail call void @_Z3dfsii(i32 noundef %27, i32 noundef 1)
  br label %29

29:                                               ; preds = %28, %26
  %30 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 36), align 4, !tbaa !5
  %.not.8 = icmp eq i32 %30, 0
  br i1 %.not.8, label %32, label %31

31:                                               ; preds = %29
  tail call void @_Z3dfsii(i32 noundef %30, i32 noundef 1)
  br label %32

32:                                               ; preds = %31, %29
  %33 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 40), align 8, !tbaa !5
  %.not.9 = icmp eq i32 %33, 0
  br i1 %.not.9, label %35, label %34

34:                                               ; preds = %32
  tail call void @_Z3dfsii(i32 noundef %33, i32 noundef 1)
  br label %35

35:                                               ; preds = %34, %32
  %36 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 44), align 4, !tbaa !5
  %.not.10 = icmp eq i32 %36, 0
  br i1 %.not.10, label %38, label %37

37:                                               ; preds = %35
  tail call void @_Z3dfsii(i32 noundef %36, i32 noundef 1)
  br label %38

38:                                               ; preds = %37, %35
  %39 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 48), align 16, !tbaa !5
  %.not.11 = icmp eq i32 %39, 0
  br i1 %.not.11, label %41, label %40

40:                                               ; preds = %38
  tail call void @_Z3dfsii(i32 noundef %39, i32 noundef 1)
  br label %41

41:                                               ; preds = %40, %38
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 52), align 4, !tbaa !5
  %.not.12 = icmp eq i32 %42, 0
  br i1 %.not.12, label %44, label %43

43:                                               ; preds = %41
  tail call void @_Z3dfsii(i32 noundef %42, i32 noundef 1)
  br label %44

44:                                               ; preds = %43, %41
  %45 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 56), align 8, !tbaa !5
  %.not.13 = icmp eq i32 %45, 0
  br i1 %.not.13, label %47, label %46

46:                                               ; preds = %44
  tail call void @_Z3dfsii(i32 noundef %45, i32 noundef 1)
  br label %47

47:                                               ; preds = %46, %44
  %48 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 60), align 4, !tbaa !5
  %.not.14 = icmp eq i32 %48, 0
  br i1 %.not.14, label %50, label %49

49:                                               ; preds = %47
  tail call void @_Z3dfsii(i32 noundef %48, i32 noundef 1)
  br label %50

50:                                               ; preds = %49, %47
  %51 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 64), align 16, !tbaa !5
  %.not.15 = icmp eq i32 %51, 0
  br i1 %.not.15, label %53, label %52

52:                                               ; preds = %50
  tail call void @_Z3dfsii(i32 noundef %51, i32 noundef 1)
  br label %53

53:                                               ; preds = %52, %50
  %54 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 68), align 4, !tbaa !5
  %.not.16 = icmp eq i32 %54, 0
  br i1 %.not.16, label %56, label %55

55:                                               ; preds = %53
  tail call void @_Z3dfsii(i32 noundef %54, i32 noundef 1)
  br label %56

56:                                               ; preds = %55, %53
  %57 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 72), align 8, !tbaa !5
  %.not.17 = icmp eq i32 %57, 0
  br i1 %.not.17, label %59, label %58

58:                                               ; preds = %56
  tail call void @_Z3dfsii(i32 noundef %57, i32 noundef 1)
  br label %59

59:                                               ; preds = %58, %56
  %60 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 76), align 4, !tbaa !5
  %.not.18 = icmp eq i32 %60, 0
  br i1 %.not.18, label %62, label %61

61:                                               ; preds = %59
  tail call void @_Z3dfsii(i32 noundef %60, i32 noundef 1)
  br label %62

62:                                               ; preds = %61, %59
  %63 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 80), align 16, !tbaa !5
  %.not.19 = icmp eq i32 %63, 0
  br i1 %.not.19, label %65, label %64

64:                                               ; preds = %62
  tail call void @_Z3dfsii(i32 noundef %63, i32 noundef 1)
  br label %65

65:                                               ; preds = %64, %62
  %66 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 84), align 4, !tbaa !5
  %.not.20 = icmp eq i32 %66, 0
  br i1 %.not.20, label %68, label %67

67:                                               ; preds = %65
  tail call void @_Z3dfsii(i32 noundef %66, i32 noundef 1)
  br label %68

68:                                               ; preds = %67, %65
  %69 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 88), align 8, !tbaa !5
  %.not.21 = icmp eq i32 %69, 0
  br i1 %.not.21, label %71, label %70

70:                                               ; preds = %68
  tail call void @_Z3dfsii(i32 noundef %69, i32 noundef 1)
  br label %71

71:                                               ; preds = %70, %68
  %72 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 92), align 4, !tbaa !5
  %.not.22 = icmp eq i32 %72, 0
  br i1 %.not.22, label %74, label %73

73:                                               ; preds = %71
  tail call void @_Z3dfsii(i32 noundef %72, i32 noundef 1)
  br label %74

74:                                               ; preds = %73, %71
  %75 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 96), align 16, !tbaa !5
  %.not.23 = icmp eq i32 %75, 0
  br i1 %.not.23, label %77, label %76

76:                                               ; preds = %74
  tail call void @_Z3dfsii(i32 noundef %75, i32 noundef 1)
  br label %77

77:                                               ; preds = %76, %74
  %78 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 100), align 4, !tbaa !5
  %.not.24 = icmp eq i32 %78, 0
  br i1 %.not.24, label %80, label %79

79:                                               ; preds = %77
  tail call void @_Z3dfsii(i32 noundef %78, i32 noundef 1)
  br label %80

80:                                               ; preds = %79, %77
  %81 = load i32, ptr getelementptr inbounds (i8, ptr @trie, i64 104), align 8, !tbaa !5
  %.not.25 = icmp eq i32 %81, 0
  br i1 %.not.25, label %83, label %82

82:                                               ; preds = %80
  tail call void @_Z3dfsii(i32 noundef %81, i32 noundef 1)
  br label %83

83:                                               ; preds = %82, %80
  %84 = load i64, ptr @ans, align 8, !tbaa !9
  %85 = sitofp i64 %84 to double
  %86 = load i32, ptr @n, align 4, !tbaa !5
  %87 = sitofp i32 %86 to double
  %88 = fdiv double %85, %87
  %89 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %88)
  %90 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n)
  %91 = icmp eq i32 %90, 1
  br i1 %91, label %.lr.ph10, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %83, %0
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

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 = { 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 #2 = { mustprogress norecurse 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }

!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, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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