program zero_or_one_wap
  implicit none
  integer :: n, p(50) = 0, i, m = 0
  read(*,*) n
  read(*,*) p(1:n)
  do i = 1, n
    if (p(i) /= i) m = m+1
  end do
  if (m*(m-2) == 0) then
    write(*,'(a)') "YES"
  else
    write(*,'(a)') "NO"
  end if
  stop
end program zero_or_one_wap
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEm = internal unnamed_addr global i32 0
@_QFEp = internal global [50 x i32] zeroinitializer
@_QQcl.00d7ce8a23578c2418ebd4ba74655859 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3642/source.f\00"
@_QQcl.286129 = linkonce constant [3 x i8] c"(a)"
@_QQcl.594553 = linkonce constant [3 x i8] c"YES"
@_QQcl.4E4F = linkonce constant [2 x i8] c"NO"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #0 {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.00d7ce8a23578c2418ebd4ba74655859, i32 4)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.00d7ce8a23578c2418ebd4ba74655859, i32 5)
  %7 = load i32, ptr %2, align 4, !tbaa !3
  %8 = call i32 @llvm.smax.i32(i32 %7, i32 0)
  %9 = zext i32 %8 to i64
  store ptr @_QFEp, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 %9, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %10 = call i1 @_FortranAioInputDescriptor(ptr %6, ptr nonnull %1)
  %11 = call i32 @_FortranAioEndIoStatement(ptr %6)
  %12 = load i32, ptr %2, align 4, !tbaa !3
  %_QFEm.promoted = load i32, ptr @_QFEm, align 4, !tbaa !3
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %14 = zext i32 %12 to i64
  %xtraiter = and i64 %14, 1
  %15 = icmp eq i32 %12, 1
  br i1 %15, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %14, 4294967294
  br label %.lr.ph

.lr.ph:                                           ; preds = %29, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %29 ]
  %16 = phi i32 [ %_QFEm.promoted, %.lr.ph.preheader.new ], [ %30, %29 ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %29 ]
  %17 = add nsw i64 %indvars.iv, -1
  %18 = getelementptr [50 x i32], ptr @_QFEp, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !3
  %20 = zext i32 %19 to i64
  %.not = icmp eq i64 %indvars.iv, %20
  br i1 %.not, label %.lr.ph.1, label %21

21:                                               ; preds = %.lr.ph
  %22 = add i32 %16, 1
  store i32 %22, ptr @_QFEm, align 4, !tbaa !3
  br label %.lr.ph.1

.lr.ph.1:                                         ; preds = %21, %.lr.ph
  %23 = phi i32 [ %22, %21 ], [ %16, %.lr.ph ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = getelementptr [50 x i32], ptr @_QFEp, i64 0, i64 %indvars.iv
  %25 = load i32, ptr %24, align 4, !tbaa !3
  %26 = zext i32 %25 to i64
  %.not.1 = icmp eq i64 %indvars.iv.next, %26
  br i1 %.not.1, label %29, label %27

27:                                               ; preds = %.lr.ph.1
  %28 = add i32 %23, 1
  store i32 %28, ptr @_QFEm, align 4, !tbaa !3
  br label %29

29:                                               ; preds = %27, %.lr.ph.1
  %30 = phi i32 [ %28, %27 ], [ %23, %.lr.ph.1 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 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_edge.loopexit.unr-lcssa, label %.lr.ph

._crit_edge.loopexit.unr-lcssa:                   ; preds = %29, %.lr.ph.preheader
  %.lcssa.ph = phi i32 [ undef, %.lr.ph.preheader ], [ %30, %29 ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next.1, %29 ]
  %.unr = phi i32 [ %_QFEm.promoted, %.lr.ph.preheader ], [ %30, %29 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %31 = add nsw i64 %indvars.iv.unr, -1
  %32 = getelementptr [50 x i32], ptr @_QFEp, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !3
  %34 = zext i32 %33 to i64
  %.not.epil = icmp eq i64 %indvars.iv.unr, %34
  br i1 %.not.epil, label %._crit_edge, label %35

35:                                               ; preds = %.lr.ph.epil
  %36 = add i32 %.unr, 1
  store i32 %36, ptr @_QFEm, align 4, !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %35, %.lr.ph.epil, %0
  %37 = phi i32 [ %_QFEm.promoted, %0 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %36, %35 ], [ %.unr, %.lr.ph.epil ]
  %38 = add i32 %37, -2
  %39 = mul i32 %38, %37
  %40 = icmp eq i32 %39, 0
  %. = select i1 %40, i32 10, i32 12
  %.5 = select i1 %40, i64 3, i64 2
  %_QQcl.594553._QQcl.4E4F = select i1 %40, ptr @_QQcl.594553, ptr @_QQcl.4E4F
  %41 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.286129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.00d7ce8a23578c2418ebd4ba74655859, i32 %.)
  %42 = call i1 @_FortranAioOutputAscii(ptr %41, ptr nonnull %_QQcl.594553._QQcl.4E4F, i64 %.5)
  %43 = call i32 @_FortranAioEndIoStatement(ptr %41)
  %44 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputAscii(ptr, ptr, i64) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

attributes #0 = { noreturn }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
