; LLVM IR from tangjz/acm-icpc :: TDL_training/2016-07-08 (B - Files list - lzy)

; 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
@m = external dso_local global i32, align 4
@c = external dso_local global [1009 x i32], align 16
@suff = external dso_local global [1009 x [209 x i8]], align 16
@s = external dso_local global [209 x i8], align 16
@t = external dso_local global ptr, align 8
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4findPc(ptr 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
  store i32 0, ptr %1, align 4
  %3 = load ptr, ptr @stdin, align 8, !tbaa !5
  %4 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %3)
  %5 = load ptr, ptr @stdout, align 8, !tbaa !5
  %6 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %5)
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.4, ptr noundef @n)
  br label %8

8:                                                ; preds = %23, %0
  %9 = load i32, ptr @n, align 4, !tbaa !9
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr @n, align 4, !tbaa !9
  %11 = icmp ne i32 %9, 0
  br i1 %11, label %12, label %31

12:                                               ; preds = %8
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.5, ptr noundef @s)
  store ptr @s, ptr @t, align 8, !tbaa !5
  br label %14

14:                                               ; preds = %20, %12
  %15 = load ptr, ptr @t, align 8, !tbaa !5
  %16 = load i8, ptr %15, align 1, !tbaa !11
  %17 = sext i8 %16 to i32
  %18 = icmp ne i32 %17, 46
  br i1 %18, label %19, label %23

19:                                               ; preds = %14
  br label %20

20:                                               ; preds = %19
  %21 = load ptr, ptr @t, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i32 1
  store ptr %22, ptr @t, align 8, !tbaa !5
  br label %14, !llvm.loop !12

23:                                               ; preds = %14
  %24 = load ptr, ptr @t, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i32 1
  store ptr %25, ptr @t, align 8, !tbaa !5
  %26 = call noundef i32 @_Z4findPc(ptr noundef %25)
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [1009 x i32], ptr @c, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %28, align 4, !tbaa !9
  br label %8, !llvm.loop !14

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

32:                                               ; preds = %47, %31
  %33 = load i32, ptr %2, align 4, !tbaa !9
  %34 = load i32, ptr @m, align 4, !tbaa !9
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %50

37:                                               ; preds = %32
  %38 = load i32, ptr %2, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1009 x [209 x i8]], ptr @suff, i64 0, i64 %39
  %41 = getelementptr inbounds [209 x i8], ptr %40, i64 0, i64 0
  %42 = load i32, ptr %2, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1009 x i32], ptr @c, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, ptr noundef %41, i32 noundef %45)
  br label %47

47:                                               ; preds = %37
  %48 = load i32, ptr %2, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %2, align 4, !tbaa !9
  br label %32, !llvm.loop !15

50:                                               ; preds = %36
  ret i32 0
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #3

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

declare i32 @printf(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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !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
@m = external dso_local local_unnamed_addr global i32, align 4
@c = external dso_local local_unnamed_addr global [1009 x i32], align 16
@suff = external dso_local global [1009 x [209 x i8]], align 16
@s = external dso_local global [209 x i8], align 16
@t = external dso_local local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4findPc(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = load ptr, ptr @stdin, align 8, !tbaa !5
  %2 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %1)
  %3 = load ptr, ptr @stdout, align 8, !tbaa !5
  %4 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %3)
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.4, ptr noundef nonnull @n)
  %6 = load i32, ptr @n, align 4, !tbaa !9
  %7 = add nsw i32 %6, -1
  store i32 %7, ptr @n, align 4, !tbaa !9
  %.not6 = icmp eq i32 %6, 0
  br i1 %.not6, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %14, %0
  %8 = load i32, ptr @m, align 4, !tbaa !9
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph8, label %._crit_edge

.lr.ph:                                           ; preds = %0, %14
  %10 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.5, ptr noundef nonnull @s)
  br label %11

11:                                               ; preds = %11, %.lr.ph
  %storemerge = phi ptr [ @s, %.lr.ph ], [ %13, %11 ]
  %12 = load i8, ptr %storemerge, align 1, !tbaa !11
  %.not4 = icmp eq i8 %12, 46
  %13 = getelementptr inbounds i8, ptr %storemerge, i64 1
  br i1 %.not4, label %14, label %11, !llvm.loop !12

14:                                               ; preds = %11
  store ptr %13, ptr @t, align 8, !tbaa !5
  %15 = tail call noundef i32 @_Z4findPc(ptr noundef nonnull %13)
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [1009 x i32], ptr @c, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %17, align 4, !tbaa !9
  %20 = load i32, ptr @n, align 4, !tbaa !9
  %21 = add nsw i32 %20, -1
  store i32 %21, ptr @n, align 4, !tbaa !9
  %.not = icmp eq i32 %20, 0
  br i1 %.not, label %.preheader, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph8, %.preheader
  ret i32 0

.lr.ph8:                                          ; preds = %.preheader, %.lr.ph8
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph8 ], [ 0, %.preheader ]
  %22 = getelementptr inbounds [1009 x [209 x i8]], ptr @suff, i64 0, i64 %indvars.iv
  %23 = getelementptr inbounds [1009 x i32], ptr @c, i64 0, i64 %indvars.iv
  %24 = load i32, ptr %23, align 4, !tbaa !9
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef nonnull %22, i32 noundef %24)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr @m, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = icmp slt i64 %indvars.iv.next, %27
  br i1 %28, label %.lr.ph8, label %._crit_edge, !llvm.loop !15
}

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { 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 #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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}


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