program prob3
    implicit none
    integer::n, i, j
    integer, allocatable::a(:),b(:)
    read(*,*) n
    allocate(a(n),b(n))
    read(*,*) a

    if(mod(n,2) == 0)then
        do i = n,2,-2
            b(n/2-i/2+1) = a(i)
        end do
        do i = 1, n, 2
            b(n/2+(i+1)/2) = a(i)
        end do
    else
        do i = n, 1, -2
            b(n/2-i/2+1) = a(i)
        end do
        do i = 2, n-1, 2
            b(n/2 + i/2 + 1) = a(i)
        end do
    end if
    write(*,*) b
    stop
end program
; 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
@_QFEb.0 = internal unnamed_addr global ptr null
@_QFEb.8 = internal unnamed_addr global i64 0
@_QQcl.28b2577d691b663e43a1d1d281df3f7c = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7156/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 { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %3 = alloca i32, align 4
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.28b2577d691b663e43a1d1d281df3f7c, i32 5)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 4)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %7 = load i32, ptr %3, align 4, !tbaa !3
  %8 = call i32 @llvm.smax.i32(i32 %7, i32 0)
  %9 = zext i32 %8 to i64
  %10 = shl nuw nsw i64 %9, 2
  %11 = call ptr @malloc(i64 %10)
  store ptr %11, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %9, ptr @_QFEa.8, align 8, !tbaa !7
  %12 = call ptr @malloc(i64 %10)
  store ptr %12, ptr @_QFEb.0, align 8, !tbaa !7
  store i64 %9, ptr @_QFEb.8, align 8, !tbaa !7
  %13 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.28b2577d691b663e43a1d1d281df3f7c, i32 7)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack402.unpack.unpack404 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  store ptr %.unpack, ptr %2, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, 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 %2, 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 %2, 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 %2, 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 %2, 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 %2, 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 %2, 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 %2, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack402.unpack.unpack404, 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 %2, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %14 = call i1 @_FortranAioInputDescriptor(ptr %13, ptr nonnull %2)
  %15 = call i32 @_FortranAioEndIoStatement(ptr %13)
  %16 = load i32, ptr %3, align 4, !tbaa !3
  %17 = and i32 %16, 1
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %61

19:                                               ; preds = %0
  %20 = icmp sgt i32 %16, 1
  br i1 %20, label %.lr.ph520, label %._crit_edge521

.lr.ph520:                                        ; preds = %19
  %21 = lshr i32 %16, 1
  %22 = zext i32 %21 to i64
  %.unpack491 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack503 = load ptr, ptr @_QFEb.0, align 8, !tbaa !7
  br label %23

23:                                               ; preds = %.lr.ph520, %23
  %24 = phi i64 [ %22, %.lr.ph520 ], [ %38, %23 ]
  %25 = phi i32 [ %16, %.lr.ph520 ], [ %37, %23 ]
  %26 = sext i32 %25 to i64
  %27 = add nsw i64 %26, -1
  %28 = getelementptr i32, ptr %.unpack491, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !3
  %30 = load i32, ptr %3, align 4, !tbaa !3
  %31 = sdiv i32 %30, 2
  %.neg515 = sdiv i32 %25, -2
  %32 = add nsw i32 %.neg515, 1
  %33 = add i32 %32, %31
  %34 = sext i32 %33 to i64
  %35 = add nsw i64 %34, -1
  %36 = getelementptr i32, ptr %.unpack503, i64 %35
  store i32 %29, ptr %36, align 4, !tbaa !3
  %37 = add i32 %25, -2
  %38 = add nsw i64 %24, -1
  %39 = icmp ugt i64 %24, 1
  br i1 %39, label %23, label %._crit_edge521.loopexit

._crit_edge521.loopexit:                          ; preds = %23
  %.pre526 = load i32, ptr %3, align 4, !tbaa !3
  br label %._crit_edge521

._crit_edge521:                                   ; preds = %._crit_edge521.loopexit, %19
  %40 = phi i32 [ %.pre526, %._crit_edge521.loopexit ], [ %16, %19 ]
  %41 = icmp sgt i32 %40, 0
  br i1 %41, label %.lr.ph523, label %.loopexit

.lr.ph523:                                        ; preds = %._crit_edge521
  %.lhs.trunc = add i32 %40, 1
  %42 = lshr i32 %.lhs.trunc, 1
  %.zext = zext i32 %42 to i64
  %.unpack467 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack479 = load ptr, ptr @_QFEb.0, align 8, !tbaa !7
  br label %43

43:                                               ; preds = %.lr.ph523, %43
  %44 = phi i64 [ %.zext, %.lr.ph523 ], [ %59, %43 ]
  %45 = phi i32 [ 1, %.lr.ph523 ], [ %58, %43 ]
  %46 = sext i32 %45 to i64
  %47 = add nsw i64 %46, -1
  %48 = getelementptr i32, ptr %.unpack467, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !3
  %50 = load i32, ptr %3, align 4, !tbaa !3
  %51 = sdiv i32 %50, 2
  %52 = add nuw i32 %45, 1
  %53 = sdiv i32 %52, 2
  %54 = add nsw i32 %51, %53
  %55 = sext i32 %54 to i64
  %56 = add nsw i64 %55, -1
  %57 = getelementptr i32, ptr %.unpack479, i64 %56
  store i32 %49, ptr %57, align 4, !tbaa !3
  %58 = add nuw i32 %45, 2
  %59 = add nsw i64 %44, -1
  %60 = icmp ugt i64 %44, 1
  br i1 %60, label %43, label %.loopexit

61:                                               ; preds = %0
  %62 = icmp sgt i32 %16, 0
  br i1 %62, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %61
  %.neg529 = add i32 %16, 1
  %63 = lshr i32 %.neg529, 1
  %64 = zext i32 %63 to i64
  %.unpack443 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack455 = load ptr, ptr @_QFEb.0, align 8, !tbaa !7
  br label %65

65:                                               ; preds = %.lr.ph, %65
  %66 = phi i64 [ %64, %.lr.ph ], [ %80, %65 ]
  %67 = phi i32 [ %16, %.lr.ph ], [ %79, %65 ]
  %68 = sext i32 %67 to i64
  %69 = add nsw i64 %68, -1
  %70 = getelementptr i32, ptr %.unpack443, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !3
  %72 = load i32, ptr %3, align 4, !tbaa !3
  %73 = sdiv i32 %72, 2
  %.neg = sdiv i32 %67, -2
  %74 = add nsw i32 %.neg, 1
  %75 = add i32 %74, %73
  %76 = sext i32 %75 to i64
  %77 = add nsw i64 %76, -1
  %78 = getelementptr i32, ptr %.unpack455, i64 %77
  store i32 %71, ptr %78, align 4, !tbaa !3
  %79 = add i32 %67, -2
  %80 = add nsw i64 %66, -1
  %81 = icmp ugt i64 %66, 1
  br i1 %81, label %65, label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %65
  %.pre = load i32, ptr %3, align 4, !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %61
  %82 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %16, %61 ]
  %83 = add i32 %82, -1
  %84 = icmp sgt i32 %83, 1
  br i1 %84, label %.lr.ph518, label %.loopexit

.lr.ph518:                                        ; preds = %._crit_edge
  %85 = lshr i32 %83, 1
  %86 = zext i32 %85 to i64
  %.unpack419 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack431 = load ptr, ptr @_QFEb.0, align 8, !tbaa !7
  br label %87

87:                                               ; preds = %.lr.ph518, %87
  %indvars.iv = phi i64 [ 2, %.lr.ph518 ], [ %indvars.iv.next, %87 ]
  %88 = phi i64 [ %86, %.lr.ph518 ], [ %101, %87 ]
  %89 = add nsw i64 %indvars.iv, -1
  %90 = getelementptr i32, ptr %.unpack419, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !3
  %92 = load i32, ptr %3, align 4, !tbaa !3
  %93 = sdiv i32 %92, 2
  %94 = trunc i64 %indvars.iv to i32
  %95 = ashr exact i32 %94, 1
  %96 = add nsw i32 %95, 1
  %97 = add nsw i32 %96, %93
  %98 = sext i32 %97 to i64
  %99 = add nsw i64 %98, -1
  %100 = getelementptr i32, ptr %.unpack431, i64 %99
  store i32 %91, ptr %100, align 4, !tbaa !3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
  %101 = add nsw i64 %88, -1
  %102 = icmp ugt i64 %88, 1
  br i1 %102, label %87, label %.loopexit

.loopexit:                                        ; preds = %87, %43, %._crit_edge, %._crit_edge521
  %103 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.28b2577d691b663e43a1d1d281df3f7c, i32 24)
  %.unpack407 = load ptr, ptr @_QFEb.0, align 8, !tbaa !7
  %.unpack414.unpack.unpack416 = load i64, ptr @_QFEb.8, align 8, !tbaa !7
  store ptr %.unpack407, ptr %1, align 8, !tbaa !7
  %.fca.1.gep118 = 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.gep118, align 8, !tbaa !7
  %.fca.2.gep120 = 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.gep120, align 8, !tbaa !7
  %.fca.3.gep122 = 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.gep122, align 4, !tbaa !7
  %.fca.4.gep124 = 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.gep124, align 1, !tbaa !7
  %.fca.5.gep126 = 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.gep126, align 2, !tbaa !7
  %.fca.6.gep128 = 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.gep128, align 1, !tbaa !7
  %.fca.7.0.0.gep130 = 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.gep130, align 8, !tbaa !7
  %.fca.7.0.1.gep132 = 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 %.unpack414.unpack.unpack416, ptr %.fca.7.0.1.gep132, align 8, !tbaa !7
  %.fca.7.0.2.gep134 = 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.gep134, align 8, !tbaa !7
  %104 = call i1 @_FortranAioOutputDescriptor(ptr %103, ptr nonnull %1)
  %105 = call i32 @_FortranAioEndIoStatement(ptr %103)
  %106 = 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 @_FortranAioOutputDescriptor(ptr, ptr) 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) #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}
