#import <stdio.h>
#import <stdlib.h>

int main(int argc, const char * argv[]) {
    long N, T;
    scanf("%ld %ld", &N, &T);
    long *t = (long*)malloc(N * sizeof(long));
    
    long n;
    long i = 0;
    while (scanf("%ld", &n) != EOF) {
        t[i] = n;
        i++;
    }
    
    long last = 0;
    long total = 0;
    for(i=0;i<N;i++){
        total += T - ((t[i]<last) ? (last-t[i]) : 0);
        last = t[i]+T;
    }
    
    printf("%ld", total);
    
    free(t);
    return 0;
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_797/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_797/source.m"
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"

@.str = private unnamed_addr constant [8 x i8] c"%ld %ld\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%ld\00", align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %argc, ptr nocapture noundef readnone %argv) local_unnamed_addr #0 {
entry:
  %N = alloca i64, align 8
  %T = alloca i64, align 8
  %n = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %N) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %T) #6
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N, ptr noundef nonnull %T)
  %0 = load i64, ptr %N, align 8, !tbaa !5
  %mul = shl i64 %0, 3
  %call1 = call noalias ptr @malloc(i64 noundef %mul) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %n) #6
  %call224 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
  %cmp.not25 = icmp eq i32 %call224, -1
  br i1 %cmp.not25, label %for.cond.preheader, label %while.body

for.cond.preheader:                               ; preds = %while.body, %entry
  %1 = load i64, ptr %N, align 8, !tbaa !5
  %cmp327 = icmp sgt i64 %1, 0
  br i1 %cmp327, label %for.body.lr.ph, label %for.end

for.body.lr.ph:                                   ; preds = %for.cond.preheader
  %2 = load i64, ptr %T, align 8, !tbaa !5
  %min.iters.check = icmp ult i64 %1, 4
  br i1 %min.iters.check, label %for.body.preheader, label %vector.ph

vector.ph:                                        ; preds = %for.body.lr.ph
  %n.vec = and i64 %1, -4
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %2, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <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 ], [ %17, %vector.body ]
  %vec.phi31 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %18, %vector.body ]
  %vector.recur = phi <2 x i64> [ <i64 poison, i64 0>, %vector.ph ], [ %8, %vector.body ]
  %3 = getelementptr inbounds i64, ptr %call1, i64 %index
  %wide.load = load <2 x i64>, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i64, ptr %3, i64 2
  %wide.load32 = load <2 x i64>, ptr %4, align 8, !tbaa !5
  %5 = add <2 x i64> %broadcast.splat, %vec.phi
  %6 = add <2 x i64> %broadcast.splat, %vec.phi31
  %7 = add nsw <2 x i64> %wide.load, %broadcast.splat
  %8 = add nsw <2 x i64> %wide.load32, %broadcast.splat
  %9 = shufflevector <2 x i64> %vector.recur, <2 x i64> %7, <2 x i32> <i32 1, i32 2>
  %10 = shufflevector <2 x i64> %7, <2 x i64> %8, <2 x i32> <i32 1, i32 2>
  %11 = icmp slt <2 x i64> %wide.load, %9
  %12 = icmp slt <2 x i64> %wide.load32, %10
  %13 = sub <2 x i64> %wide.load, %9
  %14 = sub <2 x i64> %wide.load32, %10
  %15 = select <2 x i1> %11, <2 x i64> %13, <2 x i64> zeroinitializer
  %16 = select <2 x i1> %12, <2 x i64> %14, <2 x i64> zeroinitializer
  %17 = add <2 x i64> %5, %15
  %18 = add <2 x i64> %6, %16
  %index.next = add nuw i64 %index, 4
  %19 = icmp eq i64 %index.next, %n.vec
  br i1 %19, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %18, %17
  %20 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %1, %n.vec
  %vector.recur.extract = extractelement <2 x i64> %8, i64 1
  br i1 %cmp.n, label %for.end, label %for.body.preheader

for.body.preheader:                               ; preds = %for.body.lr.ph, %middle.block
  %total.030.ph = phi i64 [ %20, %middle.block ], [ 0, %for.body.lr.ph ]
  %scalar.recur.ph = phi i64 [ %vector.recur.extract, %middle.block ], [ 0, %for.body.lr.ph ]
  %i.128.ph = phi i64 [ %n.vec, %middle.block ], [ 0, %for.body.lr.ph ]
  br label %for.body

while.body:                                       ; preds = %entry, %while.body
  %i.026 = phi i64 [ %inc, %while.body ], [ 0, %entry ]
  %21 = load i64, ptr %n, align 8, !tbaa !5
  %arrayidx = getelementptr inbounds i64, ptr %call1, i64 %i.026
  store i64 %21, ptr %arrayidx, align 8, !tbaa !5
  %inc = add nuw nsw i64 %i.026, 1
  %call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %n)
  %cmp.not = icmp eq i32 %call2, -1
  br i1 %cmp.not, label %for.cond.preheader, label %while.body

for.body:                                         ; preds = %for.body.preheader, %for.body
  %total.030 = phi i64 [ %add, %for.body ], [ %total.030.ph, %for.body.preheader ]
  %scalar.recur = phi i64 [ %add9, %for.body ], [ %scalar.recur.ph, %for.body.preheader ]
  %i.128 = phi i64 [ %inc10, %for.body ], [ %i.128.ph, %for.body.preheader ]
  %arrayidx4 = getelementptr inbounds i64, ptr %call1, i64 %i.128
  %22 = load i64, ptr %arrayidx4, align 8, !tbaa !5
  %cmp5 = icmp slt i64 %22, %scalar.recur
  %sub.neg = sub i64 %22, %scalar.recur
  %spec.select = select i1 %cmp5, i64 %sub.neg, i64 0
  %sub7 = add i64 %2, %total.030
  %add = add i64 %sub7, %spec.select
  %add9 = add nsw i64 %22, %2
  %inc10 = add nuw nsw i64 %i.128, 1
  %exitcond.not = icmp eq i64 %inc10, %1
  br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !12

for.end:                                          ; preds = %for.body, %middle.block, %for.cond.preheader
  %total.0.lcssa = phi i64 [ 0, %for.cond.preheader ], [ %20, %middle.block ], [ %add, %for.body ]
  %call11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %total.0.lcssa)
  call void @free(ptr noundef %call1) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %n) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %T) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %N) #6
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !11, !10}
