; LLVM IR from shyams2/SIMPLE_Solver :: SIMPLE.ll (Z10correctionv)

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

@u = external dso_local global [90601 x double], align 16
@v = external dso_local global [90601 x double], align 16
@pc = external dso_local global [90000 x double], align 16
@dx = external dso_local global double, align 8
@dy = external dso_local global double, align 8
@dt = external dso_local global double, align 8
@rho = external dso_local global double, align 8
@k = external dso_local global i32, align 4
@n1 = external dso_local global i32, align 4
@n2 = external dso_local global i32, align 4
@n3 = external dso_local global i32, align 4
@n4 = external dso_local global i32, align 4
@n5 = external dso_local global i32, align 4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6nodconii(i32 noundef, i32 noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z10correctionv() #1 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %2

2:                                                ; preds = %82, %0
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %4 = load i32, ptr @k, align 4, !tbaa !5
  %5 = sub nsw i32 %4, 1
  %6 = load i32, ptr @k, align 4, !tbaa !5
  %7 = sub nsw i32 %6, 1
  %8 = mul nsw i32 %5, %7
  %9 = icmp slt i32 %3, %8
  br i1 %9, label %10, label %85

10:                                               ; preds = %2
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = load i32, ptr @k, align 4, !tbaa !5
  %13 = sub nsw i32 %12, 1
  call void @_Z6nodconii(i32 noundef %11, i32 noundef %13)
  %14 = load i32, ptr @n5, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [90601 x double], ptr @u, i64 0, i64 %15
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = load double, ptr @dt, align 8, !tbaa !9
  %19 = load double, ptr @rho, align 8, !tbaa !9
  %20 = fdiv double %18, %19
  %21 = load i32, ptr @n2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [90000 x double], ptr @pc, i64 0, i64 %22
  %24 = load double, ptr %23, align 8, !tbaa !9
  %25 = load i32, ptr @n3, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [90000 x double], ptr @pc, i64 0, i64 %26
  %28 = load double, ptr %27, align 8, !tbaa !9
  %29 = fadd double %24, %28
  %30 = load i32, ptr @n1, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [90000 x double], ptr @pc, i64 0, i64 %31
  %33 = load double, ptr %32, align 8, !tbaa !9
  %34 = fsub double %29, %33
  %35 = load i32, ptr @n4, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [90000 x double], ptr @pc, i64 0, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !9
  %39 = fsub double %34, %38
  %40 = load double, ptr @dx, align 8, !tbaa !9
  %41 = fmul double 2.000000e+00, %40
  %42 = fdiv double %39, %41
  %43 = fneg double %20
  %44 = call double @llvm.fmuladd.f64(double %43, double %42, double %17)
  %45 = load i32, ptr @n5, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [90601 x double], ptr @u, i64 0, i64 %46
  store double %44, ptr %47, align 8, !tbaa !9
  %48 = load i32, ptr @n5, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [90601 x double], ptr @v, i64 0, i64 %49
  %51 = load double, ptr %50, align 8, !tbaa !9
  %52 = load double, ptr @dt, align 8, !tbaa !9
  %53 = load double, ptr @rho, align 8, !tbaa !9
  %54 = fdiv double %52, %53
  %55 = load i32, ptr @n4, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [90000 x double], ptr @pc, i64 0, i64 %56
  %58 = load double, ptr %57, align 8, !tbaa !9
  %59 = load i32, ptr @n3, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [90000 x double], ptr @pc, i64 0, i64 %60
  %62 = load double, ptr %61, align 8, !tbaa !9
  %63 = fadd double %58, %62
  %64 = load i32, ptr @n1, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [90000 x double], ptr @pc, i64 0, i64 %65
  %67 = load double, ptr %66, align 8, !tbaa !9
  %68 = fsub double %63, %67
  %69 = load i32, ptr @n2, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [90000 x double], ptr @pc, i64 0, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !9
  %73 = fsub double %68, %72
  %74 = load double, ptr @dy, align 8, !tbaa !9
  %75 = fmul double 2.000000e+00, %74
  %76 = fdiv double %73, %75
  %77 = fneg double %54
  %78 = call double @llvm.fmuladd.f64(double %77, double %76, double %51)
  %79 = load i32, ptr @n5, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [90601 x double], ptr @v, i64 0, i64 %80
  store double %78, ptr %81, align 8, !tbaa !9
  br label %82

82:                                               ; preds = %10
  %83 = load i32, ptr %1, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %1, align 4, !tbaa !5
  br label %2, !llvm.loop !11

85:                                               ; preds = %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

@u = external dso_local local_unnamed_addr global [90601 x double], align 16
@v = external dso_local local_unnamed_addr global [90601 x double], align 16
@pc = external dso_local local_unnamed_addr global [90000 x double], align 16
@dx = external dso_local local_unnamed_addr global double, align 8
@dy = external dso_local local_unnamed_addr global double, align 8
@dt = external dso_local local_unnamed_addr global double, align 8
@rho = external dso_local local_unnamed_addr global double, align 8
@k = external dso_local local_unnamed_addr global i32, align 4
@n1 = external dso_local local_unnamed_addr global i32, align 4
@n2 = external dso_local local_unnamed_addr global i32, align 4
@n3 = external dso_local local_unnamed_addr global i32, align 4
@n4 = external dso_local local_unnamed_addr global i32, align 4
@n5 = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z6nodconii(i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z10correctionv() local_unnamed_addr #0 {
  %1 = load i32, ptr @k, align 4, !tbaa !5
  %2 = add nsw i32 %1, -1
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %.lr.ph
  %3 = phi i32 [ %46, %.lr.ph ], [ %2, %0 ]
  %.03 = phi i32 [ %44, %.lr.ph ], [ 0, %0 ]
  tail call void @_Z6nodconii(i32 noundef %.03, i32 noundef %3)
  %4 = load i32, ptr @n5, align 4, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = getelementptr inbounds [90601 x double], ptr @u, i64 0, i64 %5
  %7 = load double, ptr %6, align 8, !tbaa !9
  %8 = load double, ptr @dt, align 8, !tbaa !9
  %9 = load double, ptr @rho, align 8, !tbaa !9
  %10 = load i32, ptr @n2, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [90000 x double], ptr @pc, i64 0, i64 %11
  %13 = load double, ptr %12, align 8, !tbaa !9
  %14 = load i32, ptr @n3, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [90000 x double], ptr @pc, i64 0, i64 %15
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = fadd double %13, %17
  %19 = load i32, ptr @n1, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [90000 x double], ptr @pc, i64 0, i64 %20
  %22 = load double, ptr %21, align 8, !tbaa !9
  %23 = fsub double %18, %22
  %24 = load i32, ptr @n4, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [90000 x double], ptr @pc, i64 0, i64 %25
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = fsub double %23, %27
  %29 = load double, ptr @dx, align 8, !tbaa !9
  %30 = fmul double %29, 2.000000e+00
  %31 = fdiv double %28, %30
  %32 = fneg double %8
  %33 = fdiv double %32, %9
  %34 = tail call double @llvm.fmuladd.f64(double %33, double %31, double %7)
  store double %34, ptr %6, align 8, !tbaa !9
  %35 = getelementptr inbounds [90601 x double], ptr @v, i64 0, i64 %5
  %36 = load double, ptr %35, align 8, !tbaa !9
  %37 = fadd double %17, %27
  %38 = fsub double %37, %22
  %39 = fsub double %38, %13
  %40 = load double, ptr @dy, align 8, !tbaa !9
  %41 = fmul double %40, 2.000000e+00
  %42 = fdiv double %39, %41
  %43 = tail call double @llvm.fmuladd.f64(double %33, double %42, double %36)
  store double %43, ptr %35, align 8, !tbaa !9
  %44 = add nuw nsw i32 %.03, 1
  %45 = load i32, ptr @k, align 4, !tbaa !5
  %46 = add nsw i32 %45, -1
  %47 = mul nsw i32 %46, %46
  %48 = icmp ult i32 %44, %47
  br i1 %48, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %0
  ret void
}

attributes #0 = { mustprogress 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 = { mustprogress 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass