program r20711b

implicit none
integer :: i, x, n
integer, allocatable :: a(:)

read *, n

allocate(a(1:n))

x = 0

read *, a(:)

do i = 1, n, 2
 if(mod(a(i),2)==1) then
 x = x + 1
 end if
end do

print *, x

end program r20711b
; 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.6d904a240045285e4e6afa8a0aebc9ca = linkonce constant [72 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_936/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

define void @_QQmain() local_unnamed_addr {
  %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.6d904a240045285e4e6afa8a0aebc9ca, i32 7)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = load i32, ptr %2, align 4, !tbaa !3
  %7 = call i32 @llvm.smax.i32(i32 %6, i32 0)
  %8 = zext i32 %7 to i64
  %9 = shl nuw nsw i64 %8, 2
  %10 = call ptr @malloc(i64 %9)
  store ptr %10, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %8, ptr @_QFEa.8, align 8, !tbaa !7
  %11 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.6d904a240045285e4e6afa8a0aebc9ca, i32 13)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack87.unpack.unpack89 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  %12 = call i64 @llvm.smax.i64(i64 %.unpack87.unpack.unpack89, i64 0)
  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 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 %12, 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
  %13 = call i1 @_FortranAioInputDescriptor(ptr %11, ptr nonnull %1)
  %14 = call i32 @_FortranAioEndIoStatement(ptr %11)
  %15 = load i32, ptr %2, align 4, !tbaa !3
  %16 = icmp sgt i32 %15, 0
  br i1 %16, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %.lhs.trunc = add i32 %15, 1
  %17 = lshr i32 %.lhs.trunc, 1
  %.zext = zext i32 %17 to i64
  %.unpack92 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %18 = add nuw nsw i64 %.zext, 1
  %19 = icmp ugt i32 %.lhs.trunc, 1
  %umin105.neg = sext i1 %19 to i64
  %20 = add nsw i64 %18, %umin105.neg
  %min.iters.check = icmp ult i64 %20, 9
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.lr.ph
  %21 = icmp ugt i32 %.lhs.trunc, 1
  %umin.neg = sext i1 %21 to i64
  %22 = add nsw i64 %umin.neg, %.zext
  %.not = icmp ult i64 %22, 1073741824
  br i1 %.not, label %vector.ph, label %scalar.ph.preheader

vector.ph:                                        ; preds = %vector.scevcheck
  %n.mod.vf = and i64 %20, 7
  %23 = icmp eq i64 %n.mod.vf, 0
  %24 = select i1 %23, i64 8, i64 %n.mod.vf
  %n.vec = sub nsw i64 %20, %24
  %ind.end = sub nsw i64 %.zext, %n.vec
  %.cast = trunc i64 %n.vec to i32
  %25 = shl i32 %.cast, 1
  %ind.end106 = or i32 %25, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %37, %vector.body ]
  %vec.phi108 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %38, %vector.body ]
  %.cast109 = trunc i64 %index to i32
  %26 = shl i32 %.cast109, 1
  %27 = sext i32 %26 to i64
  %narrow = or i32 %26, 8
  %28 = sext i32 %narrow to i64
  %29 = getelementptr i32, ptr %.unpack92, i64 %27
  %30 = getelementptr i32, ptr %.unpack92, i64 %28
  %wide.vec = load <8 x i32>, ptr %29, align 4, !tbaa !3
  %wide.vec110 = load <8 x i32>, ptr %30, align 4, !tbaa !3
  %strided.vec = shufflevector <8 x i32> %wide.vec, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
  %strided.vec111 = shufflevector <8 x i32> %wide.vec110, <8 x i32> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
  %31 = and <4 x i32> %strided.vec, <i32 -2147483647, i32 -2147483647, i32 -2147483647, i32 -2147483647>
  %32 = and <4 x i32> %strided.vec111, <i32 -2147483647, i32 -2147483647, i32 -2147483647, i32 -2147483647>
  %33 = icmp eq <4 x i32> %31, <i32 1, i32 1, i32 1, i32 1>
  %34 = icmp eq <4 x i32> %32, <i32 1, i32 1, i32 1, i32 1>
  %35 = zext <4 x i1> %33 to <4 x i32>
  %36 = zext <4 x i1> %34 to <4 x i32>
  %37 = add <4 x i32> %vec.phi, %35
  %38 = add <4 x i32> %vec.phi108, %36
  %index.next = add nuw i64 %index, 8
  %39 = icmp eq i64 %index.next, %n.vec
  br i1 %39, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %38, %37
  %40 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  br label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %vector.scevcheck, %.lr.ph, %middle.block
  %.ph = phi i64 [ %.zext, %vector.scevcheck ], [ %.zext, %.lr.ph ], [ %ind.end, %middle.block ]
  %.ph113 = phi i32 [ 1, %vector.scevcheck ], [ 1, %.lr.ph ], [ %ind.end106, %middle.block ]
  %.0104.ph = phi i32 [ 0, %vector.scevcheck ], [ 0, %.lr.ph ], [ %40, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %41 = phi i64 [ %51, %scalar.ph ], [ %.ph, %scalar.ph.preheader ]
  %42 = phi i32 [ %50, %scalar.ph ], [ %.ph113, %scalar.ph.preheader ]
  %.0104 = phi i32 [ %spec.select, %scalar.ph ], [ %.0104.ph, %scalar.ph.preheader ]
  %43 = sext i32 %42 to i64
  %44 = add nsw i64 %43, -1
  %45 = getelementptr i32, ptr %.unpack92, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !3
  %47 = and i32 %46, -2147483647
  %48 = icmp eq i32 %47, 1
  %49 = zext i1 %48 to i32
  %spec.select = add i32 %.0104, %49
  %50 = add nuw i32 %42, 2
  %51 = add nsw i64 %41, -1
  %52 = icmp ugt i64 %41, 1
  br i1 %52, label %scalar.ph, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %scalar.ph, %0
  %.0.lcssa = phi i32 [ 0, %0 ], [ %spec.select, %scalar.ph ]
  %53 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.6d904a240045285e4e6afa8a0aebc9ca, i32 21)
  %54 = call i1 @_FortranAioOutputInteger32(ptr %53, i32 %.0.lcssa)
  %55 = call i32 @_FortranAioEndIoStatement(ptr %53)
  ret void
}

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 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #2

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind 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}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !10}
