; LLVM IR from NaokiHori/VerySimpleNSSolver :: src/integrate/predict/compute_duy (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 }

@uy_jmin = external constant i64, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @uy_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
  %26 = load i64, ptr @uy_jmin, align 8, !tbaa !14
  store i64 %26, ptr %14, align 8, !tbaa !14
  br label %27

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

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

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

33:                                               ; preds = %81, %32
  %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 %27, !llvm.loop !19

88:                                               ; preds = %31
  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"

@uy_jmin = external local_unnamed_addr constant i64, align 8

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @uy_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
  %10 = load i64, ptr @uy_jmin, align 8, !tbaa !12
  %.not28 = icmp ugt i64 %10, %9
  br i1 %.not28, label %._crit_edge30, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %5
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load double, ptr %11, align 8, !tbaa !13
  %.not2526 = icmp eq i64 %7, 0
  %13 = fmul double %1, %3
  %14 = fdiv double %13, %12
  %15 = fdiv double %14, %12
  br i1 %.not2526, label %._crit_edge30, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader.lr.ph
  %16 = add i64 %7, 1
  %umax = tail call i64 @llvm.umax.i64(i64 %16, i64 2)
  %17 = shl i64 %umax, 3
  %18 = add i64 %umax, -1
  %min.iters.check = icmp ult i64 %16, 5
  %n.vec = and i64 %18, -4
  %ind.end = or disjoint i64 %n.vec, 1
  %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 %18, %n.vec
  %19 = and i64 %umax, 1
  %lcmp.mod.not.not = icmp eq i64 %19, 0
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %.02429 = phi i64 [ %57, %._crit_edge ], [ %10, %.preheader.preheader ]
  %20 = getelementptr inbounds ptr, ptr %2, i64 %.02429
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  %22 = getelementptr inbounds ptr, ptr %4, i64 %.02429
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.preheader
  %.027.ph = phi i64 [ 1, %vector.memcheck ], [ 1, %.preheader ], [ %ind.end, %middle.block ]
  %.neg = add i64 %.027.ph, 1
  br i1 %lcmp.mod.not.not, label %scalar.ph.prol, label %scalar.ph.prol.loopexit

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader
  %24 = getelementptr double, ptr %21, i64 %.027.ph
  %25 = getelementptr i8, ptr %24, i64 -8
  %26 = load double, ptr %25, align 8, !tbaa !16
  %27 = load double, ptr %24, align 8, !tbaa !16
  %28 = fmul double %27, 2.000000e+00
  %29 = fsub double %26, %28
  %30 = add nuw i64 %.027.ph, 1
  %31 = getelementptr inbounds double, ptr %21, i64 %30
  %32 = load double, ptr %31, align 8, !tbaa !16
  %33 = fadd double %32, %29
  %34 = getelementptr inbounds double, ptr %23, i64 %.027.ph
  %35 = load double, ptr %34, align 8, !tbaa !16
  %36 = tail call double @llvm.fmuladd.f64(double %15, double %33, double %35)
  store double %36, ptr %34, align 8, !tbaa !16
  br label %scalar.ph.prol.loopexit

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %.027.unr = phi i64 [ %.027.ph, %scalar.ph.preheader ], [ %30, %scalar.ph.prol ]
  %37 = icmp eq i64 %umax, %.neg
  br i1 %37, label %._crit_edge, label %scalar.ph

vector.memcheck:                                  ; preds = %.preheader
  %scevgep32 = getelementptr i8, ptr %23, i64 %17
  %38 = getelementptr i8, ptr %21, i64 %17
  %bound0 = icmp ult ptr %23, %38
  %bound1 = icmp ult ptr %21, %scevgep32
  %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 = or disjoint i64 %index, 1
  %39 = getelementptr double, ptr %21, i64 %offset.idx
  %40 = getelementptr i8, ptr %39, i64 -8
  %41 = getelementptr i8, ptr %39, i64 8
  %wide.load = load <2 x double>, ptr %40, align 8, !tbaa !16, !alias.scope !17
  %wide.load34 = load <2 x double>, ptr %41, align 8, !tbaa !16, !alias.scope !17
  %42 = getelementptr i8, ptr %39, i64 16
  %wide.load35 = load <2 x double>, ptr %39, align 8, !tbaa !16, !alias.scope !17
  %wide.load36 = load <2 x double>, ptr %42, align 8, !tbaa !16, !alias.scope !17
  %43 = fmul <2 x double> %wide.load35, <double 2.000000e+00, double 2.000000e+00>
  %44 = fmul <2 x double> %wide.load36, <double 2.000000e+00, double 2.000000e+00>
  %45 = fsub <2 x double> %wide.load, %43
  %46 = fsub <2 x double> %wide.load34, %44
  %47 = or disjoint i64 %index, 2
  %48 = getelementptr inbounds double, ptr %21, i64 %47
  %49 = getelementptr inbounds i8, ptr %48, i64 16
  %wide.load37 = load <2 x double>, ptr %48, align 8, !tbaa !16, !alias.scope !17
  %wide.load38 = load <2 x double>, ptr %49, align 8, !tbaa !16, !alias.scope !17
  %50 = fadd <2 x double> %wide.load37, %45
  %51 = fadd <2 x double> %wide.load38, %46
  %52 = getelementptr inbounds double, ptr %23, i64 %offset.idx
  %53 = getelementptr inbounds i8, ptr %52, i64 16
  %wide.load39 = load <2 x double>, ptr %52, align 8, !tbaa !16, !alias.scope !20, !noalias !17
  %wide.load40 = load <2 x double>, ptr %53, align 8, !tbaa !16, !alias.scope !20, !noalias !17
  %54 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %broadcast.splat, <2 x double> %50, <2 x double> %wide.load39)
  %55 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %broadcast.splat, <2 x double> %51, <2 x double> %wide.load40)
  store <2 x double> %54, ptr %52, align 8, !tbaa !16, !alias.scope !20, !noalias !17
  store <2 x double> %55, ptr %53, align 8, !tbaa !16, !alias.scope !20, !noalias !17
  %index.next = add nuw i64 %index, 4
  %56 = icmp eq i64 %index.next, %n.vec
  br i1 %56, 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_edge30:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %5
  ret i32 0

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block
  %57 = add i64 %.02429, 1
  %.not = icmp ugt i64 %57, %9
  br i1 %.not, label %._crit_edge30, label %.preheader, !llvm.loop !26

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %.027 = phi i64 [ %77, %scalar.ph ], [ %.027.unr, %scalar.ph.prol.loopexit ]
  %58 = getelementptr double, ptr %21, i64 %.027
  %59 = getelementptr i8, ptr %58, i64 -8
  %60 = load double, ptr %59, align 8, !tbaa !16
  %61 = load double, ptr %58, align 8, !tbaa !16
  %62 = fmul double %61, 2.000000e+00
  %63 = fsub double %60, %62
  %64 = add nuw i64 %.027, 1
  %65 = getelementptr inbounds double, ptr %21, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !16
  %67 = fadd double %66, %63
  %68 = getelementptr inbounds double, ptr %23, i64 %.027
  %69 = load double, ptr %68, align 8, !tbaa !16
  %70 = tail call double @llvm.fmuladd.f64(double %15, double %67, double %69)
  store double %70, ptr %68, align 8, !tbaa !16
  %71 = getelementptr double, ptr %21, i64 %64
  %72 = getelementptr i8, ptr %71, i64 -8
  %73 = load double, ptr %72, align 8, !tbaa !16
  %74 = load double, ptr %71, align 8, !tbaa !16
  %75 = fmul double %74, 2.000000e+00
  %76 = fsub double %73, %75
  %77 = add nuw i64 %.027, 2
  %78 = getelementptr inbounds double, ptr %21, i64 %77
  %79 = load double, ptr %78, align 8, !tbaa !16
  %80 = fadd double %79, %76
  %81 = getelementptr inbounds double, ptr %23, i64 %64
  %82 = load double, ptr %81, align 8, !tbaa !16
  %83 = tail call double @llvm.fmuladd.f64(double %15, double %80, double %82)
  store double %83, ptr %81, align 8, !tbaa !16
  %exitcond.1 = icmp eq i64 %16, %77
  br i1 %exitcond.1, 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 = !{!10, !10, i64 0}
!13 = !{!6, !7, i64 32}
!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