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

; 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 }
%struct.flow_field_t = type { ptr, ptr, ptr, ptr }

@uy_jmin = external constant i64, align 8

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

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

29:                                               ; preds = %25
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %50

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

31:                                               ; preds = %43, %30
  %32 = load i64, ptr %13, 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 %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %46

36:                                               ; preds = %31
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load i64, ptr %11, align 8, !tbaa !14
  %39 = getelementptr inbounds ptr, ptr %37, i64 %38
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %41 = load i64, ptr %13, align 8, !tbaa !14
  %42 = getelementptr inbounds double, ptr %40, i64 %41
  store double 0.000000e+00, ptr %42, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %36
  %44 = load i64, ptr %13, align 8, !tbaa !14
  %45 = add i64 %44, 1
  store i64 %45, ptr %13, align 8, !tbaa !14
  br label %31, !llvm.loop !16

46:                                               ; preds = %35
  br label %47

47:                                               ; preds = %46
  %48 = load i64, ptr %11, align 8, !tbaa !14
  %49 = add i64 %48, 1
  store i64 %49, ptr %11, align 8, !tbaa !14
  br label %25, !llvm.loop !18

50:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.flow_field_t, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !19
  store ptr %53, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.flow_field_t, ptr %54, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !21
  store ptr %56, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.flow_field_t, ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !22
  store ptr %59, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  store double 1.000000e-03, ptr %17, align 8, !tbaa !9
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = load ptr, ptr %14, align 8, !tbaa !5
  %62 = load ptr, ptr %15, align 8, !tbaa !5
  %63 = load double, ptr %7, align 8, !tbaa !9
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = call i32 @uy_advx(ptr noundef %60, ptr noundef %61, ptr noundef %62, double noundef %63, ptr noundef %64)
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load ptr, ptr %15, align 8, !tbaa !5
  %68 = load double, ptr %7, align 8, !tbaa !9
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = call i32 @uy_advy(ptr noundef %66, ptr noundef %67, double noundef %68, ptr noundef %69)
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load ptr, ptr %15, align 8, !tbaa !5
  %73 = load double, ptr %7, align 8, !tbaa !9
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = call i32 @uy_difx(ptr noundef %71, double noundef 1.000000e-03, ptr noundef %72, double noundef %73, ptr noundef %74)
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = load ptr, ptr %15, align 8, !tbaa !5
  %78 = load double, ptr %7, align 8, !tbaa !9
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = call i32 @uy_dify(ptr noundef %76, double noundef 1.000000e-03, ptr noundef %77, double noundef %78, ptr noundef %79)
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load ptr, ptr %16, align 8, !tbaa !5
  %83 = load double, ptr %7, align 8, !tbaa !9
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = call i32 @uy_pres(ptr noundef %81, ptr noundef %82, double noundef %83, ptr noundef %84)
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare i32 @uy_advx(ptr noundef, ptr noundef, ptr noundef, double noundef, ptr noundef) #2

declare i32 @uy_advy(ptr noundef, ptr noundef, double noundef, ptr noundef) #2

declare i32 @uy_difx(ptr noundef, double noundef, ptr noundef, double noundef, ptr noundef) #2

declare i32 @uy_dify(ptr noundef, double noundef, ptr noundef, double noundef, ptr noundef) #2

declare i32 @uy_pres(ptr noundef, ptr noundef, double noundef, ptr noundef) #2

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 = { "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 #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 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{!20, !6, i64 0}
!20 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!21 = !{!20, !6, i64 8}
!22 = !{!20, !6, i64 16}


; 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: nounwind uwtable
define dso_local noundef i32 @compute_duy(ptr noundef %0, ptr nocapture noundef readonly %1, double noundef %2, ptr noundef %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
  %9 = load i64, ptr @uy_jmin, align 8, !tbaa !12
  %.not38 = icmp ugt i64 %9, %8
  %.not3536 = icmp eq i64 %6, 0
  %or.cond = select i1 %.not38, i1 true, i1 %.not3536
  br i1 %or.cond, label %._crit_edge40, label %.preheader.preheader

.preheader.preheader:                             ; preds = %4
  %10 = add i64 %6, 1
  %umax = tail call i64 @llvm.umax.i64(i64 %10, i64 2)
  %11 = shl i64 %umax, 3
  %12 = add i64 %11, -8
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %.039 = phi i64 [ %15, %.preheader ], [ %9, %.preheader.preheader ]
  %13 = getelementptr inbounds ptr, ptr %3, i64 %.039
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %scevgep = getelementptr i8, ptr %14, i64 8
  tail call void @llvm.memset.p0.i64(ptr align 8 %scevgep, i8 0, i64 %12, i1 false), !tbaa !15
  %15 = add i64 %.039, 1
  %.not = icmp ugt i64 %15, %8
  br i1 %.not, label %._crit_edge40, label %.preheader, !llvm.loop !16

._crit_edge40:                                    ; preds = %.preheader, %4
  %16 = load ptr, ptr %1, align 8, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %1, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !20
  %19 = getelementptr inbounds i8, ptr %1, i64 16
  %20 = load ptr, ptr %19, align 8, !tbaa !21
  %21 = tail call i32 @uy_advx(ptr noundef %0, ptr noundef %16, ptr noundef %18, double noundef %2, ptr noundef %3) #4
  %22 = tail call i32 @uy_advy(ptr noundef %0, ptr noundef %18, double noundef %2, ptr noundef %3) #4
  %23 = tail call i32 @uy_difx(ptr noundef %0, double noundef 1.000000e-03, ptr noundef %18, double noundef %2, ptr noundef %3) #4
  %24 = tail call i32 @uy_dify(ptr noundef %0, double noundef 1.000000e-03, ptr noundef %18, double noundef %2, ptr noundef %3) #4
  %25 = tail call i32 @uy_pres(ptr noundef %0, ptr noundef %20, double noundef %2, ptr noundef %3) #4
  ret i32 0
}

declare i32 @uy_advx(ptr noundef, ptr noundef, ptr noundef, double noundef, ptr noundef) local_unnamed_addr #1

declare i32 @uy_advy(ptr noundef, ptr noundef, double noundef, ptr noundef) local_unnamed_addr #1

declare i32 @uy_difx(ptr noundef, double noundef, ptr noundef, double noundef, ptr noundef) local_unnamed_addr #1

declare i32 @uy_dify(ptr noundef, double noundef, ptr noundef, double noundef, ptr noundef) local_unnamed_addr #1

declare i32 @uy_pres(ptr noundef, ptr noundef, double noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 = { "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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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, !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 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !14, i64 0}
!19 = !{!"", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!20 = !{!19, !14, i64 8}
!21 = !{!19, !14, i64 16}


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