; LLVM IR from NaokiHori/VerySimpleNSSolver :: src/boundary_condition (uy)

; 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"

%struct.domain_t = type { double, double, i64, i64, double, double }

; Function Attrs: nounwind uwtable
define dso_local i32 @impose_boundary_condition_uy_y(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.domain_t, ptr %9, i32 0, i32 2
  %11 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %11, ptr %6, align 8, !tbaa !13
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.domain_t, ptr %12, i32 0, i32 3
  %14 = load i64, ptr %13, align 8, !tbaa !14
  store i64 %14, ptr %7, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store i64 0, ptr %8, align 8, !tbaa !13
  br label %15

15:                                               ; preds = %40, %2
  %16 = load i64, ptr %8, align 8, !tbaa !13
  %17 = load i64, ptr %6, align 8, !tbaa !13
  %18 = add i64 %17, 1
  %19 = icmp ule i64 %16, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  br label %43

21:                                               ; preds = %15
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds ptr, ptr %22, i64 1
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = load i64, ptr %8, align 8, !tbaa !13
  %26 = getelementptr inbounds double, ptr %24, i64 %25
  %27 = load double, ptr %26, align 8, !tbaa !15
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds ptr, ptr %28, i64 0
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = load i64, ptr %8, align 8, !tbaa !13
  %32 = getelementptr inbounds double, ptr %30, i64 %31
  store double %27, ptr %32, align 8, !tbaa !15
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load i64, ptr %7, align 8, !tbaa !13
  %35 = add i64 %34, 1
  %36 = getelementptr inbounds ptr, ptr %33, i64 %35
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = load i64, ptr %8, align 8, !tbaa !13
  %39 = getelementptr inbounds double, ptr %37, i64 %38
  store double -1.000000e+00, ptr %39, align 8, !tbaa !15
  br label %40

40:                                               ; preds = %21
  %41 = load i64, ptr %8, align 8, !tbaa !13
  %42 = add i64 %41, 1
  store i64 %42, ptr %8, align 8, !tbaa !13
  br label %15, !llvm.loop !16

43:                                               ; preds = %20
  store i32 0, ptr %3, align 4
  br label %45

44:                                               ; No predecessors!
  store i32 1, ptr %3, align 4
  br label %45

45:                                               ; preds = %44, %43
  %46 = load i32, ptr %3, align 4
  ret i32 %46
}

; 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 16}
!10 = !{!"", !11, i64 0, !11, i64 8, !12, i64 16, !12, i64 24, !11, i64 32, !11, i64 40}
!11 = !{!"double", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !12, i64 24}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; 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"

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @impose_boundary_condition_uy_y(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load i64, ptr %5, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %9 = load ptr, ptr %1, align 8, !tbaa !12
  %10 = getelementptr ptr, ptr %1, i64 %6
  %11 = getelementptr i8, ptr %10, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %13 = add i64 %4, 2
  %umax = tail call i64 @llvm.umax.i64(i64 %13, i64 1)
  %min.iters.check = icmp ult i64 %13, 14
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %2
  %.012.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %2 ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %umax, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader, %scalar.ph.prol
  %.012.prol = phi i64 [ %18, %scalar.ph.prol ], [ %.012.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %14 = getelementptr inbounds double, ptr %8, i64 %.012.prol
  %15 = load double, ptr %14, align 8, !tbaa !14
  %16 = getelementptr inbounds double, ptr %9, i64 %.012.prol
  store double %15, ptr %16, align 8, !tbaa !14
  %17 = getelementptr inbounds double, ptr %12, i64 %.012.prol
  store double -1.000000e+00, ptr %17, align 8, !tbaa !14
  %18 = add nuw i64 %.012.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol, !llvm.loop !15

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.012.unr = phi i64 [ %.012.ph, %scalar.ph.preheader ], [ %18, %scalar.ph.prol ]
  %19 = sub i64 %.012.ph, %umax
  %20 = icmp ugt i64 %19, -4
  br i1 %20, label %.loopexit, label %scalar.ph

vector.memcheck:                                  ; preds = %2
  %21 = ptrtoint ptr %12 to i64
  %22 = ptrtoint ptr %9 to i64
  %23 = ptrtoint ptr %8 to i64
  %24 = sub i64 %21, %22
  %diff.check = icmp ult i64 %24, 32
  %25 = sub i64 %22, %23
  %diff.check13 = icmp ult i64 %25, 32
  %conflict.rdx = or i1 %diff.check, %diff.check13
  %26 = sub i64 %21, %23
  %diff.check14 = icmp ult i64 %26, 32
  %conflict.rdx15 = or i1 %conflict.rdx, %diff.check14
  br i1 %conflict.rdx15, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %umax, -4
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %27 = getelementptr inbounds double, ptr %8, i64 %index
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  %wide.load = load <2 x double>, ptr %27, align 8, !tbaa !14
  %wide.load16 = load <2 x double>, ptr %28, align 8, !tbaa !14
  %29 = getelementptr inbounds double, ptr %9, i64 %index
  %30 = getelementptr inbounds i8, ptr %29, i64 16
  store <2 x double> %wide.load, ptr %29, align 8, !tbaa !14
  store <2 x double> %wide.load16, ptr %30, align 8, !tbaa !14
  %31 = getelementptr inbounds double, ptr %12, i64 %index
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  store <2 x double> <double -1.000000e+00, double -1.000000e+00>, ptr %31, align 8, !tbaa !14
  store <2 x double> <double -1.000000e+00, double -1.000000e+00>, ptr %32, align 8, !tbaa !14
  %index.next = add nuw i64 %index, 4
  %33 = icmp eq i64 %index.next, %n.vec
  br i1 %33, label %middle.block, label %vector.body, !llvm.loop !17

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %13, %n.vec
  br i1 %cmp.n, label %.loopexit, label %scalar.ph.preheader

.loopexit:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  ret i32 0

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %.012 = phi i64 [ %53, %scalar.ph ], [ %.012.unr, %scalar.ph.prol.loopexit ]
  %34 = getelementptr inbounds double, ptr %8, i64 %.012
  %35 = load double, ptr %34, align 8, !tbaa !14
  %36 = getelementptr inbounds double, ptr %9, i64 %.012
  store double %35, ptr %36, align 8, !tbaa !14
  %37 = getelementptr inbounds double, ptr %12, i64 %.012
  store double -1.000000e+00, ptr %37, align 8, !tbaa !14
  %38 = add nuw i64 %.012, 1
  %39 = getelementptr inbounds double, ptr %8, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !14
  %41 = getelementptr inbounds double, ptr %9, i64 %38
  store double %40, ptr %41, align 8, !tbaa !14
  %42 = getelementptr inbounds double, ptr %12, i64 %38
  store double -1.000000e+00, ptr %42, align 8, !tbaa !14
  %43 = add nuw i64 %.012, 2
  %44 = getelementptr inbounds double, ptr %8, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !14
  %46 = getelementptr inbounds double, ptr %9, i64 %43
  store double %45, ptr %46, align 8, !tbaa !14
  %47 = getelementptr inbounds double, ptr %12, i64 %43
  store double -1.000000e+00, ptr %47, align 8, !tbaa !14
  %48 = add nuw i64 %.012, 3
  %49 = getelementptr inbounds double, ptr %8, i64 %48
  %50 = load double, ptr %49, align 8, !tbaa !14
  %51 = getelementptr inbounds double, ptr %9, i64 %48
  store double %50, ptr %51, align 8, !tbaa !14
  %52 = getelementptr inbounds double, ptr %12, i64 %48
  store double -1.000000e+00, ptr %52, align 8, !tbaa !14
  %53 = add nuw i64 %.012, 4
  %exitcond.3 = icmp eq i64 %13, %53
  br i1 %exitcond.3, label %.loopexit, label %scalar.ph, !llvm.loop !21
}

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

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, 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" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !10, i64 16}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !7, i64 32, !7, i64 40}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}
!17 = distinct !{!17, !18, !19, !20}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!"llvm.loop.isvectorized", i32 1}
!20 = !{!"llvm.loop.unroll.runtime.disable"}
!21 = distinct !{!21, !18, !19}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass