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

; 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_difx(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 4
  %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 = getelementptr inbounds ptr, ptr %46, i64 %47
  %49 = load ptr, ptr %48, align 8, !tbaa !5
  %50 = load i64, ptr %16, align 8, !tbaa !14
  %51 = sub i64 %50, 1
  %52 = getelementptr inbounds double, ptr %49, 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 = getelementptr inbounds ptr, ptr %64, i64 %65
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %68 = load i64, ptr %16, align 8, !tbaa !14
  %69 = add i64 %68, 1
  %70 = getelementptr inbounds double, ptr %67, 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 32}
!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_difx(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 32
  %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
  %umax38 = tail call i64 @llvm.umax.i64(i64 %18, i64 %19)
  %21 = sub i64 %umax38, %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 [ %46, %._crit_edge ], [ 1, %.lr.ph.preheader ]
  %22 = getelementptr inbounds ptr, ptr %2, i64 %.02429
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = getelementptr inbounds ptr, ptr %4, i64 %.02429
  %25 = load ptr, ptr %24, 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 %25, i64 %17
  %scevgep35 = getelementptr i8, ptr %25, i64 %20
  %26 = getelementptr i8, ptr %23, i64 %17
  %scevgep36 = getelementptr i8, ptr %26, i64 -8
  %27 = getelementptr i8, ptr %23, i64 %20
  %scevgep37 = getelementptr i8, ptr %27, i64 8
  %bound0 = icmp ult ptr %scevgep, %scevgep37
  %bound1 = icmp ult ptr %scevgep36, %scevgep35
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, 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
  %28 = getelementptr double, ptr %23, i64 %offset.idx
  %29 = getelementptr i8, ptr %28, i64 -8
  %30 = getelementptr i8, ptr %28, i64 8
  %wide.load = load <2 x double>, ptr %29, align 8, !tbaa !16, !alias.scope !17
  %wide.load39 = load <2 x double>, ptr %30, align 8, !tbaa !16, !alias.scope !17
  %31 = getelementptr i8, ptr %28, i64 16
  %wide.load40 = load <2 x double>, ptr %28, align 8, !tbaa !16, !alias.scope !17
  %wide.load41 = load <2 x double>, ptr %31, align 8, !tbaa !16, !alias.scope !17
  %32 = fmul <2 x double> %wide.load40, <double 2.000000e+00, double 2.000000e+00>
  %33 = fmul <2 x double> %wide.load41, <double 2.000000e+00, double 2.000000e+00>
  %34 = fsub <2 x double> %wide.load, %32
  %35 = fsub <2 x double> %wide.load39, %33
  %36 = getelementptr double, ptr %23, i64 %offset.idx
  %37 = getelementptr i8, ptr %36, i64 8
  %38 = getelementptr i8, ptr %36, i64 24
  %wide.load42 = load <2 x double>, ptr %37, align 8, !tbaa !16, !alias.scope !17
  %wide.load43 = load <2 x double>, ptr %38, align 8, !tbaa !16, !alias.scope !17
  %39 = fadd <2 x double> %wide.load42, %34
  %40 = fadd <2 x double> %wide.load43, %35
  %41 = getelementptr inbounds double, ptr %25, i64 %offset.idx
  %42 = getelementptr inbounds i8, ptr %41, i64 16
  %wide.load44 = load <2 x double>, ptr %41, align 8, !tbaa !16, !alias.scope !20, !noalias !17
  %wide.load45 = load <2 x double>, ptr %42, align 8, !tbaa !16, !alias.scope !20, !noalias !17
  %43 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %broadcast.splat, <2 x double> %39, <2 x double> %wide.load44)
  %44 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %broadcast.splat, <2 x double> %40, <2 x double> %wide.load45)
  store <2 x double> %43, ptr %41, align 8, !tbaa !16, !alias.scope !20, !noalias !17
  store <2 x double> %44, ptr %42, align 8, !tbaa !16, !alias.scope !20, !noalias !17
  %index.next = add nuw i64 %index, 4
  %45 = icmp eq i64 %index.next, %n.vec
  br i1 %45, label %middle.block, label %vector.body, !llvm.loop !22

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

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

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.027 = phi i64 [ %53, %scalar.ph ], [ %.027.ph, %scalar.ph.preheader ]
  %47 = getelementptr double, ptr %23, i64 %.027
  %48 = getelementptr i8, ptr %47, i64 -8
  %49 = load double, ptr %48, align 8, !tbaa !16
  %50 = load double, ptr %47, align 8, !tbaa !16
  %51 = fmul double %50, 2.000000e+00
  %52 = fsub double %49, %51
  %53 = add i64 %.027, 1
  %54 = getelementptr inbounds double, ptr %23, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !16
  %56 = fadd double %55, %52
  %57 = getelementptr inbounds double, ptr %25, 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
  %.not25 = icmp ugt i64 %53, %7
  br i1 %.not25, label %._crit_edge, label %scalar.ph, !llvm.loop !27
}

; 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 32}
!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 = distinct !{!22, !23, !24, !25}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!"llvm.loop.isvectorized", i32 1}
!25 = !{!"llvm.loop.unroll.runtime.disable"}
!26 = distinct !{!26, !23}
!27 = distinct !{!27, !23, !24}


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