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

; 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_pres(ptr noundef %0, ptr noundef %1, double noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca double, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store double %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.domain_t, ptr %15, i32 0, i32 2
  %17 = load i64, ptr %16, align 8, !tbaa !11
  store i64 %17, ptr %9, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.domain_t, ptr %18, i32 0, i32 3
  %20 = load i64, ptr %19, align 8, !tbaa !15
  store i64 %20, ptr %10, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.domain_t, ptr %21, i32 0, i32 4
  %23 = load double, ptr %22, align 8, !tbaa !16
  store double %23, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store i64 1, ptr %12, align 8, !tbaa !14
  br label %24

24:                                               ; preds = %70, %4
  %25 = load i64, ptr %12, align 8, !tbaa !14
  %26 = load i64, ptr %10, align 8, !tbaa !14
  %27 = icmp ule i64 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 2, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %73

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

31:                                               ; preds = %66, %29
  %32 = load i64, ptr %14, align 8, !tbaa !14
  %33 = load i64, ptr %9, align 8, !tbaa !14
  %34 = icmp ule i64 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  store i32 5, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %69

36:                                               ; preds = %31
  %37 = load double, ptr %7, align 8, !tbaa !9
  %38 = load double, ptr %11, align 8, !tbaa !9
  %39 = fdiv double %37, %38
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load i64, ptr %12, align 8, !tbaa !14
  %42 = getelementptr inbounds ptr, ptr %40, i64 %41
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %44 = load i64, ptr %14, align 8, !tbaa !14
  %45 = sub i64 %44, 1
  %46 = getelementptr inbounds double, ptr %43, i64 %45
  %47 = load double, ptr %46, align 8, !tbaa !9
  %48 = fneg double %47
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load i64, ptr %12, align 8, !tbaa !14
  %51 = getelementptr inbounds ptr, ptr %49, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = load i64, ptr %14, align 8, !tbaa !14
  %54 = getelementptr inbounds double, ptr %52, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !9
  %56 = fadd double %48, %55
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = load i64, ptr %12, align 8, !tbaa !14
  %59 = getelementptr inbounds ptr, ptr %57, i64 %58
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = load i64, ptr %14, align 8, !tbaa !14
  %62 = getelementptr inbounds double, ptr %60, i64 %61
  %63 = load double, ptr %62, align 8, !tbaa !9
  %64 = fneg double %39
  %65 = call double @llvm.fmuladd.f64(double %64, double %56, double %63)
  store double %65, ptr %62, align 8, !tbaa !9
  br label %66

66:                                               ; preds = %36
  %67 = load i64, ptr %14, align 8, !tbaa !14
  %68 = add i64 %67, 1
  store i64 %68, ptr %14, align 8, !tbaa !14
  br label %31, !llvm.loop !17

69:                                               ; preds = %35
  br label %70

70:                                               ; preds = %69
  %71 = load i64, ptr %12, align 8, !tbaa !14
  %72 = add i64 %71, 1
  store i64 %72, ptr %12, align 8, !tbaa !14
  br label %24, !llvm.loop !19

73:                                               ; preds = %28
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #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_pres(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, double noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load i64, ptr %7, align 8, !tbaa !11
  %.not23 = icmp eq i64 %8, 0
  br i1 %.not23, label %._crit_edge27, label %.lr.ph26

.lr.ph26:                                         ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load double, ptr %9, align 8, !tbaa !12
  %11 = load i64, ptr @ux_imin, align 8, !tbaa !13
  %.not2021 = icmp ugt i64 %11, %6
  %12 = fneg double %2
  %13 = fdiv double %12, %10
  br i1 %.not2021, label %._crit_edge27, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph26
  %14 = add i64 %8, 1
  %umax = tail call i64 @llvm.umax.i64(i64 %14, i64 2)
  %15 = shl i64 %11, 3
  %16 = add i64 %11, 1
  %17 = add i64 %6, 1
  %umax29 = tail call i64 @llvm.umax.i64(i64 %16, i64 %17)
  %18 = shl i64 %umax29, 3
  %umax33 = tail call i64 @llvm.umax.i64(i64 %16, i64 %17)
  %19 = sub i64 %umax33, %11
  %min.iters.check = icmp ult i64 %19, 4
  %n.vec = and i64 %19, -4
  %ind.end = add i64 %11, %n.vec
  %broadcast.splatinsert = insertelement <2 x double> poison, double %13, i64 0
  %broadcast.splat = shufflevector <2 x double> %broadcast.splatinsert, <2 x double> poison, <2 x i32> zeroinitializer
  %cmp.n = icmp eq i64 %19, %n.vec
  br label %.lr.ph

._crit_edge27:                                    ; preds = %._crit_edge, %.lr.ph26, %4
  ret i32 0

.lr.ph:                                           ; preds = %.lr.ph.preheader, %._crit_edge
  %.01924 = phi i64 [ %36, %._crit_edge ], [ 1, %.lr.ph.preheader ]
  %20 = getelementptr inbounds ptr, ptr %1, i64 %.01924
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  %22 = getelementptr inbounds ptr, ptr %3, i64 %.01924
  %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, %.lr.ph
  %.022.ph = phi i64 [ %11, %vector.memcheck ], [ %11, %.lr.ph ], [ %ind.end, %middle.block ]
  br label %scalar.ph

vector.memcheck:                                  ; preds = %.lr.ph
  %scevgep = getelementptr i8, ptr %23, i64 %15
  %scevgep30 = getelementptr i8, ptr %23, i64 %18
  %24 = getelementptr i8, ptr %21, i64 %15
  %scevgep31 = getelementptr i8, ptr %24, i64 -8
  %scevgep32 = getelementptr i8, ptr %21, i64 %18
  %bound0 = icmp ult ptr %scevgep, %scevgep32
  %bound1 = icmp ult ptr %scevgep31, %scevgep30
  %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 %11, %index
  %25 = getelementptr double, ptr %21, i64 %offset.idx
  %26 = getelementptr i8, ptr %25, i64 -8
  %27 = getelementptr i8, ptr %25, i64 8
  %wide.load = load <2 x double>, ptr %26, align 8, !tbaa !16, !alias.scope !17
  %wide.load34 = load <2 x double>, ptr %27, align 8, !tbaa !16, !alias.scope !17
  %28 = getelementptr i8, ptr %25, i64 16
  %wide.load35 = load <2 x double>, ptr %25, align 8, !tbaa !16, !alias.scope !17
  %wide.load36 = load <2 x double>, ptr %28, align 8, !tbaa !16, !alias.scope !17
  %29 = fsub <2 x double> %wide.load35, %wide.load
  %30 = fsub <2 x double> %wide.load36, %wide.load34
  %31 = getelementptr inbounds double, ptr %23, i64 %offset.idx
  %32 = getelementptr inbounds i8, ptr %31, i64 16
  %wide.load37 = load <2 x double>, ptr %31, align 8, !tbaa !16, !alias.scope !20, !noalias !17
  %wide.load38 = load <2 x double>, ptr %32, align 8, !tbaa !16, !alias.scope !20, !noalias !17
  %33 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %broadcast.splat, <2 x double> %29, <2 x double> %wide.load37)
  %34 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %broadcast.splat, <2 x double> %30, <2 x double> %wide.load38)
  store <2 x double> %33, ptr %31, align 8, !tbaa !16, !alias.scope !20, !noalias !17
  store <2 x double> %34, ptr %32, align 8, !tbaa !16, !alias.scope !20, !noalias !17
  %index.next = add nuw i64 %index, 4
  %35 = icmp eq i64 %index.next, %n.vec
  br i1 %35, 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
  %36 = add nuw i64 %.01924, 1
  %exitcond = icmp eq i64 %36, %umax
  br i1 %exitcond, label %._crit_edge27, label %.lr.ph, !llvm.loop !26

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.022 = phi i64 [ %45, %scalar.ph ], [ %.022.ph, %scalar.ph.preheader ]
  %37 = getelementptr double, ptr %21, i64 %.022
  %38 = getelementptr i8, ptr %37, i64 -8
  %39 = load double, ptr %38, align 8, !tbaa !16
  %40 = load double, ptr %37, align 8, !tbaa !16
  %41 = fsub double %40, %39
  %42 = getelementptr inbounds double, ptr %23, i64 %.022
  %43 = load double, ptr %42, align 8, !tbaa !16
  %44 = tail call double @llvm.fmuladd.f64(double %13, double %41, double %43)
  store double %44, ptr %42, align 8, !tbaa !16
  %45 = add i64 %.022, 1
  %.not20 = icmp ugt i64 %45, %6
  br i1 %.not20, 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,SROAPass,SimplifyCFGPass,TailCallElimPass