integer n, k, x, y, ans
ans = 0
read*, n, k, x, y
if(n > k) then
	ans = (n - k) * y
    n = k
end if
ans = ans + n * x
print*, int(ans)
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.63d2bd5a9648d85eda01e246e0f6d53a = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7915/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.63d2bd5a9648d85eda01e246e0f6d53a, i32 3)
  %6 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %2, i32 4)
  %7 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %1, i32 4)
  %8 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %3, i32 4)
  %9 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %4, i32 4)
  %10 = call i32 @_FortranAioEndIoStatement(ptr %5)
  %11 = load i32, ptr %2, align 4, !tbaa !3
  %12 = load i32, ptr %1, align 4, !tbaa !3
  %13 = icmp sgt i32 %11, %12
  br i1 %13, label %14, label %18

14:                                               ; preds = %0
  %15 = sub i32 %11, %12
  %16 = load i32, ptr %4, align 4, !tbaa !3
  %17 = mul i32 %16, %15
  store i32 %12, ptr %2, align 4, !tbaa !3
  br label %18

18:                                               ; preds = %14, %0
  %19 = phi i32 [ %12, %14 ], [ %11, %0 ]
  %.0 = phi i32 [ %17, %14 ], [ 0, %0 ]
  %20 = load i32, ptr %3, align 4, !tbaa !3
  %21 = mul i32 %20, %19
  %22 = add i32 %21, %.0
  %23 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.63d2bd5a9648d85eda01e246e0f6d53a, i32 9)
  %24 = call i1 @_FortranAioOutputInteger32(ptr %23, i32 %22)
  %25 = call i32 @_FortranAioEndIoStatement(ptr %23)
  ret void
}

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 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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