INTEGER N
CHARACTER(100) S
CHARACTER(26)::A="abcdefghijklmnopqrstuvwxyz"
INTEGER B,P!PはパワフルのP
INTEGER M,U!前、後ろ
READ*,N,S
P=0
DO I=1, N-1!前の文字列の長さを決めています
  B=0
  DO J=1,26
    M=SCAN(S,A(J:J))
    IF(M==0)CYCLE!後ろのif文にいれてMとUを並べて書いた方が綺麗に見えるけどこっちのが処理少なくて済むはず
    U=SCAN(S,A(J:J),.TRUE.)
    IF( M<=I .AND. I<U )B=B+1
  END DO
  P=MAX(P,B)
END DO
PRINT"(I0)",P
END
; 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 = internal global [26 x i8] c"abcdefghijklmnopqrstuvwxyz"
@_QFEs = internal global [100 x i8] undef
@_QQcl.5b205869c404cc26d99eeab66f82b127 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_5935/source.f\00"
@_QQcl.28493029 = linkonce constant [4 x i8] c"(I0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i32, align 4
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.5b205869c404cc26d99eeab66f82b127, i32 6)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 4)
  %4 = call i1 @_FortranAioInputAscii(ptr %2, ptr nonnull @_QFEs, i64 100)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %6 = load i32, ptr %1, align 4, !tbaa !3
  %7 = add i32 %6, -1
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.preheader.preheader, label %._crit_edge

.preheader.preheader:                             ; preds = %0
  %9 = zext i32 %7 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %25
  %10 = phi i64 [ %28, %25 ], [ %9, %.preheader.preheader ]
  %11 = phi i32 [ %27, %25 ], [ 1, %.preheader.preheader ]
  %.01217 = phi i32 [ %26, %25 ], [ 0, %.preheader.preheader ]
  br label %12

12:                                               ; preds = %.preheader, %24
  %indvars.iv = phi i64 [ 1, %.preheader ], [ %indvars.iv.next, %24 ]
  %.016 = phi i32 [ 0, %.preheader ], [ %.1, %24 ]
  %13 = add nsw i64 %indvars.iv, -1
  %14 = getelementptr [26 x [1 x i8]], ptr @_QFEa, i64 0, i64 %13
  %15 = call i64 @_FortranAScan1(ptr nonnull @_QFEs, i64 100, ptr %14, i64 1, i1 false)
  %16 = trunc i64 %15 to i32
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %24, label %17

17:                                               ; preds = %12
  %18 = call i64 @_FortranAScan1(ptr nonnull @_QFEs, i64 100, ptr %14, i64 1, i1 true)
  %19 = trunc i64 %18 to i32
  %20 = icmp sge i32 %11, %16
  %21 = icmp slt i32 %11, %19
  %22 = and i1 %20, %21
  %23 = zext i1 %22 to i32
  %spec.select = add i32 %.016, %23
  br label %24

24:                                               ; preds = %17, %12
  %.1 = phi i32 [ %.016, %12 ], [ %spec.select, %17 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 27
  br i1 %exitcond.not, label %25, label %12

25:                                               ; preds = %24
  %26 = call i32 @llvm.smax.i32(i32 %.01217, i32 %.1)
  %27 = add nuw i32 %11, 1
  %28 = add nsw i64 %10, -1
  %29 = icmp sgt i64 %10, 1
  br i1 %29, label %.preheader, label %._crit_edge

._crit_edge:                                      ; preds = %25, %0
  %.012.lcssa = phi i32 [ 0, %0 ], [ %26, %25 ]
  %30 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28493029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.5b205869c404cc26d99eeab66f82b127, i32 18)
  %31 = call i1 @_FortranAioOutputInteger32(ptr %30, i32 %.012.lcssa)
  %32 = call i32 @_FortranAioEndIoStatement(ptr %30)
  ret void
}

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

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

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

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

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

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, 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 i32 @llvm.smax.i32(i32, i32) #0

attributes #0 = { 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"}
