program prob3
    implicit none
    integer(8) :: n, a, b, ans
    read(*,*) n,a,b
    if(mod(a+b, 2) == 0) then
        ans = (b-a) / 2
    else
        ans = min(2*n - (a+b) + 1, a+b-1)
        ans = ans / 2
    end if
    write(*,*) ans
    stop
contains
end program prob3
; 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.abdde1ca156166cd658a09ae608cf4f4 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_2763/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.abdde1ca156166cd658a09ae608cf4f4, i32 4)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 8)
  %6 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %1, i32 8)
  %7 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %2, i32 8)
  %8 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %9 = load i64, ptr %1, align 8, !tbaa !3
  %10 = load i64, ptr %2, align 8, !tbaa !3
  %11 = add i64 %10, %9
  %12 = and i64 %11, 1
  %13 = icmp eq i64 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %0
  %15 = sub i64 %10, %9
  br label %23

16:                                               ; preds = %0
  %17 = load i64, ptr %3, align 8, !tbaa !3
  %18 = shl i64 %17, 1
  %19 = sub i64 1, %11
  %20 = add i64 %19, %18
  %21 = add i64 %11, -1
  %22 = call i64 @llvm.smin.i64(i64 %20, i64 %21)
  br label %23

23:                                               ; preds = %14, %16
  %.0.in = phi i64 [ %15, %14 ], [ %22, %16 ]
  %.0 = sdiv i64 %.0.in, 2
  %24 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.abdde1ca156166cd658a09ae608cf4f4, i32 11)
  %25 = call i1 @_FortranAioOutputInteger64(ptr %24, i64 %.0)
  %26 = call i32 @_FortranAioEndIoStatement(ptr %24)
  %27 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

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 @_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"}
