; LLVM IR from tangjz/acm-icpc :: poj (1390)

; 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
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [201 x i32], align 16
@c = external dso_local global [201 x i32], align 16
@pos = external dso_local global [201 x i32], align 16
@pre = external dso_local global [201 x i32], align 16
@Case = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [13 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z1Fiii(i32 noundef, i32 noundef, 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 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)
  store i32 1, ptr @Case, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %87, %0
  %7 = load i32, ptr @Case, align 4, !tbaa !5
  %8 = load i32, ptr @t, align 4, !tbaa !5
  %9 = icmp sle i32 %7, %8
  br i1 %9, label %10, label %90

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

12:                                               ; preds = %49, %10
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = icmp sle i32 %13, %14
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %12
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3)
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %36

21:                                               ; preds = %17
  %22 = load i32, ptr @m, align 4, !tbaa !5
  %23 = sub nsw i32 %22, 1
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [201 x i32], ptr @a, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = icmp eq i32 %26, %27
  br i1 %28, label %29, label %36

29:                                               ; preds = %21
  %30 = load i32, ptr @m, align 4, !tbaa !5
  %31 = sub nsw i32 %30, 1
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [201 x i32], ptr @c, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %33, align 4, !tbaa !5
  br label %45

36:                                               ; preds = %21, %17
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = load i32, ptr @m, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [201 x i32], ptr @a, i64 0, i64 %39
  store i32 %37, ptr %40, align 4, !tbaa !5
  %41 = load i32, ptr @m, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr @m, align 4, !tbaa !5
  %43 = sext i32 %41 to i64
  %44 = getelementptr inbounds [201 x i32], ptr @c, i64 0, i64 %43
  store i32 1, ptr %44, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %36, %29
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [201 x i32], ptr @pos, i64 0, i64 %47
  store i32 -1, ptr %48, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %45
  %50 = load i32, ptr %2, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !9

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

53:                                               ; preds = %76, %52
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = load i32, ptr @m, align 4, !tbaa !5
  %56 = icmp slt i32 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %79

58:                                               ; preds = %53
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [201 x i32], ptr @a, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [201 x i32], ptr @pos, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = load i32, ptr %4, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [201 x i32], ptr @pre, i64 0, i64 %67
  store i32 %65, ptr %68, align 4, !tbaa !5
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [201 x i32], ptr @a, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [201 x i32], ptr @pos, i64 0, i64 %74
  store i32 %69, ptr %75, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %58
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %4, align 4, !tbaa !5
  br label %53, !llvm.loop !11

79:                                               ; preds = %57
  %80 = load i32, ptr @n, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr @n, align 4, !tbaa !5
  %82 = load i32, ptr @Case, align 4, !tbaa !5
  %83 = load i32, ptr @m, align 4, !tbaa !5
  %84 = sub nsw i32 %83, 1
  %85 = call noundef i32 @_Z1Fiii(i32 noundef 0, i32 noundef %84, i32 noundef 0)
  %86 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %82, i32 noundef %85)
  br label %87

87:                                               ; preds = %79
  %88 = load i32, ptr @Case, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr @Case, align 4, !tbaa !5
  br label %6, !llvm.loop !12

90:                                               ; preds = %6
  ret i32 0
}

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

declare i32 @printf(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 = { 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 = !{!"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}


; 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
@n = external dso_local global i32, align 4
@m = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local local_unnamed_addr global [201 x i32], align 16
@c = external dso_local local_unnamed_addr global [201 x i32], align 16
@pos = external dso_local local_unnamed_addr global [201 x i32], align 16
@pre = external dso_local local_unnamed_addr global [201 x i32], align 16
@Case = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [13 x i8], align 1

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

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

; Function Attrs: mustprogress 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() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  store i32 1, ptr @Case, align 4, !tbaa !5
  %3 = load i32, ptr @t, align 4, !tbaa !5
  %.not21 = icmp slt i32 %3, 1
  br i1 %.not21, label %._crit_edge24, label %.lr.ph23

.lr.ph23:                                         ; preds = %0, %._crit_edge19
  store i32 0, ptr @m, align 4, !tbaa !5
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not1114 = icmp slt i32 %5, 1
  br i1 %.not1114, label %.lr.ph23.._crit_edge_crit_edge, label %.lr.ph

.lr.ph23.._crit_edge_crit_edge:                   ; preds = %.lr.ph23
  %.pre30 = load i32, ptr @m, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %26, %.lr.ph23.._crit_edge_crit_edge
  %6 = phi i32 [ %.pre30, %.lr.ph23.._crit_edge_crit_edge ], [ %27, %26 ]
  %.lcssa = phi i32 [ %5, %.lr.ph23.._crit_edge_crit_edge ], [ %29, %26 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph18.preheader, label %._crit_edge19

.lr.ph18.preheader:                               ; preds = %._crit_edge
  %wide.trip.count = zext nneg i32 %6 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %8 = icmp eq i32 %6, 1
  br i1 %8, label %._crit_edge19.loopexit.unr-lcssa, label %.lr.ph18.preheader.new

.lr.ph18.preheader.new:                           ; preds = %.lr.ph18.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %.lr.ph18

.lr.ph:                                           ; preds = %.lr.ph23, %26
  %indvars.iv = phi i64 [ %indvars.iv.next, %26 ], [ 1, %.lr.ph23 ]
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %10 = load i32, ptr @m, align 4, !tbaa !5
  %.not12 = icmp eq i32 %10, 0
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br i1 %.not12, label %21, label %11

11:                                               ; preds = %.lr.ph
  %12 = add nsw i32 %10, -1
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [201 x i32], ptr @a, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = icmp eq i32 %15, %.pre
  br i1 %16, label %17, label %21

17:                                               ; preds = %11
  %18 = getelementptr inbounds [201 x i32], ptr @c, i64 0, i64 %13
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %18, align 4, !tbaa !5
  br label %26

21:                                               ; preds = %11, %.lr.ph
  %22 = sext i32 %10 to i64
  %23 = getelementptr inbounds [201 x i32], ptr @a, i64 0, i64 %22
  store i32 %.pre, ptr %23, align 4, !tbaa !5
  %24 = add nsw i32 %10, 1
  store i32 %24, ptr @m, align 4, !tbaa !5
  %25 = getelementptr inbounds [201 x i32], ptr @c, i64 0, i64 %22
  store i32 1, ptr %25, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %21, %17
  %27 = phi i32 [ %24, %21 ], [ %10, %17 ]
  %28 = getelementptr inbounds [201 x i32], ptr @pos, i64 0, i64 %indvars.iv
  store i32 -1, ptr %28, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %.not11.not = icmp slt i64 %indvars.iv, %30
  br i1 %.not11.not, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge19.loopexit.unr-lcssa:                 ; preds = %.lr.ph18, %.lr.ph18.preheader
  %indvars.iv27.unr = phi i64 [ 0, %.lr.ph18.preheader ], [ %indvars.iv.next28.1, %.lr.ph18 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge19, label %.lr.ph18.epil

.lr.ph18.epil:                                    ; preds = %._crit_edge19.loopexit.unr-lcssa
  %31 = getelementptr inbounds [201 x i32], ptr @a, i64 0, i64 %indvars.iv27.unr
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [201 x i32], ptr @pos, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = getelementptr inbounds [201 x i32], ptr @pre, i64 0, i64 %indvars.iv27.unr
  store i32 %35, ptr %36, align 4, !tbaa !5
  %37 = trunc nuw nsw i64 %indvars.iv27.unr to i32
  store i32 %37, ptr %34, align 4, !tbaa !5
  br label %._crit_edge19

._crit_edge19:                                    ; preds = %.lr.ph18.epil, %._crit_edge19.loopexit.unr-lcssa, %._crit_edge
  %38 = add nsw i32 %.lcssa, 1
  store i32 %38, ptr @n, align 4, !tbaa !5
  %39 = load i32, ptr @Case, align 4, !tbaa !5
  %40 = add nsw i32 %6, -1
  %41 = call noundef i32 @_Z1Fiii(i32 noundef 0, i32 noundef %40, i32 noundef 0)
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %39, i32 noundef %41)
  %43 = load i32, ptr @Case, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr @Case, align 4, !tbaa !5
  %45 = load i32, ptr @t, align 4, !tbaa !5
  %.not.not = icmp slt i32 %43, %45
  br i1 %.not.not, label %.lr.ph23, label %._crit_edge24, !llvm.loop !11

.lr.ph18:                                         ; preds = %.lr.ph18, %.lr.ph18.preheader.new
  %indvars.iv27 = phi i64 [ 0, %.lr.ph18.preheader.new ], [ %indvars.iv.next28.1, %.lr.ph18 ]
  %niter = phi i64 [ 0, %.lr.ph18.preheader.new ], [ %niter.next.1, %.lr.ph18 ]
  %46 = getelementptr inbounds [201 x i32], ptr @a, i64 0, i64 %indvars.iv27
  %47 = load i32, ptr %46, align 8, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [201 x i32], ptr @pos, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = getelementptr inbounds [201 x i32], ptr @pre, i64 0, i64 %indvars.iv27
  store i32 %50, ptr %51, align 8, !tbaa !5
  %52 = trunc nuw nsw i64 %indvars.iv27 to i32
  store i32 %52, ptr %49, align 4, !tbaa !5
  %indvars.iv.next28 = or disjoint i64 %indvars.iv27, 1
  %53 = getelementptr inbounds [201 x i32], ptr @a, i64 0, i64 %indvars.iv.next28
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [201 x i32], ptr @pos, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = getelementptr inbounds [201 x i32], ptr @pre, i64 0, i64 %indvars.iv.next28
  store i32 %57, ptr %58, align 4, !tbaa !5
  %59 = trunc nuw nsw i64 %indvars.iv.next28 to i32
  store i32 %59, ptr %56, align 4, !tbaa !5
  %indvars.iv.next28.1 = add nuw nsw i64 %indvars.iv27, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge19.loopexit.unr-lcssa, label %.lr.ph18, !llvm.loop !12

._crit_edge24:                                    ; preds = %._crit_edge19, %0
  ret i32 0
}

; 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 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 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 = { 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 #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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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