      function agm(a,b)
      implicit none
      double precision agm,a,b,eps,c
      parameter(eps=1.0d-15)
   10 c=0.5d0*(a+b)
      b=sqrt(a*b)
      a=c
      if(a-b.gt.eps*a) go to 10
      agm=0.5d0*(a+b)
      end
      program test
      implicit none
      double precision agm
      print*,agm(1.0d0,1.0d0/sqrt(2.0d0))
      end
; 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.abdb6ef0094e4ab53b24058c8d0f52f0 = linkonce constant [70 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: nofree nosync nounwind memory(argmem: readwrite)
define double @agm_(ptr nocapture %0, ptr nocapture %1) local_unnamed_addr #0 {
  %.pre = load double, ptr %0, align 8, !tbaa !3
  %.pre4 = load double, ptr %1, align 8, !tbaa !3
  br label %3

3:                                                ; preds = %3, %2
  %4 = phi double [ %10, %3 ], [ %.pre4, %2 ]
  %5 = phi double [ %7, %3 ], [ %.pre, %2 ]
  %6 = fadd contract double %5, %4
  %7 = fmul contract double %6, 5.000000e-01
  %8 = fmul contract double %5, %4
  %9 = tail call contract double @llvm.sqrt.f64(double %8)
  store double %9, ptr %1, align 8, !tbaa !3
  store double %7, ptr %0, align 8, !tbaa !3
  %10 = load double, ptr %1, align 8, !tbaa !3
  %11 = fsub contract double %7, %10
  %12 = fmul contract double %7, 1.000000e-15
  %13 = fcmp ogt double %11, %12
  br i1 %13, label %3, label %14

14:                                               ; preds = %3
  %15 = fadd contract double %7, %10
  %16 = fmul contract double %15, 5.000000e-01
  ret double %16
}

define void @_QQmain() local_unnamed_addr {
  %1 = tail call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.abdb6ef0094e4ab53b24058c8d0f52f0, i32 14)
  br label %2

2:                                                ; preds = %2, %0
  %3 = phi double [ %8, %2 ], [ 0x3FE6A09E667F3BCC, %0 ]
  %4 = phi double [ %6, %2 ], [ 1.000000e+00, %0 ]
  %5 = fadd contract double %3, %4
  %6 = fmul contract double %5, 5.000000e-01
  %7 = fmul contract double %3, %4
  %8 = tail call contract double @llvm.sqrt.f64(double %7)
  %9 = fsub contract double %6, %8
  %10 = fmul contract double %6, 1.000000e-15
  %11 = fcmp ogt double %9, %10
  br i1 %11, label %2, label %agm_.exit

agm_.exit:                                        ; preds = %2
  %12 = fadd contract double %6, %8
  %13 = fmul contract double %12, 5.000000e-01
  %14 = tail call i1 @_FortranAioOutputReal64(ptr %1, double %13)
  %15 = tail call i32 @_FortranAioEndIoStatement(ptr %1)
  ret void
}

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

declare i1 @_FortranAioOutputReal64(ptr, double) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #1

attributes #0 = { nofree nosync nounwind memory(argmem: readwrite) }
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 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
