; LLVM IR from bondhugula/pluto :: test (jacobi-1d-mod)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@u = external dso_local global [2 x [1000 x i32]], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  store i32 1000, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 1000, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %60, %0
  %7 = load i32, ptr %5, align 4, !tbaa !5
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = sub nsw i32 %8, 1
  %10 = icmp sle i32 %7, %9
  br i1 %10, label %11, label %63

11:                                               ; preds = %6
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %56, %11
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = sub nsw i32 %14, 2
  %16 = icmp sle i32 %13, %15
  br i1 %16, label %17, label %59

17:                                               ; preds = %12
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = sub nsw i32 %18, 1
  %20 = srem i32 %19, 2
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %21
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = sub nsw i32 %23, 1
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [1000 x i32], ptr %22, i64 0, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = sub nsw i32 %28, 1
  %30 = srem i32 %29, 2
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %31
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [1000 x i32], ptr %32, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = add nsw i32 %27, %36
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = sub nsw i32 %38, 1
  %40 = srem i32 %39, 2
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %41
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [1000 x i32], ptr %42, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = add nsw i32 %37, %47
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = srem i32 %49, 2
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %51
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1000 x i32], ptr %52, i64 0, i64 %54
  store i32 %48, ptr %55, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %17
  %57 = load i32, ptr %4, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %4, align 4, !tbaa !5
  br label %12, !llvm.loop !9

59:                                               ; preds = %12
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %5, align 4, !tbaa !5
  br label %6, !llvm.loop !11

63:                                               ; preds = %6
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = sub nsw i32 %64, 1
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %66
  %68 = getelementptr inbounds [1000 x i32], ptr %67, i64 0, i64 1
  %69 = load i32, ptr %68, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  ret i32 %69
}

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind }

!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 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@u = external dso_local local_unnamed_addr global [2 x [1000 x i32]], align 16

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
  br label %.preheader

.preheader:                                       ; preds = %0, %.loopexit
  %.017 = phi i32 [ 1, %0 ], [ %61, %.loopexit ]
  %1 = and i32 %.017, 1
  %.urem = xor i32 %1, 1
  %2 = zext nneg i32 %.urem to i64
  %3 = and i32 %.017, 1
  %4 = zext nneg i32 %3 to i64
  %.phi.trans.insert = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 1
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !5
  %vector.recur.init = insertelement <4 x i32> poison, i32 %.pre, i64 3
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %.preheader
  %index = phi i64 [ 0, %.preheader ], [ %index.next, %vector.body ]
  %vector.recur = phi <4 x i32> [ %vector.recur.init, %.preheader ], [ %wide.load23, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %5 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 %index
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %wide.load = load <4 x i32>, ptr %5, align 16, !tbaa !5
  %wide.load21 = load <4 x i32>, ptr %6, align 16, !tbaa !5
  %7 = or disjoint i64 %index, 2
  %8 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 %7
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  %wide.load22 = load <4 x i32>, ptr %8, align 8, !tbaa !5
  %wide.load23 = load <4 x i32>, ptr %9, align 8, !tbaa !5
  %10 = shufflevector <4 x i32> %vector.recur, <4 x i32> %wide.load22, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
  %11 = shufflevector <4 x i32> %wide.load22, <4 x i32> %wide.load23, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
  %12 = add nsw <4 x i32> %10, %wide.load
  %13 = add nsw <4 x i32> %11, %wide.load21
  %14 = add nsw <4 x i32> %12, %wide.load22
  %15 = add nsw <4 x i32> %13, %wide.load23
  %16 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %4, i64 %offset.idx
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  store <4 x i32> %14, ptr %16, align 4, !tbaa !5
  store <4 x i32> %15, ptr %17, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %18 = icmp eq i64 %index.next, 992
  br i1 %18, label %.loopexit, label %vector.body, !llvm.loop !9

.loopexit:                                        ; preds = %vector.body
  %vector.recur.extract = extractelement <4 x i32> %wide.load23, i64 3
  %19 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 992
  %20 = load i32, ptr %19, align 16, !tbaa !5
  %21 = add nsw i32 %vector.recur.extract, %20
  %22 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 994
  %23 = load i32, ptr %22, align 8, !tbaa !5
  %24 = add nsw i32 %21, %23
  %25 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %4, i64 993
  store i32 %24, ptr %25, align 4, !tbaa !5
  %26 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 993
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = add nsw i32 %23, %27
  %29 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 995
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = add nsw i32 %28, %30
  %32 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %4, i64 994
  store i32 %31, ptr %32, align 8, !tbaa !5
  %33 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 994
  %34 = load i32, ptr %33, align 8, !tbaa !5
  %35 = add nsw i32 %30, %34
  %36 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 996
  %37 = load i32, ptr %36, align 16, !tbaa !5
  %38 = add nsw i32 %35, %37
  %39 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %4, i64 995
  store i32 %38, ptr %39, align 4, !tbaa !5
  %40 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 995
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = add nsw i32 %37, %41
  %43 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 997
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = add nsw i32 %42, %44
  %46 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %4, i64 996
  store i32 %45, ptr %46, align 16, !tbaa !5
  %47 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 996
  %48 = load i32, ptr %47, align 16, !tbaa !5
  %49 = add nsw i32 %44, %48
  %50 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 998
  %51 = load i32, ptr %50, align 8, !tbaa !5
  %52 = add nsw i32 %49, %51
  %53 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %4, i64 997
  store i32 %52, ptr %53, align 4, !tbaa !5
  %54 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 997
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = add nsw i32 %51, %55
  %57 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %2, i64 999
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = add nsw i32 %56, %58
  %60 = getelementptr inbounds [2 x [1000 x i32]], ptr @u, i64 0, i64 %4, i64 998
  store i32 %59, ptr %60, align 8, !tbaa !5
  %61 = add nuw nsw i32 %.017, 1
  %exitcond19.not = icmp eq i32 %61, 1000
  br i1 %exitcond19.not, label %62, label %.preheader, !llvm.loop !13

62:                                               ; preds = %.loopexit
  %63 = load i32, ptr getelementptr inbounds (i8, ptr @u, i64 3996004), align 4, !tbaa !5
  ret i32 %63
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) 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" }

!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 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass