; LLVM IR from NaokiHori/VerySimpleNSSolver :: src/integrate/predict/compute_dux (dify)

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

@ux_imin = external constant i64, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @ux_dify(ptr noundef %0, double noundef %1, ptr noundef %2, double noundef %3, ptr noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca double, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store double %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.domain_t, ptr %17, i32 0, i32 2
  %19 = load i64, ptr %18, align 8, !tbaa !11
  store i64 %19, ptr %11, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.domain_t, ptr %20, i32 0, i32 3
  %22 = load i64, ptr %21, align 8, !tbaa !15
  store i64 %22, ptr %12, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.domain_t, ptr %23, i32 0, i32 5
  %25 = load double, ptr %24, align 8, !tbaa !16
  store double %25, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  store i64 1, ptr %14, align 8, !tbaa !14
  br label %26

26:                                               ; preds = %85, %5
  %27 = load i64, ptr %14, align 8, !tbaa !14
  %28 = load i64, ptr %12, align 8, !tbaa !14
  %29 = icmp ule i64 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 2, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %88

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %32 = load i64, ptr @ux_imin, align 8, !tbaa !14
  store i64 %32, ptr %16, align 8, !tbaa !14
  br label %33

33:                                               ; preds = %81, %31
  %34 = load i64, ptr %16, align 8, !tbaa !14
  %35 = load i64, ptr %11, align 8, !tbaa !14
  %36 = icmp ule i64 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  store i32 5, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  br label %84

38:                                               ; preds = %33
  %39 = load double, ptr %9, align 8, !tbaa !9
  %40 = load double, ptr %7, align 8, !tbaa !9
  %41 = fmul double %39, %40
  %42 = load double, ptr %13, align 8, !tbaa !9
  %43 = fdiv double %41, %42
  %44 = load double, ptr %13, align 8, !tbaa !9
  %45 = fdiv double %43, %44
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load i64, ptr %14, align 8, !tbaa !14
  %48 = sub i64 %47, 1
  %49 = getelementptr inbounds ptr, ptr %46, i64 %48
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = load i64, ptr %16, align 8, !tbaa !14
  %52 = getelementptr inbounds double, ptr %50, i64 %51
  %53 = load double, ptr %52, align 8, !tbaa !9
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = load i64, ptr %14, align 8, !tbaa !14
  %56 = getelementptr inbounds ptr, ptr %54, i64 %55
  %57 = load ptr, ptr %56, align 8, !tbaa !5
  %58 = load i64, ptr %16, align 8, !tbaa !14
  %59 = getelementptr inbounds double, ptr %57, i64 %58
  %60 = load double, ptr %59, align 8, !tbaa !9
  %61 = fmul double 2.000000e+00, %60
  %62 = fneg double %61
  %63 = call double @llvm.fmuladd.f64(double 1.000000e+00, double %53, double %62)
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = load i64, ptr %14, align 8, !tbaa !14
  %66 = add i64 %65, 1
  %67 = getelementptr inbounds ptr, ptr %64, i64 %66
  %68 = load ptr, ptr %67, align 8, !tbaa !5
  %69 = load i64, ptr %16, align 8, !tbaa !14
  %70 = getelementptr inbounds double, ptr %68, i64 %69
  %71 = load double, ptr %70, align 8, !tbaa !9
  %72 = call double @llvm.fmuladd.f64(double 1.000000e+00, double %71, double %63)
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = load i64, ptr %14, align 8, !tbaa !14
  %75 = getelementptr inbounds ptr, ptr %73, i64 %74
  %76 = load ptr, ptr %75, align 8, !tbaa !5
  %77 = load i64, ptr %16, align 8, !tbaa !14
  %78 = getelementptr inbounds double, ptr %76, i64 %77
  %79 = load double, ptr %78, align 8, !tbaa !9
  %80 = call double @llvm.fmuladd.f64(double %45, double %72, double %79)
  store double %80, ptr %78, align 8, !tbaa !9
  br label %81

81:                                               ; preds = %38
  %82 = load i64, ptr %16, align 8, !tbaa !14
  %83 = add i64 %82, 1
  store i64 %83, ptr %16, align 8, !tbaa !14
  br label %33, !llvm.loop !17

84:                                               ; preds = %37
  br label %85

85:                                               ; preds = %84
  %86 = load i64, ptr %14, align 8, !tbaa !14
  %87 = add i64 %86, 1
  store i64 %87, ptr %14, align 8, !tbaa !14
  br label %26, !llvm.loop !19

88:                                               ; preds = %30
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret i32 0
}

; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 16}
!12 = !{!"", !10, i64 0, !10, i64 8, !13, i64 16, !13, i64 24, !10, i64 32, !10, i64 40}
!13 = !{!"long", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 24}
!16 = !{!12, !10, i64 40}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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

@ux_imin = external local_unnamed_addr constant i64, align 8

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @ux_dify(ptr nocapture noundef readonly %0, double noundef %1, ptr nocapture noundef readonly %2, double noundef %3, ptr nocapture noundef readonly %4) local_unnamed_addr #0 {
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i64, ptr %8, align 8, !tbaa !11
  %.not28 = icmp eq i64 %9, 0
  br i1 %.not28, label %._crit_edge32, label %.lr.ph31

.lr.ph31:                                         ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = load double, ptr %10, align 8, !tbaa !12
  %12 = load i64, ptr @ux_imin, align 8, !tbaa !13
  %.not2526 = icmp ugt i64 %12, %7
  %13 = fmul double %1, %3
  %14 = fdiv double %13, %11
  %15 = fdiv double %14, %11
  br i1 %.not2526, label %._crit_edge32, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph31
  %16 = add i64 %9, 1
  %umax = tail call i64 @llvm.umax.i64(i64 %16, i64 2)
  %17 = shl i64 %12, 3
  %18 = add i64 %12, 1
  %19 = add i64 %7, 1
  %umax34 = tail call i64 @llvm.umax.i64(i64 %18, i64 %19)
  %20 = shl i64 %umax34, 3
  %umax49 = tail call i64 @llvm.umax.i64(i64 %18, i64 %19)
  %21 = sub i64 %umax49, %12
  %min.iters.check = icmp ult i64 %21, 4
  %n.vec = and i64 %21, -4
  %ind.end = add i64 %12, %n.vec
  %broadcast.splatinsert = insertelement <2 x double> poison, double %15, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  %cmp.n = icmp eq i64 %21, %n.vec
  br label %.lr.ph

._crit_edge32:                                    ; preds = %._crit_edge, %.lr.ph31, %5
  ret i32 0

.lr.ph:                                           ; preds = %.lr.ph.preheader, %._crit_edge
  %.02429 = phi i64 [ %47, %._crit_edge ], [ 1, %.lr.ph.preheader ]
  %22 = getelementptr ptr, ptr %2, i64 %.02429
  %23 = getelementptr i8, ptr %22, i64 -8
  %24 = load ptr, ptr %23, align 8, !tbaa !14
  %25 = load ptr, ptr %22, align 8, !tbaa !14
  %26 = getelementptr i8, ptr %22, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %28 = getelementptr inbounds ptr, ptr %4, i64 %.02429
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.lr.ph
  %.027.ph = phi i64 [ %12, %vector.memcheck ], [ %12, %.lr.ph ], [ %ind.end, %middle.block ]
  br label %scalar.ph

