; LLVM IR from tangjz/acm-icpc :: codeforces/complete (520A)

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

@n = external dso_local global i32, align 4
@vis = external dso_local global [26 x i8], align 16
@str = external dso_local global [101 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @str)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %6

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

10:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %24

11:                                               ; preds = %6
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [101 x i8], ptr @str, i64 0, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !9
  %16 = sext i8 %15 to i32
  %17 = call i32 @tolower(i32 noundef %16) #5
  %18 = sub nsw i32 %17, 97
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [26 x i8], ptr @vis, i64 0, i64 %19
  store i8 1, ptr %20, align 1, !tbaa !10
  br label %21

21:                                               ; preds = %11
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !12

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

25:                                               ; preds = %38, %24
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = icmp slt i32 %26, 26
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  store i32 5, ptr %4, align 4
  br label %41

29:                                               ; preds = %25
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [26 x i8], ptr @vis, i64 0, i64 %31
  %33 = load i8, ptr %32, align 1, !tbaa !10, !range !14, !noundef !15
  %34 = trunc i8 %33 to i1
  br i1 %34, label %37, label %35

35:                                               ; preds = %29
  %36 = call i32 @puts(ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %41

37:                                               ; preds = %29
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %3, align 4, !tbaa !5
  br label %25, !llvm.loop !16

41:                                               ; preds = %35, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  %42 = load i32, ptr %4, align 4
  switch i32 %42, label %47 [
    i32 5, label %43
    i32 1, label %45
  ]

43:                                               ; preds = %41
  %44 = call i32 @puts(ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  br label %45

45:                                               ; preds = %43, %41
  %46 = load i32, ptr %1, align 4
  ret i32 %46

47:                                               ; preds = %41
  unreachable
}

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @tolower(i32 noundef) #3

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

declare i32 @puts(ptr noundef) #1

attributes #0 = { 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 #1 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind willreturn memory(read) "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 }
attributes #5 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"bool", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !13}


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

@n = external dso_local global i32, align 4
@vis = external dso_local local_unnamed_addr global [26 x i8], align 16
@str = external dso_local global [101 x i8], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @str)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph.preheader, label %.preheader

.lr.ph.preheader:                                 ; preds = %0
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %0
  %4 = load i8, ptr @vis, align 16, !tbaa !9, !range !11, !noundef !12
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %13, label %88

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %6 = getelementptr inbounds [101 x i8], ptr @str, i64 0, i64 %indvars.iv
  %7 = load i8, ptr %6, align 1, !tbaa !13
  %8 = sext i8 %7 to i32
  %9 = tail call i32 @tolower(i32 noundef %8) #3
  %10 = add nsw i32 %9, -97
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [26 x i8], ptr @vis, i64 0, i64 %11
  store i8 1, ptr %12, align 1, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %.lr.ph, !llvm.loop !14

13:                                               ; preds = %.preheader
  %14 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 1), align 1, !tbaa !9, !range !11, !noundef !12
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %16, label %88

16:                                               ; preds = %13
  %17 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 2), align 2, !tbaa !9, !range !11, !noundef !12
  %18 = trunc nuw i8 %17 to i1
  br i1 %18, label %19, label %88

19:                                               ; preds = %16
  %20 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 3), align 1, !tbaa !9, !range !11, !noundef !12
  %21 = trunc nuw i8 %20 to i1
  br i1 %21, label %22, label %88

22:                                               ; preds = %19
  %23 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 4), align 4, !tbaa !9, !range !11, !noundef !12
  %24 = trunc nuw i8 %23 to i1
  br i1 %24, label %25, label %88

25:                                               ; preds = %22
  %26 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 5), align 1, !tbaa !9, !range !11, !noundef !12
  %27 = trunc nuw i8 %26 to i1
  br i1 %27, label %28, label %88

28:                                               ; preds = %25
  %29 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 6), align 2, !tbaa !9, !range !11, !noundef !12
  %30 = trunc nuw i8 %29 to i1
  br i1 %30, label %31, label %88

31:                                               ; preds = %28
  %32 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 7), align 1, !tbaa !9, !range !11, !noundef !12
  %33 = trunc nuw i8 %32 to i1
  br i1 %33, label %34, label %88

