; LLVM IR from tangjz/acm-icpc :: self_training/2015-01-29 (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"

@key = external dso_local global [4 x i32], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@tot = external dso_local global i32, align 4
@temp = external dso_local global i32, align 4
@str = external dso_local global [233 x i8], align 16
@tmp = external dso_local global [10 x i8], align 1
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z6decodei(i32 noundef) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i8, align 1
  %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 @t)
  br label %6

6:                                                ; preds = %96, %0
  %7 = load i32, ptr @t, align 4, !tbaa !5
  %8 = add nsw i32 %7, -1
  store i32 %8, ptr @t, align 4, !tbaa !5
  %9 = icmp ne i32 %7, 0
  br i1 %9, label %10, label %98

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 1, ptr %2) #5
  store i8 0, ptr %2, align 1, !tbaa !9
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @key, ptr noundef getelementptr inbounds ([4 x i32], ptr @key, i64 0, i64 1), ptr noundef getelementptr inbounds ([4 x i32], ptr @key, i64 0, i64 2), ptr noundef getelementptr inbounds ([4 x i32], ptr @key, i64 0, i64 3))
  br label %12

12:                                               ; preds = %70, %10
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = add nsw i32 %13, -1
  store i32 %14, ptr @n, align 4, !tbaa !5
  %15 = icmp ne i32 %13, 0
  br i1 %15, label %16, label %71

16:                                               ; preds = %12
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @temp)
  %18 = load i32, ptr @temp, align 4, !tbaa !5
  %19 = call noundef i32 @_Z6decodei(i32 noundef %18)
  store i32 %19, ptr @temp, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 2, ptr %3, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %33, %16
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = icmp sge i32 %21, 0
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %20
  %25 = load i32, ptr @temp, align 4, !tbaa !5
  %26 = srem i32 %25, 100
  %27 = trunc i32 %26 to i8
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [10 x i8], ptr @tmp, i64 0, i64 %29
  store i8 %27, ptr %30, align 1, !tbaa !11
  %31 = load i32, ptr @temp, align 4, !tbaa !5
  %32 = sdiv i32 %31, 100
  store i32 %32, ptr @temp, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %24
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr %3, align 4, !tbaa !5
  br label %20, !llvm.loop !12

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

37:                                               ; preds = %67, %36
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = icmp slt i32 %38, 3
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %37
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [10 x i8], ptr @tmp, i64 0, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !11
  %46 = sext i8 %45 to i32
  %47 = icmp sle i32 %46, 26
  br i1 %47, label %48, label %61

48:                                               ; preds = %41
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [10 x i8], ptr @tmp, i64 0, i64 %50
  %52 = load i8, ptr %51, align 1, !tbaa !11
  %53 = sext i8 %52 to i32
  %54 = add nsw i32 65, %53
  %55 = sub nsw i32 %54, 1
  %56 = trunc i32 %55 to i8
  %57 = load i32, ptr @tot, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr @tot, align 4, !tbaa !5
  %59 = sext i32 %57 to i64
  %60 = getelementptr inbounds [233 x i8], ptr @str, i64 0, i64 %59
  store i8 %56, ptr %60, align 1, !tbaa !11
  br label %66

61:                                               ; preds = %41
  %62 = load i32, ptr @tot, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr @tot, align 4, !tbaa !5
  %64 = sext i32 %62 to i64
  %65 = getelementptr inbounds [233 x i8], ptr @str, i64 0, i64 %64
  store i8 32, ptr %65, align 1, !tbaa !11
  br label %66

66:                                               ; preds = %61, %48
  br label %67

67:                                               ; preds = %66
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %4, align 4, !tbaa !5
  br label %37, !llvm.loop !14

70:                                               ; preds = %40
  br label %12, !llvm.loop !15

71:                                               ; preds = %12
  br label %72

72:                                               ; preds = %85, %71
  %73 = load i32, ptr @tot, align 4, !tbaa !5
  %74 = icmp ne i32 %73, 0
  br i1 %74, label %75, label %83

75:                                               ; preds = %72
  %76 = load i32, ptr @tot, align 4, !tbaa !5
  %77 = sub nsw i32 %76, 1
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [233 x i8], ptr @str, i64 0, i64 %78
  %80 = load i8, ptr %79, align 1, !tbaa !11
  %81 = sext i8 %80 to i32
  %82 = icmp eq i32 %81, 32
  br label %83

83:                                               ; preds = %75, %72
  %84 = phi i1 [ false, %72 ], [ %82, %75 ]
  br i1 %84, label %85, label %88

85:                                               ; preds = %83
  %86 = load i32, ptr @tot, align 4, !tbaa !5
  %87 = add nsw i32 %86, -1
  store i32 %87, ptr @tot, align 4, !tbaa !5
  br label %72, !llvm.loop !16

88:                                               ; preds = %83
  %89 = load i32, ptr @tot, align 4, !tbaa !5
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %96

91:                                               ; preds = %88
  %92 = load i32, ptr @tot, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [233 x i8], ptr @str, i64 0, i64 %93
  store i8 0, ptr %94, align 1, !tbaa !11
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef @str)
  store i32 0, ptr @tot, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %91, %88
  %97 = call i32 @putchar(i32 noundef 10)
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #5
  br label %6, !llvm.loop !17

