program walk_and_teleport
  implicit none
  integer :: n, i
  integer(8) :: a, b, x(100000), s
  x = 0_8
  read(*,*) n, a, b
  read(*,*) x(1:n)
  s = 0
  do i = 1, n-1
    s = s + min(a*(x(i+1)-x(i)),b)
  end do
  write(*,'(i0)') s
  stop
end program walk_and_teleport
; 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"

@_QFEx = internal global [100000 x i64] undef
@_QQcl.344de1f266cf98344a537596a1f75aee = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7568/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #0 {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(800000) @_QFEx, i8 0, i64 800000, i1 false), !tbaa !3
  %5 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.344de1f266cf98344a537596a1f75aee, i32 6)
  %6 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %4, i32 4)
  %7 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %2, i32 8)
  %8 = call i1 @_FortranAioInputInteger(ptr %5, ptr nonnull %3, i32 8)
  %9 = call i32 @_FortranAioEndIoStatement(ptr %5)
  %10 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.344de1f266cf98344a537596a1f75aee, i32 7)
  %11 = load i32, ptr %4, align 4, !tbaa !3
  %12 = call i32 @llvm.smax.i32(i32 %11, i32 0)
  %13 = zext i32 %12 to i64
  store ptr @_QFEx, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 8, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 10, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 %13, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 8, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %14 = call i1 @_FortranAioInputDescriptor(ptr %10, ptr nonnull %1)
  %15 = call i32 @_FortranAioEndIoStatement(ptr %10)
  %16 = load i32, ptr %4, align 4, !tbaa !3
  %17 = add i32 %16, -1
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %19 = zext i32 %17 to i64
  %20 = load i64, ptr %2, align 8, !tbaa !3
  %21 = load i64, ptr %3, align 8, !tbaa !3
  %min.iters.check = icmp ult i32 %17, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.lr.ph
  %22 = add nsw i64 %19, -1
  %23 = trunc i64 %22 to i32
  %24 = icmp ugt i32 %23, 2147483645
  %25 = icmp ugt i64 %22, 4294967295
  %26 = or i1 %24, %25
  br i1 %26, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.scevcheck
  %n.vec = and i64 %19, 4294967292
  %ind.end = or i64 %n.vec, 1
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %20, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert12 = insertelement <2 x i64> poison, i64 %20, i64 0
  %broadcast.splat13 = shufflevector <2 x i64> %broadcast.splatinsert12, <2 x i64> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert14 = insertelement <2 x i64> poison, i64 %21, i64 0
  %broadcast.splat15 = shufflevector <2 x i64> %broadcast.splatinsert14, <2 x i64> poison, <2 x i32> zeroinitializer
  %broadcast.splatinsert16 = insertelement <2 x i64> poison, i64 %21, i64 0
  %broadcast.splat17 = shufflevector <2 x i64> %broadcast.splatinsert16, <2 x i64> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %40, %vector.body ]
  %vec.phi8 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %41, %vector.body ]
  %27 = shl i64 %index, 32
  %28 = ashr exact i64 %27, 32
  %29 = or i64 %28, 1
  %30 = getelementptr [100000 x i64], ptr @_QFEx, i64 0, i64 %29
  %wide.load = load <2 x i64>, ptr %30, align 8, !tbaa !3
  %31 = getelementptr i64, ptr %30, i64 2
  %wide.load9 = load <2 x i64>, ptr %31, align 8, !tbaa !3
  %32 = getelementptr [100000 x i64], ptr @_QFEx, i64 0, i64 %index
  %wide.load10 = load <2 x i64>, ptr %32, align 16, !tbaa !3
  %33 = getelementptr i64, ptr %32, i64 2
  %wide.load11 = load <2 x i64>, ptr %33, align 16, !tbaa !3
  %34 = sub <2 x i64> %wide.load, %wide.load10
  %35 = sub <2 x i64> %wide.load9, %wide.load11
  %36 = mul <2 x i64> %34, %broadcast.splat
  %37 = mul <2 x i64> %35, %broadcast.splat13
  %38 = call <2 x i64> @llvm.smin.v2i64(<2 x i64> %36, <2 x i64> %broadcast.splat15)
  %39 = call <2 x i64> @llvm.smin.v2i64(<2 x i64> %37, <2 x i64> %broadcast.splat17)
  %40 = add <2 x i64> %38, %vec.phi
  %41 = add <2 x i64> %39, %vec.phi8
  %index.next = add nuw i64 %index, 4
  %42 = icmp eq i64 %index.next, %n.vec
  br i1 %42, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %41, %40
  %43 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %n.vec, %19
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %vector.scevcheck, %.lr.ph, %middle.block
  %indvars.iv.ph = phi i64 [ 1, %vector.scevcheck ], [ 1, %.lr.ph ], [ %ind.end, %middle.block ]
  %.06.ph = phi i64 [ 0, %vector.scevcheck ], [ 0, %.lr.ph ], [ %43, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %.06 = phi i64 [ %54, %scalar.ph ], [ %.06.ph, %scalar.ph.preheader ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %sext = shl i64 %indvars.iv.next, 32
  %44 = ashr exact i64 %sext, 32
  %45 = add nsw i64 %44, -1
  %46 = getelementptr [100000 x i64], ptr @_QFEx, i64 0, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !3
  %48 = add nsw i64 %indvars.iv, -1
  %49 = getelementptr [100000 x i64], ptr @_QFEx, i64 0, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !3
  %51 = sub i64 %47, %50
  %52 = mul i64 %51, %20
  %53 = call i64 @llvm.smin.i64(i64 %52, i64 %21)
  %54 = add i64 %53, %.06
  %exitcond.not = icmp eq i64 %indvars.iv, %19
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %0
  %.0.lcssa = phi i64 [ 0, %0 ], [ %43, %middle.block ], [ %54, %scalar.ph ]
  %55 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.344de1f266cf98344a537596a1f75aee, i32 12)
  %56 = call i1 @_FortranAioOutputInteger64(ptr %55, i64 %.0.lcssa)
  %57 = call i32 @_FortranAioEndIoStatement(ptr %55)
  %58 = 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 i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x i64> @llvm.smin.v2i64(<2 x i64>, <2 x i64>) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #3

attributes #0 = { noreturn }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nocallback nofree nosync nounwind 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"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !10}
