; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (1162)

; 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.point = type { double, double }

@p = external dso_local global [105 x %struct.point], align 16
@n = external dso_local global i32, align 4
@ans = external dso_local global double, align 8
@map = external dso_local global [105 x [105 x double]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4primv() #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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %6

6:                                                ; preds = %114, %0
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %8 = xor i32 %7, -1
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %117

10:                                               ; preds = %6
  store double 0.000000e+00, ptr @ans, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %26, %10
  %12 = load i32, ptr %2, align 4, !tbaa !9
  %13 = load i32, ptr @n, align 4, !tbaa !9
  %14 = icmp sle i32 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %29

16:                                               ; preds = %11
  %17 = load i32, ptr %2, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %18
  %20 = getelementptr inbounds %struct.point, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %2, align 4, !tbaa !9
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %22
  %24 = getelementptr inbounds %struct.point, ptr %23, i32 0, i32 1
  %25 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %20, ptr noundef %24)
  br label %26

26:                                               ; preds = %16
  %27 = load i32, ptr %2, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %2, align 4, !tbaa !9
  br label %11, !llvm.loop !11

29:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %111, %29
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = load i32, ptr @n, align 4, !tbaa !9
  %33 = icmp sle i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 7, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %114

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 1, ptr %5, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %107, %35
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = load i32, ptr @n, align 4, !tbaa !9
  %39 = icmp sle i32 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  store i32 10, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %110

41:                                               ; preds = %36
  %42 = load i32, ptr %3, align 4, !tbaa !9
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = icmp eq i32 %42, %43
  br i1 %44, label %45, label %52

45:                                               ; preds = %41
  %46 = load i32, ptr %3, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [105 x [105 x double]], ptr @map, i64 0, i64 %47
  %49 = load i32, ptr %5, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [105 x double], ptr %48, i64 0, i64 %50
  store double 0x418FFFFFF8000000, ptr %51, align 8, !tbaa !5
  br label %106

52:                                               ; preds = %41
  %53 = load i32, ptr %3, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %54
  %56 = getelementptr inbounds %struct.point, ptr %55, i32 0, i32 0
  %57 = load double, ptr %56, align 16, !tbaa !13
  %58 = load i32, ptr %5, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %59
  %61 = getelementptr inbounds %struct.point, ptr %60, i32 0, i32 0
  %62 = load double, ptr %61, align 16, !tbaa !13
  %63 = fsub double %57, %62
  %64 = load i32, ptr %3, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %65
  %67 = getelementptr inbounds %struct.point, ptr %66, i32 0, i32 0
  %68 = load double, ptr %67, align 16, !tbaa !13
  %69 = load i32, ptr %5, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %70
  %72 = getelementptr inbounds %struct.point, ptr %71, i32 0, i32 0
  %73 = load double, ptr %72, align 16, !tbaa !13
  %74 = fsub double %68, %73
  %75 = load i32, ptr %3, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %76
  %78 = getelementptr inbounds %struct.point, ptr %77, i32 0, i32 1
  %79 = load double, ptr %78, align 8, !tbaa !15
  %80 = load i32, ptr %5, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %81
  %83 = getelementptr inbounds %struct.point, ptr %82, i32 0, i32 1
  %84 = load double, ptr %83, align 8, !tbaa !15
  %85 = fsub double %79, %84
  %86 = load i32, ptr %3, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %87
  %89 = getelementptr inbounds %struct.point, ptr %88, i32 0, i32 1
  %90 = load double, ptr %89, align 8, !tbaa !15
  %91 = load i32, ptr %5, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %92
  %94 = getelementptr inbounds %struct.point, ptr %93, i32 0, i32 1
  %95 = load double, ptr %94, align 8, !tbaa !15
  %96 = fsub double %90, %95
  %97 = fmul double %85, %96
  %98 = call double @llvm.fmuladd.f64(double %63, double %74, double %97)
  %99 = call double @sqrt(double noundef %98) #6
  %100 = load i32, ptr %3, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [105 x [105 x double]], ptr @map, i64 0, i64 %101
  %103 = load i32, ptr %5, align 4, !tbaa !9
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [105 x double], ptr %102, i64 0, i64 %104
  store double %99, ptr %105, align 8, !tbaa !5
  br label %106

106:                                              ; preds = %52, %45
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %5, align 4, !tbaa !9
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %5, align 4, !tbaa !9
  br label %36, !llvm.loop !16

110:                                              ; preds = %40
  br label %111

111:                                              ; preds = %110
  %112 = load i32, ptr %3, align 4, !tbaa !9
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %3, align 4, !tbaa !9
  br label %30, !llvm.loop !17

114:                                              ; preds = %34
  call void @_Z4primv()
  %115 = load double, ptr @ans, align 8, !tbaa !5
  %116 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %115)
  br label %6, !llvm.loop !18

117:                                              ; preds = %6
  ret i32 0
}

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #4

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse 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 #3 = { "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 #4 = { 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS5point", !6, i64 0, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}


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

%struct.point = type { double, double }

@p = external dso_local global [105 x %struct.point], align 16
@n = external dso_local global i32, align 4
@ans = external dso_local local_unnamed_addr global double, align 8
@map = external dso_local local_unnamed_addr global [105 x [105 x double]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z4primv() local_unnamed_addr #0

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %.not36 = icmp eq i32 %1, -1
  br i1 %.not36, label %._crit_edge39, label %.lr.ph38

.lr.ph38:                                         ; preds = %0, %._crit_edge35
  store double 0.000000e+00, ptr @ans, align 8, !tbaa !5
  %2 = load i32, ptr @n, align 4, !tbaa !9
  %.not2428 = icmp slt i32 %2, 1
  br i1 %.not2428, label %._crit_edge35, label %.lr.ph

.preheader27:                                     ; preds = %.lr.ph
  %.not2533 = icmp slt i32 %7, 1
  br i1 %.not2533, label %._crit_edge35, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader27
  %3 = add nuw i32 %7, 1
  %wide.trip.count48 = zext i32 %3 to i64
  br label %.preheader

.lr.ph:                                           ; preds = %.lr.ph38, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph38 ]
  %4 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %indvars.iv
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %7 = load i32, ptr @n, align 4, !tbaa !9
  %8 = sext i32 %7 to i64
  %.not24.not = icmp slt i64 %indvars.iv, %8
  br i1 %.not24.not, label %.lr.ph, label %.preheader27, !llvm.loop !11

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge
  %indvars.iv45 = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.next46, %._crit_edge ]
  %9 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %indvars.iv45
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  br label %14

._crit_edge35:                                    ; preds = %._crit_edge, %.lr.ph38, %.preheader27
  tail call void @_Z4primv()
  %11 = load double, ptr @ans, align 8, !tbaa !5
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %11)
  %13 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %.not = icmp eq i32 %13, -1
  br i1 %.not, label %._crit_edge39, label %.lr.ph38, !llvm.loop !13

._crit_edge:                                      ; preds = %27
  %indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 1
  %exitcond49.not = icmp eq i64 %indvars.iv.next46, %wide.trip.count48
  br i1 %exitcond49.not, label %._crit_edge35, label %.preheader, !llvm.loop !14

14:                                               ; preds = %.preheader, %27
  %indvars.iv42 = phi i64 [ 1, %.preheader ], [ %indvars.iv.next43, %27 ]
  %15 = icmp eq i64 %indvars.iv45, %indvars.iv42
  br i1 %15, label %27, label %16

16:                                               ; preds = %14
  %17 = load double, ptr %9, align 16, !tbaa !15
  %18 = getelementptr inbounds [105 x %struct.point], ptr @p, i64 0, i64 %indvars.iv42
  %19 = load double, ptr %18, align 16, !tbaa !15
  %20 = fsub double %17, %19
  %21 = load double, ptr %10, align 8, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %18, i64 8
  %23 = load double, ptr %22, align 8, !tbaa !17
  %24 = fsub double %21, %23
  %25 = fmul double %24, %24
  %26 = tail call double @llvm.fmuladd.f64(double %20, double %20, double %25)
  %sqrt = tail call double @llvm.sqrt.f64(double %26)
  br label %27

27:                                               ; preds = %14, %16
  %sqrt.sink = phi double [ %sqrt, %16 ], [ 0x418FFFFFF8000000, %14 ]
  %28 = getelementptr inbounds [105 x [105 x double]], ptr @map, i64 0, i64 %indvars.iv45, i64 %indvars.iv42
  store double %sqrt.sink, ptr %28, align 8
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next43, %wide.trip.count48
  br i1 %exitcond.not, label %._crit_edge, label %14, !llvm.loop !18

._crit_edge39:                                    ; preds = %._crit_edge35, %0
  ret i32 0
}

; 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

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 norecurse 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 = { 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) }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTS5point", !6, i64 0, !6, i64 8}
!17 = !{!16, !6, i64 8}
!18 = distinct !{!18, !12}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass