PROGRAM ATCODER

implicit none
integer :: k,s,x,y,z,ans,i,j

read(*,*) k,s

ans = 0
do i = 0, k, 1
  x = i
  do j = 0, k, 1
    y = j
    z = s - x - y
    if ( z>=0 .and. z<=k ) then
      ans = ans + 1
    end if
  end do
end do

print'(i0)', ans

END PROGRAM ATCODER
; 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"

@_QQcl.8b18241f71cffc4f36ea280229d2c702 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7595/source.f\00"
@_QQcl.28693029 = 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 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.8b18241f71cffc4f36ea280229d2c702, i32 6)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %1, i32 4)
  %5 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %7 = load i32, ptr %1, align 4, !tbaa !3
  %8 = sext i32 %7 to i64
  %9 = add nsw i64 %8, 1
  %10 = icmp sgt i32 %7, -1
  br i1 %10, label %.preheader.lr.ph, label %._crit_edge15

.preheader.lr.ph:                                 ; preds = %0
  %11 = load i32, ptr %2, align 4
  %12 = add nsw i64 %8, 2
  %smin = call i64 @llvm.smin.i64(i64 %9, i64 1)
  %13 = sub i64 %12, %smin
  %min.iters.check = icmp ult i64 %13, 8
  %n.vec = and i64 %13, -8
  %ind.end = sub i64 %9, %n.vec
  %ind.end17 = trunc i64 %n.vec to i32
  %broadcast.splatinsert23 = insertelement <4 x i32> poison, i32 %11, i64 0
  %broadcast.splat24 = shufflevector <4 x i32> %broadcast.splatinsert23, <4 x i32> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert25 = insertelement <4 x i32> poison, i32 %11, i64 0
  %broadcast.splat26 = shufflevector <4 x i32> %broadcast.splatinsert25, <4 x i32> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert27 = insertelement <4 x i32> poison, i32 %7, i64 0
  %broadcast.splat28 = shufflevector <4 x i32> %broadcast.splatinsert27, <4 x i32> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert29 = insertelement <4 x i32> poison, i32 %7, i64 0
  %broadcast.splat30 = shufflevector <4 x i32> %broadcast.splatinsert29, <4 x i32> poison, <4 x i32> zeroinitializer
  %cmp.n = icmp eq i64 %13, %n.vec
  br label %.preheader.us

.preheader.us:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph
  %14 = phi i64 [ %9, %.preheader.lr.ph ], [ %47, %._crit_edge.us ]
  %15 = phi i32 [ 0, %.preheader.lr.ph ], [ %46, %._crit_edge.us ]
  %.014.us = phi i32 [ 0, %.preheader.lr.ph ], [ %spec.select.us.lcssa, %._crit_edge.us ]
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.preheader.us
  %16 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %.014.us, i64 0
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %15, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  %.scalar = add i32 %15, 4
  %17 = insertelement <4 x i32> poison, i32 %.scalar, i64 0
  %18 = shufflevector <4 x i32> %17, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ %16, %vector.ph ], [ %31, %vector.body ]
  %vec.phi20 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %32, %vector.body ]
  %19 = add nuw <4 x i32> %vec.ind, %broadcast.splat
  %20 = add <4 x i32> %18, %vec.ind
  %21 = sub <4 x i32> %broadcast.splat24, %19
  %22 = sub <4 x i32> %broadcast.splat26, %20
  %23 = icmp sgt <4 x i32> %21, <i32 -1, i32 -1, i32 -1, i32 -1>
  %24 = icmp sgt <4 x i32> %22, <i32 -1, i32 -1, i32 -1, i32 -1>
  %25 = icmp sle <4 x i32> %21, %broadcast.splat28
  %26 = icmp sle <4 x i32> %22, %broadcast.splat30
  %27 = and <4 x i1> %23, %25
  %28 = and <4 x i1> %24, %26
  %29 = zext <4 x i1> %27 to <4 x i32>
  %30 = zext <4 x i1> %28 to <4 x i32>
  %31 = add <4 x i32> %vec.phi, %29
  %32 = add <4 x i32> %vec.phi20, %30
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %33 = icmp eq i64 %index.next, %n.vec
  br i1 %33, label %middle.block, label %vector.body, !llvm.loop !7

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %32, %31
  %34 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  br i1 %cmp.n, label %._crit_edge.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %.preheader.us, %middle.block
  %.ph = phi i64 [ %9, %.preheader.us ], [ %ind.end, %middle.block ]
  %.ph31 = phi i32 [ 0, %.preheader.us ], [ %ind.end17, %middle.block ]
  %.113.us.ph = phi i32 [ %.014.us, %.preheader.us ], [ %34, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %35 = phi i64 [ %44, %scalar.ph ], [ %.ph, %scalar.ph.preheader ]
  %36 = phi i32 [ %43, %scalar.ph ], [ %.ph31, %scalar.ph.preheader ]
  %.113.us = phi i32 [ %spec.select.us, %scalar.ph ], [ %.113.us.ph, %scalar.ph.preheader ]
  %37 = add nuw i32 %36, %15
  %38 = sub i32 %11, %37
  %39 = icmp sgt i32 %38, -1
  %40 = icmp sle i32 %38, %7
  %41 = and i1 %39, %40
  %42 = zext i1 %41 to i32
  %spec.select.us = add i32 %.113.us, %42
  %43 = add nuw i32 %36, 1
  %44 = add nsw i64 %35, -1
  %45 = icmp sgt i64 %35, 1
  br i1 %45, label %scalar.ph, label %._crit_edge.us, !llvm.loop !10

._crit_edge.us:                                   ; preds = %scalar.ph, %middle.block
  %spec.select.us.lcssa = phi i32 [ %34, %middle.block ], [ %spec.select.us, %scalar.ph ]
  %46 = add nuw i32 %15, 1
  %47 = add nsw i64 %14, -1
  %48 = icmp sgt i64 %14, 1
  br i1 %48, label %.preheader.us, label %._crit_edge15

._crit_edge15:                                    ; preds = %._crit_edge.us, %0
  %.0.lcssa = phi i32 [ 0, %0 ], [ %spec.select.us.lcssa, %._crit_edge.us ]
  %49 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.8b18241f71cffc4f36ea280229d2c702, i32 20)
  %50 = call i1 @_FortranAioOutputInteger32(ptr %49, i32 %.0.lcssa)
  %51 = call i32 @_FortranAioEndIoStatement(ptr %49)
  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 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 i64 @llvm.smin.i64(i64, i64) #0

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

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 = distinct !{!7, !8, !9}
!8 = !{!"llvm.loop.isvectorized", i32 1}
!9 = !{!"llvm.loop.unroll.runtime.disable"}
!10 = distinct !{!10, !9, !8}
