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

; 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_ux_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 double, align 8
  %9 = alloca double, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.domain_t, ptr %11, i32 0, i32 2
  %13 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %13, ptr %6, align 8, !tbaa !13
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.domain_t, ptr %14, i32 0, i32 3
  %16 = load i64, ptr %15, align 8, !tbaa !14
  store i64 %16, ptr %7, align 8, !tbaa !13
  store double 0.000000e+00, ptr %8, align 8, !tbaa !15
  store double 0.000000e+00, ptr %9, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i64 0, ptr %10, align 8, !tbaa !13
  br label %17

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

22:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  br label %54

23:                                               ; preds = %17
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds ptr, ptr %24, i64 1
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = load i64, ptr %10, align 8, !tbaa !13
  %28 = getelementptr inbounds double, ptr %26, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !15
  %30 = fadd double 0.000000e+00, %29
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds ptr, ptr %31, i64 0
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = load i64, ptr %10, align 8, !tbaa !13
  %35 = getelementptr inbounds double, ptr %33, i64 %34
  store double %30, ptr %35, align 8, !tbaa !15
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load i64, ptr %7, align 8, !tbaa !13
  %38 = getelementptr inbounds ptr, ptr %36, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = load i64, ptr %10, align 8, !tbaa !13
  %41 = getelementptr inbounds double, ptr %39, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !15
  %43 = fsub double 0.000000e+00, %42
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load i64, ptr %7, align 8, !tbaa !13
  %46 = add i64 %45, 1
  %47 = getelementptr inbounds ptr, ptr %44, i64 %46
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = load i64, ptr %10, align 8, !tbaa !13
  %50 = getelementptr inbounds double, ptr %48, i64 %49
  store double %43, ptr %50, align 8, !tbaa !15
  br label %51

51:                                               ; preds = %23
  %52 = load i64, ptr %10, align 8, !tbaa !13
  %53 = add i64 %52, 1
  store i64 %53, ptr %10, align 8, !tbaa !13
  br label %17, !llvm.loop !16

54:                                               ; preds = %22
  store i32 0, ptr %3, align 4
  br label %56

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

56:                                               ; preds = %55, %54
  %57 = load i32, ptr %3, align 4
  ret i32 %57
}

; 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_ux_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 inbounds ptr, ptr %1, i64 %6
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  %12 = getelementptr i8, ptr %10, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  %14 = add i64 %4, 2
  %umax = tail call i64 @llvm.umax.i64(i64 %14, i64 1)
  %min.iters.check = icmp ult i64 %14, 14
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %2
  %.015.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %2 ], [ %n.vec, %middle.block ]
  %.neg = or disjoint i64 %.015.ph, 1
  %xtraiter = and i64 %umax, 1
  %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
  %15 = getelementptr inbounds double, ptr %8, i64 %.015.ph
  %16 = load double, ptr %15, align 8, !tbaa !14
  %17 = fadd double %16, 0.000000e+00
  %18 = getelementptr inbounds double, ptr %9, i64 %.015.ph
  store double %17, ptr %18, align 8, !tbaa !14
  %19 = getelementptr inbounds double, ptr %11, i64 %.015.ph
  %20 = load double, ptr %19, align 8, !tbaa !14
  %21 = fsub double 0.000000e+00, %20
  %22 = getelementptr inbounds double, ptr %13, i64 %.015.ph
  store double %21, ptr %22, align 8, !tbaa !14
  %23 = or disjoint i64 %.015.ph, 1
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.015.unr = phi i64 [ %.015.ph, %scalar.ph.preheader ], [ %23, %scalar.ph.prol ]
  %24 = icmp eq i64 %umax, %.neg
  br i1 %24, label %.loopexit, label %scalar.ph

vector.memcheck:                                  ; preds = %2
  %25 = ptrtoint ptr %13 to i64
  %26 = ptrtoint ptr %11 to i64
  %27 = ptrtoint ptr %9 to i64
  %28 = ptrtoint ptr %8 to i64
  %29 = sub i64 %25, %27
  %diff.check = icmp ult i64 %29, 32
  %30 = sub i64 %27, %28
  %diff.check16 = icmp ult i64 %30, 32
  %conflict.rdx = or i1 %diff.check, %diff.check16
  %31 = sub i64 %26, %27
  %diff.check17 = icmp ult i64 %31, 32
  %conflict.rdx18 = or i1 %conflict.rdx, %diff.check17
  %32 = sub i64 %25, %28
  %diff.check19 = icmp ult i64 %32, 32
  %conflict.rdx20 = or i1 %conflict.rdx18, %diff.check19
  %33 = sub i64 %25, %26
  %diff.check21 = icmp ult i64 %33, 32
  %conflict.rdx22 = or i1 %conflict.rdx20, %diff.check21
  br i1 %conflict.rdx22, 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 ]
  %34 = getelementptr inbounds double, ptr %8, i64 %index
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  %wide.load = load <2 x double>, ptr %34, align 8, !tbaa !14
  %wide.load23 = load <2 x double>, ptr %35, align 8, !tbaa !14
  %36 = fadd <2 x double> %wide.load, zeroinitializer
  %37 = fadd <2 x double> %wide.load23, zeroinitializer
  %38 = getelementptr inbounds double, ptr %9, i64 %index
  %39 = getelementptr inbounds i8, ptr %38, i64 16
  store <2 x double> %36, ptr %38, align 8, !tbaa !14
  store <2 x double> %37, ptr %39, align 8, !tbaa !14
  %40 = getelementptr inbounds double, ptr %11, i64 %index
  %41 = getelementptr inbounds i8, ptr %40, i64 16
  %wide.load24 = load <2 x double>, ptr %40, align 8, !tbaa !14
  %wide.load25 = load <2 x double>, ptr %41, align 8, !tbaa !14
  %42 = fsub <2 x double> zeroinitializer, %wide.load24
  %43 = fsub <2 x double> zeroinitializer, %wide.load25
  %44 = getelementptr inbounds double, ptr %13, i64 %index
  %45 = getelementptr inbounds i8, ptr %44, i64 16
  store <2 x double> %42, ptr %44, align 8, !tbaa !14
  store <2 x double> %43, ptr %45, align 8, !tbaa !14
  %index.next = add nuw i64 %index, 4
  %46 = icmp eq i64 %index.next, %n.vec
  br i1 %46, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %14, %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
  %.015 = phi i64 [ %64, %scalar.ph ], [ %.015.unr, %scalar.ph.prol.loopexit ]
  %47 = getelementptr inbounds double, ptr %8, i64 %.015
  %48 = load double, ptr %47, align 8, !tbaa !14
  %49 = fadd double %48, 0.000000e+00
  %50 = getelementptr inbounds double, ptr %9, i64 %.015
  store double %49, ptr %50, align 8, !tbaa !14
  %51 = getelementptr inbounds double, ptr %11, i64 %.015
  %52 = load double, ptr %51, align 8, !tbaa !14
  %53 = fsub double 0.000000e+00, %52
  %54 = getelementptr inbounds double, ptr %13, i64 %.015
  store double %53, ptr %54, align 8, !tbaa !14
  %55 = add nuw i64 %.015, 1
  %56 = getelementptr inbounds double, ptr %8, i64 %55
  %57 = load double, ptr %56, align 8, !tbaa !14
  %58 = fadd double %57, 0.000000e+00
  %59 = getelementptr inbounds double, ptr %9, i64 %55
  store double %58, ptr %59, align 8, !tbaa !14
  %60 = getelementptr inbounds double, ptr %11, i64 %55
  %61 = load double, ptr %60, align 8, !tbaa !14
  %62 = fsub double 0.000000e+00, %61
  %63 = getelementptr inbounds double, ptr %13, i64 %55
  store double %62, ptr %63, align 8, !tbaa !14
  %64 = add nuw i64 %.015, 2
  %exitcond.1 = icmp eq i64 %4, %.015
  br i1 %exitcond.1, label %.loopexit, label %scalar.ph, !llvm.loop !19
}

; 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, !17, !18}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.isvectorized", i32 1}
!18 = !{!"llvm.loop.unroll.runtime.disable"}
!19 = distinct !{!19, !16, !17}


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