; LLVM IR from tangjz/acm-icpc :: self_training/2015-03-15 (F)

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

@t = external dso_local global i32, align 4
@a = external dso_local global [4 x i32], 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 norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %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
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %9

9:                                                ; preds = %96, %0
  %10 = load i32, ptr @t, align 4, !tbaa !5
  %11 = add nsw i32 %10, -1
  store i32 %11, ptr @t, align 4, !tbaa !5
  %12 = icmp ne i32 %10, 0
  br i1 %12, label %13, label %102

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

14:                                               ; preds = %23, %13
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 4
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %26

18:                                               ; preds = %14
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr @a, i64 %20
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %21)
  br label %23

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

26:                                               ; preds = %17
  call void @_ZSt4sortIPiEvT_S1_(ptr noundef @a, ptr noundef getelementptr inbounds (i32, ptr @a, i64 4))
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #4
  store i8 0, ptr %3, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %93, %26
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = icmp slt i32 %28, 4
  br i1 %29, label %30, label %34

30:                                               ; preds = %27
  %31 = load i8, ptr %3, align 1, !tbaa !11, !range !13, !noundef !14
  %32 = trunc i8 %31 to i1
  %33 = xor i1 %32, true
  br label %34

34:                                               ; preds = %30, %27
  %35 = phi i1 [ false, %27 ], [ %33, %30 ]
  br i1 %35, label %37, label %36

36:                                               ; preds = %34
  store i32 7, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %96

37:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %6, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %89, %37
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = icmp slt i32 %41, 4
  br i1 %42, label %43, label %47

43:                                               ; preds = %40
  %44 = load i8, ptr %3, align 1, !tbaa !11, !range !13, !noundef !14
  %45 = trunc i8 %44 to i1
  %46 = xor i1 %45, true
  br label %47

47:                                               ; preds = %43, %40
  %48 = phi i1 [ false, %40 ], [ %46, %43 ]
  br i1 %48, label %50, label %49

49:                                               ; preds = %47
  store i32 10, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %92

50:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %7, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %85, %50
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = icmp slt i32 %54, 4
  br i1 %55, label %56, label %60

56:                                               ; preds = %53
  %57 = load i8, ptr %3, align 1, !tbaa !11, !range !13, !noundef !14
  %58 = trunc i8 %57 to i1
  %59 = xor i1 %58, true
  br label %60

60:                                               ; preds = %56, %53
  %61 = phi i1 [ false, %53 ], [ %59, %56 ]
  br i1 %61, label %63, label %62

62:                                               ; preds = %60
  store i32 13, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %88

63:                                               ; preds = %60
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [4 x i32], ptr @a, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [4 x i32], ptr @a, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = add nsw i32 %67, %71
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [4 x i32], ptr @a, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = icmp sgt i32 %72, %76
  %78 = zext i1 %77 to i32
  %79 = load i8, ptr %3, align 1, !tbaa !11, !range !13, !noundef !14
  %80 = trunc i8 %79 to i1
  %81 = zext i1 %80 to i32
  %82 = or i32 %81, %78
  %83 = icmp ne i32 %82, 0
  %84 = zext i1 %83 to i8
  store i8 %84, ptr %3, align 1, !tbaa !11
  br label %85

85:                                               ; preds = %63
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %7, align 4, !tbaa !5
  br label %53, !llvm.loop !15

88:                                               ; preds = %62
  br label %89

89:                                               ; preds = %88
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %6, align 4, !tbaa !5
  br label %40, !llvm.loop !16

92:                                               ; preds = %49
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %4, align 4, !tbaa !5
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %4, align 4, !tbaa !5
  br label %27, !llvm.loop !17

96:                                               ; preds = %36
  %97 = load i8, ptr %3, align 1, !tbaa !11, !range !13, !noundef !14
  %98 = trunc i8 %97 to i1
  %99 = zext i1 %98 to i64
  %100 = select i1 %98, ptr @.str.1, ptr @.str.2
  %101 = call i32 @puts(ptr noundef %100)
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #4
  br label %9, !llvm.loop !18

102:                                              ; preds = %9
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) #3

declare i32 @puts(ptr noundef) #1

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


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

@t = external dso_local global i32, align 4
@a = external dso_local global [4 x i32], 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 norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %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
  %.not41 = icmp eq i32 %2, 0
  br i1 %.not41, label %._crit_edge, label %.preheader

.preheader:                                       ; preds = %0, %.loopexit29.3
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a)
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @a, i64 4))
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @a, i64 8))
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @a, i64 12))
  tail call void @_ZSt4sortIPiEvT_S1_(ptr noundef nonnull @a, ptr noundef nonnull getelementptr inbounds (i8, ptr @a, i64 16))
  %8 = load i32, ptr @a, align 16, !tbaa !5
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !5
  %10 = add nsw i32 %9, %8
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 8), align 8, !tbaa !5
  %12 = icmp sgt i32 %10, %11
  br i1 %12, label %.loopexit.loopexit, label %43, !llvm.loop !9

