program sample
    implicit none
  
    integer(8) :: i,j,m,n,x,b
    
    integer(8),allocatable :: a(:),y(:)
  
    read(*,*) n,m,x
    allocate(a(m))
    read(*,*)a
    do i=1,m
        if(a(i)>x)then
            b=i
        exit
        end if
    end do
    if (b-1<m-b+1)then
        write(*,*)b-1
    else
        write(*,*)m-b+1
    endif

  
    
    stop
end program sample
  


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

@_QFEa.0 = internal unnamed_addr global ptr null
@_QFEa.8 = internal unnamed_addr global i64 0
@_QQcl.42c4d35acf49cd92b3d461b6fc1ecff9 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6089/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #1 {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.42c4d35acf49cd92b3d461b6fc1ecff9, i32 8)
  %6 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %3, i32 8)
  %7 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %2, i32 8)
  %8 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %4, i32 8)
  %9 = call i32 @_FortranAioEndIoStatement(ptr %5)
  %10 = load i64, ptr %2, align 8, !tbaa !3
  %11 = call i64 @llvm.smax.i64(i64 %10, i64 0)
  %12 = shl i64 %11, 3
  %13 = call ptr @malloc(i64 %12)
  store ptr %13, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %11, ptr @_QFEa.8, align 8, !tbaa !7
  %14 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.42c4d35acf49cd92b3d461b6fc1ecff9, i32 10)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack93.unpack.unpack95 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  store ptr %.unpack, 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 8, 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 10, 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 %.unpack93.unpack.unpack95, 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 8, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %15 = call i1 @_FortranAioInputDescriptor(ptr %14, ptr nonnull %1)
  %16 = call i32 @_FortranAioEndIoStatement(ptr %14)
  %17 = load i64, ptr %2, align 8, !tbaa !3
  %18 = icmp sgt i64 %17, 0
  br i1 %18, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = add nsw i64 %17, 1
  br label %._crit_edge

.lr.ph:                                           ; preds = %0
  %.unpack98 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %19 = load i64, ptr %4, align 8, !tbaa !3
  %20 = add nuw i64 %17, 1
  br label %21

21:                                               ; preds = %.lr.ph, %26
  %.0112 = phi i64 [ 1, %.lr.ph ], [ %27, %26 ]
  %22 = add i64 %.0112, -1
  %23 = getelementptr i64, ptr %.unpack98, i64 %22
  %24 = load i64, ptr %23, align 8, !tbaa !3
  %25 = icmp sgt i64 %24, %19
  br i1 %25, label %._crit_edge, label %26

26:                                               ; preds = %21
  %27 = add nuw i64 %.0112, 1
  %exitcond.not = icmp eq i64 %.0112, %17
  br i1 %exitcond.not, label %._crit_edge, label %21

._crit_edge:                                      ; preds = %26, %21, %.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %20, %21 ], [ %20, %26 ]
  %.0.lcssa110 = phi i64 [ 1, %.._crit_edge_crit_edge ], [ %20, %26 ], [ %.0112, %21 ]
  %28 = add i64 %.0.lcssa110, -1
  %29 = sub i64 %.pre-phi, %.0.lcssa110
  %30 = icmp slt i64 %28, %29
  br i1 %30, label %31, label %33

31:                                               ; preds = %._crit_edge
  %32 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.42c4d35acf49cd92b3d461b6fc1ecff9, i32 18)
  br label %38

33:                                               ; preds = %._crit_edge
  %34 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.42c4d35acf49cd92b3d461b6fc1ecff9, i32 20)
  %35 = load i64, ptr %2, align 8, !tbaa !3
  %36 = sub i64 1, %.0.lcssa110
  %37 = add i64 %36, %35
  br label %38

38:                                               ; preds = %31, %33
  %.sink118 = phi i64 [ %28, %31 ], [ %37, %33 ]
  %.sink117 = phi ptr [ %32, %31 ], [ %34, %33 ]
  %39 = call i1 @_FortranAioOutputInteger64(ptr %.sink117, i64 %.sink118)
  %40 = call i32 @_FortranAioEndIoStatement(ptr %.sink117)
  %41 = 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 @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

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

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { noreturn }
attributes #2 = { 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}
