integer function fib(n)
  integer, intent(in) :: n
  if (n < 0 ) then
    write (*,*) 'Bad argument: fib(',n,')'
    stop
  else
    fib = purefib(n)
  end if
contains
  recursive pure integer function purefib(n) result(f)
    integer, intent(in) :: n
    if (n < 2 ) then
      f = n
    else
      f = purefib(n-1) + purefib(n-2)
    end if
  end function purefib
end function fib
; 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.aa632a93f26b9c6fbac2ff94ddf59173 = linkonce constant [72 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_572/source.f\00"
@_QQcl.42616420617267756D656E743A2066696228 = linkonce constant [18 x i8] c"Bad argument: fib("
@_QQcl.29 = linkonce constant [1 x i8] c")"

define i32 @fib_(ptr nocapture readonly %0) local_unnamed_addr {
  %2 = load i32, ptr %0, align 4, !tbaa !3
  %3 = icmp slt i32 %2, 0
  br i1 %3, label %4, label %12

4:                                                ; preds = %1
  %5 = tail call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.aa632a93f26b9c6fbac2ff94ddf59173, i32 4)
  %6 = tail call i1 @_FortranAioOutputAscii(ptr %5, ptr nonnull @_QQcl.42616420617267756D656E743A2066696228, i64 18)
  %7 = load i32, ptr %0, align 4, !tbaa !3
  %8 = tail call i1 @_FortranAioOutputInteger32(ptr %5, i32 %7)
  %9 = tail call i1 @_FortranAioOutputAscii(ptr %5, ptr nonnull @_QQcl.29, i64 1)
  %10 = tail call i32 @_FortranAioEndIoStatement(ptr %5)
  %11 = tail call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

12:                                               ; preds = %1
  %13 = tail call i32 @_QFfibPpurefib(ptr nonnull %0)
  ret i32 %13
}

; Function Attrs: nofree nosync nounwind memory(argmem: read)
define i32 @_QFfibPpurefib(ptr nocapture readonly %0) local_unnamed_addr #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = load i32, ptr %0, align 4, !tbaa !3
  %5 = icmp slt i32 %4, 2
  br i1 %5, label %12, label %6

6:                                                ; preds = %1
  %7 = add nsw i32 %4, -1
  store i32 %7, ptr %3, align 4, !tbaa !3
  %8 = call i32 @_QFfibPpurefib(ptr nonnull %3)
  %9 = add nsw i32 %4, -2
  store i32 %9, ptr %2, align 4, !tbaa !3
  %10 = call i32 @_QFfibPpurefib(ptr nonnull %2)
  %11 = add i32 %10, %8
  br label %12

12:                                               ; preds = %1, %6
  %.0 = phi i32 [ %11, %6 ], [ %4, %1 ]
  ret i32 %.0
}

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

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

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

attributes #0 = { nofree nosync nounwind memory(argmem: read) }

!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"}
