program sample
  implicit none
  integer :: a,b,c,d,e,i,j
  integer :: s(4)

  read(*,*) a,b,c,d

  if(b<=c)then
     write(*,*) 0
     stop
  else if(d<=a)then
     write(*,*) 0
     stop
  else
     s(1)=a
     s(2)=b
     s(3)=c
     s(4)=d
     do i=1,3
        do j=i+1,4
           if(s(i)>s(j))then
              e=s(j)
              s(j)=s(i)
              s(i)=e
           endif
        enddo
     enddo
     write(*,*) s(3)-s(2)
  endif

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"

@_QQcl.7c8c2ed7bff76d89ed75101c742b5a05 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7034/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.7c8c2ed7bff76d89ed75101c742b5a05, i32 6)
  %6 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %1, i32 4)
  %7 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %2, i32 4)
  %8 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %3, i32 4)
  %9 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %4, i32 4)
  %10 = call i32 @_FortranAioEndIoStatement(ptr %5)
  %11 = load i32, ptr %2, align 4, !tbaa !3
  %12 = load i32, ptr %3, align 4, !tbaa !3
  %.not = icmp sgt i32 %11, %12
  br i1 %.not, label %18, label %13

13:                                               ; preds = %0
  %14 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.7c8c2ed7bff76d89ed75101c742b5a05, i32 9)
  %15 = call i1 @_FortranAioOutputInteger32(ptr %14, i32 0)
  %16 = call i32 @_FortranAioEndIoStatement(ptr %14)
  %17 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

18:                                               ; preds = %0
  %19 = load i32, ptr %4, align 4, !tbaa !3
  %20 = load i32, ptr %1, align 4, !tbaa !3
  %.not14 = icmp sgt i32 %19, %20
  br i1 %.not14, label %.lr.ph, label %21

21:                                               ; preds = %18
  %22 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.7c8c2ed7bff76d89ed75101c742b5a05, i32 12)
  %23 = call i1 @_FortranAioOutputInteger32(ptr %22, i32 0)
  %24 = call i32 @_FortranAioEndIoStatement(ptr %22)
  %25 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

.lr.ph:                                           ; preds = %18
  %spec.select = call i32 @llvm.smax.i32(i32 %20, i32 %11)
  %spec.select31 = call i32 @llvm.smin.i32(i32 %20, i32 %11)
  %.sroa.15.0 = call i32 @llvm.smax.i32(i32 %spec.select31, i32 %12)
  %.sroa.0.1 = call i32 @llvm.smin.i32(i32 %spec.select31, i32 %12)
  %.sroa.23.0 = call i32 @llvm.smax.i32(i32 %.sroa.0.1, i32 %19)
  %.sroa.15.2 = call i32 @llvm.smax.i32(i32 %spec.select, i32 %.sroa.15.0)
  %.sroa.7.2 = call i32 @llvm.smin.i32(i32 %spec.select, i32 %.sroa.15.0)
  %.sroa.23.2 = call i32 @llvm.smax.i32(i32 %.sroa.7.2, i32 %.sroa.23.0)
  %.sroa.7.3 = call i32 @llvm.smin.i32(i32 %.sroa.7.2, i32 %.sroa.23.0)
  %.sroa.15.4 = call i32 @llvm.smin.i32(i32 %.sroa.15.2, i32 %.sroa.23.2)
  %26 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.7c8c2ed7bff76d89ed75101c742b5a05, i32 28)
  %27 = sub i32 %.sroa.15.4, %.sroa.7.3
  %28 = call i1 @_FortranAioOutputInteger32(ptr %26, i32 %27)
  %29 = call i32 @_FortranAioEndIoStatement(ptr %26)
  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 @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) 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) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.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"}
