program prob1
    implicit none
    integer(8) :: a, b, k, i
    read(*,*) a, b, k
    do i = 1, k
        if(mod(i, 2) == 1)then
            if(mod(a, 2) == 1)then
                a = a - 1
            end if
            b = b + a / 2
            a = a / 2
        else
            if(mod(b, 2) == 1)then
                b = b - 1
            end if
            a = a + b / 2
            b = b / 2
        end if
    end do
    write(*,*) a, b

    stop
contains
end program prob1
; 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.f7b089726f840329b3033a563945bfdd = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_5418/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.f7b089726f840329b3033a563945bfdd, i32 4)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %1, i32 8)
  %6 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %2, i32 8)
  %7 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 8)
  %8 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %9 = load i64, ptr %3, align 8, !tbaa !3
  %10 = icmp sgt i64 %9, 0
  br i1 %10, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %0
  %.promoted2 = load i64, ptr %1, align 8, !tbaa !3
  %.promoted = load i64, ptr %2, align 8, !tbaa !3
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %28
  %11 = phi i64 [ %31, %28 ], [ 1, %.lr.ph.preheader ]
  %12 = phi i64 [ %30, %28 ], [ %.promoted, %.lr.ph.preheader ]
  %13 = phi i64 [ %29, %28 ], [ %.promoted2, %.lr.ph.preheader ]
  %14 = and i64 %11, -9223372036854775807
  %15 = icmp eq i64 %14, 1
  br i1 %15, label %16, label %22

16:                                               ; preds = %.lr.ph
  %17 = and i64 %13, -9223372036854775807
  %18 = icmp eq i64 %17, 1
  %19 = sext i1 %18 to i64
  %spec.select = add nsw i64 %13, %19
  %20 = sdiv i64 %spec.select, 2
  %21 = add i64 %20, %12
  store i64 %21, ptr %2, align 8, !tbaa !3
  store i64 %20, ptr %1, align 8, !tbaa !3
  br label %28

22:                                               ; preds = %.lr.ph
  %23 = and i64 %12, -9223372036854775807
  %24 = icmp eq i64 %23, 1
  %25 = sext i1 %24 to i64
  %spec.select3 = add nsw i64 %12, %25
  %26 = sdiv i64 %spec.select3, 2
  %27 = add i64 %26, %13
  store i64 %27, ptr %1, align 8, !tbaa !3
  store i64 %26, ptr %2, align 8, !tbaa !3
  br label %28

28:                                               ; preds = %16, %22
  %29 = phi i64 [ %20, %16 ], [ %27, %22 ]
  %30 = phi i64 [ %21, %16 ], [ %26, %22 ]
  %31 = add nuw i64 %11, 1
  %exitcond.not = icmp eq i64 %11, %9
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %28, %0
  %32 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.f7b089726f840329b3033a563945bfdd, i32 20)
  %33 = load i64, ptr %1, align 8, !tbaa !3
  %34 = call i1 @_FortranAioOutputInteger64(ptr %32, i64 %33)
  %35 = load i64, ptr %2, align 8, !tbaa !3
  %36 = call i1 @_FortranAioOutputInteger64(ptr %32, i64 %35)
  %37 = call i32 @_FortranAioEndIoStatement(ptr %32)
  %38 = 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

attributes #0 = { noreturn }

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