vector.memcheck:                                  ; preds = %.lr.ph
  %scevgep = getelementptr i8, ptr %29, i64 %17
  %scevgep35 = getelementptr i8, ptr %29, i64 %20
  %scevgep36 = getelementptr i8, ptr %24, i64 %17
  %scevgep37 = getelementptr i8, ptr %24, i64 %20
  %scevgep38 = getelementptr i8, ptr %25, i64 %17
  %scevgep39 = getelementptr i8, ptr %25, i64 %20
  %scevgep40 = getelementptr i8, ptr %27, i64 %17
  %scevgep41 = getelementptr i8, ptr %27, i64 %20
  %bound0 = icmp ult ptr %scevgep, %scevgep37
  %bound1 = icmp ult ptr %scevgep36, %scevgep35
  %found.conflict = and i1 %bound0, %bound1
  %bound042 = icmp ult ptr %scevgep, %scevgep39
  %bound143 = icmp ult ptr %scevgep38, %scevgep35
  %found.conflict44 = and i1 %bound042, %bound143
  %conflict.rdx = or i1 %found.conflict, %found.conflict44
  %bound045 = icmp ult ptr %scevgep, %scevgep41
  %bound146 = icmp ult ptr %scevgep40, %scevgep35
  %found.conflict47 = and i1 %bound045, %bound146
  %conflict.rdx48 = or i1 %conflict.rdx, %found.conflict47
  br i1 %conflict.rdx48, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %vector.memcheck, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.memcheck ]
  %offset.idx = add i64 %12, %index
  %30 = getelementptr inbounds double, ptr %24, i64 %offset.idx
  %31 = getelementptr inbounds i8, ptr %30, i64 16
  %wide.load = load <2 x double>, ptr %30, align 8, !tbaa !16, !alias.scope !17
  %wide.load50 = load <2 x double>, ptr %31, align 8, !tbaa !16, !alias.scope !17
  %32 = getelementptr inbounds double, ptr %25, i64 %offset.idx
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %wide.load51 = load <2 x double>, ptr %32, align 8, !tbaa !16, !alias.scope !20
  %wide.load52 = load <2 x double>, ptr %33, align 8, !tbaa !16, !alias.scope !20
  %34 = fmul <2 x double> %wide.load51, <double 2.000000e+00, double 2.000000e+00>
  %35 = fmul <2 x double> %wide.load52, <double 2.000000e+00, double 2.000000e+00>
  %36 = fsub <2 x double> %wide.load, %34
  %37 = fsub <2 x double> %wide.load50, %35
  %38 = getelementptr inbounds double, ptr %27, i64 %offset.idx
  %39 = getelementptr inbounds i8, ptr %38, i64 16
  %wide.load53 = load <2 x double>, ptr %38, align 8, !tbaa !16, !alias.scope !22
  %wide.load54 = load <2 x double>, ptr %39, align 8, !tbaa !16, !alias.scope !22
  %40 = fadd <2 x double> %wide.load53, %36
  %41 = fadd <2 x double> %wide.load54, %37
  %42 = getelementptr inbounds double, ptr %29, i64 %offset.idx
  %43 = getelementptr inbounds i8, ptr %42, i64 16
  %wide.load55 = load <2 x double>, ptr %42, align 8, !tbaa !16, !alias.scope !24, !noalias !26
  %wide.load56 = load <2 x double>, ptr %43, align 8, !tbaa !16, !alias.scope !24, !noalias !26
  %44 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %broadcast.splat, <2 x double> %40, <2 x double> %wide.load55)
  %45 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %broadcast.splat, <2 x double> %41, <2 x double> %wide.load56)
  store <2 x double> %44, ptr %42, align 8, !tbaa !16, !alias.scope !24, !noalias !26
  store <2 x double> %45, ptr %43, align 8, !tbaa !16, !alias.scope !24, !noalias !26
  %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 !27

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

._crit_edge:                                      ; preds = %scalar.ph, %middle.block
  %47 = add nuw i64 %.02429, 1
  %exitcond = icmp eq i64 %47, %umax
  br i1 %exitcond, label %._crit_edge32, label %.lr.ph, !llvm.loop !31

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.027 = phi i64 [ %60, %scalar.ph ], [ %.027.ph, %scalar.ph.preheader ]
  %48 = getelementptr inbounds double, ptr %24, i64 %.027
  %49 = load double, ptr %48, align 8, !tbaa !16
  %50 = getelementptr inbounds double, ptr %25, i64 %.027
  %51 = load double, ptr %50, align 8, !tbaa !16
  %52 = fmul double %51, 2.000000e+00
  %53 = fsub double %49, %52
  %54 = getelementptr inbounds double, ptr %27, i64 %.027
  %55 = load double, ptr %54, align 8, !tbaa !16
  %56 = fadd double %55, %53
  %57 = getelementptr inbounds double, ptr %29, i64 %.027
  %58 = load double, ptr %57, align 8, !tbaa !16
  %59 = tail call double @llvm.fmuladd.f64(double %15, double %56, double %58)
  store double %59, ptr %57, align 8, !tbaa !16
  %60 = add i64 %.027, 1
  %.not25 = icmp ugt i64 %60, %7
  br i1 %.not25, label %._crit_edge, label %scalar.ph, !llvm.loop !32
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #2

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = !{!6, !7, i64 40}
!13 = !{!10, !10, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!18}
!18 = distinct !{!18, !19}
!19 = distinct !{!19, !"LVerDomain"}
!20 = !{!21}
!21 = distinct !{!21, !19}
!22 = !{!23}
!23 = distinct !{!23, !19}
!24 = !{!25}
!25 = distinct !{!25, !19}
!26 = !{!18, !21, !23}
!27 = distinct !{!27, !28, !29, !30}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!"llvm.loop.isvectorized", i32 1}
!30 = !{!"llvm.loop.unroll.runtime.disable"}
!31 = distinct !{!31, !28}
!32 = distinct !{!32, !28, !29}


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