.loopexit29:                                      ; preds = %.loopexit.1, %.loopexit.loopexit
  %.pre-phi54.lcssa = phi i1 [ %.lcssa, %.loopexit.loopexit ], [ %spec.select, %.loopexit.1 ]
  %.2.lcssa.lcssa = phi i8 [ %.lcssa57, %.loopexit.loopexit ], [ %.2.lcssa.1, %.loopexit.1 ]
  br i1 %.pre-phi54.lcssa, label %.loopexit29.3, label %13, !llvm.loop !11

13:                                               ; preds = %.loopexit29
  %14 = trunc i8 %.2.lcssa.lcssa to i1
  br i1 %14, label %.loopexit29.1, label %.lr.ph37.1

.lr.ph37.1:                                       ; preds = %13
  %15 = trunc i8 %.2.lcssa.lcssa to i1
  br i1 %15, label %.loopexit.170, label %.lr.ph.160

.lr.ph.160:                                       ; preds = %.lr.ph37.1
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 8), align 8, !tbaa !5
  %17 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !5
  %18 = add nsw i32 %16, %17
  %19 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 12), align 4, !tbaa !5
  %20 = icmp sgt i32 %18, %19
  %21 = zext i1 %20 to i8
  %22 = or i8 %.2.lcssa.lcssa, %21
  %23 = trunc i8 %22 to i1
  br label %.loopexit.170

.loopexit.170:                                    ; preds = %.lr.ph.160, %.lr.ph37.1
  %.pre-phi54.166 = phi i1 [ %15, %.lr.ph37.1 ], [ %23, %.lr.ph.160 ]
  %.2.lcssa.167 = phi i8 [ %.2.lcssa.lcssa, %.lr.ph37.1 ], [ %22, %.lr.ph.160 ]
  %24 = trunc i8 %.2.lcssa.167 to i1
  %.pre-phi54.lcssa.1 = select i1 %.pre-phi54.166, i1 %.pre-phi54.166, i1 %24
  br label %.loopexit29.1

.loopexit29.1:                                    ; preds = %.loopexit.170, %13
  %.pre-phi.1 = phi i1 [ %14, %13 ], [ %.pre-phi54.lcssa.1, %.loopexit.170 ]
  %.1.lcssa.1 = phi i8 [ %.2.lcssa.lcssa, %13 ], [ %.2.lcssa.167, %.loopexit.170 ]
  br i1 %.pre-phi.1, label %.loopexit29.3, label %.loopexit29.2, !llvm.loop !11

.loopexit29.2:                                    ; preds = %.loopexit29.1
  %25 = trunc i8 %.1.lcssa.1 to i1
  %26 = trunc i8 %.1.lcssa.1 to i1
  %.pre-phi.2 = select i1 %25, i1 %25, i1 %26
  %27 = trunc i8 %.1.lcssa.1 to i1
  %spec.select79 = select i1 %.pre-phi.2, i1 %.pre-phi.2, i1 %27
  br label %.loopexit29.3, !llvm.loop !11

.loopexit29.3:                                    ; preds = %.loopexit29.2, %.loopexit29.1, %.loopexit29
  %.pre-phi.lcssa = phi i1 [ %.pre-phi54.lcssa, %.loopexit29 ], [ %.pre-phi.1, %.loopexit29.1 ], [ %spec.select79, %.loopexit29.2 ]
  %28 = select i1 %.pre-phi.lcssa, ptr @.str.1, ptr @.str.2
  %29 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %28)
  %30 = load i32, ptr @t, align 4, !tbaa !5
  %31 = add nsw i32 %30, -1
  store i32 %31, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %30, 0
  br i1 %.not, label %._crit_edge, label %.preheader, !llvm.loop !12

.loopexit.loopexit:                               ; preds = %43, %.preheader
  %.lcssa = phi i1 [ %12, %.preheader ], [ %46, %43 ]
  %.lcssa57 = zext i1 %.lcssa to i8
  br i1 %.lcssa, label %.loopexit29, label %32, !llvm.loop !13

32:                                               ; preds = %.loopexit.loopexit
  %33 = trunc i8 %.lcssa57 to i1
  br i1 %33, label %.loopexit.1, label %.lr.ph.1

.lr.ph.1:                                         ; preds = %32
  %34 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 8), align 8, !tbaa !5
  %35 = load i32, ptr @a, align 16, !tbaa !5
  %36 = add nsw i32 %34, %35
  %37 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 12), align 4, !tbaa !5
  %38 = icmp sgt i32 %36, %37
  %39 = zext i1 %38 to i8
  %40 = or i8 %.lcssa57, %39
  %41 = trunc i8 %40 to i1
  br label %.loopexit.1

.loopexit.1:                                      ; preds = %.lr.ph.1, %32
  %.pre-phi54.1 = phi i1 [ %33, %32 ], [ %41, %.lr.ph.1 ]
  %.2.lcssa.1 = phi i8 [ %.lcssa57, %32 ], [ %40, %.lr.ph.1 ]
  %42 = trunc i8 %.2.lcssa.1 to i1
  %spec.select = select i1 %.pre-phi54.1, i1 %.pre-phi54.1, i1 %42
  br label %.loopexit29, !llvm.loop !13

43:                                               ; preds = %.preheader
  %44 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 12), align 4, !tbaa !5
  %45 = icmp sgt i32 %10, %44
  %46 = or i1 %12, %45
  br label %.loopexit.loopexit

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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 = { 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 #2 = { 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" }

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


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