; LLVM IR from tangjz/acm-icpc :: self_training/2015-04-17 (E)

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

@s = external dso_local global [129 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5equali(i32 noundef) #0

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

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

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

6:                                                ; preds = %45, %0
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @s)
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %9, label %13

9:                                                ; preds = %6
  %10 = load i8, ptr @s, align 16, !tbaa !5
  %11 = sext i8 %10 to i32
  %12 = icmp ne i32 %11, 35
  br label %13

13:                                               ; preds = %9, %6
  %14 = phi i1 [ false, %6 ], [ %12, %9 ]
  br i1 %14, label %15, label %52

15:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !8
  br label %16

16:                                               ; preds = %28, %15
  %17 = load i32, ptr %2, align 4, !tbaa !8
  %18 = icmp slt i32 %17, 128
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %31

20:                                               ; preds = %16
  %21 = load i32, ptr %2, align 4, !tbaa !8
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [129 x i8], ptr @s, i64 0, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = sext i8 %24 to i32
  %26 = sub nsw i32 %25, 48
  %27 = trunc i32 %26 to i8
  store i8 %27, ptr %23, align 1, !tbaa !5
  br label %28

28:                                               ; preds = %20
  %29 = load i32, ptr %2, align 4, !tbaa !8
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %2, align 4, !tbaa !8
  br label %16, !llvm.loop !10

31:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #4
  store i8 0, ptr %3, align 1, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !8
  br label %32

32:                                               ; preds = %41, %31
  %33 = load i32, ptr %4, align 4, !tbaa !8
  %34 = icmp slt i32 %33, 524288
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  store i32 7, ptr %5, align 4
  br label %44

36:                                               ; preds = %32
  %37 = load i32, ptr %4, align 4, !tbaa !8
  %38 = call noundef zeroext i1 @_Z5equali(i32 noundef %37)
  br i1 %38, label %40, label %39

39:                                               ; preds = %36
  store i8 1, ptr %3, align 1, !tbaa !12
  store i32 7, ptr %5, align 4
  br label %44

40:                                               ; preds = %36
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %4, align 4, !tbaa !8
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %4, align 4, !tbaa !8
  br label %32, !llvm.loop !14

44:                                               ; preds = %39, %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %45

45:                                               ; preds = %44
  %46 = load i8, ptr %3, align 1, !tbaa !12, !range !15, !noundef !16
  %47 = trunc i8 %46 to i1
  %48 = xor i1 %47, true
  %49 = zext i1 %48 to i64
  %50 = select i1 %48, ptr @.str.1, ptr @.str.2
  %51 = call i32 @puts(ptr noundef %50)
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  br label %6, !llvm.loop !17

52:                                               ; preds = %13
  ret i32 0
}

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

declare i32 @puts(ptr noundef) #3

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


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

@s = external dso_local global [129 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5equali(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @s)
  %2 = icmp eq i32 %1, 1
  %3 = load i8, ptr @s, align 16
  %4 = icmp ne i8 %3, 35
  %5 = select i1 %2, i1 %4, i1 false
  br i1 %5, label %vector.body, label %._crit_edge

vector.body:                                      ; preds = %0, %vector.body.backedge
  %index = phi i64 [ %index.be, %vector.body.backedge ], [ 0, %0 ]
  %6 = getelementptr inbounds [129 x i8], ptr @s, i64 0, i64 %index
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %wide.load = load <16 x i8>, ptr %6, align 16, !tbaa !5
  %wide.load14 = load <16 x i8>, ptr %7, align 16, !tbaa !5
  %8 = add <16 x i8> %wide.load, <i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48>
  %9 = add <16 x i8> %wide.load14, <i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48, i8 -48>
  store <16 x i8> %8, ptr %6, align 16, !tbaa !5
  store <16 x i8> %9, ptr %7, align 16, !tbaa !5
  %index.next = add nuw i64 %index, 32
  %10 = icmp eq i64 %index.next, 128
  br i1 %10, label %.preheader, label %vector.body.backedge

vector.body.backedge:                             ; preds = %vector.body, %14
  %index.be = phi i64 [ %index.next, %vector.body ], [ 0, %14 ]
  br label %vector.body, !llvm.loop !8

11:                                               ; preds = %.preheader
  %12 = add nuw nsw i32 %.011, 1
  %exitcond13 = icmp eq i32 %12, 524288
  br i1 %exitcond13, label %14, label %.preheader, !llvm.loop !10

.preheader:                                       ; preds = %vector.body, %11
  %.011 = phi i32 [ %12, %11 ], [ 0, %vector.body ]
  %13 = tail call noundef zeroext i1 @_Z5equali(i32 noundef %.011)
  br i1 %13, label %11, label %14

14:                                               ; preds = %.preheader, %11
  %15 = phi ptr [ @.str.1, %11 ], [ @.str.2, %.preheader ]
  %16 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %15)
  %17 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @s)
  %18 = icmp eq i32 %17, 1
  %19 = load i8, ptr @s, align 16
  %20 = icmp ne i8 %19, 35
  %21 = select i1 %18, i1 %20, i1 false
  br i1 %21, label %vector.body.backedge, label %._crit_edge

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #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" }
attributes #1 = { mustprogress 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 #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" }

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass