program sample
    implicit none
  
    integer(8) :: i,j,m,n
    real(8)::a,b
    integer(8),allocatable :: x(:),y(:)
    character(len=100000)::s
    character(len=1)::t
  
  
    read(*,*)s
    n=len_trim(s)
    m=0
    do i=1,n,2
        if (s(i:i)=='1')then
            m=m+1
        end if
    end do
    do i=2,n,2
        if (s(i:i)=='0')then
            m=m+1
        end if
    end do
    if (n-m<m)then
        m=n-m
    end if

    write(*,*) m
  
    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"

@_QFEs = internal global [100000 x i8] undef
@_QQcl.767b770d56c27d9a320f5bc8bc1e4153 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4494/source.f\00"
@_QQcl.31 = linkonce constant [1 x i8] c"1"
@_QQcl.30 = linkonce constant [1 x i8] c"0"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #0 {
  %1 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.767b770d56c27d9a320f5bc8bc1e4153, i32 11)
  %2 = tail call i1 @_FortranAioInputAscii(ptr %1, ptr nonnull @_QFEs, i64 100000)
  %3 = tail call i32 @_FortranAioEndIoStatement(ptr %1)
  br label %4

4:                                                ; preds = %0, %4
  %5 = phi i64 [ 99999, %0 ], [ %9, %4 ]
  %6 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %5
  %7 = load i8, ptr %6, align 1, !tbaa !3
  %8 = icmp eq i8 %7, 32
  %9 = add nsw i64 %5, -1
  %10 = icmp ne i64 %5, 0
  %11 = and i1 %8, %10
  br i1 %11, label %4, label %12

12:                                               ; preds = %4
  %13 = shl i64 %5, 32
  %sext = add i64 %13, 4294967296
  %14 = ashr exact i64 %sext, 32
  %15 = select i1 %8, i64 0, i64 %14
  %16 = icmp sgt i64 %15, 0
  br i1 %16, label %.lr.ph.preheader, label %._crit_edge24

.lr.ph.preheader:                                 ; preds = %12
  %.lhs.trunc = add nsw i64 %15, 1
  %17 = lshr i64 %.lhs.trunc, 1
  %.zext = and i64 %17, 2147483647
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %18 = phi i64 [ %26, %.lr.ph ], [ %.zext, %.lr.ph.preheader ]
  %19 = phi i64 [ %25, %.lr.ph ], [ 1, %.lr.ph.preheader ]
  %.020 = phi i64 [ %spec.select, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %20 = add nsw i64 %19, -1
  %21 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %20
  %22 = tail call i32 @_FortranACharacterCompareScalar1(ptr %21, ptr nonnull @_QQcl.31, i64 1, i64 1)
  %23 = icmp eq i32 %22, 0
  %24 = zext i1 %23 to i64
  %spec.select = add i64 %.020, %24
  %25 = add nuw nsw i64 %19, 2
  %26 = add nsw i64 %18, -1
  %27 = icmp ugt i64 %18, 1
  br i1 %27, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph
  %28 = icmp sgt i64 %15, 1
  br i1 %28, label %.lr.ph23.preheader, label %._crit_edge24

.lr.ph23.preheader:                               ; preds = %._crit_edge
  %29 = lshr i64 %15, 1
  br label %.lr.ph23

.lr.ph23:                                         ; preds = %.lr.ph23.preheader, %.lr.ph23
  %30 = phi i64 [ %38, %.lr.ph23 ], [ %29, %.lr.ph23.preheader ]
  %31 = phi i64 [ %37, %.lr.ph23 ], [ 2, %.lr.ph23.preheader ]
  %.221 = phi i64 [ %spec.select17, %.lr.ph23 ], [ %spec.select, %.lr.ph23.preheader ]
  %32 = add nsw i64 %31, -1
  %33 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %32
  %34 = tail call i32 @_FortranACharacterCompareScalar1(ptr %33, ptr nonnull @_QQcl.30, i64 1, i64 1)
  %35 = icmp eq i32 %34, 0
  %36 = zext i1 %35 to i64
  %spec.select17 = add i64 %.221, %36
  %37 = add nuw nsw i64 %31, 2
  %38 = add nsw i64 %30, -1
  %39 = icmp ugt i64 %30, 1
  br i1 %39, label %.lr.ph23, label %._crit_edge24

._crit_edge24:                                    ; preds = %.lr.ph23, %12, %._crit_edge
  %.2.lcssa = phi i64 [ %spec.select, %._crit_edge ], [ 0, %12 ], [ %spec.select17, %.lr.ph23 ]
  %40 = sub i64 %15, %.2.lcssa
  %spec.select18 = tail call i64 @llvm.smin.i64(i64 %40, i64 %.2.lcssa)
  %41 = tail call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.767b770d56c27d9a320f5bc8bc1e4153, i32 28)
  %42 = tail call i1 @_FortranAioOutputInteger64(ptr %41, i64 %spec.select18)
  %43 = tail call i32 @_FortranAioEndIoStatement(ptr %41)
  %44 = tail call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

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

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

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare i32 @_FortranACharacterCompareScalar1(ptr, ptr, i64, i64) 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.smin.i64(i64, i64) #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"}
