program ABC_093_C_SameIntegers
   implicit none
   integer am, m, i,countN, a(1: 3)
   read(*, *) a(1: 3)
   do i = 1, 2
      am = maxval(a(i+1:3))
	  m  = maxloc(a(i+1:3), 1) + i
	  if (a(i) < am) then
	      a(m) = a(i)
		  a(i) = am
	  end if
   end do
   countN = 0
   if(a(1) == a(2)) then
       if(mod(a(1)-a(3),2) == 0) then
           countN = (a(1) - a(3)) / 2
           write(*, *) countN
	   else
           countN = (a(1) - a(3)) / 2 + 1 + 1
           write(*, *) countN
	   end if
   else
       if(mod(a(1)-a(3),2) == 0) then
           countN = (a(1) - a(3)) / 2
	       a(3) = a(3) + 2 * (a(1) - a(3)) / 2
       else
           countN = (a(1) - a(3)) / 2 + 1
	       a(3) = a(3) + 2 * (a(1) - a(3)) / 2 + 1
	       a(2) = a(2) + 1
       end if
       if(a(1) == a(2)) then
           write(*, *) countN
       else if(mod(a(1)-a(2),2) == 0) then
           countN = countN + (a(1) - a(2)) / 2
	       write(*, *) countN
       else
           countN = countN + (a(1) - a(2)) / 2 + 1 + 1
	       write(*, *) countN
       end if 
   end if
end program ABC_093_C_SameIntegers
; 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.6e5ab11f9954b214bfd8e30b6ba1937d = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6120/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

define void @_QQmain() local_unnamed_addr {
_FortranAMaxvalInteger4x1_contract_simplified.exit:
  %0 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %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 }, align 8
  %3 = alloca [3 x i32], align 4
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.6e5ab11f9954b214bfd8e30b6ba1937d, i32 4)
  store ptr %3, ptr %1, align 8, !tbaa !3
  %.fca.1.gep27 = 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.gep27, align 8, !tbaa !3
  %.fca.2.gep29 = 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.gep29, align 8, !tbaa !3
  %.fca.3.gep31 = 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.gep31, align 4, !tbaa !3
  %.fca.4.gep33 = 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.gep33, align 1, !tbaa !3
  %.fca.5.gep35 = 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.gep35, align 2, !tbaa !3
  %.fca.6.gep37 = 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.gep37, align 1, !tbaa !3
  %.fca.7.0.0.gep = 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.gep, align 8, !tbaa !3
  %.fca.7.0.1.gep = 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 3, ptr %.fca.7.0.1.gep, align 8, !tbaa !3
  %.fca.7.0.2.gep = 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.gep, align 8, !tbaa !3
  %5 = call i1 @_FortranAioInputDescriptor(ptr %4, ptr nonnull %1)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %.fca.1.gep61 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 1
  %.fca.2.gep63 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 2
  %.fca.3.gep65 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 3
  %.fca.4.gep67 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 4
  %.fca.5.gep69 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 5
  %.fca.6.gep71 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 6
  %.fca.7.0.0.gep73 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 7, i64 0, i64 0
  %.fca.7.0.1.gep75 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 7, i64 0, i64 1
  %.fca.7.0.2.gep77 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 7, i64 0, i64 2
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 1
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 2
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 3
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 4
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 5
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %2, i64 0, i32 6
  %7 = getelementptr inbounds [3 x i32], ptr %3, i64 0, i64 1
  %8 = load i32, ptr %7, align 4, !tbaa !7
  %9 = getelementptr inbounds [3 x i32], ptr %3, i64 0, i64 2
  %10 = load i32, ptr %9, align 4, !tbaa !7
  %11 = call i32 @llvm.smax.i32(i32 %10, i32 %8)
  store ptr %7, ptr %0, align 8, !tbaa !3
  store i64 4, ptr %.fca.1.gep61, align 8, !tbaa !3
  store i32 20180515, ptr %.fca.2.gep63, align 8, !tbaa !3
  store i8 1, ptr %.fca.3.gep65, align 4, !tbaa !3
  store i8 9, ptr %.fca.4.gep67, align 1, !tbaa !3
  store i8 0, ptr %.fca.5.gep69, align 2, !tbaa !3
  store i8 0, ptr %.fca.6.gep71, align 1, !tbaa !3
  store i64 1, ptr %.fca.7.0.0.gep73, align 8, !tbaa !3
  store i64 2, ptr %.fca.7.0.1.gep75, align 8, !tbaa !3
  store i64 4, ptr %.fca.7.0.2.gep77, align 8, !tbaa !3
  store ptr null, ptr %2, align 8, !tbaa !3
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !3
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !3
  store i8 0, ptr %.fca.3.gep, align 4, !tbaa !3
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !3
  store i8 2, ptr %.fca.5.gep, align 2, !tbaa !3
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !3
  %12 = call {} @_FortranAMaxlocDim(ptr nonnull %2, ptr nonnull %0, i32 4, i32 1, ptr nonnull @_QQcl.6e5ab11f9954b214bfd8e30b6ba1937d, i32 7, ptr null, i1 false)
  %.fca.0.load = load ptr, ptr %2, align 8, !tbaa !3
  %13 = load i32, ptr %.fca.0.load, align 4, !tbaa !7
  call void @free(ptr %.fca.0.load)
  %14 = load i32, ptr %3, align 4, !tbaa !7
  %15 = icmp slt i32 %14, %11
  br i1 %15, label %16, label %_FortranAMaxvalInteger4x1_contract_simplified.exit.1