34:                                               ; preds = %31
  %35 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 8), align 8, !tbaa !9, !range !11, !noundef !12
  %36 = trunc nuw i8 %35 to i1
  br i1 %36, label %37, label %88

37:                                               ; preds = %34
  %38 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 9), align 1, !tbaa !9, !range !11, !noundef !12
  %39 = trunc nuw i8 %38 to i1
  br i1 %39, label %40, label %88

40:                                               ; preds = %37
  %41 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 10), align 2, !tbaa !9, !range !11, !noundef !12
  %42 = trunc nuw i8 %41 to i1
  br i1 %42, label %43, label %88

43:                                               ; preds = %40
  %44 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 11), align 1, !tbaa !9, !range !11, !noundef !12
  %45 = trunc nuw i8 %44 to i1
  br i1 %45, label %46, label %88

46:                                               ; preds = %43
  %47 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 12), align 4, !tbaa !9, !range !11, !noundef !12
  %48 = trunc nuw i8 %47 to i1
  br i1 %48, label %49, label %88

49:                                               ; preds = %46
  %50 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 13), align 1, !tbaa !9, !range !11, !noundef !12
  %51 = trunc nuw i8 %50 to i1
  br i1 %51, label %52, label %88

52:                                               ; preds = %49
  %53 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 14), align 2, !tbaa !9, !range !11, !noundef !12
  %54 = trunc nuw i8 %53 to i1
  br i1 %54, label %55, label %88

55:                                               ; preds = %52
  %56 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 15), align 1, !tbaa !9, !range !11, !noundef !12
  %57 = trunc nuw i8 %56 to i1
  br i1 %57, label %58, label %88

58:                                               ; preds = %55
  %59 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 16), align 16, !tbaa !9, !range !11, !noundef !12
  %60 = trunc nuw i8 %59 to i1
  br i1 %60, label %61, label %88

61:                                               ; preds = %58
  %62 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 17), align 1, !tbaa !9, !range !11, !noundef !12
  %63 = trunc nuw i8 %62 to i1
  br i1 %63, label %64, label %88

64:                                               ; preds = %61
  %65 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 18), align 2, !tbaa !9, !range !11, !noundef !12
  %66 = trunc nuw i8 %65 to i1
  br i1 %66, label %67, label %88

67:                                               ; preds = %64
  %68 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 19), align 1, !tbaa !9, !range !11, !noundef !12
  %69 = trunc nuw i8 %68 to i1
  br i1 %69, label %70, label %88

70:                                               ; preds = %67
  %71 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 20), align 4, !tbaa !9, !range !11, !noundef !12
  %72 = trunc nuw i8 %71 to i1
  br i1 %72, label %73, label %88

73:                                               ; preds = %70
  %74 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 21), align 1, !tbaa !9, !range !11, !noundef !12
  %75 = trunc nuw i8 %74 to i1
  br i1 %75, label %76, label %88

76:                                               ; preds = %73
  %77 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 22), align 2, !tbaa !9, !range !11, !noundef !12
  %78 = trunc nuw i8 %77 to i1
  br i1 %78, label %79, label %88

79:                                               ; preds = %76
  %80 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 23), align 1, !tbaa !9, !range !11, !noundef !12
  %81 = trunc nuw i8 %80 to i1
  br i1 %81, label %82, label %88

82:                                               ; preds = %79
  %83 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 24), align 8, !tbaa !9, !range !11, !noundef !12
  %84 = trunc nuw i8 %83 to i1
  br i1 %84, label %85, label %88

85:                                               ; preds = %82
  %86 = load i8, ptr getelementptr inbounds (i8, ptr @vis, i64 25), align 1, !tbaa !9, !range !11, !noundef !12
  %87 = trunc nuw i8 %86 to i1
  br i1 %87, label %89, label %88

88:                                               ; preds = %85, %82, %79, %76, %73, %70, %67, %64, %61, %58, %55, %52, %49, %46, %43, %40, %37, %34, %31, %28, %25, %22, %19, %16, %13, %.preheader
  br label %89

89:                                               ; preds = %85, %88
  %.str.1.sink = phi ptr [ @.str.1, %88 ], [ @.str.2, %85 ]
  %90 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.1.sink)
  ret i32 0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare i32 @tolower(i32 noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress nofree norecurse 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 #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 nofree nounwind willreturn memory(read) "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 willreturn memory(read) }

!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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass