; LLVM IR from 0r-gh0/NUMERICAL_ANALYSIS :: CODES (LSM)

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

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca [20 x double], align 16
  %5 = alloca [20 x double], align 16
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 160, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 160, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store double 0.000000e+00, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store double 0.000000e+00, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store double 0.000000e+00, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store double 0.000000e+00, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %12 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %64, %0
  %15 = load i32, ptr %11, align 4, !tbaa !9
  %16 = load i32, ptr %10, align 4, !tbaa !9
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %67

19:                                               ; preds = %14
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = add nsw i32 %20, 1
  %22 = load i32, ptr %11, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %21, i32 noundef %23)
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [20 x double], ptr %4, i64 0, i64 %26
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [20 x double], ptr %5, i64 0, i64 %29
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.3, ptr noundef %27, ptr noundef %30)
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [20 x double], ptr %4, i64 0, i64 %33
  %35 = load double, ptr %34, align 8, !tbaa !5
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [20 x double], ptr %4, i64 0, i64 %37
  %39 = load double, ptr %38, align 8, !tbaa !5
  %40 = load double, ptr %6, align 8, !tbaa !5
  %41 = call double @llvm.fmuladd.f64(double %35, double %39, double %40)
  store double %41, ptr %6, align 8, !tbaa !5
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [20 x double], ptr %4, i64 0, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !5
  %46 = load double, ptr %7, align 8, !tbaa !5
  %47 = fadd double %46, %45
  store double %47, ptr %7, align 8, !tbaa !5
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [20 x double], ptr %5, i64 0, i64 %49
  %51 = load double, ptr %50, align 8, !tbaa !5
  %52 = load double, ptr %8, align 8, !tbaa !5
  %53 = fadd double %52, %51
  store double %53, ptr %8, align 8, !tbaa !5
  %54 = load i32, ptr %11, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [20 x double], ptr %4, i64 0, i64 %55
  %57 = load double, ptr %56, align 8, !tbaa !5
  %58 = load i32, ptr %11, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [20 x double], ptr %5, i64 0, i64 %59
  %61 = load double, ptr %60, align 8, !tbaa !5
  %62 = load double, ptr %9, align 8, !tbaa !5
  %63 = call double @llvm.fmuladd.f64(double %57, double %61, double %62)
  store double %63, ptr %9, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %19
  %65 = load i32, ptr %11, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %11, align 4, !tbaa !9
  br label %14, !llvm.loop !11

67:                                               ; preds = %18
  %68 = load double, ptr %6, align 8, !tbaa !5
  %69 = load double, ptr %8, align 8, !tbaa !5
  %70 = load double, ptr %7, align 8, !tbaa !5
  %71 = load double, ptr %9, align 8, !tbaa !5
  %72 = fmul double %70, %71
  %73 = fneg double %72
  %74 = call double @llvm.fmuladd.f64(double %68, double %69, double %73)
  %75 = load i32, ptr %10, align 4, !tbaa !9
  %76 = sitofp i32 %75 to double
  %77 = load double, ptr %6, align 8, !tbaa !5
  %78 = load double, ptr %7, align 8, !tbaa !5
  %79 = load double, ptr %7, align 8, !tbaa !5
  %80 = fmul double %78, %79
  %81 = fneg double %80
  %82 = call double @llvm.fmuladd.f64(double %76, double %77, double %81)
  %83 = fdiv double %74, %82
  store double %83, ptr %3, align 8, !tbaa !5
  %84 = load i32, ptr %10, align 4, !tbaa !9
  %85 = sitofp i32 %84 to double
  %86 = load double, ptr %9, align 8, !tbaa !5
  %87 = load double, ptr %7, align 8, !tbaa !5
  %88 = load double, ptr %8, align 8, !tbaa !5
  %89 = fmul double %87, %88
  %90 = fneg double %89
  %91 = call double @llvm.fmuladd.f64(double %85, double %86, double %90)
  %92 = load i32, ptr %10, align 4, !tbaa !9
  %93 = sitofp i32 %92 to double
  %94 = load double, ptr %6, align 8, !tbaa !5
  %95 = load double, ptr %7, align 8, !tbaa !5
  %96 = load double, ptr %7, align 8, !tbaa !5
  %97 = fmul double %95, %96
  %98 = fneg double %97
  %99 = call double @llvm.fmuladd.f64(double %93, double %94, double %98)
  %100 = fdiv double %91, %99
  store double %100, ptr %2, align 8, !tbaa !5
  %101 = load double, ptr %2, align 8, !tbaa !5
  %102 = load double, ptr %3, align 8, !tbaa !5
  %103 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %101, double noundef %102)
  %104 = load double, ptr %2, align 8, !tbaa !5
  %105 = load double, ptr %3, align 8, !tbaa !5
  %106 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, double noundef %104, double noundef %105)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  ret i32 0
}

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

declare i32 @printf(ptr noundef, ...) #2

declare i32 @__isoc99_scanf(ptr noundef, ...) #2

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

; 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 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

@.str = external hidden unnamed_addr constant [29 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [20 x double], align 16
  %2 = alloca [20 x double], align 16
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %6 = load i32, ptr %3, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa = phi i32 [ %6, %0 ], [ %44, %.lr.ph ]
  %8 = phi <2 x double> [ zeroinitializer, %0 ], [ %43, %.lr.ph ]
  %9 = phi <2 x double> [ zeroinitializer, %0 ], [ %41, %.lr.ph ]
  %10 = extractelement <2 x double> %9, i64 0
  %11 = fneg double %10
  %12 = extractelement <2 x double> %8, i64 1
  %13 = fmul double %12, %11
  %14 = extractelement <2 x double> %8, i64 0
  %15 = extractelement <2 x double> %9, i64 1
  %16 = call double @llvm.fmuladd.f64(double %14, double %15, double %13)
  %17 = sitofp i32 %.lcssa to double
  %18 = insertelement <2 x double> poison, double %11, i64 0
  %19 = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> zeroinitializer
  %20 = fmul <2 x double> %9, %19
  %21 = insertelement <2 x double> poison, double %17, i64 0
  %22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
  %23 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %22, <2 x double> %8, <2 x double> %20)
  %24 = extractelement <2 x double> %23, i64 0
  %25 = fdiv double %16, %24
  %26 = extractelement <2 x double> %23, i64 1
  %27 = fdiv double %26, %24
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %27, double noundef %25)
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, double noundef %27, double noundef %25)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %1) #5
  ret i32 0

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %30 = phi <2 x double> [ %43, %.lr.ph ], [ zeroinitializer, %0 ]
  %31 = phi <2 x double> [ %41, %.lr.ph ], [ zeroinitializer, %0 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %32 = trunc nuw nsw i64 %indvars.iv.next to i32
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %32, i32 noundef %32)
  %34 = getelementptr inbounds [20 x double], ptr %1, i64 0, i64 %indvars.iv
  %35 = getelementptr inbounds [20 x double], ptr %2, i64 0, i64 %indvars.iv
  %36 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.3, ptr noundef nonnull %34, ptr noundef nonnull %35)
  %37 = load double, ptr %34, align 8, !tbaa !9
  %38 = load double, ptr %35, align 8, !tbaa !9
  %39 = insertelement <2 x double> poison, double %37, i64 0
  %40 = insertelement <2 x double> %39, double %38, i64 1
  %41 = fadd <2 x double> %31, %40
  %42 = shufflevector <2 x double> %39, <2 x double> poison, <2 x i32> zeroinitializer
  %43 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %42, <2 x double> %40, <2 x double> %30)
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = icmp slt i64 %indvars.iv.next, %45
  br i1 %46, label %.lr.ph, label %._crit_edge, !llvm.loop !11
}

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

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

; 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>) #4

attributes #0 = { nofree 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 willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass