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

@pai = external dso_local global ptr, align 8
@trans = external dso_local global [256 x i32], align 16
@yours = external dso_local global [25 x i8], align 16
@mine = external dso_local global [25 x i8], align 16
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5judgev() #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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; 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) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4initv() #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5checkv() #4

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #5 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.memset.p0.i64(ptr align 16 @trans, i8 -1, i64 1024, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %17, %0
  %4 = load i32, ptr %2, align 4, !tbaa !5
  %5 = icmp slt i32 %4, 15
  br i1 %5, label %7, label %6

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

7:                                                ; preds = %3
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = load ptr, ptr @pai, align 8, !tbaa !9
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds i8, ptr %9, i64 %11
  %13 = load i8, ptr %12, align 1, !tbaa !11
  %14 = sext i8 %13 to i32
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %15
  store i32 %8, ptr %16, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %7
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %2, align 4, !tbaa !5
  br label %3, !llvm.loop !12

20:                                               ; preds = %6
  br label %21

21:                                               ; preds = %24, %20
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @yours, ptr noundef @mine)
  %23 = icmp eq i32 %22, 2
  br i1 %23, label %24, label %29

24:                                               ; preds = %21
  call void @_Z5judgev()
  call void @_Z4initv()
  %25 = call noundef zeroext i1 @_Z5checkv()
  %26 = zext i1 %25 to i64
  %27 = select i1 %25, ptr @.str.3, ptr @.str.4
  %28 = call i32 @puts(ptr noundef %27)
  br label %21, !llvm.loop !14

29:                                               ; preds = %21
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 #5 = { 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 #6 = { 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 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !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"

@pai = external dso_local local_unnamed_addr global ptr, align 8
@trans = external dso_local local_unnamed_addr global [256 x i32], align 16
@yours = external dso_local global [25 x i8], align 16
@mine = external dso_local global [25 x i8], align 16
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5judgev() local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z4initv() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5checkv() local_unnamed_addr #3

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #4 {
.preheader:
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1024) @trans, i8 -1, i64 1024, i1 false)
  %0 = load ptr, ptr @pai, align 8, !tbaa !5
  %1 = load i8, ptr %0, align 1, !tbaa !9
  %2 = sext i8 %1 to i64
  %3 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %2
  store i32 0, ptr %3, align 4, !tbaa !10
  %4 = getelementptr inbounds i8, ptr %0, i64 1
  %5 = load i8, ptr %4, align 1, !tbaa !9
  %6 = sext i8 %5 to i64
  %7 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %6
  store i32 1, ptr %7, align 4, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %0, i64 2
  %9 = load i8, ptr %8, align 1, !tbaa !9
  %10 = sext i8 %9 to i64
  %11 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %10
  store i32 2, ptr %11, align 4, !tbaa !10
  %12 = getelementptr inbounds i8, ptr %0, i64 3
  %13 = load i8, ptr %12, align 1, !tbaa !9
  %14 = sext i8 %13 to i64
  %15 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %14
  store i32 3, ptr %15, align 4, !tbaa !10
  %16 = getelementptr inbounds i8, ptr %0, i64 4
  %17 = load i8, ptr %16, align 1, !tbaa !9
  %18 = sext i8 %17 to i64
  %19 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %18
  store i32 4, ptr %19, align 4, !tbaa !10
  %20 = getelementptr inbounds i8, ptr %0, i64 5
  %21 = load i8, ptr %20, align 1, !tbaa !9
  %22 = sext i8 %21 to i64
  %23 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %22
  store i32 5, ptr %23, align 4, !tbaa !10
  %24 = getelementptr inbounds i8, ptr %0, i64 6
  %25 = load i8, ptr %24, align 1, !tbaa !9
  %26 = sext i8 %25 to i64
  %27 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %26
  store i32 6, ptr %27, align 4, !tbaa !10
  %28 = getelementptr inbounds i8, ptr %0, i64 7
  %29 = load i8, ptr %28, align 1, !tbaa !9
  %30 = sext i8 %29 to i64
  %31 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %30
  store i32 7, ptr %31, align 4, !tbaa !10
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load i8, ptr %32, align 1, !tbaa !9
  %34 = sext i8 %33 to i64
  %35 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %34
  store i32 8, ptr %35, align 4, !tbaa !10
  %36 = getelementptr inbounds i8, ptr %0, i64 9
  %37 = load i8, ptr %36, align 1, !tbaa !9
  %38 = sext i8 %37 to i64
  %39 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %38
  store i32 9, ptr %39, align 4, !tbaa !10
  %40 = getelementptr inbounds i8, ptr %0, i64 10
  %41 = load i8, ptr %40, align 1, !tbaa !9
  %42 = sext i8 %41 to i64
  %43 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %42
  store i32 10, ptr %43, align 4, !tbaa !10
  %44 = getelementptr inbounds i8, ptr %0, i64 11
  %45 = load i8, ptr %44, align 1, !tbaa !9
  %46 = sext i8 %45 to i64
  %47 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %46
  store i32 11, ptr %47, align 4, !tbaa !10
  %48 = getelementptr inbounds i8, ptr %0, i64 12
  %49 = load i8, ptr %48, align 1, !tbaa !9
  %50 = sext i8 %49 to i64
  %51 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %50
  store i32 12, ptr %51, align 4, !tbaa !10
  %52 = getelementptr inbounds i8, ptr %0, i64 13
  %53 = load i8, ptr %52, align 1, !tbaa !9
  %54 = sext i8 %53 to i64
  %55 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %54
  store i32 13, ptr %55, align 4, !tbaa !10
  %56 = getelementptr inbounds i8, ptr %0, i64 14
  %57 = load i8, ptr %56, align 1, !tbaa !9
  %58 = sext i8 %57 to i64
  %59 = getelementptr inbounds [256 x i32], ptr @trans, i64 0, i64 %58
  store i32 14, ptr %59, align 4, !tbaa !10
  %60 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @yours, ptr noundef nonnull @mine)
  %61 = icmp eq i32 %60, 2
  br i1 %61, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  tail call void @_Z5judgev()
  tail call void @_Z4initv()
  %62 = tail call noundef zeroext i1 @_Z5checkv()
  %63 = select i1 %62, ptr @.str.3, ptr @.str.4
  %64 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %63)
  %65 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @yours, ptr noundef nonnull @mine)
  %66 = icmp eq i32 %65, 2
  br i1 %66, label %.lr.ph, label %._crit_edge, !llvm.loop !12

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

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

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 nocallback nofree nounwind willreturn memory(argmem: write) }
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 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 #4 = { 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" }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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