98:                                               ; preds = %6
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare i32 @putchar(i32 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { inlinehint 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 #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 = !{!"bool", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}
!17 = distinct !{!17, !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"

@key = external dso_local global [4 x i32], align 16
@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@tot = external dso_local local_unnamed_addr global i32, align 4
@temp = external dso_local global i32, align 4
@str = external dso_local global [233 x i8], align 16
@tmp = external dso_local local_unnamed_addr global [10 x i8], align 1
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

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

; Function Attrs: mustprogress norecurse 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 @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not20 = icmp eq i32 %2, 0
  br i1 %.not20, label %._crit_edge, label %.lr.ph21

.lr.ph21:                                         ; preds = %0, %.critedge.thread
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @key, ptr noundef nonnull getelementptr inbounds (i8, ptr @key, i64 4), ptr noundef nonnull getelementptr inbounds (i8, ptr @key, i64 8), ptr noundef nonnull getelementptr inbounds (i8, ptr @key, i64 12))
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr @n, align 4, !tbaa !5
  %.not1117 = icmp eq i32 %5, 0
  br i1 %.not1117, label %.lr.ph21.thread-pre-split_crit_edge, label %.lr.ph

.lr.ph21.thread-pre-split_crit_edge:              ; preds = %.lr.ph21
  %.pr.pre = load i32, ptr @tot, align 4, !tbaa !5
  br label %thread-pre-split

.lr.ph:                                           ; preds = %.lr.ph21, %.lr.ph
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @temp)
  %8 = load i32, ptr @temp, align 4, !tbaa !5
  %9 = tail call noundef i32 @_Z6decodei(i32 noundef %8)
  %10 = srem i32 %9, 100
  %11 = trunc nsw i32 %10 to i8
  store i8 %11, ptr getelementptr inbounds (i8, ptr @tmp, i64 2), align 1, !tbaa !9
  %12 = sdiv i32 %9, 100
  %13 = srem i32 %12, 100
  %14 = trunc nsw i32 %13 to i8
  store i8 %14, ptr getelementptr inbounds (i8, ptr @tmp, i64 1), align 1, !tbaa !9
  %15 = sdiv i32 %9, 10000
  %16 = srem i32 %15, 100
  %17 = trunc nsw i32 %16 to i8
  store i8 %17, ptr @tmp, align 1, !tbaa !9
  %18 = sdiv i32 %9, 1000000
  store i32 %18, ptr @temp, align 4, !tbaa !5
  %tot.promoted = load i32, ptr @tot, align 4, !tbaa !5
  %19 = icmp slt i32 %16, 27
  %20 = add nsw i8 %17, 64
  %.sink = select i1 %19, i8 %20, i8 32
  %21 = add nsw i32 %tot.promoted, 1
  %22 = sext i32 %tot.promoted to i64
  %23 = getelementptr inbounds [233 x i8], ptr @str, i64 0, i64 %22
  store i8 %.sink, ptr %23, align 1, !tbaa !9
  %24 = icmp slt i32 %13, 27
  %25 = add nsw i8 %14, 64
  %.sink32 = select i1 %24, i8 %25, i8 32
  %26 = add nsw i32 %tot.promoted, 2
  %27 = sext i32 %21 to i64
  %28 = getelementptr inbounds [233 x i8], ptr @str, i64 0, i64 %27
  store i8 %.sink32, ptr %28, align 1, !tbaa !9
  %29 = icmp slt i32 %10, 27
  %30 = add nsw i8 %11, 64
  %.sink35 = select i1 %29, i8 %30, i8 32
  %31 = add nsw i32 %tot.promoted, 3
  store i32 %31, ptr @tot, align 4, !tbaa !5
  %32 = sext i32 %26 to i64
  %33 = getelementptr inbounds [233 x i8], ptr @str, i64 0, i64 %32
  store i8 %.sink35, ptr %33, align 1, !tbaa !9
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr @n, align 4, !tbaa !5
  %.not11 = icmp eq i32 %34, 0
  br i1 %.not11, label %thread-pre-split, label %.lr.ph, !llvm.loop !10

thread-pre-split:                                 ; preds = %.lr.ph, %.lr.ph21.thread-pre-split_crit_edge
  %.pr = phi i32 [ %.pr.pre, %.lr.ph21.thread-pre-split_crit_edge ], [ %31, %.lr.ph ]
  %.not1218 = icmp eq i32 %.pr, 0
  br i1 %.not1218, label %.critedge.thread, label %.lr.ph19.preheader

.lr.ph19.preheader:                               ; preds = %thread-pre-split
  %36 = sext i32 %.pr to i64
  br label %.lr.ph19

.lr.ph19:                                         ; preds = %.lr.ph19.preheader, %40
  %indvars.iv = phi i64 [ %36, %.lr.ph19.preheader ], [ %indvars.iv.next, %40 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %37 = getelementptr inbounds [233 x i8], ptr @str, i64 0, i64 %indvars.iv.next
  %38 = load i8, ptr %37, align 1, !tbaa !9
  %39 = icmp eq i8 %38, 32
  br i1 %39, label %40, label %.critedge

40:                                               ; preds = %.lr.ph19
  %41 = trunc nsw i64 %indvars.iv.next to i32
  store i32 %41, ptr @tot, align 4, !tbaa !5
  %.not12 = icmp eq i64 %indvars.iv.next, 0
  br i1 %.not12, label %.critedge.thread, label %.lr.ph19, !llvm.loop !12

.critedge:                                        ; preds = %.lr.ph19
  %sext = shl i64 %indvars.iv, 32
  %42 = ashr exact i64 %sext, 32
  %43 = getelementptr inbounds [233 x i8], ptr @str, i64 0, i64 %42
  store i8 0, ptr %43, align 1, !tbaa !9
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef nonnull @str)
  store i32 0, ptr @tot, align 4, !tbaa !5
  br label %.critedge.thread

.critedge.thread:                                 ; preds = %40, %thread-pre-split, %.critedge
  %45 = tail call i32 @putchar(i32 noundef 10)
  %46 = load i32, ptr @t, align 4, !tbaa !5
  %47 = add nsw i32 %46, -1
  store i32 %47, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %46, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph21, !llvm.loop !13

._crit_edge:                                      ; preds = %.critedge.thread, %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 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #3

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 = { 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 = { 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 = { inlinehint mustprogress nofree 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" }

!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}
!13 = distinct !{!13, !11}


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