16:                                               ; preds = %_FortranAMaxvalInteger4x1_contract_simplified.exit
  %17 = add i32 %13, 1
  %18 = sext i32 %17 to i64
  %19 = add nsw i64 %18, -1
  %20 = getelementptr [3 x i32], ptr %3, i64 0, i64 %19
  store i32 %14, ptr %20, align 4, !tbaa !7
  store i32 %11, ptr %3, align 4, !tbaa !7
  br label %_FortranAMaxvalInteger4x1_contract_simplified.exit.1

_FortranAMaxvalInteger4x1_contract_simplified.exit.1: ; preds = %16, %_FortranAMaxvalInteger4x1_contract_simplified.exit
  %21 = getelementptr inbounds [3 x i32], ptr %3, i64 0, i64 2
  %22 = load i32, ptr %21, align 4, !tbaa !7
  store ptr %21, ptr %0, align 8, !tbaa !3
  store i64 4, ptr %.fca.1.gep61, align 8, !tbaa !3
  store i32 20180515, ptr %.fca.2.gep63, align 8, !tbaa !3
  store i8 1, ptr %.fca.3.gep65, align 4, !tbaa !3
  store i8 9, ptr %.fca.4.gep67, align 1, !tbaa !3
  store i8 0, ptr %.fca.5.gep69, align 2, !tbaa !3
  store i8 0, ptr %.fca.6.gep71, align 1, !tbaa !3
  store i64 1, ptr %.fca.7.0.0.gep73, align 8, !tbaa !3
  store i64 1, ptr %.fca.7.0.1.gep75, align 8, !tbaa !3
  store i64 4, ptr %.fca.7.0.2.gep77, align 8, !tbaa !3
  store ptr null, ptr %2, align 8, !tbaa !3
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !3
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !3
  store i8 0, ptr %.fca.3.gep, align 4, !tbaa !3
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !3
  store i8 2, ptr %.fca.5.gep, align 2, !tbaa !3
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !3
  %23 = call {} @_FortranAMaxlocDim(ptr nonnull %2, ptr nonnull %0, i32 4, i32 1, ptr nonnull @_QQcl.6e5ab11f9954b214bfd8e30b6ba1937d, i32 7, ptr null, i1 false)
  %.fca.0.load.1 = load ptr, ptr %2, align 8, !tbaa !3
  %24 = load i32, ptr %.fca.0.load.1, align 4, !tbaa !7
  call void @free(ptr %.fca.0.load.1)
  %25 = load i32, ptr %7, align 4, !tbaa !7
  %26 = icmp slt i32 %25, %22
  br i1 %26, label %27, label %32

27:                                               ; preds = %_FortranAMaxvalInteger4x1_contract_simplified.exit.1
  %28 = add i32 %24, 2
  %29 = sext i32 %28 to i64
  %30 = add nsw i64 %29, -1
  %31 = getelementptr [3 x i32], ptr %3, i64 0, i64 %30
  store i32 %25, ptr %31, align 4, !tbaa !7
  store i32 %22, ptr %7, align 4, !tbaa !7
  br label %32

32:                                               ; preds = %27, %_FortranAMaxvalInteger4x1_contract_simplified.exit.1
  %33 = phi i32 [ %22, %27 ], [ %25, %_FortranAMaxvalInteger4x1_contract_simplified.exit.1 ]
  %34 = load i32, ptr %3, align 4, !tbaa !7
  %35 = icmp eq i32 %34, %33
  %36 = load i32, ptr %21, align 4, !tbaa !7
  br i1 %35, label %37, label %49

37:                                               ; preds = %32
  %38 = sub i32 %33, %36
  %39 = and i32 %38, 1
  %40 = icmp eq i32 %39, 0
  %41 = sdiv i32 %38, 2
  br i1 %40, label %42, label %45

42:                                               ; preds = %37
  %43 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.6e5ab11f9954b214bfd8e30b6ba1937d, i32 17)
  %44 = call i1 @_FortranAioOutputInteger32(ptr %43, i32 %41)
  br label %85

45:                                               ; preds = %37
  %46 = add nsw i32 %41, 2
  %47 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.6e5ab11f9954b214bfd8e30b6ba1937d, i32 20)
  %48 = call i1 @_FortranAioOutputInteger32(ptr %47, i32 %46)
  br label %85

49:                                               ; preds = %32
  %50 = sub i32 %34, %36
  %51 = and i32 %50, 1
  %52 = icmp eq i32 %51, 0
  %53 = sdiv i32 %50, 2
  br i1 %52, label %54, label %58

54:                                               ; preds = %49
  %55 = shl i32 %50, 1
  %56 = ashr exact i32 %55, 1
  %57 = add i32 %56, %36
  br label %65

58:                                               ; preds = %49
  %59 = add nsw i32 %53, 1
  %60 = shl i32 %50, 1
  %61 = ashr exact i32 %60, 1
  %62 = add i32 %36, 1
  %63 = add i32 %62, %61
  %64 = add i32 %33, 1
  store i32 %64, ptr %7, align 4, !tbaa !7
  br label %65

65:                                               ; preds = %54, %58
  %66 = phi i32 [ %33, %54 ], [ %64, %58 ]
  %.sink = phi i32 [ %57, %54 ], [ %63, %58 ]
  %.0 = phi i32 [ %53, %54 ], [ %59, %58 ]
  store i32 %.sink, ptr %21, align 4
  %67 = icmp eq i32 %34, %66
  br i1 %67, label %68, label %71

68:                                               ; preds = %65
  %69 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.6e5ab11f9954b214bfd8e30b6ba1937d, i32 32)
  %70 = call i1 @_FortranAioOutputInteger32(ptr %69, i32 %.0)
  br label %85

71:                                               ; preds = %65
  %72 = sub i32 %34, %66
  %73 = and i32 %72, 1
  %74 = icmp eq i32 %73, 0
  %75 = sdiv i32 %72, 2
  br i1 %74, label %76, label %80

76:                                               ; preds = %71
  %77 = add nsw i32 %75, %.0
  %78 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.6e5ab11f9954b214bfd8e30b6ba1937d, i32 35)
  %79 = call i1 @_FortranAioOutputInteger32(ptr %78, i32 %77)
  br label %85

80:                                               ; preds = %71
  %81 = add nsw i32 %.0, 2
  %82 = add i32 %81, %75
  %83 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.6e5ab11f9954b214bfd8e30b6ba1937d, i32 38)
  %84 = call i1 @_FortranAioOutputInteger32(ptr %83, i32 %82)
  br label %85

85:                                               ; preds = %42, %45, %68, %76, %80
  %.sink118 = phi ptr [ %43, %42 ], [ %47, %45 ], [ %69, %68 ], [ %78, %76 ], [ %83, %80 ]
  %86 = call i32 @_FortranAioEndIoStatement(ptr %.sink118)
  ret void
}

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

declare i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare {} @_FortranAMaxlocDim(ptr, ptr, i32, i32, ptr, i32, ptr, i1) local_unnamed_addr

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

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress 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 = !{!"descriptor member", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any data access", !5, i64 0}
