; LLVM IR from tangjz/acm-icpc :: leetcode/extra (meituan_001-小美的用户名)

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZZ4mainE3buf = external hidden global [21 x i8], align 16
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 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 i8, align 1
  %5 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %7

7:                                                ; preds = %65, %0
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = add nsw i32 %8, -1
  store i32 %9, ptr %2, align 4, !tbaa !5
  %10 = icmp ne i32 %8, 0
  br i1 %10, label %11, label %70

11:                                               ; preds = %7
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @_ZZ4mainE3buf)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #4
  %13 = load i8, ptr @_ZZ4mainE3buf, align 16, !tbaa !9
  %14 = sext i8 %13 to i32
  %15 = call i32 @isalpha(i32 noundef %14) #5
  %16 = icmp ne i32 %15, 0
  %17 = xor i1 %16, true
  %18 = zext i1 %17 to i8
  store i8 %18, ptr %4, align 1, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %56, %11
  %20 = load i8, ptr %4, align 1, !tbaa !10, !range !12, !noundef !13
  %21 = trunc i8 %20 to i1
  br i1 %21, label %28, label %22

22:                                               ; preds = %19
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [21 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %24
  %26 = load i8, ptr %25, align 1, !tbaa !9
  %27 = icmp ne i8 %26, 0
  br label %28

28:                                               ; preds = %22, %19
  %29 = phi i1 [ false, %19 ], [ %27, %22 ]
  br i1 %29, label %31, label %30

30:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %59

31:                                               ; preds = %28
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [21 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %33
  %35 = load i8, ptr %34, align 1, !tbaa !9
  %36 = sext i8 %35 to i32
  %37 = call i32 @isalpha(i32 noundef %36) #5
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %31
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = or i32 %40, 1
  store i32 %41, ptr %3, align 4, !tbaa !5
  br label %55

42:                                               ; preds = %31
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [21 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !9
  %47 = sext i8 %46 to i32
  %48 = call i32 @isdigit(i32 noundef %47) #5
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %53

50:                                               ; preds = %42
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = or i32 %51, 2
  store i32 %52, ptr %3, align 4, !tbaa !5
  br label %54

53:                                               ; preds = %42
  store i8 1, ptr %4, align 1, !tbaa !10
  br label %54

54:                                               ; preds = %53, %50
  br label %55

55:                                               ; preds = %54, %39
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %5, align 4, !tbaa !5
  br label %19, !llvm.loop !14

59:                                               ; preds = %30
  %60 = load i8, ptr %4, align 1, !tbaa !10, !range !12, !noundef !13
  %61 = trunc i8 %60 to i1
  br i1 %61, label %65, label %62

62:                                               ; preds = %59
  %63 = load i32, ptr %3, align 4, !tbaa !5
  %64 = icmp eq i32 %63, 3
  br label %65

65:                                               ; preds = %62, %59
  %66 = phi i1 [ false, %59 ], [ %64, %62 ]
  %67 = zext i1 %66 to i64
  %68 = select i1 %66, ptr @.str.2, ptr @.str.3
  %69 = call i32 @puts(ptr noundef %68)
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %7, !llvm.loop !16

70:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 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: nounwind willreturn memory(read)
declare i32 @isalpha(i32 noundef) #3

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

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

declare i32 @puts(ptr noundef) #2

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


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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZZ4mainE3buf = external hidden global [21 x i8], align 16
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = add nsw i32 %3, -1
  store i32 %4, ptr %1, align 4, !tbaa !5
  %.not26 = icmp eq i32 %3, 0
  br i1 %.not26, label %._crit_edge, label %.lr.ph27

.lr.ph27:                                         ; preds = %0, %.critedge
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @_ZZ4mainE3buf)
  %6 = load i8, ptr @_ZZ4mainE3buf, align 16, !tbaa !9
  %7 = sext i8 %6 to i32
  %8 = call i32 @isalpha(i32 noundef %7) #5
  %.not13 = icmp eq i32 %8, 0
  br i1 %.not13, label %.critedge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph27
  %9 = load i8, ptr @_ZZ4mainE3buf, align 16, !tbaa !9
  %.not14.not29 = icmp eq i8 %9, 0
  br i1 %.not14.not29, label %.critedge, label %.lr.ph32

.critedge:                                        ; preds = %20, %.lr.ph.backedge, %.lr.ph.preheader, %.lr.ph27
  %.010.lcssa = phi i32 [ 0, %.lr.ph27 ], [ 0, %.lr.ph.preheader ], [ %.01019.be, %.lr.ph.backedge ], [ %.0101931, %20 ]
  %.09.lcssa = phi i1 [ true, %.lr.ph27 ], [ false, %.lr.ph.preheader ], [ false, %.lr.ph.backedge ], [ true, %20 ]
  %10 = icmp ne i32 %.010.lcssa, 3
  %.not17 = select i1 %.09.lcssa, i1 true, i1 %10
  %11 = select i1 %.not17, ptr @.str.3, ptr @.str.2
  %12 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %11)
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = add nsw i32 %13, -1
  store i32 %14, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph27, !llvm.loop !10

.lr.ph32:                                         ; preds = %.lr.ph.preheader, %.lr.ph.backedge
  %15 = phi i8 [ %24, %.lr.ph.backedge ], [ %9, %.lr.ph.preheader ]
  %.0101931 = phi i32 [ %.01019.be, %.lr.ph.backedge ], [ 0, %.lr.ph.preheader ]
  %indvars.iv30 = phi i64 [ %indvars.iv.be, %.lr.ph.backedge ], [ 0, %.lr.ph.preheader ]
  %16 = sext i8 %15 to i32
  %17 = call i32 @isalpha(i32 noundef %16) #5
  %.not15 = icmp eq i32 %17, 0
  br i1 %.not15, label %20, label %18

18:                                               ; preds = %.lr.ph32
  %19 = or i32 %.0101931, 1
  br label %.lr.ph.backedge

20:                                               ; preds = %.lr.ph32
  %21 = add nsw i32 %16, -58
  %isdigit = icmp ult i32 %21, -10
  %22 = or i32 %.0101931, 2
  br i1 %isdigit, label %.critedge, label %.lr.ph.backedge

.lr.ph.backedge:                                  ; preds = %20, %18
  %.01019.be = phi i32 [ %22, %20 ], [ %19, %18 ]
  %indvars.iv.be = add nuw nsw i64 %indvars.iv30, 1
  %23 = getelementptr inbounds [21 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %indvars.iv.be
  %24 = load i8, ptr %23, align 1, !tbaa !9
  %.not14.not = icmp eq i8 %24, 0
  br i1 %.not14.not, label %.critedge, label %.lr.ph32, !llvm.loop !12

._crit_edge:                                      ; preds = %.critedge, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0
}

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

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

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

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

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


; Effective O3 passes: ADCEPass,AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass