! 2019.12.22
!
      program answer
      implicit none
      integer(8) :: A,B
      integer(8) :: over
      integer(8) :: ans
      integer(8),external :: Euclid
!
      read(*,*) A,B
      over = Euclid(A,B)
      ans = A*B/over
      write(*,*) ans
      end program answer
!------------------------------------------------
      function Euclid(x,y) result(res)
!------------------------------------------------
      implicit none
      integer(8) :: x,y
      integer(8) :: res
      integer :: x1,y1
      intrinsic abs
!
      x1 = x
      y1 = y
!
      do
        res = x1 - y1
        if(res > 0) then
          x1 = res
        else if(res < 0) then
          y1 = -res
        else if(res == 0) then
          res = x1
          exit
        end if
      end do
      end function Euclid
; 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.8989bc9983ffe69fed4e42adbc0397b2 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_2817/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.8989bc9983ffe69fed4e42adbc0397b2, i32 10)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %1, i32 8)
  %5 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 8)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %7 = load i64, ptr %1, align 8, !tbaa !3
  %8 = trunc i64 %7 to i32
  %9 = load i64, ptr %2, align 8, !tbaa !3
  %10 = trunc i64 %9 to i32
  br label %.outer.i.outer

.outer.loopexit.loopexit.i:                       ; preds = %16
  %11 = sub i32 0, %14
  br label %.outer.i.outer

.outer.i.outer:                                   ; preds = %.outer.loopexit.loopexit.i, %0
  %.09.ph.i.ph = phi i32 [ %17, %.outer.loopexit.loopexit.i ], [ %8, %0 ]
  %.0.ph.i.ph = phi i32 [ %11, %.outer.loopexit.loopexit.i ], [ %10, %0 ]
  br label %.outer.i

.outer.i:                                         ; preds = %.outer.i.outer, %.outer.i
  %.09.ph.i = phi i32 [ %12, %.outer.i ], [ %.09.ph.i.ph, %.outer.i.outer ]
  %12 = sub i32 %.09.ph.i, %.0.ph.i.ph
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.outer.i, label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.outer.i, %16
  %14 = phi i32 [ %17, %16 ], [ %12, %.outer.i ]
  %15 = icmp slt i32 %14, 0
  br i1 %15, label %16, label %euclid_.exit

16:                                               ; preds = %.lr.ph.i
  %17 = add i32 %14, %.09.ph.i
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.outer.loopexit.loopexit.i, label %.lr.ph.i

euclid_.exit:                                     ; preds = %.lr.ph.i
  %19 = sext i32 %.09.ph.i to i64
  %20 = mul i64 %9, %7
  %21 = sdiv i64 %20, %19
  %22 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.8989bc9983ffe69fed4e42adbc0397b2, i32 13)
  %23 = call i1 @_FortranAioOutputInteger64(ptr %22, i64 %21)
  %24 = call i32 @_FortranAioEndIoStatement(ptr %22)
  ret void
}

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: read)
define i64 @euclid_(ptr nocapture readonly %0, ptr nocapture readonly %1) local_unnamed_addr #0 {
  %3 = load i64, ptr %0, align 8, !tbaa !3
  %4 = trunc i64 %3 to i32
  %5 = load i64, ptr %1, align 8, !tbaa !3
  %6 = trunc i64 %5 to i32
  br label %.outer.outer

.outer.loopexit.loopexit:                         ; preds = %12
  %7 = sub i32 0, %10
  br label %.outer.outer

.outer.outer:                                     ; preds = %.outer.loopexit.loopexit, %2
  %.09.ph.ph = phi i32 [ %13, %.outer.loopexit.loopexit ], [ %4, %2 ]
  %.0.ph.ph = phi i32 [ %7, %.outer.loopexit.loopexit ], [ %6, %2 ]
  br label %.outer

.outer:                                           ; preds = %.outer.outer, %.outer
  %.09.ph = phi i32 [ %8, %.outer ], [ %.09.ph.ph, %.outer.outer ]
  %8 = sub i32 %.09.ph, %.0.ph.ph
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.outer, label %.lr.ph

.lr.ph:                                           ; preds = %.outer, %12
  %10 = phi i32 [ %13, %12 ], [ %8, %.outer ]
  %11 = icmp slt i32 %10, 0
  br i1 %11, label %12, label %15

12:                                               ; preds = %.lr.ph
  %13 = add i32 %.09.ph, %10
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.outer.loopexit.loopexit, label %.lr.ph

15:                                               ; preds = %.lr.ph
  %16 = sext i32 %.09.ph to i64
  ret i64 %16
}

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

attributes #0 = { nofree norecurse 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"}
